2
0

pdf.combined.js 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936
  1. /* Copyright 2012 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function (root, factory) {
  16. 'use strict';
  17. if (typeof define === 'function' && define.amd) {
  18. define('pdfjs-dist/build/pdf.combined', ['exports'], factory);
  19. } else if (typeof exports !== 'undefined') {
  20. factory(exports);
  21. } else {
  22. factory(root['pdfjsDistBuildPdfCombined'] = {});
  23. }
  24. }(this, function (exports) {
  25. 'use strict';
  26. var pdfjsVersion = '1.7.256';
  27. var pdfjsBuild = 'd3ae5b38';
  28. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  29. var pdfjsLibs = {};
  30. (function pdfjsWrapper() {
  31. (function (root, factory) {
  32. factory(root.pdfjsCoreArithmeticDecoder = {});
  33. }(this, function (exports) {
  34. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  35. var QeTable = [
  36. {
  37. qe: 0x5601,
  38. nmps: 1,
  39. nlps: 1,
  40. switchFlag: 1
  41. },
  42. {
  43. qe: 0x3401,
  44. nmps: 2,
  45. nlps: 6,
  46. switchFlag: 0
  47. },
  48. {
  49. qe: 0x1801,
  50. nmps: 3,
  51. nlps: 9,
  52. switchFlag: 0
  53. },
  54. {
  55. qe: 0x0AC1,
  56. nmps: 4,
  57. nlps: 12,
  58. switchFlag: 0
  59. },
  60. {
  61. qe: 0x0521,
  62. nmps: 5,
  63. nlps: 29,
  64. switchFlag: 0
  65. },
  66. {
  67. qe: 0x0221,
  68. nmps: 38,
  69. nlps: 33,
  70. switchFlag: 0
  71. },
  72. {
  73. qe: 0x5601,
  74. nmps: 7,
  75. nlps: 6,
  76. switchFlag: 1
  77. },
  78. {
  79. qe: 0x5401,
  80. nmps: 8,
  81. nlps: 14,
  82. switchFlag: 0
  83. },
  84. {
  85. qe: 0x4801,
  86. nmps: 9,
  87. nlps: 14,
  88. switchFlag: 0
  89. },
  90. {
  91. qe: 0x3801,
  92. nmps: 10,
  93. nlps: 14,
  94. switchFlag: 0
  95. },
  96. {
  97. qe: 0x3001,
  98. nmps: 11,
  99. nlps: 17,
  100. switchFlag: 0
  101. },
  102. {
  103. qe: 0x2401,
  104. nmps: 12,
  105. nlps: 18,
  106. switchFlag: 0
  107. },
  108. {
  109. qe: 0x1C01,
  110. nmps: 13,
  111. nlps: 20,
  112. switchFlag: 0
  113. },
  114. {
  115. qe: 0x1601,
  116. nmps: 29,
  117. nlps: 21,
  118. switchFlag: 0
  119. },
  120. {
  121. qe: 0x5601,
  122. nmps: 15,
  123. nlps: 14,
  124. switchFlag: 1
  125. },
  126. {
  127. qe: 0x5401,
  128. nmps: 16,
  129. nlps: 14,
  130. switchFlag: 0
  131. },
  132. {
  133. qe: 0x5101,
  134. nmps: 17,
  135. nlps: 15,
  136. switchFlag: 0
  137. },
  138. {
  139. qe: 0x4801,
  140. nmps: 18,
  141. nlps: 16,
  142. switchFlag: 0
  143. },
  144. {
  145. qe: 0x3801,
  146. nmps: 19,
  147. nlps: 17,
  148. switchFlag: 0
  149. },
  150. {
  151. qe: 0x3401,
  152. nmps: 20,
  153. nlps: 18,
  154. switchFlag: 0
  155. },
  156. {
  157. qe: 0x3001,
  158. nmps: 21,
  159. nlps: 19,
  160. switchFlag: 0
  161. },
  162. {
  163. qe: 0x2801,
  164. nmps: 22,
  165. nlps: 19,
  166. switchFlag: 0
  167. },
  168. {
  169. qe: 0x2401,
  170. nmps: 23,
  171. nlps: 20,
  172. switchFlag: 0
  173. },
  174. {
  175. qe: 0x2201,
  176. nmps: 24,
  177. nlps: 21,
  178. switchFlag: 0
  179. },
  180. {
  181. qe: 0x1C01,
  182. nmps: 25,
  183. nlps: 22,
  184. switchFlag: 0
  185. },
  186. {
  187. qe: 0x1801,
  188. nmps: 26,
  189. nlps: 23,
  190. switchFlag: 0
  191. },
  192. {
  193. qe: 0x1601,
  194. nmps: 27,
  195. nlps: 24,
  196. switchFlag: 0
  197. },
  198. {
  199. qe: 0x1401,
  200. nmps: 28,
  201. nlps: 25,
  202. switchFlag: 0
  203. },
  204. {
  205. qe: 0x1201,
  206. nmps: 29,
  207. nlps: 26,
  208. switchFlag: 0
  209. },
  210. {
  211. qe: 0x1101,
  212. nmps: 30,
  213. nlps: 27,
  214. switchFlag: 0
  215. },
  216. {
  217. qe: 0x0AC1,
  218. nmps: 31,
  219. nlps: 28,
  220. switchFlag: 0
  221. },
  222. {
  223. qe: 0x09C1,
  224. nmps: 32,
  225. nlps: 29,
  226. switchFlag: 0
  227. },
  228. {
  229. qe: 0x08A1,
  230. nmps: 33,
  231. nlps: 30,
  232. switchFlag: 0
  233. },
  234. {
  235. qe: 0x0521,
  236. nmps: 34,
  237. nlps: 31,
  238. switchFlag: 0
  239. },
  240. {
  241. qe: 0x0441,
  242. nmps: 35,
  243. nlps: 32,
  244. switchFlag: 0
  245. },
  246. {
  247. qe: 0x02A1,
  248. nmps: 36,
  249. nlps: 33,
  250. switchFlag: 0
  251. },
  252. {
  253. qe: 0x0221,
  254. nmps: 37,
  255. nlps: 34,
  256. switchFlag: 0
  257. },
  258. {
  259. qe: 0x0141,
  260. nmps: 38,
  261. nlps: 35,
  262. switchFlag: 0
  263. },
  264. {
  265. qe: 0x0111,
  266. nmps: 39,
  267. nlps: 36,
  268. switchFlag: 0
  269. },
  270. {
  271. qe: 0x0085,
  272. nmps: 40,
  273. nlps: 37,
  274. switchFlag: 0
  275. },
  276. {
  277. qe: 0x0049,
  278. nmps: 41,
  279. nlps: 38,
  280. switchFlag: 0
  281. },
  282. {
  283. qe: 0x0025,
  284. nmps: 42,
  285. nlps: 39,
  286. switchFlag: 0
  287. },
  288. {
  289. qe: 0x0015,
  290. nmps: 43,
  291. nlps: 40,
  292. switchFlag: 0
  293. },
  294. {
  295. qe: 0x0009,
  296. nmps: 44,
  297. nlps: 41,
  298. switchFlag: 0
  299. },
  300. {
  301. qe: 0x0005,
  302. nmps: 45,
  303. nlps: 42,
  304. switchFlag: 0
  305. },
  306. {
  307. qe: 0x0001,
  308. nmps: 45,
  309. nlps: 43,
  310. switchFlag: 0
  311. },
  312. {
  313. qe: 0x5601,
  314. nmps: 46,
  315. nlps: 46,
  316. switchFlag: 0
  317. }
  318. ];
  319. function ArithmeticDecoder(data, start, end) {
  320. this.data = data;
  321. this.bp = start;
  322. this.dataEnd = end;
  323. this.chigh = data[start];
  324. this.clow = 0;
  325. this.byteIn();
  326. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  327. this.clow = this.clow << 7 & 0xFFFF;
  328. this.ct -= 7;
  329. this.a = 0x8000;
  330. }
  331. ArithmeticDecoder.prototype = {
  332. byteIn: function ArithmeticDecoder_byteIn() {
  333. var data = this.data;
  334. var bp = this.bp;
  335. if (data[bp] === 0xFF) {
  336. var b1 = data[bp + 1];
  337. if (b1 > 0x8F) {
  338. this.clow += 0xFF00;
  339. this.ct = 8;
  340. } else {
  341. bp++;
  342. this.clow += data[bp] << 9;
  343. this.ct = 7;
  344. this.bp = bp;
  345. }
  346. } else {
  347. bp++;
  348. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  349. this.ct = 8;
  350. this.bp = bp;
  351. }
  352. if (this.clow > 0xFFFF) {
  353. this.chigh += this.clow >> 16;
  354. this.clow &= 0xFFFF;
  355. }
  356. },
  357. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  358. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  359. var qeTableIcx = QeTable[cx_index];
  360. var qeIcx = qeTableIcx.qe;
  361. var d;
  362. var a = this.a - qeIcx;
  363. if (this.chigh < qeIcx) {
  364. if (a < qeIcx) {
  365. a = qeIcx;
  366. d = cx_mps;
  367. cx_index = qeTableIcx.nmps;
  368. } else {
  369. a = qeIcx;
  370. d = 1 ^ cx_mps;
  371. if (qeTableIcx.switchFlag === 1) {
  372. cx_mps = d;
  373. }
  374. cx_index = qeTableIcx.nlps;
  375. }
  376. } else {
  377. this.chigh -= qeIcx;
  378. if ((a & 0x8000) !== 0) {
  379. this.a = a;
  380. return cx_mps;
  381. }
  382. if (a < qeIcx) {
  383. d = 1 ^ cx_mps;
  384. if (qeTableIcx.switchFlag === 1) {
  385. cx_mps = d;
  386. }
  387. cx_index = qeTableIcx.nlps;
  388. } else {
  389. d = cx_mps;
  390. cx_index = qeTableIcx.nmps;
  391. }
  392. }
  393. do {
  394. if (this.ct === 0) {
  395. this.byteIn();
  396. }
  397. a <<= 1;
  398. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  399. this.clow = this.clow << 1 & 0xFFFF;
  400. this.ct--;
  401. } while ((a & 0x8000) === 0);
  402. this.a = a;
  403. contexts[pos] = cx_index << 1 | cx_mps;
  404. return d;
  405. }
  406. };
  407. return ArithmeticDecoder;
  408. }();
  409. exports.ArithmeticDecoder = ArithmeticDecoder;
  410. }));
  411. (function (root, factory) {
  412. factory(root.pdfjsCoreCharsets = {});
  413. }(this, function (exports) {
  414. var ISOAdobeCharset = [
  415. '.notdef',
  416. 'space',
  417. 'exclam',
  418. 'quotedbl',
  419. 'numbersign',
  420. 'dollar',
  421. 'percent',
  422. 'ampersand',
  423. 'quoteright',
  424. 'parenleft',
  425. 'parenright',
  426. 'asterisk',
  427. 'plus',
  428. 'comma',
  429. 'hyphen',
  430. 'period',
  431. 'slash',
  432. 'zero',
  433. 'one',
  434. 'two',
  435. 'three',
  436. 'four',
  437. 'five',
  438. 'six',
  439. 'seven',
  440. 'eight',
  441. 'nine',
  442. 'colon',
  443. 'semicolon',
  444. 'less',
  445. 'equal',
  446. 'greater',
  447. 'question',
  448. 'at',
  449. 'A',
  450. 'B',
  451. 'C',
  452. 'D',
  453. 'E',
  454. 'F',
  455. 'G',
  456. 'H',
  457. 'I',
  458. 'J',
  459. 'K',
  460. 'L',
  461. 'M',
  462. 'N',
  463. 'O',
  464. 'P',
  465. 'Q',
  466. 'R',
  467. 'S',
  468. 'T',
  469. 'U',
  470. 'V',
  471. 'W',
  472. 'X',
  473. 'Y',
  474. 'Z',
  475. 'bracketleft',
  476. 'backslash',
  477. 'bracketright',
  478. 'asciicircum',
  479. 'underscore',
  480. 'quoteleft',
  481. 'a',
  482. 'b',
  483. 'c',
  484. 'd',
  485. 'e',
  486. 'f',
  487. 'g',
  488. 'h',
  489. 'i',
  490. 'j',
  491. 'k',
  492. 'l',
  493. 'm',
  494. 'n',
  495. 'o',
  496. 'p',
  497. 'q',
  498. 'r',
  499. 's',
  500. 't',
  501. 'u',
  502. 'v',
  503. 'w',
  504. 'x',
  505. 'y',
  506. 'z',
  507. 'braceleft',
  508. 'bar',
  509. 'braceright',
  510. 'asciitilde',
  511. 'exclamdown',
  512. 'cent',
  513. 'sterling',
  514. 'fraction',
  515. 'yen',
  516. 'florin',
  517. 'section',
  518. 'currency',
  519. 'quotesingle',
  520. 'quotedblleft',
  521. 'guillemotleft',
  522. 'guilsinglleft',
  523. 'guilsinglright',
  524. 'fi',
  525. 'fl',
  526. 'endash',
  527. 'dagger',
  528. 'daggerdbl',
  529. 'periodcentered',
  530. 'paragraph',
  531. 'bullet',
  532. 'quotesinglbase',
  533. 'quotedblbase',
  534. 'quotedblright',
  535. 'guillemotright',
  536. 'ellipsis',
  537. 'perthousand',
  538. 'questiondown',
  539. 'grave',
  540. 'acute',
  541. 'circumflex',
  542. 'tilde',
  543. 'macron',
  544. 'breve',
  545. 'dotaccent',
  546. 'dieresis',
  547. 'ring',
  548. 'cedilla',
  549. 'hungarumlaut',
  550. 'ogonek',
  551. 'caron',
  552. 'emdash',
  553. 'AE',
  554. 'ordfeminine',
  555. 'Lslash',
  556. 'Oslash',
  557. 'OE',
  558. 'ordmasculine',
  559. 'ae',
  560. 'dotlessi',
  561. 'lslash',
  562. 'oslash',
  563. 'oe',
  564. 'germandbls',
  565. 'onesuperior',
  566. 'logicalnot',
  567. 'mu',
  568. 'trademark',
  569. 'Eth',
  570. 'onehalf',
  571. 'plusminus',
  572. 'Thorn',
  573. 'onequarter',
  574. 'divide',
  575. 'brokenbar',
  576. 'degree',
  577. 'thorn',
  578. 'threequarters',
  579. 'twosuperior',
  580. 'registered',
  581. 'minus',
  582. 'eth',
  583. 'multiply',
  584. 'threesuperior',
  585. 'copyright',
  586. 'Aacute',
  587. 'Acircumflex',
  588. 'Adieresis',
  589. 'Agrave',
  590. 'Aring',
  591. 'Atilde',
  592. 'Ccedilla',
  593. 'Eacute',
  594. 'Ecircumflex',
  595. 'Edieresis',
  596. 'Egrave',
  597. 'Iacute',
  598. 'Icircumflex',
  599. 'Idieresis',
  600. 'Igrave',
  601. 'Ntilde',
  602. 'Oacute',
  603. 'Ocircumflex',
  604. 'Odieresis',
  605. 'Ograve',
  606. 'Otilde',
  607. 'Scaron',
  608. 'Uacute',
  609. 'Ucircumflex',
  610. 'Udieresis',
  611. 'Ugrave',
  612. 'Yacute',
  613. 'Ydieresis',
  614. 'Zcaron',
  615. 'aacute',
  616. 'acircumflex',
  617. 'adieresis',
  618. 'agrave',
  619. 'aring',
  620. 'atilde',
  621. 'ccedilla',
  622. 'eacute',
  623. 'ecircumflex',
  624. 'edieresis',
  625. 'egrave',
  626. 'iacute',
  627. 'icircumflex',
  628. 'idieresis',
  629. 'igrave',
  630. 'ntilde',
  631. 'oacute',
  632. 'ocircumflex',
  633. 'odieresis',
  634. 'ograve',
  635. 'otilde',
  636. 'scaron',
  637. 'uacute',
  638. 'ucircumflex',
  639. 'udieresis',
  640. 'ugrave',
  641. 'yacute',
  642. 'ydieresis',
  643. 'zcaron'
  644. ];
  645. var ExpertCharset = [
  646. '.notdef',
  647. 'space',
  648. 'exclamsmall',
  649. 'Hungarumlautsmall',
  650. 'dollaroldstyle',
  651. 'dollarsuperior',
  652. 'ampersandsmall',
  653. 'Acutesmall',
  654. 'parenleftsuperior',
  655. 'parenrightsuperior',
  656. 'twodotenleader',
  657. 'onedotenleader',
  658. 'comma',
  659. 'hyphen',
  660. 'period',
  661. 'fraction',
  662. 'zerooldstyle',
  663. 'oneoldstyle',
  664. 'twooldstyle',
  665. 'threeoldstyle',
  666. 'fouroldstyle',
  667. 'fiveoldstyle',
  668. 'sixoldstyle',
  669. 'sevenoldstyle',
  670. 'eightoldstyle',
  671. 'nineoldstyle',
  672. 'colon',
  673. 'semicolon',
  674. 'commasuperior',
  675. 'threequartersemdash',
  676. 'periodsuperior',
  677. 'questionsmall',
  678. 'asuperior',
  679. 'bsuperior',
  680. 'centsuperior',
  681. 'dsuperior',
  682. 'esuperior',
  683. 'isuperior',
  684. 'lsuperior',
  685. 'msuperior',
  686. 'nsuperior',
  687. 'osuperior',
  688. 'rsuperior',
  689. 'ssuperior',
  690. 'tsuperior',
  691. 'ff',
  692. 'fi',
  693. 'fl',
  694. 'ffi',
  695. 'ffl',
  696. 'parenleftinferior',
  697. 'parenrightinferior',
  698. 'Circumflexsmall',
  699. 'hyphensuperior',
  700. 'Gravesmall',
  701. 'Asmall',
  702. 'Bsmall',
  703. 'Csmall',
  704. 'Dsmall',
  705. 'Esmall',
  706. 'Fsmall',
  707. 'Gsmall',
  708. 'Hsmall',
  709. 'Ismall',
  710. 'Jsmall',
  711. 'Ksmall',
  712. 'Lsmall',
  713. 'Msmall',
  714. 'Nsmall',
  715. 'Osmall',
  716. 'Psmall',
  717. 'Qsmall',
  718. 'Rsmall',
  719. 'Ssmall',
  720. 'Tsmall',
  721. 'Usmall',
  722. 'Vsmall',
  723. 'Wsmall',
  724. 'Xsmall',
  725. 'Ysmall',
  726. 'Zsmall',
  727. 'colonmonetary',
  728. 'onefitted',
  729. 'rupiah',
  730. 'Tildesmall',
  731. 'exclamdownsmall',
  732. 'centoldstyle',
  733. 'Lslashsmall',
  734. 'Scaronsmall',
  735. 'Zcaronsmall',
  736. 'Dieresissmall',
  737. 'Brevesmall',
  738. 'Caronsmall',
  739. 'Dotaccentsmall',
  740. 'Macronsmall',
  741. 'figuredash',
  742. 'hypheninferior',
  743. 'Ogoneksmall',
  744. 'Ringsmall',
  745. 'Cedillasmall',
  746. 'onequarter',
  747. 'onehalf',
  748. 'threequarters',
  749. 'questiondownsmall',
  750. 'oneeighth',
  751. 'threeeighths',
  752. 'fiveeighths',
  753. 'seveneighths',
  754. 'onethird',
  755. 'twothirds',
  756. 'zerosuperior',
  757. 'onesuperior',
  758. 'twosuperior',
  759. 'threesuperior',
  760. 'foursuperior',
  761. 'fivesuperior',
  762. 'sixsuperior',
  763. 'sevensuperior',
  764. 'eightsuperior',
  765. 'ninesuperior',
  766. 'zeroinferior',
  767. 'oneinferior',
  768. 'twoinferior',
  769. 'threeinferior',
  770. 'fourinferior',
  771. 'fiveinferior',
  772. 'sixinferior',
  773. 'seveninferior',
  774. 'eightinferior',
  775. 'nineinferior',
  776. 'centinferior',
  777. 'dollarinferior',
  778. 'periodinferior',
  779. 'commainferior',
  780. 'Agravesmall',
  781. 'Aacutesmall',
  782. 'Acircumflexsmall',
  783. 'Atildesmall',
  784. 'Adieresissmall',
  785. 'Aringsmall',
  786. 'AEsmall',
  787. 'Ccedillasmall',
  788. 'Egravesmall',
  789. 'Eacutesmall',
  790. 'Ecircumflexsmall',
  791. 'Edieresissmall',
  792. 'Igravesmall',
  793. 'Iacutesmall',
  794. 'Icircumflexsmall',
  795. 'Idieresissmall',
  796. 'Ethsmall',
  797. 'Ntildesmall',
  798. 'Ogravesmall',
  799. 'Oacutesmall',
  800. 'Ocircumflexsmall',
  801. 'Otildesmall',
  802. 'Odieresissmall',
  803. 'OEsmall',
  804. 'Oslashsmall',
  805. 'Ugravesmall',
  806. 'Uacutesmall',
  807. 'Ucircumflexsmall',
  808. 'Udieresissmall',
  809. 'Yacutesmall',
  810. 'Thornsmall',
  811. 'Ydieresissmall'
  812. ];
  813. var ExpertSubsetCharset = [
  814. '.notdef',
  815. 'space',
  816. 'dollaroldstyle',
  817. 'dollarsuperior',
  818. 'parenleftsuperior',
  819. 'parenrightsuperior',
  820. 'twodotenleader',
  821. 'onedotenleader',
  822. 'comma',
  823. 'hyphen',
  824. 'period',
  825. 'fraction',
  826. 'zerooldstyle',
  827. 'oneoldstyle',
  828. 'twooldstyle',
  829. 'threeoldstyle',
  830. 'fouroldstyle',
  831. 'fiveoldstyle',
  832. 'sixoldstyle',
  833. 'sevenoldstyle',
  834. 'eightoldstyle',
  835. 'nineoldstyle',
  836. 'colon',
  837. 'semicolon',
  838. 'commasuperior',
  839. 'threequartersemdash',
  840. 'periodsuperior',
  841. 'asuperior',
  842. 'bsuperior',
  843. 'centsuperior',
  844. 'dsuperior',
  845. 'esuperior',
  846. 'isuperior',
  847. 'lsuperior',
  848. 'msuperior',
  849. 'nsuperior',
  850. 'osuperior',
  851. 'rsuperior',
  852. 'ssuperior',
  853. 'tsuperior',
  854. 'ff',
  855. 'fi',
  856. 'fl',
  857. 'ffi',
  858. 'ffl',
  859. 'parenleftinferior',
  860. 'parenrightinferior',
  861. 'hyphensuperior',
  862. 'colonmonetary',
  863. 'onefitted',
  864. 'rupiah',
  865. 'centoldstyle',
  866. 'figuredash',
  867. 'hypheninferior',
  868. 'onequarter',
  869. 'onehalf',
  870. 'threequarters',
  871. 'oneeighth',
  872. 'threeeighths',
  873. 'fiveeighths',
  874. 'seveneighths',
  875. 'onethird',
  876. 'twothirds',
  877. 'zerosuperior',
  878. 'onesuperior',
  879. 'twosuperior',
  880. 'threesuperior',
  881. 'foursuperior',
  882. 'fivesuperior',
  883. 'sixsuperior',
  884. 'sevensuperior',
  885. 'eightsuperior',
  886. 'ninesuperior',
  887. 'zeroinferior',
  888. 'oneinferior',
  889. 'twoinferior',
  890. 'threeinferior',
  891. 'fourinferior',
  892. 'fiveinferior',
  893. 'sixinferior',
  894. 'seveninferior',
  895. 'eightinferior',
  896. 'nineinferior',
  897. 'centinferior',
  898. 'dollarinferior',
  899. 'periodinferior',
  900. 'commainferior'
  901. ];
  902. exports.ISOAdobeCharset = ISOAdobeCharset;
  903. exports.ExpertCharset = ExpertCharset;
  904. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  905. }));
  906. (function (root, factory) {
  907. factory(root.pdfjsCoreEncodings = {});
  908. }(this, function (exports) {
  909. var ExpertEncoding = [
  910. '',
  911. '',
  912. '',
  913. '',
  914. '',
  915. '',
  916. '',
  917. '',
  918. '',
  919. '',
  920. '',
  921. '',
  922. '',
  923. '',
  924. '',
  925. '',
  926. '',
  927. '',
  928. '',
  929. '',
  930. '',
  931. '',
  932. '',
  933. '',
  934. '',
  935. '',
  936. '',
  937. '',
  938. '',
  939. '',
  940. '',
  941. '',
  942. 'space',
  943. 'exclamsmall',
  944. 'Hungarumlautsmall',
  945. '',
  946. 'dollaroldstyle',
  947. 'dollarsuperior',
  948. 'ampersandsmall',
  949. 'Acutesmall',
  950. 'parenleftsuperior',
  951. 'parenrightsuperior',
  952. 'twodotenleader',
  953. 'onedotenleader',
  954. 'comma',
  955. 'hyphen',
  956. 'period',
  957. 'fraction',
  958. 'zerooldstyle',
  959. 'oneoldstyle',
  960. 'twooldstyle',
  961. 'threeoldstyle',
  962. 'fouroldstyle',
  963. 'fiveoldstyle',
  964. 'sixoldstyle',
  965. 'sevenoldstyle',
  966. 'eightoldstyle',
  967. 'nineoldstyle',
  968. 'colon',
  969. 'semicolon',
  970. 'commasuperior',
  971. 'threequartersemdash',
  972. 'periodsuperior',
  973. 'questionsmall',
  974. '',
  975. 'asuperior',
  976. 'bsuperior',
  977. 'centsuperior',
  978. 'dsuperior',
  979. 'esuperior',
  980. '',
  981. '',
  982. 'isuperior',
  983. '',
  984. '',
  985. 'lsuperior',
  986. 'msuperior',
  987. 'nsuperior',
  988. 'osuperior',
  989. '',
  990. '',
  991. 'rsuperior',
  992. 'ssuperior',
  993. 'tsuperior',
  994. '',
  995. 'ff',
  996. 'fi',
  997. 'fl',
  998. 'ffi',
  999. 'ffl',
  1000. 'parenleftinferior',
  1001. '',
  1002. 'parenrightinferior',
  1003. 'Circumflexsmall',
  1004. 'hyphensuperior',
  1005. 'Gravesmall',
  1006. 'Asmall',
  1007. 'Bsmall',
  1008. 'Csmall',
  1009. 'Dsmall',
  1010. 'Esmall',
  1011. 'Fsmall',
  1012. 'Gsmall',
  1013. 'Hsmall',
  1014. 'Ismall',
  1015. 'Jsmall',
  1016. 'Ksmall',
  1017. 'Lsmall',
  1018. 'Msmall',
  1019. 'Nsmall',
  1020. 'Osmall',
  1021. 'Psmall',
  1022. 'Qsmall',
  1023. 'Rsmall',
  1024. 'Ssmall',
  1025. 'Tsmall',
  1026. 'Usmall',
  1027. 'Vsmall',
  1028. 'Wsmall',
  1029. 'Xsmall',
  1030. 'Ysmall',
  1031. 'Zsmall',
  1032. 'colonmonetary',
  1033. 'onefitted',
  1034. 'rupiah',
  1035. 'Tildesmall',
  1036. '',
  1037. '',
  1038. '',
  1039. '',
  1040. '',
  1041. '',
  1042. '',
  1043. '',
  1044. '',
  1045. '',
  1046. '',
  1047. '',
  1048. '',
  1049. '',
  1050. '',
  1051. '',
  1052. '',
  1053. '',
  1054. '',
  1055. '',
  1056. '',
  1057. '',
  1058. '',
  1059. '',
  1060. '',
  1061. '',
  1062. '',
  1063. '',
  1064. '',
  1065. '',
  1066. '',
  1067. '',
  1068. '',
  1069. '',
  1070. 'exclamdownsmall',
  1071. 'centoldstyle',
  1072. 'Lslashsmall',
  1073. '',
  1074. '',
  1075. 'Scaronsmall',
  1076. 'Zcaronsmall',
  1077. 'Dieresissmall',
  1078. 'Brevesmall',
  1079. 'Caronsmall',
  1080. '',
  1081. 'Dotaccentsmall',
  1082. '',
  1083. '',
  1084. 'Macronsmall',
  1085. '',
  1086. '',
  1087. 'figuredash',
  1088. 'hypheninferior',
  1089. '',
  1090. '',
  1091. 'Ogoneksmall',
  1092. 'Ringsmall',
  1093. 'Cedillasmall',
  1094. '',
  1095. '',
  1096. '',
  1097. 'onequarter',
  1098. 'onehalf',
  1099. 'threequarters',
  1100. 'questiondownsmall',
  1101. 'oneeighth',
  1102. 'threeeighths',
  1103. 'fiveeighths',
  1104. 'seveneighths',
  1105. 'onethird',
  1106. 'twothirds',
  1107. '',
  1108. '',
  1109. 'zerosuperior',
  1110. 'onesuperior',
  1111. 'twosuperior',
  1112. 'threesuperior',
  1113. 'foursuperior',
  1114. 'fivesuperior',
  1115. 'sixsuperior',
  1116. 'sevensuperior',
  1117. 'eightsuperior',
  1118. 'ninesuperior',
  1119. 'zeroinferior',
  1120. 'oneinferior',
  1121. 'twoinferior',
  1122. 'threeinferior',
  1123. 'fourinferior',
  1124. 'fiveinferior',
  1125. 'sixinferior',
  1126. 'seveninferior',
  1127. 'eightinferior',
  1128. 'nineinferior',
  1129. 'centinferior',
  1130. 'dollarinferior',
  1131. 'periodinferior',
  1132. 'commainferior',
  1133. 'Agravesmall',
  1134. 'Aacutesmall',
  1135. 'Acircumflexsmall',
  1136. 'Atildesmall',
  1137. 'Adieresissmall',
  1138. 'Aringsmall',
  1139. 'AEsmall',
  1140. 'Ccedillasmall',
  1141. 'Egravesmall',
  1142. 'Eacutesmall',
  1143. 'Ecircumflexsmall',
  1144. 'Edieresissmall',
  1145. 'Igravesmall',
  1146. 'Iacutesmall',
  1147. 'Icircumflexsmall',
  1148. 'Idieresissmall',
  1149. 'Ethsmall',
  1150. 'Ntildesmall',
  1151. 'Ogravesmall',
  1152. 'Oacutesmall',
  1153. 'Ocircumflexsmall',
  1154. 'Otildesmall',
  1155. 'Odieresissmall',
  1156. 'OEsmall',
  1157. 'Oslashsmall',
  1158. 'Ugravesmall',
  1159. 'Uacutesmall',
  1160. 'Ucircumflexsmall',
  1161. 'Udieresissmall',
  1162. 'Yacutesmall',
  1163. 'Thornsmall',
  1164. 'Ydieresissmall'
  1165. ];
  1166. var MacExpertEncoding = [
  1167. '',
  1168. '',
  1169. '',
  1170. '',
  1171. '',
  1172. '',
  1173. '',
  1174. '',
  1175. '',
  1176. '',
  1177. '',
  1178. '',
  1179. '',
  1180. '',
  1181. '',
  1182. '',
  1183. '',
  1184. '',
  1185. '',
  1186. '',
  1187. '',
  1188. '',
  1189. '',
  1190. '',
  1191. '',
  1192. '',
  1193. '',
  1194. '',
  1195. '',
  1196. '',
  1197. '',
  1198. '',
  1199. 'space',
  1200. 'exclamsmall',
  1201. 'Hungarumlautsmall',
  1202. 'centoldstyle',
  1203. 'dollaroldstyle',
  1204. 'dollarsuperior',
  1205. 'ampersandsmall',
  1206. 'Acutesmall',
  1207. 'parenleftsuperior',
  1208. 'parenrightsuperior',
  1209. 'twodotenleader',
  1210. 'onedotenleader',
  1211. 'comma',
  1212. 'hyphen',
  1213. 'period',
  1214. 'fraction',
  1215. 'zerooldstyle',
  1216. 'oneoldstyle',
  1217. 'twooldstyle',
  1218. 'threeoldstyle',
  1219. 'fouroldstyle',
  1220. 'fiveoldstyle',
  1221. 'sixoldstyle',
  1222. 'sevenoldstyle',
  1223. 'eightoldstyle',
  1224. 'nineoldstyle',
  1225. 'colon',
  1226. 'semicolon',
  1227. '',
  1228. 'threequartersemdash',
  1229. '',
  1230. 'questionsmall',
  1231. '',
  1232. '',
  1233. '',
  1234. '',
  1235. 'Ethsmall',
  1236. '',
  1237. '',
  1238. 'onequarter',
  1239. 'onehalf',
  1240. 'threequarters',
  1241. 'oneeighth',
  1242. 'threeeighths',
  1243. 'fiveeighths',
  1244. 'seveneighths',
  1245. 'onethird',
  1246. 'twothirds',
  1247. '',
  1248. '',
  1249. '',
  1250. '',
  1251. '',
  1252. '',
  1253. 'ff',
  1254. 'fi',
  1255. 'fl',
  1256. 'ffi',
  1257. 'ffl',
  1258. 'parenleftinferior',
  1259. '',
  1260. 'parenrightinferior',
  1261. 'Circumflexsmall',
  1262. 'hypheninferior',
  1263. 'Gravesmall',
  1264. 'Asmall',
  1265. 'Bsmall',
  1266. 'Csmall',
  1267. 'Dsmall',
  1268. 'Esmall',
  1269. 'Fsmall',
  1270. 'Gsmall',
  1271. 'Hsmall',
  1272. 'Ismall',
  1273. 'Jsmall',
  1274. 'Ksmall',
  1275. 'Lsmall',
  1276. 'Msmall',
  1277. 'Nsmall',
  1278. 'Osmall',
  1279. 'Psmall',
  1280. 'Qsmall',
  1281. 'Rsmall',
  1282. 'Ssmall',
  1283. 'Tsmall',
  1284. 'Usmall',
  1285. 'Vsmall',
  1286. 'Wsmall',
  1287. 'Xsmall',
  1288. 'Ysmall',
  1289. 'Zsmall',
  1290. 'colonmonetary',
  1291. 'onefitted',
  1292. 'rupiah',
  1293. 'Tildesmall',
  1294. '',
  1295. '',
  1296. 'asuperior',
  1297. 'centsuperior',
  1298. '',
  1299. '',
  1300. '',
  1301. '',
  1302. 'Aacutesmall',
  1303. 'Agravesmall',
  1304. 'Acircumflexsmall',
  1305. 'Adieresissmall',
  1306. 'Atildesmall',
  1307. 'Aringsmall',
  1308. 'Ccedillasmall',
  1309. 'Eacutesmall',
  1310. 'Egravesmall',
  1311. 'Ecircumflexsmall',
  1312. 'Edieresissmall',
  1313. 'Iacutesmall',
  1314. 'Igravesmall',
  1315. 'Icircumflexsmall',
  1316. 'Idieresissmall',
  1317. 'Ntildesmall',
  1318. 'Oacutesmall',
  1319. 'Ogravesmall',
  1320. 'Ocircumflexsmall',
  1321. 'Odieresissmall',
  1322. 'Otildesmall',
  1323. 'Uacutesmall',
  1324. 'Ugravesmall',
  1325. 'Ucircumflexsmall',
  1326. 'Udieresissmall',
  1327. '',
  1328. 'eightsuperior',
  1329. 'fourinferior',
  1330. 'threeinferior',
  1331. 'sixinferior',
  1332. 'eightinferior',
  1333. 'seveninferior',
  1334. 'Scaronsmall',
  1335. '',
  1336. 'centinferior',
  1337. 'twoinferior',
  1338. '',
  1339. 'Dieresissmall',
  1340. '',
  1341. 'Caronsmall',
  1342. 'osuperior',
  1343. 'fiveinferior',
  1344. '',
  1345. 'commainferior',
  1346. 'periodinferior',
  1347. 'Yacutesmall',
  1348. '',
  1349. 'dollarinferior',
  1350. '',
  1351. 'Thornsmall',
  1352. '',
  1353. 'nineinferior',
  1354. 'zeroinferior',
  1355. 'Zcaronsmall',
  1356. 'AEsmall',
  1357. 'Oslashsmall',
  1358. 'questiondownsmall',
  1359. 'oneinferior',
  1360. 'Lslashsmall',
  1361. '',
  1362. '',
  1363. '',
  1364. '',
  1365. '',
  1366. '',
  1367. 'Cedillasmall',
  1368. '',
  1369. '',
  1370. '',
  1371. '',
  1372. '',
  1373. 'OEsmall',
  1374. 'figuredash',
  1375. 'hyphensuperior',
  1376. '',
  1377. '',
  1378. '',
  1379. '',
  1380. 'exclamdownsmall',
  1381. '',
  1382. 'Ydieresissmall',
  1383. '',
  1384. 'onesuperior',
  1385. 'twosuperior',
  1386. 'threesuperior',
  1387. 'foursuperior',
  1388. 'fivesuperior',
  1389. 'sixsuperior',
  1390. 'sevensuperior',
  1391. 'ninesuperior',
  1392. 'zerosuperior',
  1393. '',
  1394. 'esuperior',
  1395. 'rsuperior',
  1396. 'tsuperior',
  1397. '',
  1398. '',
  1399. 'isuperior',
  1400. 'ssuperior',
  1401. 'dsuperior',
  1402. '',
  1403. '',
  1404. '',
  1405. '',
  1406. '',
  1407. 'lsuperior',
  1408. 'Ogoneksmall',
  1409. 'Brevesmall',
  1410. 'Macronsmall',
  1411. 'bsuperior',
  1412. 'nsuperior',
  1413. 'msuperior',
  1414. 'commasuperior',
  1415. 'periodsuperior',
  1416. 'Dotaccentsmall',
  1417. 'Ringsmall'
  1418. ];
  1419. var MacRomanEncoding = [
  1420. '',
  1421. '',
  1422. '',
  1423. '',
  1424. '',
  1425. '',
  1426. '',
  1427. '',
  1428. '',
  1429. '',
  1430. '',
  1431. '',
  1432. '',
  1433. '',
  1434. '',
  1435. '',
  1436. '',
  1437. '',
  1438. '',
  1439. '',
  1440. '',
  1441. '',
  1442. '',
  1443. '',
  1444. '',
  1445. '',
  1446. '',
  1447. '',
  1448. '',
  1449. '',
  1450. '',
  1451. '',
  1452. 'space',
  1453. 'exclam',
  1454. 'quotedbl',
  1455. 'numbersign',
  1456. 'dollar',
  1457. 'percent',
  1458. 'ampersand',
  1459. 'quotesingle',
  1460. 'parenleft',
  1461. 'parenright',
  1462. 'asterisk',
  1463. 'plus',
  1464. 'comma',
  1465. 'hyphen',
  1466. 'period',
  1467. 'slash',
  1468. 'zero',
  1469. 'one',
  1470. 'two',
  1471. 'three',
  1472. 'four',
  1473. 'five',
  1474. 'six',
  1475. 'seven',
  1476. 'eight',
  1477. 'nine',
  1478. 'colon',
  1479. 'semicolon',
  1480. 'less',
  1481. 'equal',
  1482. 'greater',
  1483. 'question',
  1484. 'at',
  1485. 'A',
  1486. 'B',
  1487. 'C',
  1488. 'D',
  1489. 'E',
  1490. 'F',
  1491. 'G',
  1492. 'H',
  1493. 'I',
  1494. 'J',
  1495. 'K',
  1496. 'L',
  1497. 'M',
  1498. 'N',
  1499. 'O',
  1500. 'P',
  1501. 'Q',
  1502. 'R',
  1503. 'S',
  1504. 'T',
  1505. 'U',
  1506. 'V',
  1507. 'W',
  1508. 'X',
  1509. 'Y',
  1510. 'Z',
  1511. 'bracketleft',
  1512. 'backslash',
  1513. 'bracketright',
  1514. 'asciicircum',
  1515. 'underscore',
  1516. 'grave',
  1517. 'a',
  1518. 'b',
  1519. 'c',
  1520. 'd',
  1521. 'e',
  1522. 'f',
  1523. 'g',
  1524. 'h',
  1525. 'i',
  1526. 'j',
  1527. 'k',
  1528. 'l',
  1529. 'm',
  1530. 'n',
  1531. 'o',
  1532. 'p',
  1533. 'q',
  1534. 'r',
  1535. 's',
  1536. 't',
  1537. 'u',
  1538. 'v',
  1539. 'w',
  1540. 'x',
  1541. 'y',
  1542. 'z',
  1543. 'braceleft',
  1544. 'bar',
  1545. 'braceright',
  1546. 'asciitilde',
  1547. '',
  1548. 'Adieresis',
  1549. 'Aring',
  1550. 'Ccedilla',
  1551. 'Eacute',
  1552. 'Ntilde',
  1553. 'Odieresis',
  1554. 'Udieresis',
  1555. 'aacute',
  1556. 'agrave',
  1557. 'acircumflex',
  1558. 'adieresis',
  1559. 'atilde',
  1560. 'aring',
  1561. 'ccedilla',
  1562. 'eacute',
  1563. 'egrave',
  1564. 'ecircumflex',
  1565. 'edieresis',
  1566. 'iacute',
  1567. 'igrave',
  1568. 'icircumflex',
  1569. 'idieresis',
  1570. 'ntilde',
  1571. 'oacute',
  1572. 'ograve',
  1573. 'ocircumflex',
  1574. 'odieresis',
  1575. 'otilde',
  1576. 'uacute',
  1577. 'ugrave',
  1578. 'ucircumflex',
  1579. 'udieresis',
  1580. 'dagger',
  1581. 'degree',
  1582. 'cent',
  1583. 'sterling',
  1584. 'section',
  1585. 'bullet',
  1586. 'paragraph',
  1587. 'germandbls',
  1588. 'registered',
  1589. 'copyright',
  1590. 'trademark',
  1591. 'acute',
  1592. 'dieresis',
  1593. 'notequal',
  1594. 'AE',
  1595. 'Oslash',
  1596. 'infinity',
  1597. 'plusminus',
  1598. 'lessequal',
  1599. 'greaterequal',
  1600. 'yen',
  1601. 'mu',
  1602. 'partialdiff',
  1603. 'summation',
  1604. 'product',
  1605. 'pi',
  1606. 'integral',
  1607. 'ordfeminine',
  1608. 'ordmasculine',
  1609. 'Omega',
  1610. 'ae',
  1611. 'oslash',
  1612. 'questiondown',
  1613. 'exclamdown',
  1614. 'logicalnot',
  1615. 'radical',
  1616. 'florin',
  1617. 'approxequal',
  1618. 'Delta',
  1619. 'guillemotleft',
  1620. 'guillemotright',
  1621. 'ellipsis',
  1622. 'space',
  1623. 'Agrave',
  1624. 'Atilde',
  1625. 'Otilde',
  1626. 'OE',
  1627. 'oe',
  1628. 'endash',
  1629. 'emdash',
  1630. 'quotedblleft',
  1631. 'quotedblright',
  1632. 'quoteleft',
  1633. 'quoteright',
  1634. 'divide',
  1635. 'lozenge',
  1636. 'ydieresis',
  1637. 'Ydieresis',
  1638. 'fraction',
  1639. 'currency',
  1640. 'guilsinglleft',
  1641. 'guilsinglright',
  1642. 'fi',
  1643. 'fl',
  1644. 'daggerdbl',
  1645. 'periodcentered',
  1646. 'quotesinglbase',
  1647. 'quotedblbase',
  1648. 'perthousand',
  1649. 'Acircumflex',
  1650. 'Ecircumflex',
  1651. 'Aacute',
  1652. 'Edieresis',
  1653. 'Egrave',
  1654. 'Iacute',
  1655. 'Icircumflex',
  1656. 'Idieresis',
  1657. 'Igrave',
  1658. 'Oacute',
  1659. 'Ocircumflex',
  1660. 'apple',
  1661. 'Ograve',
  1662. 'Uacute',
  1663. 'Ucircumflex',
  1664. 'Ugrave',
  1665. 'dotlessi',
  1666. 'circumflex',
  1667. 'tilde',
  1668. 'macron',
  1669. 'breve',
  1670. 'dotaccent',
  1671. 'ring',
  1672. 'cedilla',
  1673. 'hungarumlaut',
  1674. 'ogonek',
  1675. 'caron'
  1676. ];
  1677. var StandardEncoding = [
  1678. '',
  1679. '',
  1680. '',
  1681. '',
  1682. '',
  1683. '',
  1684. '',
  1685. '',
  1686. '',
  1687. '',
  1688. '',
  1689. '',
  1690. '',
  1691. '',
  1692. '',
  1693. '',
  1694. '',
  1695. '',
  1696. '',
  1697. '',
  1698. '',
  1699. '',
  1700. '',
  1701. '',
  1702. '',
  1703. '',
  1704. '',
  1705. '',
  1706. '',
  1707. '',
  1708. '',
  1709. '',
  1710. 'space',
  1711. 'exclam',
  1712. 'quotedbl',
  1713. 'numbersign',
  1714. 'dollar',
  1715. 'percent',
  1716. 'ampersand',
  1717. 'quoteright',
  1718. 'parenleft',
  1719. 'parenright',
  1720. 'asterisk',
  1721. 'plus',
  1722. 'comma',
  1723. 'hyphen',
  1724. 'period',
  1725. 'slash',
  1726. 'zero',
  1727. 'one',
  1728. 'two',
  1729. 'three',
  1730. 'four',
  1731. 'five',
  1732. 'six',
  1733. 'seven',
  1734. 'eight',
  1735. 'nine',
  1736. 'colon',
  1737. 'semicolon',
  1738. 'less',
  1739. 'equal',
  1740. 'greater',
  1741. 'question',
  1742. 'at',
  1743. 'A',
  1744. 'B',
  1745. 'C',
  1746. 'D',
  1747. 'E',
  1748. 'F',
  1749. 'G',
  1750. 'H',
  1751. 'I',
  1752. 'J',
  1753. 'K',
  1754. 'L',
  1755. 'M',
  1756. 'N',
  1757. 'O',
  1758. 'P',
  1759. 'Q',
  1760. 'R',
  1761. 'S',
  1762. 'T',
  1763. 'U',
  1764. 'V',
  1765. 'W',
  1766. 'X',
  1767. 'Y',
  1768. 'Z',
  1769. 'bracketleft',
  1770. 'backslash',
  1771. 'bracketright',
  1772. 'asciicircum',
  1773. 'underscore',
  1774. 'quoteleft',
  1775. 'a',
  1776. 'b',
  1777. 'c',
  1778. 'd',
  1779. 'e',
  1780. 'f',
  1781. 'g',
  1782. 'h',
  1783. 'i',
  1784. 'j',
  1785. 'k',
  1786. 'l',
  1787. 'm',
  1788. 'n',
  1789. 'o',
  1790. 'p',
  1791. 'q',
  1792. 'r',
  1793. 's',
  1794. 't',
  1795. 'u',
  1796. 'v',
  1797. 'w',
  1798. 'x',
  1799. 'y',
  1800. 'z',
  1801. 'braceleft',
  1802. 'bar',
  1803. 'braceright',
  1804. 'asciitilde',
  1805. '',
  1806. '',
  1807. '',
  1808. '',
  1809. '',
  1810. '',
  1811. '',
  1812. '',
  1813. '',
  1814. '',
  1815. '',
  1816. '',
  1817. '',
  1818. '',
  1819. '',
  1820. '',
  1821. '',
  1822. '',
  1823. '',
  1824. '',
  1825. '',
  1826. '',
  1827. '',
  1828. '',
  1829. '',
  1830. '',
  1831. '',
  1832. '',
  1833. '',
  1834. '',
  1835. '',
  1836. '',
  1837. '',
  1838. '',
  1839. 'exclamdown',
  1840. 'cent',
  1841. 'sterling',
  1842. 'fraction',
  1843. 'yen',
  1844. 'florin',
  1845. 'section',
  1846. 'currency',
  1847. 'quotesingle',
  1848. 'quotedblleft',
  1849. 'guillemotleft',
  1850. 'guilsinglleft',
  1851. 'guilsinglright',
  1852. 'fi',
  1853. 'fl',
  1854. '',
  1855. 'endash',
  1856. 'dagger',
  1857. 'daggerdbl',
  1858. 'periodcentered',
  1859. '',
  1860. 'paragraph',
  1861. 'bullet',
  1862. 'quotesinglbase',
  1863. 'quotedblbase',
  1864. 'quotedblright',
  1865. 'guillemotright',
  1866. 'ellipsis',
  1867. 'perthousand',
  1868. '',
  1869. 'questiondown',
  1870. '',
  1871. 'grave',
  1872. 'acute',
  1873. 'circumflex',
  1874. 'tilde',
  1875. 'macron',
  1876. 'breve',
  1877. 'dotaccent',
  1878. 'dieresis',
  1879. '',
  1880. 'ring',
  1881. 'cedilla',
  1882. '',
  1883. 'hungarumlaut',
  1884. 'ogonek',
  1885. 'caron',
  1886. 'emdash',
  1887. '',
  1888. '',
  1889. '',
  1890. '',
  1891. '',
  1892. '',
  1893. '',
  1894. '',
  1895. '',
  1896. '',
  1897. '',
  1898. '',
  1899. '',
  1900. '',
  1901. '',
  1902. '',
  1903. 'AE',
  1904. '',
  1905. 'ordfeminine',
  1906. '',
  1907. '',
  1908. '',
  1909. '',
  1910. 'Lslash',
  1911. 'Oslash',
  1912. 'OE',
  1913. 'ordmasculine',
  1914. '',
  1915. '',
  1916. '',
  1917. '',
  1918. '',
  1919. 'ae',
  1920. '',
  1921. '',
  1922. '',
  1923. 'dotlessi',
  1924. '',
  1925. '',
  1926. 'lslash',
  1927. 'oslash',
  1928. 'oe',
  1929. 'germandbls'
  1930. ];
  1931. var WinAnsiEncoding = [
  1932. '',
  1933. '',
  1934. '',
  1935. '',
  1936. '',
  1937. '',
  1938. '',
  1939. '',
  1940. '',
  1941. '',
  1942. '',
  1943. '',
  1944. '',
  1945. '',
  1946. '',
  1947. '',
  1948. '',
  1949. '',
  1950. '',
  1951. '',
  1952. '',
  1953. '',
  1954. '',
  1955. '',
  1956. '',
  1957. '',
  1958. '',
  1959. '',
  1960. '',
  1961. '',
  1962. '',
  1963. '',
  1964. 'space',
  1965. 'exclam',
  1966. 'quotedbl',
  1967. 'numbersign',
  1968. 'dollar',
  1969. 'percent',
  1970. 'ampersand',
  1971. 'quotesingle',
  1972. 'parenleft',
  1973. 'parenright',
  1974. 'asterisk',
  1975. 'plus',
  1976. 'comma',
  1977. 'hyphen',
  1978. 'period',
  1979. 'slash',
  1980. 'zero',
  1981. 'one',
  1982. 'two',
  1983. 'three',
  1984. 'four',
  1985. 'five',
  1986. 'six',
  1987. 'seven',
  1988. 'eight',
  1989. 'nine',
  1990. 'colon',
  1991. 'semicolon',
  1992. 'less',
  1993. 'equal',
  1994. 'greater',
  1995. 'question',
  1996. 'at',
  1997. 'A',
  1998. 'B',
  1999. 'C',
  2000. 'D',
  2001. 'E',
  2002. 'F',
  2003. 'G',
  2004. 'H',
  2005. 'I',
  2006. 'J',
  2007. 'K',
  2008. 'L',
  2009. 'M',
  2010. 'N',
  2011. 'O',
  2012. 'P',
  2013. 'Q',
  2014. 'R',
  2015. 'S',
  2016. 'T',
  2017. 'U',
  2018. 'V',
  2019. 'W',
  2020. 'X',
  2021. 'Y',
  2022. 'Z',
  2023. 'bracketleft',
  2024. 'backslash',
  2025. 'bracketright',
  2026. 'asciicircum',
  2027. 'underscore',
  2028. 'grave',
  2029. 'a',
  2030. 'b',
  2031. 'c',
  2032. 'd',
  2033. 'e',
  2034. 'f',
  2035. 'g',
  2036. 'h',
  2037. 'i',
  2038. 'j',
  2039. 'k',
  2040. 'l',
  2041. 'm',
  2042. 'n',
  2043. 'o',
  2044. 'p',
  2045. 'q',
  2046. 'r',
  2047. 's',
  2048. 't',
  2049. 'u',
  2050. 'v',
  2051. 'w',
  2052. 'x',
  2053. 'y',
  2054. 'z',
  2055. 'braceleft',
  2056. 'bar',
  2057. 'braceright',
  2058. 'asciitilde',
  2059. 'bullet',
  2060. 'Euro',
  2061. 'bullet',
  2062. 'quotesinglbase',
  2063. 'florin',
  2064. 'quotedblbase',
  2065. 'ellipsis',
  2066. 'dagger',
  2067. 'daggerdbl',
  2068. 'circumflex',
  2069. 'perthousand',
  2070. 'Scaron',
  2071. 'guilsinglleft',
  2072. 'OE',
  2073. 'bullet',
  2074. 'Zcaron',
  2075. 'bullet',
  2076. 'bullet',
  2077. 'quoteleft',
  2078. 'quoteright',
  2079. 'quotedblleft',
  2080. 'quotedblright',
  2081. 'bullet',
  2082. 'endash',
  2083. 'emdash',
  2084. 'tilde',
  2085. 'trademark',
  2086. 'scaron',
  2087. 'guilsinglright',
  2088. 'oe',
  2089. 'bullet',
  2090. 'zcaron',
  2091. 'Ydieresis',
  2092. 'space',
  2093. 'exclamdown',
  2094. 'cent',
  2095. 'sterling',
  2096. 'currency',
  2097. 'yen',
  2098. 'brokenbar',
  2099. 'section',
  2100. 'dieresis',
  2101. 'copyright',
  2102. 'ordfeminine',
  2103. 'guillemotleft',
  2104. 'logicalnot',
  2105. 'hyphen',
  2106. 'registered',
  2107. 'macron',
  2108. 'degree',
  2109. 'plusminus',
  2110. 'twosuperior',
  2111. 'threesuperior',
  2112. 'acute',
  2113. 'mu',
  2114. 'paragraph',
  2115. 'periodcentered',
  2116. 'cedilla',
  2117. 'onesuperior',
  2118. 'ordmasculine',
  2119. 'guillemotright',
  2120. 'onequarter',
  2121. 'onehalf',
  2122. 'threequarters',
  2123. 'questiondown',
  2124. 'Agrave',
  2125. 'Aacute',
  2126. 'Acircumflex',
  2127. 'Atilde',
  2128. 'Adieresis',
  2129. 'Aring',
  2130. 'AE',
  2131. 'Ccedilla',
  2132. 'Egrave',
  2133. 'Eacute',
  2134. 'Ecircumflex',
  2135. 'Edieresis',
  2136. 'Igrave',
  2137. 'Iacute',
  2138. 'Icircumflex',
  2139. 'Idieresis',
  2140. 'Eth',
  2141. 'Ntilde',
  2142. 'Ograve',
  2143. 'Oacute',
  2144. 'Ocircumflex',
  2145. 'Otilde',
  2146. 'Odieresis',
  2147. 'multiply',
  2148. 'Oslash',
  2149. 'Ugrave',
  2150. 'Uacute',
  2151. 'Ucircumflex',
  2152. 'Udieresis',
  2153. 'Yacute',
  2154. 'Thorn',
  2155. 'germandbls',
  2156. 'agrave',
  2157. 'aacute',
  2158. 'acircumflex',
  2159. 'atilde',
  2160. 'adieresis',
  2161. 'aring',
  2162. 'ae',
  2163. 'ccedilla',
  2164. 'egrave',
  2165. 'eacute',
  2166. 'ecircumflex',
  2167. 'edieresis',
  2168. 'igrave',
  2169. 'iacute',
  2170. 'icircumflex',
  2171. 'idieresis',
  2172. 'eth',
  2173. 'ntilde',
  2174. 'ograve',
  2175. 'oacute',
  2176. 'ocircumflex',
  2177. 'otilde',
  2178. 'odieresis',
  2179. 'divide',
  2180. 'oslash',
  2181. 'ugrave',
  2182. 'uacute',
  2183. 'ucircumflex',
  2184. 'udieresis',
  2185. 'yacute',
  2186. 'thorn',
  2187. 'ydieresis'
  2188. ];
  2189. var SymbolSetEncoding = [
  2190. '',
  2191. '',
  2192. '',
  2193. '',
  2194. '',
  2195. '',
  2196. '',
  2197. '',
  2198. '',
  2199. '',
  2200. '',
  2201. '',
  2202. '',
  2203. '',
  2204. '',
  2205. '',
  2206. '',
  2207. '',
  2208. '',
  2209. '',
  2210. '',
  2211. '',
  2212. '',
  2213. '',
  2214. '',
  2215. '',
  2216. '',
  2217. '',
  2218. '',
  2219. '',
  2220. '',
  2221. '',
  2222. 'space',
  2223. 'exclam',
  2224. 'universal',
  2225. 'numbersign',
  2226. 'existential',
  2227. 'percent',
  2228. 'ampersand',
  2229. 'suchthat',
  2230. 'parenleft',
  2231. 'parenright',
  2232. 'asteriskmath',
  2233. 'plus',
  2234. 'comma',
  2235. 'minus',
  2236. 'period',
  2237. 'slash',
  2238. 'zero',
  2239. 'one',
  2240. 'two',
  2241. 'three',
  2242. 'four',
  2243. 'five',
  2244. 'six',
  2245. 'seven',
  2246. 'eight',
  2247. 'nine',
  2248. 'colon',
  2249. 'semicolon',
  2250. 'less',
  2251. 'equal',
  2252. 'greater',
  2253. 'question',
  2254. 'congruent',
  2255. 'Alpha',
  2256. 'Beta',
  2257. 'Chi',
  2258. 'Delta',
  2259. 'Epsilon',
  2260. 'Phi',
  2261. 'Gamma',
  2262. 'Eta',
  2263. 'Iota',
  2264. 'theta1',
  2265. 'Kappa',
  2266. 'Lambda',
  2267. 'Mu',
  2268. 'Nu',
  2269. 'Omicron',
  2270. 'Pi',
  2271. 'Theta',
  2272. 'Rho',
  2273. 'Sigma',
  2274. 'Tau',
  2275. 'Upsilon',
  2276. 'sigma1',
  2277. 'Omega',
  2278. 'Xi',
  2279. 'Psi',
  2280. 'Zeta',
  2281. 'bracketleft',
  2282. 'therefore',
  2283. 'bracketright',
  2284. 'perpendicular',
  2285. 'underscore',
  2286. 'radicalex',
  2287. 'alpha',
  2288. 'beta',
  2289. 'chi',
  2290. 'delta',
  2291. 'epsilon',
  2292. 'phi',
  2293. 'gamma',
  2294. 'eta',
  2295. 'iota',
  2296. 'phi1',
  2297. 'kappa',
  2298. 'lambda',
  2299. 'mu',
  2300. 'nu',
  2301. 'omicron',
  2302. 'pi',
  2303. 'theta',
  2304. 'rho',
  2305. 'sigma',
  2306. 'tau',
  2307. 'upsilon',
  2308. 'omega1',
  2309. 'omega',
  2310. 'xi',
  2311. 'psi',
  2312. 'zeta',
  2313. 'braceleft',
  2314. 'bar',
  2315. 'braceright',
  2316. 'similar',
  2317. '',
  2318. '',
  2319. '',
  2320. '',
  2321. '',
  2322. '',
  2323. '',
  2324. '',
  2325. '',
  2326. '',
  2327. '',
  2328. '',
  2329. '',
  2330. '',
  2331. '',
  2332. '',
  2333. '',
  2334. '',
  2335. '',
  2336. '',
  2337. '',
  2338. '',
  2339. '',
  2340. '',
  2341. '',
  2342. '',
  2343. '',
  2344. '',
  2345. '',
  2346. '',
  2347. '',
  2348. '',
  2349. '',
  2350. 'Euro',
  2351. 'Upsilon1',
  2352. 'minute',
  2353. 'lessequal',
  2354. 'fraction',
  2355. 'infinity',
  2356. 'florin',
  2357. 'club',
  2358. 'diamond',
  2359. 'heart',
  2360. 'spade',
  2361. 'arrowboth',
  2362. 'arrowleft',
  2363. 'arrowup',
  2364. 'arrowright',
  2365. 'arrowdown',
  2366. 'degree',
  2367. 'plusminus',
  2368. 'second',
  2369. 'greaterequal',
  2370. 'multiply',
  2371. 'proportional',
  2372. 'partialdiff',
  2373. 'bullet',
  2374. 'divide',
  2375. 'notequal',
  2376. 'equivalence',
  2377. 'approxequal',
  2378. 'ellipsis',
  2379. 'arrowvertex',
  2380. 'arrowhorizex',
  2381. 'carriagereturn',
  2382. 'aleph',
  2383. 'Ifraktur',
  2384. 'Rfraktur',
  2385. 'weierstrass',
  2386. 'circlemultiply',
  2387. 'circleplus',
  2388. 'emptyset',
  2389. 'intersection',
  2390. 'union',
  2391. 'propersuperset',
  2392. 'reflexsuperset',
  2393. 'notsubset',
  2394. 'propersubset',
  2395. 'reflexsubset',
  2396. 'element',
  2397. 'notelement',
  2398. 'angle',
  2399. 'gradient',
  2400. 'registerserif',
  2401. 'copyrightserif',
  2402. 'trademarkserif',
  2403. 'product',
  2404. 'radical',
  2405. 'dotmath',
  2406. 'logicalnot',
  2407. 'logicaland',
  2408. 'logicalor',
  2409. 'arrowdblboth',
  2410. 'arrowdblleft',
  2411. 'arrowdblup',
  2412. 'arrowdblright',
  2413. 'arrowdbldown',
  2414. 'lozenge',
  2415. 'angleleft',
  2416. 'registersans',
  2417. 'copyrightsans',
  2418. 'trademarksans',
  2419. 'summation',
  2420. 'parenlefttp',
  2421. 'parenleftex',
  2422. 'parenleftbt',
  2423. 'bracketlefttp',
  2424. 'bracketleftex',
  2425. 'bracketleftbt',
  2426. 'bracelefttp',
  2427. 'braceleftmid',
  2428. 'braceleftbt',
  2429. 'braceex',
  2430. '',
  2431. 'angleright',
  2432. 'integral',
  2433. 'integraltp',
  2434. 'integralex',
  2435. 'integralbt',
  2436. 'parenrighttp',
  2437. 'parenrightex',
  2438. 'parenrightbt',
  2439. 'bracketrighttp',
  2440. 'bracketrightex',
  2441. 'bracketrightbt',
  2442. 'bracerighttp',
  2443. 'bracerightmid',
  2444. 'bracerightbt'
  2445. ];
  2446. var ZapfDingbatsEncoding = [
  2447. '',
  2448. '',
  2449. '',
  2450. '',
  2451. '',
  2452. '',
  2453. '',
  2454. '',
  2455. '',
  2456. '',
  2457. '',
  2458. '',
  2459. '',
  2460. '',
  2461. '',
  2462. '',
  2463. '',
  2464. '',
  2465. '',
  2466. '',
  2467. '',
  2468. '',
  2469. '',
  2470. '',
  2471. '',
  2472. '',
  2473. '',
  2474. '',
  2475. '',
  2476. '',
  2477. '',
  2478. '',
  2479. 'space',
  2480. 'a1',
  2481. 'a2',
  2482. 'a202',
  2483. 'a3',
  2484. 'a4',
  2485. 'a5',
  2486. 'a119',
  2487. 'a118',
  2488. 'a117',
  2489. 'a11',
  2490. 'a12',
  2491. 'a13',
  2492. 'a14',
  2493. 'a15',
  2494. 'a16',
  2495. 'a105',
  2496. 'a17',
  2497. 'a18',
  2498. 'a19',
  2499. 'a20',
  2500. 'a21',
  2501. 'a22',
  2502. 'a23',
  2503. 'a24',
  2504. 'a25',
  2505. 'a26',
  2506. 'a27',
  2507. 'a28',
  2508. 'a6',
  2509. 'a7',
  2510. 'a8',
  2511. 'a9',
  2512. 'a10',
  2513. 'a29',
  2514. 'a30',
  2515. 'a31',
  2516. 'a32',
  2517. 'a33',
  2518. 'a34',
  2519. 'a35',
  2520. 'a36',
  2521. 'a37',
  2522. 'a38',
  2523. 'a39',
  2524. 'a40',
  2525. 'a41',
  2526. 'a42',
  2527. 'a43',
  2528. 'a44',
  2529. 'a45',
  2530. 'a46',
  2531. 'a47',
  2532. 'a48',
  2533. 'a49',
  2534. 'a50',
  2535. 'a51',
  2536. 'a52',
  2537. 'a53',
  2538. 'a54',
  2539. 'a55',
  2540. 'a56',
  2541. 'a57',
  2542. 'a58',
  2543. 'a59',
  2544. 'a60',
  2545. 'a61',
  2546. 'a62',
  2547. 'a63',
  2548. 'a64',
  2549. 'a65',
  2550. 'a66',
  2551. 'a67',
  2552. 'a68',
  2553. 'a69',
  2554. 'a70',
  2555. 'a71',
  2556. 'a72',
  2557. 'a73',
  2558. 'a74',
  2559. 'a203',
  2560. 'a75',
  2561. 'a204',
  2562. 'a76',
  2563. 'a77',
  2564. 'a78',
  2565. 'a79',
  2566. 'a81',
  2567. 'a82',
  2568. 'a83',
  2569. 'a84',
  2570. 'a97',
  2571. 'a98',
  2572. 'a99',
  2573. 'a100',
  2574. '',
  2575. 'a89',
  2576. 'a90',
  2577. 'a93',
  2578. 'a94',
  2579. 'a91',
  2580. 'a92',
  2581. 'a205',
  2582. 'a85',
  2583. 'a206',
  2584. 'a86',
  2585. 'a87',
  2586. 'a88',
  2587. 'a95',
  2588. 'a96',
  2589. '',
  2590. '',
  2591. '',
  2592. '',
  2593. '',
  2594. '',
  2595. '',
  2596. '',
  2597. '',
  2598. '',
  2599. '',
  2600. '',
  2601. '',
  2602. '',
  2603. '',
  2604. '',
  2605. '',
  2606. '',
  2607. '',
  2608. 'a101',
  2609. 'a102',
  2610. 'a103',
  2611. 'a104',
  2612. 'a106',
  2613. 'a107',
  2614. 'a108',
  2615. 'a112',
  2616. 'a111',
  2617. 'a110',
  2618. 'a109',
  2619. 'a120',
  2620. 'a121',
  2621. 'a122',
  2622. 'a123',
  2623. 'a124',
  2624. 'a125',
  2625. 'a126',
  2626. 'a127',
  2627. 'a128',
  2628. 'a129',
  2629. 'a130',
  2630. 'a131',
  2631. 'a132',
  2632. 'a133',
  2633. 'a134',
  2634. 'a135',
  2635. 'a136',
  2636. 'a137',
  2637. 'a138',
  2638. 'a139',
  2639. 'a140',
  2640. 'a141',
  2641. 'a142',
  2642. 'a143',
  2643. 'a144',
  2644. 'a145',
  2645. 'a146',
  2646. 'a147',
  2647. 'a148',
  2648. 'a149',
  2649. 'a150',
  2650. 'a151',
  2651. 'a152',
  2652. 'a153',
  2653. 'a154',
  2654. 'a155',
  2655. 'a156',
  2656. 'a157',
  2657. 'a158',
  2658. 'a159',
  2659. 'a160',
  2660. 'a161',
  2661. 'a163',
  2662. 'a164',
  2663. 'a196',
  2664. 'a165',
  2665. 'a192',
  2666. 'a166',
  2667. 'a167',
  2668. 'a168',
  2669. 'a169',
  2670. 'a170',
  2671. 'a171',
  2672. 'a172',
  2673. 'a173',
  2674. 'a162',
  2675. 'a174',
  2676. 'a175',
  2677. 'a176',
  2678. 'a177',
  2679. 'a178',
  2680. 'a179',
  2681. 'a193',
  2682. 'a180',
  2683. 'a199',
  2684. 'a181',
  2685. 'a200',
  2686. 'a182',
  2687. '',
  2688. 'a201',
  2689. 'a183',
  2690. 'a184',
  2691. 'a197',
  2692. 'a185',
  2693. 'a194',
  2694. 'a198',
  2695. 'a186',
  2696. 'a195',
  2697. 'a187',
  2698. 'a188',
  2699. 'a189',
  2700. 'a190',
  2701. 'a191'
  2702. ];
  2703. function getEncoding(encodingName) {
  2704. switch (encodingName) {
  2705. case 'WinAnsiEncoding':
  2706. return WinAnsiEncoding;
  2707. case 'StandardEncoding':
  2708. return StandardEncoding;
  2709. case 'MacRomanEncoding':
  2710. return MacRomanEncoding;
  2711. case 'SymbolSetEncoding':
  2712. return SymbolSetEncoding;
  2713. case 'ZapfDingbatsEncoding':
  2714. return ZapfDingbatsEncoding;
  2715. case 'ExpertEncoding':
  2716. return ExpertEncoding;
  2717. case 'MacExpertEncoding':
  2718. return MacExpertEncoding;
  2719. default:
  2720. return null;
  2721. }
  2722. }
  2723. exports.WinAnsiEncoding = WinAnsiEncoding;
  2724. exports.StandardEncoding = StandardEncoding;
  2725. exports.MacRomanEncoding = MacRomanEncoding;
  2726. exports.SymbolSetEncoding = SymbolSetEncoding;
  2727. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  2728. exports.ExpertEncoding = ExpertEncoding;
  2729. exports.getEncoding = getEncoding;
  2730. }));
  2731. (function (root, factory) {
  2732. factory(root.pdfjsSharedUtil = {});
  2733. }(this, function (exports) {
  2734. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  2735. var FONT_IDENTITY_MATRIX = [
  2736. 0.001,
  2737. 0,
  2738. 0,
  2739. 0.001,
  2740. 0,
  2741. 0
  2742. ];
  2743. var TextRenderingMode = {
  2744. FILL: 0,
  2745. STROKE: 1,
  2746. FILL_STROKE: 2,
  2747. INVISIBLE: 3,
  2748. FILL_ADD_TO_PATH: 4,
  2749. STROKE_ADD_TO_PATH: 5,
  2750. FILL_STROKE_ADD_TO_PATH: 6,
  2751. ADD_TO_PATH: 7,
  2752. FILL_STROKE_MASK: 3,
  2753. ADD_TO_PATH_FLAG: 4
  2754. };
  2755. var ImageKind = {
  2756. GRAYSCALE_1BPP: 1,
  2757. RGB_24BPP: 2,
  2758. RGBA_32BPP: 3
  2759. };
  2760. var AnnotationType = {
  2761. TEXT: 1,
  2762. LINK: 2,
  2763. FREETEXT: 3,
  2764. LINE: 4,
  2765. SQUARE: 5,
  2766. CIRCLE: 6,
  2767. POLYGON: 7,
  2768. POLYLINE: 8,
  2769. HIGHLIGHT: 9,
  2770. UNDERLINE: 10,
  2771. SQUIGGLY: 11,
  2772. STRIKEOUT: 12,
  2773. STAMP: 13,
  2774. CARET: 14,
  2775. INK: 15,
  2776. POPUP: 16,
  2777. FILEATTACHMENT: 17,
  2778. SOUND: 18,
  2779. MOVIE: 19,
  2780. WIDGET: 20,
  2781. SCREEN: 21,
  2782. PRINTERMARK: 22,
  2783. TRAPNET: 23,
  2784. WATERMARK: 24,
  2785. THREED: 25,
  2786. REDACT: 26
  2787. };
  2788. var AnnotationFlag = {
  2789. INVISIBLE: 0x01,
  2790. HIDDEN: 0x02,
  2791. PRINT: 0x04,
  2792. NOZOOM: 0x08,
  2793. NOROTATE: 0x10,
  2794. NOVIEW: 0x20,
  2795. READONLY: 0x40,
  2796. LOCKED: 0x80,
  2797. TOGGLENOVIEW: 0x100,
  2798. LOCKEDCONTENTS: 0x200
  2799. };
  2800. var AnnotationFieldFlag = {
  2801. READONLY: 0x0000001,
  2802. REQUIRED: 0x0000002,
  2803. NOEXPORT: 0x0000004,
  2804. MULTILINE: 0x0001000,
  2805. PASSWORD: 0x0002000,
  2806. NOTOGGLETOOFF: 0x0004000,
  2807. RADIO: 0x0008000,
  2808. PUSHBUTTON: 0x0010000,
  2809. COMBO: 0x0020000,
  2810. EDIT: 0x0040000,
  2811. SORT: 0x0080000,
  2812. FILESELECT: 0x0100000,
  2813. MULTISELECT: 0x0200000,
  2814. DONOTSPELLCHECK: 0x0400000,
  2815. DONOTSCROLL: 0x0800000,
  2816. COMB: 0x1000000,
  2817. RICHTEXT: 0x2000000,
  2818. RADIOSINUNISON: 0x2000000,
  2819. COMMITONSELCHANGE: 0x4000000
  2820. };
  2821. var AnnotationBorderStyleType = {
  2822. SOLID: 1,
  2823. DASHED: 2,
  2824. BEVELED: 3,
  2825. INSET: 4,
  2826. UNDERLINE: 5
  2827. };
  2828. var StreamType = {
  2829. UNKNOWN: 0,
  2830. FLATE: 1,
  2831. LZW: 2,
  2832. DCT: 3,
  2833. JPX: 4,
  2834. JBIG: 5,
  2835. A85: 6,
  2836. AHX: 7,
  2837. CCF: 8,
  2838. RL: 9
  2839. };
  2840. var FontType = {
  2841. UNKNOWN: 0,
  2842. TYPE1: 1,
  2843. TYPE1C: 2,
  2844. CIDFONTTYPE0: 3,
  2845. CIDFONTTYPE0C: 4,
  2846. TRUETYPE: 5,
  2847. CIDFONTTYPE2: 6,
  2848. TYPE3: 7,
  2849. OPENTYPE: 8,
  2850. TYPE0: 9,
  2851. MMTYPE1: 10
  2852. };
  2853. var VERBOSITY_LEVELS = {
  2854. errors: 0,
  2855. warnings: 1,
  2856. infos: 5
  2857. };
  2858. var OPS = {
  2859. dependency: 1,
  2860. setLineWidth: 2,
  2861. setLineCap: 3,
  2862. setLineJoin: 4,
  2863. setMiterLimit: 5,
  2864. setDash: 6,
  2865. setRenderingIntent: 7,
  2866. setFlatness: 8,
  2867. setGState: 9,
  2868. save: 10,
  2869. restore: 11,
  2870. transform: 12,
  2871. moveTo: 13,
  2872. lineTo: 14,
  2873. curveTo: 15,
  2874. curveTo2: 16,
  2875. curveTo3: 17,
  2876. closePath: 18,
  2877. rectangle: 19,
  2878. stroke: 20,
  2879. closeStroke: 21,
  2880. fill: 22,
  2881. eoFill: 23,
  2882. fillStroke: 24,
  2883. eoFillStroke: 25,
  2884. closeFillStroke: 26,
  2885. closeEOFillStroke: 27,
  2886. endPath: 28,
  2887. clip: 29,
  2888. eoClip: 30,
  2889. beginText: 31,
  2890. endText: 32,
  2891. setCharSpacing: 33,
  2892. setWordSpacing: 34,
  2893. setHScale: 35,
  2894. setLeading: 36,
  2895. setFont: 37,
  2896. setTextRenderingMode: 38,
  2897. setTextRise: 39,
  2898. moveText: 40,
  2899. setLeadingMoveText: 41,
  2900. setTextMatrix: 42,
  2901. nextLine: 43,
  2902. showText: 44,
  2903. showSpacedText: 45,
  2904. nextLineShowText: 46,
  2905. nextLineSetSpacingShowText: 47,
  2906. setCharWidth: 48,
  2907. setCharWidthAndBounds: 49,
  2908. setStrokeColorSpace: 50,
  2909. setFillColorSpace: 51,
  2910. setStrokeColor: 52,
  2911. setStrokeColorN: 53,
  2912. setFillColor: 54,
  2913. setFillColorN: 55,
  2914. setStrokeGray: 56,
  2915. setFillGray: 57,
  2916. setStrokeRGBColor: 58,
  2917. setFillRGBColor: 59,
  2918. setStrokeCMYKColor: 60,
  2919. setFillCMYKColor: 61,
  2920. shadingFill: 62,
  2921. beginInlineImage: 63,
  2922. beginImageData: 64,
  2923. endInlineImage: 65,
  2924. paintXObject: 66,
  2925. markPoint: 67,
  2926. markPointProps: 68,
  2927. beginMarkedContent: 69,
  2928. beginMarkedContentProps: 70,
  2929. endMarkedContent: 71,
  2930. beginCompat: 72,
  2931. endCompat: 73,
  2932. paintFormXObjectBegin: 74,
  2933. paintFormXObjectEnd: 75,
  2934. beginGroup: 76,
  2935. endGroup: 77,
  2936. beginAnnotations: 78,
  2937. endAnnotations: 79,
  2938. beginAnnotation: 80,
  2939. endAnnotation: 81,
  2940. paintJpegXObject: 82,
  2941. paintImageMaskXObject: 83,
  2942. paintImageMaskXObjectGroup: 84,
  2943. paintImageXObject: 85,
  2944. paintInlineImageXObject: 86,
  2945. paintInlineImageXObjectGroup: 87,
  2946. paintImageXObjectRepeat: 88,
  2947. paintImageMaskXObjectRepeat: 89,
  2948. paintSolidColorImageMask: 90,
  2949. constructPath: 91
  2950. };
  2951. var verbosity = VERBOSITY_LEVELS.warnings;
  2952. function setVerbosityLevel(level) {
  2953. verbosity = level;
  2954. }
  2955. function getVerbosityLevel() {
  2956. return verbosity;
  2957. }
  2958. function info(msg) {
  2959. if (verbosity >= VERBOSITY_LEVELS.infos) {
  2960. console.log('Info: ' + msg);
  2961. }
  2962. }
  2963. function warn(msg) {
  2964. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  2965. console.log('Warning: ' + msg);
  2966. }
  2967. }
  2968. function deprecated(details) {
  2969. console.log('Deprecated API usage: ' + details);
  2970. }
  2971. function error(msg) {
  2972. if (verbosity >= VERBOSITY_LEVELS.errors) {
  2973. console.log('Error: ' + msg);
  2974. console.log(backtrace());
  2975. }
  2976. throw new Error(msg);
  2977. }
  2978. function backtrace() {
  2979. try {
  2980. throw new Error();
  2981. } catch (e) {
  2982. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  2983. }
  2984. }
  2985. function assert(cond, msg) {
  2986. if (!cond) {
  2987. error(msg);
  2988. }
  2989. }
  2990. var UNSUPPORTED_FEATURES = {
  2991. unknown: 'unknown',
  2992. forms: 'forms',
  2993. javaScript: 'javaScript',
  2994. smask: 'smask',
  2995. shadingPattern: 'shadingPattern',
  2996. font: 'font'
  2997. };
  2998. function isSameOrigin(baseUrl, otherUrl) {
  2999. try {
  3000. var base = new URL(baseUrl);
  3001. if (!base.origin || base.origin === 'null') {
  3002. return false;
  3003. }
  3004. } catch (e) {
  3005. return false;
  3006. }
  3007. var other = new URL(otherUrl, base);
  3008. return base.origin === other.origin;
  3009. }
  3010. function isValidProtocol(url) {
  3011. if (!url) {
  3012. return false;
  3013. }
  3014. switch (url.protocol) {
  3015. case 'http:':
  3016. case 'https:':
  3017. case 'ftp:':
  3018. case 'mailto:':
  3019. case 'tel:':
  3020. return true;
  3021. default:
  3022. return false;
  3023. }
  3024. }
  3025. function createValidAbsoluteUrl(url, baseUrl) {
  3026. if (!url) {
  3027. return null;
  3028. }
  3029. try {
  3030. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3031. if (isValidProtocol(absoluteUrl)) {
  3032. return absoluteUrl;
  3033. }
  3034. } catch (ex) {
  3035. }
  3036. return null;
  3037. }
  3038. function shadow(obj, prop, value) {
  3039. Object.defineProperty(obj, prop, {
  3040. value: value,
  3041. enumerable: true,
  3042. configurable: true,
  3043. writable: false
  3044. });
  3045. return value;
  3046. }
  3047. function getLookupTableFactory(initializer) {
  3048. var lookup;
  3049. return function () {
  3050. if (initializer) {
  3051. lookup = Object.create(null);
  3052. initializer(lookup);
  3053. initializer = null;
  3054. }
  3055. return lookup;
  3056. };
  3057. }
  3058. var PasswordResponses = {
  3059. NEED_PASSWORD: 1,
  3060. INCORRECT_PASSWORD: 2
  3061. };
  3062. var PasswordException = function PasswordExceptionClosure() {
  3063. function PasswordException(msg, code) {
  3064. this.name = 'PasswordException';
  3065. this.message = msg;
  3066. this.code = code;
  3067. }
  3068. PasswordException.prototype = new Error();
  3069. PasswordException.constructor = PasswordException;
  3070. return PasswordException;
  3071. }();
  3072. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  3073. function UnknownErrorException(msg, details) {
  3074. this.name = 'UnknownErrorException';
  3075. this.message = msg;
  3076. this.details = details;
  3077. }
  3078. UnknownErrorException.prototype = new Error();
  3079. UnknownErrorException.constructor = UnknownErrorException;
  3080. return UnknownErrorException;
  3081. }();
  3082. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  3083. function InvalidPDFException(msg) {
  3084. this.name = 'InvalidPDFException';
  3085. this.message = msg;
  3086. }
  3087. InvalidPDFException.prototype = new Error();
  3088. InvalidPDFException.constructor = InvalidPDFException;
  3089. return InvalidPDFException;
  3090. }();
  3091. var MissingPDFException = function MissingPDFExceptionClosure() {
  3092. function MissingPDFException(msg) {
  3093. this.name = 'MissingPDFException';
  3094. this.message = msg;
  3095. }
  3096. MissingPDFException.prototype = new Error();
  3097. MissingPDFException.constructor = MissingPDFException;
  3098. return MissingPDFException;
  3099. }();
  3100. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  3101. function UnexpectedResponseException(msg, status) {
  3102. this.name = 'UnexpectedResponseException';
  3103. this.message = msg;
  3104. this.status = status;
  3105. }
  3106. UnexpectedResponseException.prototype = new Error();
  3107. UnexpectedResponseException.constructor = UnexpectedResponseException;
  3108. return UnexpectedResponseException;
  3109. }();
  3110. var NotImplementedException = function NotImplementedExceptionClosure() {
  3111. function NotImplementedException(msg) {
  3112. this.message = msg;
  3113. }
  3114. NotImplementedException.prototype = new Error();
  3115. NotImplementedException.prototype.name = 'NotImplementedException';
  3116. NotImplementedException.constructor = NotImplementedException;
  3117. return NotImplementedException;
  3118. }();
  3119. var MissingDataException = function MissingDataExceptionClosure() {
  3120. function MissingDataException(begin, end) {
  3121. this.begin = begin;
  3122. this.end = end;
  3123. this.message = 'Missing data [' + begin + ', ' + end + ')';
  3124. }
  3125. MissingDataException.prototype = new Error();
  3126. MissingDataException.prototype.name = 'MissingDataException';
  3127. MissingDataException.constructor = MissingDataException;
  3128. return MissingDataException;
  3129. }();
  3130. var XRefParseException = function XRefParseExceptionClosure() {
  3131. function XRefParseException(msg) {
  3132. this.message = msg;
  3133. }
  3134. XRefParseException.prototype = new Error();
  3135. XRefParseException.prototype.name = 'XRefParseException';
  3136. XRefParseException.constructor = XRefParseException;
  3137. return XRefParseException;
  3138. }();
  3139. var NullCharactersRegExp = /\x00/g;
  3140. function removeNullCharacters(str) {
  3141. if (typeof str !== 'string') {
  3142. warn('The argument for removeNullCharacters must be a string.');
  3143. return str;
  3144. }
  3145. return str.replace(NullCharactersRegExp, '');
  3146. }
  3147. function bytesToString(bytes) {
  3148. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  3149. var length = bytes.length;
  3150. var MAX_ARGUMENT_COUNT = 8192;
  3151. if (length < MAX_ARGUMENT_COUNT) {
  3152. return String.fromCharCode.apply(null, bytes);
  3153. }
  3154. var strBuf = [];
  3155. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3156. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3157. var chunk = bytes.subarray(i, chunkEnd);
  3158. strBuf.push(String.fromCharCode.apply(null, chunk));
  3159. }
  3160. return strBuf.join('');
  3161. }
  3162. function stringToBytes(str) {
  3163. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  3164. var length = str.length;
  3165. var bytes = new Uint8Array(length);
  3166. for (var i = 0; i < length; ++i) {
  3167. bytes[i] = str.charCodeAt(i) & 0xFF;
  3168. }
  3169. return bytes;
  3170. }
  3171. function arrayByteLength(arr) {
  3172. if (arr.length !== undefined) {
  3173. return arr.length;
  3174. }
  3175. assert(arr.byteLength !== undefined);
  3176. return arr.byteLength;
  3177. }
  3178. function arraysToBytes(arr) {
  3179. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  3180. return arr[0];
  3181. }
  3182. var resultLength = 0;
  3183. var i, ii = arr.length;
  3184. var item, itemLength;
  3185. for (i = 0; i < ii; i++) {
  3186. item = arr[i];
  3187. itemLength = arrayByteLength(item);
  3188. resultLength += itemLength;
  3189. }
  3190. var pos = 0;
  3191. var data = new Uint8Array(resultLength);
  3192. for (i = 0; i < ii; i++) {
  3193. item = arr[i];
  3194. if (!(item instanceof Uint8Array)) {
  3195. if (typeof item === 'string') {
  3196. item = stringToBytes(item);
  3197. } else {
  3198. item = new Uint8Array(item);
  3199. }
  3200. }
  3201. itemLength = item.byteLength;
  3202. data.set(item, pos);
  3203. pos += itemLength;
  3204. }
  3205. return data;
  3206. }
  3207. function string32(value) {
  3208. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3209. }
  3210. function log2(x) {
  3211. var n = 1, i = 0;
  3212. while (x > n) {
  3213. n <<= 1;
  3214. i++;
  3215. }
  3216. return i;
  3217. }
  3218. function readInt8(data, start) {
  3219. return data[start] << 24 >> 24;
  3220. }
  3221. function readUint16(data, offset) {
  3222. return data[offset] << 8 | data[offset + 1];
  3223. }
  3224. function readUint32(data, offset) {
  3225. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  3226. }
  3227. function isLittleEndian() {
  3228. var buffer8 = new Uint8Array(2);
  3229. buffer8[0] = 1;
  3230. var buffer16 = new Uint16Array(buffer8.buffer);
  3231. return buffer16[0] === 1;
  3232. }
  3233. function isEvalSupported() {
  3234. try {
  3235. new Function('');
  3236. return true;
  3237. } catch (e) {
  3238. return false;
  3239. }
  3240. }
  3241. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  3242. function Uint32ArrayView(buffer, length) {
  3243. this.buffer = buffer;
  3244. this.byteLength = buffer.length;
  3245. this.length = length === undefined ? this.byteLength >> 2 : length;
  3246. ensureUint32ArrayViewProps(this.length);
  3247. }
  3248. Uint32ArrayView.prototype = Object.create(null);
  3249. var uint32ArrayViewSetters = 0;
  3250. function createUint32ArrayProp(index) {
  3251. return {
  3252. get: function () {
  3253. var buffer = this.buffer, offset = index << 2;
  3254. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  3255. },
  3256. set: function (value) {
  3257. var buffer = this.buffer, offset = index << 2;
  3258. buffer[offset] = value & 255;
  3259. buffer[offset + 1] = value >> 8 & 255;
  3260. buffer[offset + 2] = value >> 16 & 255;
  3261. buffer[offset + 3] = value >>> 24 & 255;
  3262. }
  3263. };
  3264. }
  3265. function ensureUint32ArrayViewProps(length) {
  3266. while (uint32ArrayViewSetters < length) {
  3267. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  3268. uint32ArrayViewSetters++;
  3269. }
  3270. }
  3271. return Uint32ArrayView;
  3272. }();
  3273. exports.Uint32ArrayView = Uint32ArrayView;
  3274. var IDENTITY_MATRIX = [
  3275. 1,
  3276. 0,
  3277. 0,
  3278. 1,
  3279. 0,
  3280. 0
  3281. ];
  3282. var Util = function UtilClosure() {
  3283. function Util() {
  3284. }
  3285. var rgbBuf = [
  3286. 'rgb(',
  3287. 0,
  3288. ',',
  3289. 0,
  3290. ',',
  3291. 0,
  3292. ')'
  3293. ];
  3294. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  3295. rgbBuf[1] = r;
  3296. rgbBuf[3] = g;
  3297. rgbBuf[5] = b;
  3298. return rgbBuf.join('');
  3299. };
  3300. Util.transform = function Util_transform(m1, m2) {
  3301. return [
  3302. m1[0] * m2[0] + m1[2] * m2[1],
  3303. m1[1] * m2[0] + m1[3] * m2[1],
  3304. m1[0] * m2[2] + m1[2] * m2[3],
  3305. m1[1] * m2[2] + m1[3] * m2[3],
  3306. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  3307. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  3308. ];
  3309. };
  3310. Util.applyTransform = function Util_applyTransform(p, m) {
  3311. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  3312. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  3313. return [
  3314. xt,
  3315. yt
  3316. ];
  3317. };
  3318. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  3319. var d = m[0] * m[3] - m[1] * m[2];
  3320. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  3321. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  3322. return [
  3323. xt,
  3324. yt
  3325. ];
  3326. };
  3327. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  3328. var p1 = Util.applyTransform(r, m);
  3329. var p2 = Util.applyTransform(r.slice(2, 4), m);
  3330. var p3 = Util.applyTransform([
  3331. r[0],
  3332. r[3]
  3333. ], m);
  3334. var p4 = Util.applyTransform([
  3335. r[2],
  3336. r[1]
  3337. ], m);
  3338. return [
  3339. Math.min(p1[0], p2[0], p3[0], p4[0]),
  3340. Math.min(p1[1], p2[1], p3[1], p4[1]),
  3341. Math.max(p1[0], p2[0], p3[0], p4[0]),
  3342. Math.max(p1[1], p2[1], p3[1], p4[1])
  3343. ];
  3344. };
  3345. Util.inverseTransform = function Util_inverseTransform(m) {
  3346. var d = m[0] * m[3] - m[1] * m[2];
  3347. return [
  3348. m[3] / d,
  3349. -m[1] / d,
  3350. -m[2] / d,
  3351. m[0] / d,
  3352. (m[2] * m[5] - m[4] * m[3]) / d,
  3353. (m[4] * m[1] - m[5] * m[0]) / d
  3354. ];
  3355. };
  3356. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  3357. return [
  3358. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  3359. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  3360. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  3361. ];
  3362. };
  3363. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  3364. var transpose = [
  3365. m[0],
  3366. m[2],
  3367. m[1],
  3368. m[3]
  3369. ];
  3370. var a = m[0] * transpose[0] + m[1] * transpose[2];
  3371. var b = m[0] * transpose[1] + m[1] * transpose[3];
  3372. var c = m[2] * transpose[0] + m[3] * transpose[2];
  3373. var d = m[2] * transpose[1] + m[3] * transpose[3];
  3374. var first = (a + d) / 2;
  3375. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  3376. var sx = first + second || 1;
  3377. var sy = first - second || 1;
  3378. return [
  3379. Math.sqrt(sx),
  3380. Math.sqrt(sy)
  3381. ];
  3382. };
  3383. Util.normalizeRect = function Util_normalizeRect(rect) {
  3384. var r = rect.slice(0);
  3385. if (rect[0] > rect[2]) {
  3386. r[0] = rect[2];
  3387. r[2] = rect[0];
  3388. }
  3389. if (rect[1] > rect[3]) {
  3390. r[1] = rect[3];
  3391. r[3] = rect[1];
  3392. }
  3393. return r;
  3394. };
  3395. Util.intersect = function Util_intersect(rect1, rect2) {
  3396. function compare(a, b) {
  3397. return a - b;
  3398. }
  3399. var orderedX = [
  3400. rect1[0],
  3401. rect1[2],
  3402. rect2[0],
  3403. rect2[2]
  3404. ].sort(compare), orderedY = [
  3405. rect1[1],
  3406. rect1[3],
  3407. rect2[1],
  3408. rect2[3]
  3409. ].sort(compare), result = [];
  3410. rect1 = Util.normalizeRect(rect1);
  3411. rect2 = Util.normalizeRect(rect2);
  3412. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  3413. result[0] = orderedX[1];
  3414. result[2] = orderedX[2];
  3415. } else {
  3416. return false;
  3417. }
  3418. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  3419. result[1] = orderedY[1];
  3420. result[3] = orderedY[2];
  3421. } else {
  3422. return false;
  3423. }
  3424. return result;
  3425. };
  3426. Util.sign = function Util_sign(num) {
  3427. return num < 0 ? -1 : 1;
  3428. };
  3429. var ROMAN_NUMBER_MAP = [
  3430. '',
  3431. 'C',
  3432. 'CC',
  3433. 'CCC',
  3434. 'CD',
  3435. 'D',
  3436. 'DC',
  3437. 'DCC',
  3438. 'DCCC',
  3439. 'CM',
  3440. '',
  3441. 'X',
  3442. 'XX',
  3443. 'XXX',
  3444. 'XL',
  3445. 'L',
  3446. 'LX',
  3447. 'LXX',
  3448. 'LXXX',
  3449. 'XC',
  3450. '',
  3451. 'I',
  3452. 'II',
  3453. 'III',
  3454. 'IV',
  3455. 'V',
  3456. 'VI',
  3457. 'VII',
  3458. 'VIII',
  3459. 'IX'
  3460. ];
  3461. Util.toRoman = function Util_toRoman(number, lowerCase) {
  3462. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  3463. var pos, romanBuf = [];
  3464. while (number >= 1000) {
  3465. number -= 1000;
  3466. romanBuf.push('M');
  3467. }
  3468. pos = number / 100 | 0;
  3469. number %= 100;
  3470. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  3471. pos = number / 10 | 0;
  3472. number %= 10;
  3473. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  3474. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  3475. var romanStr = romanBuf.join('');
  3476. return lowerCase ? romanStr.toLowerCase() : romanStr;
  3477. };
  3478. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  3479. Array.prototype.push.apply(arr1, arr2);
  3480. };
  3481. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  3482. Array.prototype.unshift.apply(arr1, arr2);
  3483. };
  3484. Util.extendObj = function extendObj(obj1, obj2) {
  3485. for (var key in obj2) {
  3486. obj1[key] = obj2[key];
  3487. }
  3488. };
  3489. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  3490. while (dict && !dict.has(name)) {
  3491. dict = dict.get('Parent');
  3492. }
  3493. if (!dict) {
  3494. return null;
  3495. }
  3496. return getArray ? dict.getArray(name) : dict.get(name);
  3497. };
  3498. Util.inherit = function Util_inherit(sub, base, prototype) {
  3499. sub.prototype = Object.create(base.prototype);
  3500. sub.prototype.constructor = sub;
  3501. for (var prop in prototype) {
  3502. sub.prototype[prop] = prototype[prop];
  3503. }
  3504. };
  3505. Util.loadScript = function Util_loadScript(src, callback) {
  3506. var script = document.createElement('script');
  3507. var loaded = false;
  3508. script.setAttribute('src', src);
  3509. if (callback) {
  3510. script.onload = function () {
  3511. if (!loaded) {
  3512. callback();
  3513. }
  3514. loaded = true;
  3515. };
  3516. }
  3517. document.getElementsByTagName('head')[0].appendChild(script);
  3518. };
  3519. return Util;
  3520. }();
  3521. var PageViewport = function PageViewportClosure() {
  3522. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  3523. this.viewBox = viewBox;
  3524. this.scale = scale;
  3525. this.rotation = rotation;
  3526. this.offsetX = offsetX;
  3527. this.offsetY = offsetY;
  3528. var centerX = (viewBox[2] + viewBox[0]) / 2;
  3529. var centerY = (viewBox[3] + viewBox[1]) / 2;
  3530. var rotateA, rotateB, rotateC, rotateD;
  3531. rotation = rotation % 360;
  3532. rotation = rotation < 0 ? rotation + 360 : rotation;
  3533. switch (rotation) {
  3534. case 180:
  3535. rotateA = -1;
  3536. rotateB = 0;
  3537. rotateC = 0;
  3538. rotateD = 1;
  3539. break;
  3540. case 90:
  3541. rotateA = 0;
  3542. rotateB = 1;
  3543. rotateC = 1;
  3544. rotateD = 0;
  3545. break;
  3546. case 270:
  3547. rotateA = 0;
  3548. rotateB = -1;
  3549. rotateC = -1;
  3550. rotateD = 0;
  3551. break;
  3552. default:
  3553. rotateA = 1;
  3554. rotateB = 0;
  3555. rotateC = 0;
  3556. rotateD = -1;
  3557. break;
  3558. }
  3559. if (dontFlip) {
  3560. rotateC = -rotateC;
  3561. rotateD = -rotateD;
  3562. }
  3563. var offsetCanvasX, offsetCanvasY;
  3564. var width, height;
  3565. if (rotateA === 0) {
  3566. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  3567. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  3568. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3569. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3570. } else {
  3571. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  3572. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  3573. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3574. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3575. }
  3576. this.transform = [
  3577. rotateA * scale,
  3578. rotateB * scale,
  3579. rotateC * scale,
  3580. rotateD * scale,
  3581. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  3582. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  3583. ];
  3584. this.width = width;
  3585. this.height = height;
  3586. this.fontScale = scale;
  3587. }
  3588. PageViewport.prototype = {
  3589. clone: function PageViewPort_clone(args) {
  3590. args = args || {};
  3591. var scale = 'scale' in args ? args.scale : this.scale;
  3592. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  3593. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  3594. },
  3595. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  3596. return Util.applyTransform([
  3597. x,
  3598. y
  3599. ], this.transform);
  3600. },
  3601. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  3602. var tl = Util.applyTransform([
  3603. rect[0],
  3604. rect[1]
  3605. ], this.transform);
  3606. var br = Util.applyTransform([
  3607. rect[2],
  3608. rect[3]
  3609. ], this.transform);
  3610. return [
  3611. tl[0],
  3612. tl[1],
  3613. br[0],
  3614. br[1]
  3615. ];
  3616. },
  3617. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  3618. return Util.applyInverseTransform([
  3619. x,
  3620. y
  3621. ], this.transform);
  3622. }
  3623. };
  3624. return PageViewport;
  3625. }();
  3626. var PDFStringTranslateTable = [
  3627. 0,
  3628. 0,
  3629. 0,
  3630. 0,
  3631. 0,
  3632. 0,
  3633. 0,
  3634. 0,
  3635. 0,
  3636. 0,
  3637. 0,
  3638. 0,
  3639. 0,
  3640. 0,
  3641. 0,
  3642. 0,
  3643. 0,
  3644. 0,
  3645. 0,
  3646. 0,
  3647. 0,
  3648. 0,
  3649. 0,
  3650. 0,
  3651. 0x2D8,
  3652. 0x2C7,
  3653. 0x2C6,
  3654. 0x2D9,
  3655. 0x2DD,
  3656. 0x2DB,
  3657. 0x2DA,
  3658. 0x2DC,
  3659. 0,
  3660. 0,
  3661. 0,
  3662. 0,
  3663. 0,
  3664. 0,
  3665. 0,
  3666. 0,
  3667. 0,
  3668. 0,
  3669. 0,
  3670. 0,
  3671. 0,
  3672. 0,
  3673. 0,
  3674. 0,
  3675. 0,
  3676. 0,
  3677. 0,
  3678. 0,
  3679. 0,
  3680. 0,
  3681. 0,
  3682. 0,
  3683. 0,
  3684. 0,
  3685. 0,
  3686. 0,
  3687. 0,
  3688. 0,
  3689. 0,
  3690. 0,
  3691. 0,
  3692. 0,
  3693. 0,
  3694. 0,
  3695. 0,
  3696. 0,
  3697. 0,
  3698. 0,
  3699. 0,
  3700. 0,
  3701. 0,
  3702. 0,
  3703. 0,
  3704. 0,
  3705. 0,
  3706. 0,
  3707. 0,
  3708. 0,
  3709. 0,
  3710. 0,
  3711. 0,
  3712. 0,
  3713. 0,
  3714. 0,
  3715. 0,
  3716. 0,
  3717. 0,
  3718. 0,
  3719. 0,
  3720. 0,
  3721. 0,
  3722. 0,
  3723. 0,
  3724. 0,
  3725. 0,
  3726. 0,
  3727. 0,
  3728. 0,
  3729. 0,
  3730. 0,
  3731. 0,
  3732. 0,
  3733. 0,
  3734. 0,
  3735. 0,
  3736. 0,
  3737. 0,
  3738. 0,
  3739. 0,
  3740. 0,
  3741. 0,
  3742. 0,
  3743. 0,
  3744. 0,
  3745. 0,
  3746. 0,
  3747. 0,
  3748. 0,
  3749. 0,
  3750. 0,
  3751. 0,
  3752. 0,
  3753. 0,
  3754. 0,
  3755. 0x2022,
  3756. 0x2020,
  3757. 0x2021,
  3758. 0x2026,
  3759. 0x2014,
  3760. 0x2013,
  3761. 0x192,
  3762. 0x2044,
  3763. 0x2039,
  3764. 0x203A,
  3765. 0x2212,
  3766. 0x2030,
  3767. 0x201E,
  3768. 0x201C,
  3769. 0x201D,
  3770. 0x2018,
  3771. 0x2019,
  3772. 0x201A,
  3773. 0x2122,
  3774. 0xFB01,
  3775. 0xFB02,
  3776. 0x141,
  3777. 0x152,
  3778. 0x160,
  3779. 0x178,
  3780. 0x17D,
  3781. 0x131,
  3782. 0x142,
  3783. 0x153,
  3784. 0x161,
  3785. 0x17E,
  3786. 0,
  3787. 0x20AC
  3788. ];
  3789. function stringToPDFString(str) {
  3790. var i, n = str.length, strBuf = [];
  3791. if (str[0] === '\xFE' && str[1] === '\xFF') {
  3792. for (i = 2; i < n; i += 2) {
  3793. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  3794. }
  3795. } else {
  3796. for (i = 0; i < n; ++i) {
  3797. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  3798. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  3799. }
  3800. }
  3801. return strBuf.join('');
  3802. }
  3803. function stringToUTF8String(str) {
  3804. return decodeURIComponent(escape(str));
  3805. }
  3806. function utf8StringToString(str) {
  3807. return unescape(encodeURIComponent(str));
  3808. }
  3809. function isEmptyObj(obj) {
  3810. for (var key in obj) {
  3811. return false;
  3812. }
  3813. return true;
  3814. }
  3815. function isBool(v) {
  3816. return typeof v === 'boolean';
  3817. }
  3818. function isInt(v) {
  3819. return typeof v === 'number' && (v | 0) === v;
  3820. }
  3821. function isNum(v) {
  3822. return typeof v === 'number';
  3823. }
  3824. function isString(v) {
  3825. return typeof v === 'string';
  3826. }
  3827. function isArray(v) {
  3828. return v instanceof Array;
  3829. }
  3830. function isArrayBuffer(v) {
  3831. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  3832. }
  3833. function isSpace(ch) {
  3834. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  3835. }
  3836. function createPromiseCapability() {
  3837. var capability = {};
  3838. capability.promise = new Promise(function (resolve, reject) {
  3839. capability.resolve = resolve;
  3840. capability.reject = reject;
  3841. });
  3842. return capability;
  3843. }
  3844. (function PromiseClosure() {
  3845. if (globalScope.Promise) {
  3846. if (typeof globalScope.Promise.all !== 'function') {
  3847. globalScope.Promise.all = function (iterable) {
  3848. var count = 0, results = [], resolve, reject;
  3849. var promise = new globalScope.Promise(function (resolve_, reject_) {
  3850. resolve = resolve_;
  3851. reject = reject_;
  3852. });
  3853. iterable.forEach(function (p, i) {
  3854. count++;
  3855. p.then(function (result) {
  3856. results[i] = result;
  3857. count--;
  3858. if (count === 0) {
  3859. resolve(results);
  3860. }
  3861. }, reject);
  3862. });
  3863. if (count === 0) {
  3864. resolve(results);
  3865. }
  3866. return promise;
  3867. };
  3868. }
  3869. if (typeof globalScope.Promise.resolve !== 'function') {
  3870. globalScope.Promise.resolve = function (value) {
  3871. return new globalScope.Promise(function (resolve) {
  3872. resolve(value);
  3873. });
  3874. };
  3875. }
  3876. if (typeof globalScope.Promise.reject !== 'function') {
  3877. globalScope.Promise.reject = function (reason) {
  3878. return new globalScope.Promise(function (resolve, reject) {
  3879. reject(reason);
  3880. });
  3881. };
  3882. }
  3883. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  3884. globalScope.Promise.prototype.catch = function (onReject) {
  3885. return globalScope.Promise.prototype.then(undefined, onReject);
  3886. };
  3887. }
  3888. return;
  3889. }
  3890. var STATUS_PENDING = 0;
  3891. var STATUS_RESOLVED = 1;
  3892. var STATUS_REJECTED = 2;
  3893. var REJECTION_TIMEOUT = 500;
  3894. var HandlerManager = {
  3895. handlers: [],
  3896. running: false,
  3897. unhandledRejections: [],
  3898. pendingRejectionCheck: false,
  3899. scheduleHandlers: function scheduleHandlers(promise) {
  3900. if (promise._status === STATUS_PENDING) {
  3901. return;
  3902. }
  3903. this.handlers = this.handlers.concat(promise._handlers);
  3904. promise._handlers = [];
  3905. if (this.running) {
  3906. return;
  3907. }
  3908. this.running = true;
  3909. setTimeout(this.runHandlers.bind(this), 0);
  3910. },
  3911. runHandlers: function runHandlers() {
  3912. var RUN_TIMEOUT = 1;
  3913. var timeoutAt = Date.now() + RUN_TIMEOUT;
  3914. while (this.handlers.length > 0) {
  3915. var handler = this.handlers.shift();
  3916. var nextStatus = handler.thisPromise._status;
  3917. var nextValue = handler.thisPromise._value;
  3918. try {
  3919. if (nextStatus === STATUS_RESOLVED) {
  3920. if (typeof handler.onResolve === 'function') {
  3921. nextValue = handler.onResolve(nextValue);
  3922. }
  3923. } else if (typeof handler.onReject === 'function') {
  3924. nextValue = handler.onReject(nextValue);
  3925. nextStatus = STATUS_RESOLVED;
  3926. if (handler.thisPromise._unhandledRejection) {
  3927. this.removeUnhandeledRejection(handler.thisPromise);
  3928. }
  3929. }
  3930. } catch (ex) {
  3931. nextStatus = STATUS_REJECTED;
  3932. nextValue = ex;
  3933. }
  3934. handler.nextPromise._updateStatus(nextStatus, nextValue);
  3935. if (Date.now() >= timeoutAt) {
  3936. break;
  3937. }
  3938. }
  3939. if (this.handlers.length > 0) {
  3940. setTimeout(this.runHandlers.bind(this), 0);
  3941. return;
  3942. }
  3943. this.running = false;
  3944. },
  3945. addUnhandledRejection: function addUnhandledRejection(promise) {
  3946. this.unhandledRejections.push({
  3947. promise: promise,
  3948. time: Date.now()
  3949. });
  3950. this.scheduleRejectionCheck();
  3951. },
  3952. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  3953. promise._unhandledRejection = false;
  3954. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3955. if (this.unhandledRejections[i].promise === promise) {
  3956. this.unhandledRejections.splice(i);
  3957. i--;
  3958. }
  3959. }
  3960. },
  3961. scheduleRejectionCheck: function scheduleRejectionCheck() {
  3962. if (this.pendingRejectionCheck) {
  3963. return;
  3964. }
  3965. this.pendingRejectionCheck = true;
  3966. setTimeout(function rejectionCheck() {
  3967. this.pendingRejectionCheck = false;
  3968. var now = Date.now();
  3969. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3970. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  3971. var unhandled = this.unhandledRejections[i].promise._value;
  3972. var msg = 'Unhandled rejection: ' + unhandled;
  3973. if (unhandled.stack) {
  3974. msg += '\n' + unhandled.stack;
  3975. }
  3976. warn(msg);
  3977. this.unhandledRejections.splice(i);
  3978. i--;
  3979. }
  3980. }
  3981. if (this.unhandledRejections.length) {
  3982. this.scheduleRejectionCheck();
  3983. }
  3984. }.bind(this), REJECTION_TIMEOUT);
  3985. }
  3986. };
  3987. var Promise = function Promise(resolver) {
  3988. this._status = STATUS_PENDING;
  3989. this._handlers = [];
  3990. try {
  3991. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  3992. } catch (e) {
  3993. this._reject(e);
  3994. }
  3995. };
  3996. Promise.all = function Promise_all(promises) {
  3997. var resolveAll, rejectAll;
  3998. var deferred = new Promise(function (resolve, reject) {
  3999. resolveAll = resolve;
  4000. rejectAll = reject;
  4001. });
  4002. var unresolved = promises.length;
  4003. var results = [];
  4004. if (unresolved === 0) {
  4005. resolveAll(results);
  4006. return deferred;
  4007. }
  4008. function reject(reason) {
  4009. if (deferred._status === STATUS_REJECTED) {
  4010. return;
  4011. }
  4012. results = [];
  4013. rejectAll(reason);
  4014. }
  4015. for (var i = 0, ii = promises.length; i < ii; ++i) {
  4016. var promise = promises[i];
  4017. var resolve = function (i) {
  4018. return function (value) {
  4019. if (deferred._status === STATUS_REJECTED) {
  4020. return;
  4021. }
  4022. results[i] = value;
  4023. unresolved--;
  4024. if (unresolved === 0) {
  4025. resolveAll(results);
  4026. }
  4027. };
  4028. }(i);
  4029. if (Promise.isPromise(promise)) {
  4030. promise.then(resolve, reject);
  4031. } else {
  4032. resolve(promise);
  4033. }
  4034. }
  4035. return deferred;
  4036. };
  4037. Promise.isPromise = function Promise_isPromise(value) {
  4038. return value && typeof value.then === 'function';
  4039. };
  4040. Promise.resolve = function Promise_resolve(value) {
  4041. return new Promise(function (resolve) {
  4042. resolve(value);
  4043. });
  4044. };
  4045. Promise.reject = function Promise_reject(reason) {
  4046. return new Promise(function (resolve, reject) {
  4047. reject(reason);
  4048. });
  4049. };
  4050. Promise.prototype = {
  4051. _status: null,
  4052. _value: null,
  4053. _handlers: null,
  4054. _unhandledRejection: null,
  4055. _updateStatus: function Promise__updateStatus(status, value) {
  4056. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  4057. return;
  4058. }
  4059. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  4060. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  4061. return;
  4062. }
  4063. this._status = status;
  4064. this._value = value;
  4065. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  4066. this._unhandledRejection = true;
  4067. HandlerManager.addUnhandledRejection(this);
  4068. }
  4069. HandlerManager.scheduleHandlers(this);
  4070. },
  4071. _resolve: function Promise_resolve(value) {
  4072. this._updateStatus(STATUS_RESOLVED, value);
  4073. },
  4074. _reject: function Promise_reject(reason) {
  4075. this._updateStatus(STATUS_REJECTED, reason);
  4076. },
  4077. then: function Promise_then(onResolve, onReject) {
  4078. var nextPromise = new Promise(function (resolve, reject) {
  4079. this.resolve = resolve;
  4080. this.reject = reject;
  4081. });
  4082. this._handlers.push({
  4083. thisPromise: this,
  4084. onResolve: onResolve,
  4085. onReject: onReject,
  4086. nextPromise: nextPromise
  4087. });
  4088. HandlerManager.scheduleHandlers(this);
  4089. return nextPromise;
  4090. },
  4091. catch: function Promise_catch(onReject) {
  4092. return this.then(undefined, onReject);
  4093. }
  4094. };
  4095. globalScope.Promise = Promise;
  4096. }());
  4097. (function WeakMapClosure() {
  4098. if (globalScope.WeakMap) {
  4099. return;
  4100. }
  4101. var id = 0;
  4102. function WeakMap() {
  4103. this.id = '$weakmap' + id++;
  4104. }
  4105. WeakMap.prototype = {
  4106. has: function (obj) {
  4107. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  4108. },
  4109. get: function (obj, defaultValue) {
  4110. return this.has(obj) ? obj[this.id] : defaultValue;
  4111. },
  4112. set: function (obj, value) {
  4113. Object.defineProperty(obj, this.id, {
  4114. value: value,
  4115. enumerable: false,
  4116. configurable: true
  4117. });
  4118. },
  4119. delete: function (obj) {
  4120. delete obj[this.id];
  4121. }
  4122. };
  4123. globalScope.WeakMap = WeakMap;
  4124. }());
  4125. var StatTimer = function StatTimerClosure() {
  4126. function rpad(str, pad, length) {
  4127. while (str.length < length) {
  4128. str += pad;
  4129. }
  4130. return str;
  4131. }
  4132. function StatTimer() {
  4133. this.started = Object.create(null);
  4134. this.times = [];
  4135. this.enabled = true;
  4136. }
  4137. StatTimer.prototype = {
  4138. time: function StatTimer_time(name) {
  4139. if (!this.enabled) {
  4140. return;
  4141. }
  4142. if (name in this.started) {
  4143. warn('Timer is already running for ' + name);
  4144. }
  4145. this.started[name] = Date.now();
  4146. },
  4147. timeEnd: function StatTimer_timeEnd(name) {
  4148. if (!this.enabled) {
  4149. return;
  4150. }
  4151. if (!(name in this.started)) {
  4152. warn('Timer has not been started for ' + name);
  4153. }
  4154. this.times.push({
  4155. 'name': name,
  4156. 'start': this.started[name],
  4157. 'end': Date.now()
  4158. });
  4159. delete this.started[name];
  4160. },
  4161. toString: function StatTimer_toString() {
  4162. var i, ii;
  4163. var times = this.times;
  4164. var out = '';
  4165. var longest = 0;
  4166. for (i = 0, ii = times.length; i < ii; ++i) {
  4167. var name = times[i]['name'];
  4168. if (name.length > longest) {
  4169. longest = name.length;
  4170. }
  4171. }
  4172. for (i = 0, ii = times.length; i < ii; ++i) {
  4173. var span = times[i];
  4174. var duration = span.end - span.start;
  4175. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  4176. }
  4177. return out;
  4178. }
  4179. };
  4180. return StatTimer;
  4181. }();
  4182. var createBlob = function createBlob(data, contentType) {
  4183. if (typeof Blob !== 'undefined') {
  4184. return new Blob([data], { type: contentType });
  4185. }
  4186. warn('The "Blob" constructor is not supported.');
  4187. };
  4188. var createObjectURL = function createObjectURLClosure() {
  4189. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  4190. return function createObjectURL(data, contentType, forceDataSchema) {
  4191. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  4192. var blob = createBlob(data, contentType);
  4193. return URL.createObjectURL(blob);
  4194. }
  4195. var buffer = 'data:' + contentType + ';base64,';
  4196. for (var i = 0, ii = data.length; i < ii; i += 3) {
  4197. var b1 = data[i] & 0xFF;
  4198. var b2 = data[i + 1] & 0xFF;
  4199. var b3 = data[i + 2] & 0xFF;
  4200. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  4201. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  4202. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  4203. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  4204. }
  4205. return buffer;
  4206. };
  4207. }();
  4208. function MessageHandler(sourceName, targetName, comObj) {
  4209. this.sourceName = sourceName;
  4210. this.targetName = targetName;
  4211. this.comObj = comObj;
  4212. this.callbackIndex = 1;
  4213. this.postMessageTransfers = true;
  4214. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  4215. var ah = this.actionHandler = Object.create(null);
  4216. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  4217. var data = event.data;
  4218. if (data.targetName !== this.sourceName) {
  4219. return;
  4220. }
  4221. if (data.isReply) {
  4222. var callbackId = data.callbackId;
  4223. if (data.callbackId in callbacksCapabilities) {
  4224. var callback = callbacksCapabilities[callbackId];
  4225. delete callbacksCapabilities[callbackId];
  4226. if ('error' in data) {
  4227. callback.reject(data.error);
  4228. } else {
  4229. callback.resolve(data.data);
  4230. }
  4231. } else {
  4232. error('Cannot resolve callback ' + callbackId);
  4233. }
  4234. } else if (data.action in ah) {
  4235. var action = ah[data.action];
  4236. if (data.callbackId) {
  4237. var sourceName = this.sourceName;
  4238. var targetName = data.sourceName;
  4239. Promise.resolve().then(function () {
  4240. return action[0].call(action[1], data.data);
  4241. }).then(function (result) {
  4242. comObj.postMessage({
  4243. sourceName: sourceName,
  4244. targetName: targetName,
  4245. isReply: true,
  4246. callbackId: data.callbackId,
  4247. data: result
  4248. });
  4249. }, function (reason) {
  4250. if (reason instanceof Error) {
  4251. reason = reason + '';
  4252. }
  4253. comObj.postMessage({
  4254. sourceName: sourceName,
  4255. targetName: targetName,
  4256. isReply: true,
  4257. callbackId: data.callbackId,
  4258. error: reason
  4259. });
  4260. });
  4261. } else {
  4262. action[0].call(action[1], data.data);
  4263. }
  4264. } else {
  4265. error('Unknown action from worker: ' + data.action);
  4266. }
  4267. }.bind(this);
  4268. comObj.addEventListener('message', this._onComObjOnMessage);
  4269. }
  4270. MessageHandler.prototype = {
  4271. on: function messageHandlerOn(actionName, handler, scope) {
  4272. var ah = this.actionHandler;
  4273. if (ah[actionName]) {
  4274. error('There is already an actionName called "' + actionName + '"');
  4275. }
  4276. ah[actionName] = [
  4277. handler,
  4278. scope
  4279. ];
  4280. },
  4281. send: function messageHandlerSend(actionName, data, transfers) {
  4282. var message = {
  4283. sourceName: this.sourceName,
  4284. targetName: this.targetName,
  4285. action: actionName,
  4286. data: data
  4287. };
  4288. this.postMessage(message, transfers);
  4289. },
  4290. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  4291. var callbackId = this.callbackIndex++;
  4292. var message = {
  4293. sourceName: this.sourceName,
  4294. targetName: this.targetName,
  4295. action: actionName,
  4296. data: data,
  4297. callbackId: callbackId
  4298. };
  4299. var capability = createPromiseCapability();
  4300. this.callbacksCapabilities[callbackId] = capability;
  4301. try {
  4302. this.postMessage(message, transfers);
  4303. } catch (e) {
  4304. capability.reject(e);
  4305. }
  4306. return capability.promise;
  4307. },
  4308. postMessage: function (message, transfers) {
  4309. if (transfers && this.postMessageTransfers) {
  4310. this.comObj.postMessage(message, transfers);
  4311. } else {
  4312. this.comObj.postMessage(message);
  4313. }
  4314. },
  4315. destroy: function () {
  4316. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  4317. }
  4318. };
  4319. function loadJpegStream(id, imageUrl, objs) {
  4320. var img = new Image();
  4321. img.onload = function loadJpegStream_onloadClosure() {
  4322. objs.resolve(id, img);
  4323. };
  4324. img.onerror = function loadJpegStream_onerrorClosure() {
  4325. objs.resolve(id, null);
  4326. warn('Error during JPEG image loading');
  4327. };
  4328. img.src = imageUrl;
  4329. }
  4330. /* Any copyright is dedicated to the Public Domain.
  4331. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4332. (function checkURLConstructor(scope) {
  4333. var hasWorkingUrl = false;
  4334. try {
  4335. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  4336. var u = new URL('b', 'http://a');
  4337. u.pathname = 'c%20d';
  4338. hasWorkingUrl = u.href === 'http://a/c%20d';
  4339. }
  4340. } catch (e) {
  4341. }
  4342. if (hasWorkingUrl) {
  4343. return;
  4344. }
  4345. var relative = Object.create(null);
  4346. relative['ftp'] = 21;
  4347. relative['file'] = 0;
  4348. relative['gopher'] = 70;
  4349. relative['http'] = 80;
  4350. relative['https'] = 443;
  4351. relative['ws'] = 80;
  4352. relative['wss'] = 443;
  4353. var relativePathDotMapping = Object.create(null);
  4354. relativePathDotMapping['%2e'] = '.';
  4355. relativePathDotMapping['.%2e'] = '..';
  4356. relativePathDotMapping['%2e.'] = '..';
  4357. relativePathDotMapping['%2e%2e'] = '..';
  4358. function isRelativeScheme(scheme) {
  4359. return relative[scheme] !== undefined;
  4360. }
  4361. function invalid() {
  4362. clear.call(this);
  4363. this._isInvalid = true;
  4364. }
  4365. function IDNAToASCII(h) {
  4366. if (h === '') {
  4367. invalid.call(this);
  4368. }
  4369. return h.toLowerCase();
  4370. }
  4371. function percentEscape(c) {
  4372. var unicode = c.charCodeAt(0);
  4373. if (unicode > 0x20 && unicode < 0x7F && [
  4374. 0x22,
  4375. 0x23,
  4376. 0x3C,
  4377. 0x3E,
  4378. 0x3F,
  4379. 0x60
  4380. ].indexOf(unicode) === -1) {
  4381. return c;
  4382. }
  4383. return encodeURIComponent(c);
  4384. }
  4385. function percentEscapeQuery(c) {
  4386. var unicode = c.charCodeAt(0);
  4387. if (unicode > 0x20 && unicode < 0x7F && [
  4388. 0x22,
  4389. 0x23,
  4390. 0x3C,
  4391. 0x3E,
  4392. 0x60
  4393. ].indexOf(unicode) === -1) {
  4394. return c;
  4395. }
  4396. return encodeURIComponent(c);
  4397. }
  4398. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  4399. function parse(input, stateOverride, base) {
  4400. function err(message) {
  4401. errors.push(message);
  4402. }
  4403. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  4404. loop:
  4405. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  4406. var c = input[cursor];
  4407. switch (state) {
  4408. case 'scheme start':
  4409. if (c && ALPHA.test(c)) {
  4410. buffer += c.toLowerCase();
  4411. state = 'scheme';
  4412. } else if (!stateOverride) {
  4413. buffer = '';
  4414. state = 'no scheme';
  4415. continue;
  4416. } else {
  4417. err('Invalid scheme.');
  4418. break loop;
  4419. }
  4420. break;
  4421. case 'scheme':
  4422. if (c && ALPHANUMERIC.test(c)) {
  4423. buffer += c.toLowerCase();
  4424. } else if (c === ':') {
  4425. this._scheme = buffer;
  4426. buffer = '';
  4427. if (stateOverride) {
  4428. break loop;
  4429. }
  4430. if (isRelativeScheme(this._scheme)) {
  4431. this._isRelative = true;
  4432. }
  4433. if (this._scheme === 'file') {
  4434. state = 'relative';
  4435. } else if (this._isRelative && base && base._scheme === this._scheme) {
  4436. state = 'relative or authority';
  4437. } else if (this._isRelative) {
  4438. state = 'authority first slash';
  4439. } else {
  4440. state = 'scheme data';
  4441. }
  4442. } else if (!stateOverride) {
  4443. buffer = '';
  4444. cursor = 0;
  4445. state = 'no scheme';
  4446. continue;
  4447. } else if (EOF === c) {
  4448. break loop;
  4449. } else {
  4450. err('Code point not allowed in scheme: ' + c);
  4451. break loop;
  4452. }
  4453. break;
  4454. case 'scheme data':
  4455. if (c === '?') {
  4456. this._query = '?';
  4457. state = 'query';
  4458. } else if (c === '#') {
  4459. this._fragment = '#';
  4460. state = 'fragment';
  4461. } else {
  4462. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4463. this._schemeData += percentEscape(c);
  4464. }
  4465. }
  4466. break;
  4467. case 'no scheme':
  4468. if (!base || !isRelativeScheme(base._scheme)) {
  4469. err('Missing scheme.');
  4470. invalid.call(this);
  4471. } else {
  4472. state = 'relative';
  4473. continue;
  4474. }
  4475. break;
  4476. case 'relative or authority':
  4477. if (c === '/' && input[cursor + 1] === '/') {
  4478. state = 'authority ignore slashes';
  4479. } else {
  4480. err('Expected /, got: ' + c);
  4481. state = 'relative';
  4482. continue;
  4483. }
  4484. break;
  4485. case 'relative':
  4486. this._isRelative = true;
  4487. if ('file' !== this._scheme) {
  4488. this._scheme = base._scheme;
  4489. }
  4490. if (EOF === c) {
  4491. this._host = base._host;
  4492. this._port = base._port;
  4493. this._path = base._path.slice();
  4494. this._query = base._query;
  4495. this._username = base._username;
  4496. this._password = base._password;
  4497. break loop;
  4498. } else if (c === '/' || c === '\\') {
  4499. if (c === '\\') {
  4500. err('\\ is an invalid code point.');
  4501. }
  4502. state = 'relative slash';
  4503. } else if (c === '?') {
  4504. this._host = base._host;
  4505. this._port = base._port;
  4506. this._path = base._path.slice();
  4507. this._query = '?';
  4508. this._username = base._username;
  4509. this._password = base._password;
  4510. state = 'query';
  4511. } else if (c === '#') {
  4512. this._host = base._host;
  4513. this._port = base._port;
  4514. this._path = base._path.slice();
  4515. this._query = base._query;
  4516. this._fragment = '#';
  4517. this._username = base._username;
  4518. this._password = base._password;
  4519. state = 'fragment';
  4520. } else {
  4521. var nextC = input[cursor + 1];
  4522. var nextNextC = input[cursor + 2];
  4523. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  4524. this._host = base._host;
  4525. this._port = base._port;
  4526. this._username = base._username;
  4527. this._password = base._password;
  4528. this._path = base._path.slice();
  4529. this._path.pop();
  4530. }
  4531. state = 'relative path';
  4532. continue;
  4533. }
  4534. break;
  4535. case 'relative slash':
  4536. if (c === '/' || c === '\\') {
  4537. if (c === '\\') {
  4538. err('\\ is an invalid code point.');
  4539. }
  4540. if (this._scheme === 'file') {
  4541. state = 'file host';
  4542. } else {
  4543. state = 'authority ignore slashes';
  4544. }
  4545. } else {
  4546. if ('file' !== this._scheme) {
  4547. this._host = base._host;
  4548. this._port = base._port;
  4549. this._username = base._username;
  4550. this._password = base._password;
  4551. }
  4552. state = 'relative path';
  4553. continue;
  4554. }
  4555. break;
  4556. case 'authority first slash':
  4557. if (c === '/') {
  4558. state = 'authority second slash';
  4559. } else {
  4560. err('Expected \'/\', got: ' + c);
  4561. state = 'authority ignore slashes';
  4562. continue;
  4563. }
  4564. break;
  4565. case 'authority second slash':
  4566. state = 'authority ignore slashes';
  4567. if ('/' !== c) {
  4568. err('Expected \'/\', got: ' + c);
  4569. continue;
  4570. }
  4571. break;
  4572. case 'authority ignore slashes':
  4573. if ('/' !== c && '\\' !== c) {
  4574. state = 'authority';
  4575. continue;
  4576. } else {
  4577. err('Expected authority, got: ' + c);
  4578. }
  4579. break;
  4580. case 'authority':
  4581. if (c === '@') {
  4582. if (seenAt) {
  4583. err('@ already seen.');
  4584. buffer += '%40';
  4585. }
  4586. seenAt = true;
  4587. for (var i = 0; i < buffer.length; i++) {
  4588. var cp = buffer[i];
  4589. if (cp === '\t' || cp === '\n' || cp === '\r') {
  4590. err('Invalid whitespace in authority.');
  4591. continue;
  4592. }
  4593. if (cp === ':' && this._password === null) {
  4594. this._password = '';
  4595. continue;
  4596. }
  4597. var tempC = percentEscape(cp);
  4598. if (null !== this._password) {
  4599. this._password += tempC;
  4600. } else {
  4601. this._username += tempC;
  4602. }
  4603. }
  4604. buffer = '';
  4605. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  4606. cursor -= buffer.length;
  4607. buffer = '';
  4608. state = 'host';
  4609. continue;
  4610. } else {
  4611. buffer += c;
  4612. }
  4613. break;
  4614. case 'file host':
  4615. if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  4616. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  4617. state = 'relative path';
  4618. } else if (buffer.length === 0) {
  4619. state = 'relative path start';
  4620. } else {
  4621. this._host = IDNAToASCII.call(this, buffer);
  4622. buffer = '';
  4623. state = 'relative path start';
  4624. }
  4625. continue;
  4626. } else if (c === '\t' || c === '\n' || c === '\r') {
  4627. err('Invalid whitespace in file host.');
  4628. } else {
  4629. buffer += c;
  4630. }
  4631. break;
  4632. case 'host':
  4633. case 'hostname':
  4634. if (c === ':' && !seenBracket) {
  4635. this._host = IDNAToASCII.call(this, buffer);
  4636. buffer = '';
  4637. state = 'port';
  4638. if (stateOverride === 'hostname') {
  4639. break loop;
  4640. }
  4641. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
  4642. this._host = IDNAToASCII.call(this, buffer);
  4643. buffer = '';
  4644. state = 'relative path start';
  4645. if (stateOverride) {
  4646. break loop;
  4647. }
  4648. continue;
  4649. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4650. if (c === '[') {
  4651. seenBracket = true;
  4652. } else if (c === ']') {
  4653. seenBracket = false;
  4654. }
  4655. buffer += c;
  4656. } else {
  4657. err('Invalid code point in host/hostname: ' + c);
  4658. }
  4659. break;
  4660. case 'port':
  4661. if (/[0-9]/.test(c)) {
  4662. buffer += c;
  4663. } else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) {
  4664. if ('' !== buffer) {
  4665. var temp = parseInt(buffer, 10);
  4666. if (temp !== relative[this._scheme]) {
  4667. this._port = temp + '';
  4668. }
  4669. buffer = '';
  4670. }
  4671. if (stateOverride) {
  4672. break loop;
  4673. }
  4674. state = 'relative path start';
  4675. continue;
  4676. } else if (c === '\t' || c === '\n' || c === '\r') {
  4677. err('Invalid code point in port: ' + c);
  4678. } else {
  4679. invalid.call(this);
  4680. }
  4681. break;
  4682. case 'relative path start':
  4683. if (c === '\\') {
  4684. err('\'\\\' not allowed in path.');
  4685. }
  4686. state = 'relative path';
  4687. if ('/' !== c && '\\' !== c) {
  4688. continue;
  4689. }
  4690. break;
  4691. case 'relative path':
  4692. if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) {
  4693. if (c === '\\') {
  4694. err('\\ not allowed in relative path.');
  4695. }
  4696. var tmp;
  4697. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  4698. buffer = tmp;
  4699. }
  4700. if (buffer === '..') {
  4701. this._path.pop();
  4702. if ('/' !== c && '\\' !== c) {
  4703. this._path.push('');
  4704. }
  4705. } else if (buffer === '.' && '/' !== c && '\\' !== c) {
  4706. this._path.push('');
  4707. } else if ('.' !== buffer) {
  4708. if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  4709. buffer = buffer[0] + ':';
  4710. }
  4711. this._path.push(buffer);
  4712. }
  4713. buffer = '';
  4714. if (c === '?') {
  4715. this._query = '?';
  4716. state = 'query';
  4717. } else if (c === '#') {
  4718. this._fragment = '#';
  4719. state = 'fragment';
  4720. }
  4721. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4722. buffer += percentEscape(c);
  4723. }
  4724. break;
  4725. case 'query':
  4726. if (!stateOverride && c === '#') {
  4727. this._fragment = '#';
  4728. state = 'fragment';
  4729. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4730. this._query += percentEscapeQuery(c);
  4731. }
  4732. break;
  4733. case 'fragment':
  4734. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4735. this._fragment += c;
  4736. }
  4737. break;
  4738. }
  4739. cursor++;
  4740. }
  4741. }
  4742. function clear() {
  4743. this._scheme = '';
  4744. this._schemeData = '';
  4745. this._username = '';
  4746. this._password = null;
  4747. this._host = '';
  4748. this._port = '';
  4749. this._path = [];
  4750. this._query = '';
  4751. this._fragment = '';
  4752. this._isInvalid = false;
  4753. this._isRelative = false;
  4754. }
  4755. function JURL(url, base)
  4756. {
  4757. if (base !== undefined && !(base instanceof JURL)) {
  4758. base = new JURL(String(base));
  4759. }
  4760. this._url = url;
  4761. clear.call(this);
  4762. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  4763. parse.call(this, input, null, base);
  4764. }
  4765. JURL.prototype = {
  4766. toString: function () {
  4767. return this.href;
  4768. },
  4769. get href() {
  4770. if (this._isInvalid) {
  4771. return this._url;
  4772. }
  4773. var authority = '';
  4774. if ('' !== this._username || null !== this._password) {
  4775. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  4776. }
  4777. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  4778. },
  4779. set href(href) {
  4780. clear.call(this);
  4781. parse.call(this, href);
  4782. },
  4783. get protocol() {
  4784. return this._scheme + ':';
  4785. },
  4786. set protocol(protocol) {
  4787. if (this._isInvalid) {
  4788. return;
  4789. }
  4790. parse.call(this, protocol + ':', 'scheme start');
  4791. },
  4792. get host() {
  4793. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  4794. },
  4795. set host(host) {
  4796. if (this._isInvalid || !this._isRelative) {
  4797. return;
  4798. }
  4799. parse.call(this, host, 'host');
  4800. },
  4801. get hostname() {
  4802. return this._host;
  4803. },
  4804. set hostname(hostname) {
  4805. if (this._isInvalid || !this._isRelative) {
  4806. return;
  4807. }
  4808. parse.call(this, hostname, 'hostname');
  4809. },
  4810. get port() {
  4811. return this._port;
  4812. },
  4813. set port(port) {
  4814. if (this._isInvalid || !this._isRelative) {
  4815. return;
  4816. }
  4817. parse.call(this, port, 'port');
  4818. },
  4819. get pathname() {
  4820. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  4821. },
  4822. set pathname(pathname) {
  4823. if (this._isInvalid || !this._isRelative) {
  4824. return;
  4825. }
  4826. this._path = [];
  4827. parse.call(this, pathname, 'relative path start');
  4828. },
  4829. get search() {
  4830. return this._isInvalid || !this._query || this._query === '?' ? '' : this._query;
  4831. },
  4832. set search(search) {
  4833. if (this._isInvalid || !this._isRelative) {
  4834. return;
  4835. }
  4836. this._query = '?';
  4837. if (search[0] === '?') {
  4838. search = search.slice(1);
  4839. }
  4840. parse.call(this, search, 'query');
  4841. },
  4842. get hash() {
  4843. return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment;
  4844. },
  4845. set hash(hash) {
  4846. if (this._isInvalid) {
  4847. return;
  4848. }
  4849. this._fragment = '#';
  4850. if (hash[0] === '#') {
  4851. hash = hash.slice(1);
  4852. }
  4853. parse.call(this, hash, 'fragment');
  4854. },
  4855. get origin() {
  4856. var host;
  4857. if (this._isInvalid || !this._scheme) {
  4858. return '';
  4859. }
  4860. switch (this._scheme) {
  4861. case 'data':
  4862. case 'file':
  4863. case 'javascript':
  4864. case 'mailto':
  4865. return 'null';
  4866. }
  4867. host = this.host;
  4868. if (!host) {
  4869. return '';
  4870. }
  4871. return this._scheme + '://' + host;
  4872. }
  4873. };
  4874. var OriginalURL = scope.URL;
  4875. if (OriginalURL) {
  4876. JURL.createObjectURL = function (blob) {
  4877. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  4878. };
  4879. JURL.revokeObjectURL = function (url) {
  4880. OriginalURL.revokeObjectURL(url);
  4881. };
  4882. }
  4883. scope.URL = JURL;
  4884. }(globalScope));
  4885. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  4886. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  4887. exports.OPS = OPS;
  4888. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  4889. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  4890. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  4891. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  4892. exports.AnnotationFlag = AnnotationFlag;
  4893. exports.AnnotationType = AnnotationType;
  4894. exports.FontType = FontType;
  4895. exports.ImageKind = ImageKind;
  4896. exports.InvalidPDFException = InvalidPDFException;
  4897. exports.MessageHandler = MessageHandler;
  4898. exports.MissingDataException = MissingDataException;
  4899. exports.MissingPDFException = MissingPDFException;
  4900. exports.NotImplementedException = NotImplementedException;
  4901. exports.PageViewport = PageViewport;
  4902. exports.PasswordException = PasswordException;
  4903. exports.PasswordResponses = PasswordResponses;
  4904. exports.StatTimer = StatTimer;
  4905. exports.StreamType = StreamType;
  4906. exports.TextRenderingMode = TextRenderingMode;
  4907. exports.UnexpectedResponseException = UnexpectedResponseException;
  4908. exports.UnknownErrorException = UnknownErrorException;
  4909. exports.Util = Util;
  4910. exports.XRefParseException = XRefParseException;
  4911. exports.arrayByteLength = arrayByteLength;
  4912. exports.arraysToBytes = arraysToBytes;
  4913. exports.assert = assert;
  4914. exports.bytesToString = bytesToString;
  4915. exports.createBlob = createBlob;
  4916. exports.createPromiseCapability = createPromiseCapability;
  4917. exports.createObjectURL = createObjectURL;
  4918. exports.deprecated = deprecated;
  4919. exports.error = error;
  4920. exports.getLookupTableFactory = getLookupTableFactory;
  4921. exports.getVerbosityLevel = getVerbosityLevel;
  4922. exports.globalScope = globalScope;
  4923. exports.info = info;
  4924. exports.isArray = isArray;
  4925. exports.isArrayBuffer = isArrayBuffer;
  4926. exports.isBool = isBool;
  4927. exports.isEmptyObj = isEmptyObj;
  4928. exports.isInt = isInt;
  4929. exports.isNum = isNum;
  4930. exports.isString = isString;
  4931. exports.isSpace = isSpace;
  4932. exports.isSameOrigin = isSameOrigin;
  4933. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  4934. exports.isLittleEndian = isLittleEndian;
  4935. exports.isEvalSupported = isEvalSupported;
  4936. exports.loadJpegStream = loadJpegStream;
  4937. exports.log2 = log2;
  4938. exports.readInt8 = readInt8;
  4939. exports.readUint16 = readUint16;
  4940. exports.readUint32 = readUint32;
  4941. exports.removeNullCharacters = removeNullCharacters;
  4942. exports.setVerbosityLevel = setVerbosityLevel;
  4943. exports.shadow = shadow;
  4944. exports.string32 = string32;
  4945. exports.stringToBytes = stringToBytes;
  4946. exports.stringToPDFString = stringToPDFString;
  4947. exports.stringToUTF8String = stringToUTF8String;
  4948. exports.utf8StringToString = utf8StringToString;
  4949. exports.warn = warn;
  4950. }));
  4951. (function (root, factory) {
  4952. factory(root.pdfjsCoreBidi = {}, root.pdfjsSharedUtil);
  4953. }(this, function (exports, sharedUtil) {
  4954. var warn = sharedUtil.warn;
  4955. var baseTypes = [
  4956. 'BN',
  4957. 'BN',
  4958. 'BN',
  4959. 'BN',
  4960. 'BN',
  4961. 'BN',
  4962. 'BN',
  4963. 'BN',
  4964. 'BN',
  4965. 'S',
  4966. 'B',
  4967. 'S',
  4968. 'WS',
  4969. 'B',
  4970. 'BN',
  4971. 'BN',
  4972. 'BN',
  4973. 'BN',
  4974. 'BN',
  4975. 'BN',
  4976. 'BN',
  4977. 'BN',
  4978. 'BN',
  4979. 'BN',
  4980. 'BN',
  4981. 'BN',
  4982. 'BN',
  4983. 'BN',
  4984. 'B',
  4985. 'B',
  4986. 'B',
  4987. 'S',
  4988. 'WS',
  4989. 'ON',
  4990. 'ON',
  4991. 'ET',
  4992. 'ET',
  4993. 'ET',
  4994. 'ON',
  4995. 'ON',
  4996. 'ON',
  4997. 'ON',
  4998. 'ON',
  4999. 'ES',
  5000. 'CS',
  5001. 'ES',
  5002. 'CS',
  5003. 'CS',
  5004. 'EN',
  5005. 'EN',
  5006. 'EN',
  5007. 'EN',
  5008. 'EN',
  5009. 'EN',
  5010. 'EN',
  5011. 'EN',
  5012. 'EN',
  5013. 'EN',
  5014. 'CS',
  5015. 'ON',
  5016. 'ON',
  5017. 'ON',
  5018. 'ON',
  5019. 'ON',
  5020. 'ON',
  5021. 'L',
  5022. 'L',
  5023. 'L',
  5024. 'L',
  5025. 'L',
  5026. 'L',
  5027. 'L',
  5028. 'L',
  5029. 'L',
  5030. 'L',
  5031. 'L',
  5032. 'L',
  5033. 'L',
  5034. 'L',
  5035. 'L',
  5036. 'L',
  5037. 'L',
  5038. 'L',
  5039. 'L',
  5040. 'L',
  5041. 'L',
  5042. 'L',
  5043. 'L',
  5044. 'L',
  5045. 'L',
  5046. 'L',
  5047. 'ON',
  5048. 'ON',
  5049. 'ON',
  5050. 'ON',
  5051. 'ON',
  5052. 'ON',
  5053. 'L',
  5054. 'L',
  5055. 'L',
  5056. 'L',
  5057. 'L',
  5058. 'L',
  5059. 'L',
  5060. 'L',
  5061. 'L',
  5062. 'L',
  5063. 'L',
  5064. 'L',
  5065. 'L',
  5066. 'L',
  5067. 'L',
  5068. 'L',
  5069. 'L',
  5070. 'L',
  5071. 'L',
  5072. 'L',
  5073. 'L',
  5074. 'L',
  5075. 'L',
  5076. 'L',
  5077. 'L',
  5078. 'L',
  5079. 'ON',
  5080. 'ON',
  5081. 'ON',
  5082. 'ON',
  5083. 'BN',
  5084. 'BN',
  5085. 'BN',
  5086. 'BN',
  5087. 'BN',
  5088. 'BN',
  5089. 'B',
  5090. 'BN',
  5091. 'BN',
  5092. 'BN',
  5093. 'BN',
  5094. 'BN',
  5095. 'BN',
  5096. 'BN',
  5097. 'BN',
  5098. 'BN',
  5099. 'BN',
  5100. 'BN',
  5101. 'BN',
  5102. 'BN',
  5103. 'BN',
  5104. 'BN',
  5105. 'BN',
  5106. 'BN',
  5107. 'BN',
  5108. 'BN',
  5109. 'BN',
  5110. 'BN',
  5111. 'BN',
  5112. 'BN',
  5113. 'BN',
  5114. 'BN',
  5115. 'BN',
  5116. 'CS',
  5117. 'ON',
  5118. 'ET',
  5119. 'ET',
  5120. 'ET',
  5121. 'ET',
  5122. 'ON',
  5123. 'ON',
  5124. 'ON',
  5125. 'ON',
  5126. 'L',
  5127. 'ON',
  5128. 'ON',
  5129. 'BN',
  5130. 'ON',
  5131. 'ON',
  5132. 'ET',
  5133. 'ET',
  5134. 'EN',
  5135. 'EN',
  5136. 'ON',
  5137. 'L',
  5138. 'ON',
  5139. 'ON',
  5140. 'ON',
  5141. 'EN',
  5142. 'L',
  5143. 'ON',
  5144. 'ON',
  5145. 'ON',
  5146. 'ON',
  5147. 'ON',
  5148. 'L',
  5149. 'L',
  5150. 'L',
  5151. 'L',
  5152. 'L',
  5153. 'L',
  5154. 'L',
  5155. 'L',
  5156. 'L',
  5157. 'L',
  5158. 'L',
  5159. 'L',
  5160. 'L',
  5161. 'L',
  5162. 'L',
  5163. 'L',
  5164. 'L',
  5165. 'L',
  5166. 'L',
  5167. 'L',
  5168. 'L',
  5169. 'L',
  5170. 'L',
  5171. 'ON',
  5172. 'L',
  5173. 'L',
  5174. 'L',
  5175. 'L',
  5176. 'L',
  5177. 'L',
  5178. 'L',
  5179. 'L',
  5180. 'L',
  5181. 'L',
  5182. 'L',
  5183. 'L',
  5184. 'L',
  5185. 'L',
  5186. 'L',
  5187. 'L',
  5188. 'L',
  5189. 'L',
  5190. 'L',
  5191. 'L',
  5192. 'L',
  5193. 'L',
  5194. 'L',
  5195. 'L',
  5196. 'L',
  5197. 'L',
  5198. 'L',
  5199. 'L',
  5200. 'L',
  5201. 'L',
  5202. 'L',
  5203. 'ON',
  5204. 'L',
  5205. 'L',
  5206. 'L',
  5207. 'L',
  5208. 'L',
  5209. 'L',
  5210. 'L',
  5211. 'L'
  5212. ];
  5213. var arabicTypes = [
  5214. 'AN',
  5215. 'AN',
  5216. 'AN',
  5217. 'AN',
  5218. 'AN',
  5219. 'AN',
  5220. 'ON',
  5221. 'ON',
  5222. 'AL',
  5223. 'ET',
  5224. 'ET',
  5225. 'AL',
  5226. 'CS',
  5227. 'AL',
  5228. 'ON',
  5229. 'ON',
  5230. 'NSM',
  5231. 'NSM',
  5232. 'NSM',
  5233. 'NSM',
  5234. 'NSM',
  5235. 'NSM',
  5236. 'NSM',
  5237. 'NSM',
  5238. 'NSM',
  5239. 'NSM',
  5240. 'NSM',
  5241. 'AL',
  5242. 'AL',
  5243. '',
  5244. 'AL',
  5245. 'AL',
  5246. 'AL',
  5247. 'AL',
  5248. 'AL',
  5249. 'AL',
  5250. 'AL',
  5251. 'AL',
  5252. 'AL',
  5253. 'AL',
  5254. 'AL',
  5255. 'AL',
  5256. 'AL',
  5257. 'AL',
  5258. 'AL',
  5259. 'AL',
  5260. 'AL',
  5261. 'AL',
  5262. 'AL',
  5263. 'AL',
  5264. 'AL',
  5265. 'AL',
  5266. 'AL',
  5267. 'AL',
  5268. 'AL',
  5269. 'AL',
  5270. 'AL',
  5271. 'AL',
  5272. 'AL',
  5273. 'AL',
  5274. 'AL',
  5275. 'AL',
  5276. 'AL',
  5277. 'AL',
  5278. 'AL',
  5279. 'AL',
  5280. 'AL',
  5281. 'AL',
  5282. 'AL',
  5283. 'AL',
  5284. 'AL',
  5285. 'AL',
  5286. 'AL',
  5287. 'AL',
  5288. 'AL',
  5289. 'NSM',
  5290. 'NSM',
  5291. 'NSM',
  5292. 'NSM',
  5293. 'NSM',
  5294. 'NSM',
  5295. 'NSM',
  5296. 'NSM',
  5297. 'NSM',
  5298. 'NSM',
  5299. 'NSM',
  5300. 'NSM',
  5301. 'NSM',
  5302. 'NSM',
  5303. 'NSM',
  5304. 'NSM',
  5305. 'NSM',
  5306. 'NSM',
  5307. 'NSM',
  5308. 'NSM',
  5309. 'NSM',
  5310. 'AN',
  5311. 'AN',
  5312. 'AN',
  5313. 'AN',
  5314. 'AN',
  5315. 'AN',
  5316. 'AN',
  5317. 'AN',
  5318. 'AN',
  5319. 'AN',
  5320. 'ET',
  5321. 'AN',
  5322. 'AN',
  5323. 'AL',
  5324. 'AL',
  5325. 'AL',
  5326. 'NSM',
  5327. 'AL',
  5328. 'AL',
  5329. 'AL',
  5330. 'AL',
  5331. 'AL',
  5332. 'AL',
  5333. 'AL',
  5334. 'AL',
  5335. 'AL',
  5336. 'AL',
  5337. 'AL',
  5338. 'AL',
  5339. 'AL',
  5340. 'AL',
  5341. 'AL',
  5342. 'AL',
  5343. 'AL',
  5344. 'AL',
  5345. 'AL',
  5346. 'AL',
  5347. 'AL',
  5348. 'AL',
  5349. 'AL',
  5350. 'AL',
  5351. 'AL',
  5352. 'AL',
  5353. 'AL',
  5354. 'AL',
  5355. 'AL',
  5356. 'AL',
  5357. 'AL',
  5358. 'AL',
  5359. 'AL',
  5360. 'AL',
  5361. 'AL',
  5362. 'AL',
  5363. 'AL',
  5364. 'AL',
  5365. 'AL',
  5366. 'AL',
  5367. 'AL',
  5368. 'AL',
  5369. 'AL',
  5370. 'AL',
  5371. 'AL',
  5372. 'AL',
  5373. 'AL',
  5374. 'AL',
  5375. 'AL',
  5376. 'AL',
  5377. 'AL',
  5378. 'AL',
  5379. 'AL',
  5380. 'AL',
  5381. 'AL',
  5382. 'AL',
  5383. 'AL',
  5384. 'AL',
  5385. 'AL',
  5386. 'AL',
  5387. 'AL',
  5388. 'AL',
  5389. 'AL',
  5390. 'AL',
  5391. 'AL',
  5392. 'AL',
  5393. 'AL',
  5394. 'AL',
  5395. 'AL',
  5396. 'AL',
  5397. 'AL',
  5398. 'AL',
  5399. 'AL',
  5400. 'AL',
  5401. 'AL',
  5402. 'AL',
  5403. 'AL',
  5404. 'AL',
  5405. 'AL',
  5406. 'AL',
  5407. 'AL',
  5408. 'AL',
  5409. 'AL',
  5410. 'AL',
  5411. 'AL',
  5412. 'AL',
  5413. 'AL',
  5414. 'AL',
  5415. 'AL',
  5416. 'AL',
  5417. 'AL',
  5418. 'AL',
  5419. 'AL',
  5420. 'AL',
  5421. 'AL',
  5422. 'AL',
  5423. 'AL',
  5424. 'AL',
  5425. 'AL',
  5426. 'AL',
  5427. 'AL',
  5428. 'NSM',
  5429. 'NSM',
  5430. 'NSM',
  5431. 'NSM',
  5432. 'NSM',
  5433. 'NSM',
  5434. 'NSM',
  5435. 'AN',
  5436. 'ON',
  5437. 'NSM',
  5438. 'NSM',
  5439. 'NSM',
  5440. 'NSM',
  5441. 'NSM',
  5442. 'NSM',
  5443. 'AL',
  5444. 'AL',
  5445. 'NSM',
  5446. 'NSM',
  5447. 'ON',
  5448. 'NSM',
  5449. 'NSM',
  5450. 'NSM',
  5451. 'NSM',
  5452. 'AL',
  5453. 'AL',
  5454. 'EN',
  5455. 'EN',
  5456. 'EN',
  5457. 'EN',
  5458. 'EN',
  5459. 'EN',
  5460. 'EN',
  5461. 'EN',
  5462. 'EN',
  5463. 'EN',
  5464. 'AL',
  5465. 'AL',
  5466. 'AL',
  5467. 'AL',
  5468. 'AL',
  5469. 'AL'
  5470. ];
  5471. function isOdd(i) {
  5472. return (i & 1) !== 0;
  5473. }
  5474. function isEven(i) {
  5475. return (i & 1) === 0;
  5476. }
  5477. function findUnequal(arr, start, value) {
  5478. for (var j = start, jj = arr.length; j < jj; ++j) {
  5479. if (arr[j] !== value) {
  5480. return j;
  5481. }
  5482. }
  5483. return j;
  5484. }
  5485. function setValues(arr, start, end, value) {
  5486. for (var j = start; j < end; ++j) {
  5487. arr[j] = value;
  5488. }
  5489. }
  5490. function reverseValues(arr, start, end) {
  5491. for (var i = start, j = end - 1; i < j; ++i, --j) {
  5492. var temp = arr[i];
  5493. arr[i] = arr[j];
  5494. arr[j] = temp;
  5495. }
  5496. }
  5497. function createBidiText(str, isLTR, vertical) {
  5498. return {
  5499. str: str,
  5500. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  5501. };
  5502. }
  5503. var chars = [];
  5504. var types = [];
  5505. function bidi(str, startLevel, vertical) {
  5506. var isLTR = true;
  5507. var strLength = str.length;
  5508. if (strLength === 0 || vertical) {
  5509. return createBidiText(str, isLTR, vertical);
  5510. }
  5511. chars.length = strLength;
  5512. types.length = strLength;
  5513. var numBidi = 0;
  5514. var i, ii;
  5515. for (i = 0; i < strLength; ++i) {
  5516. chars[i] = str.charAt(i);
  5517. var charCode = str.charCodeAt(i);
  5518. var charType = 'L';
  5519. if (charCode <= 0x00ff) {
  5520. charType = baseTypes[charCode];
  5521. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  5522. charType = 'R';
  5523. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  5524. charType = arabicTypes[charCode & 0xff];
  5525. if (!charType) {
  5526. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  5527. }
  5528. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  5529. charType = 'AL';
  5530. }
  5531. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  5532. numBidi++;
  5533. }
  5534. types[i] = charType;
  5535. }
  5536. if (numBidi === 0) {
  5537. isLTR = true;
  5538. return createBidiText(str, isLTR);
  5539. }
  5540. if (startLevel === -1) {
  5541. if (numBidi / strLength < 0.3) {
  5542. isLTR = true;
  5543. startLevel = 0;
  5544. } else {
  5545. isLTR = false;
  5546. startLevel = 1;
  5547. }
  5548. }
  5549. var levels = [];
  5550. for (i = 0; i < strLength; ++i) {
  5551. levels[i] = startLevel;
  5552. }
  5553. var e = isOdd(startLevel) ? 'R' : 'L';
  5554. var sor = e;
  5555. var eor = sor;
  5556. var lastType = sor;
  5557. for (i = 0; i < strLength; ++i) {
  5558. if (types[i] === 'NSM') {
  5559. types[i] = lastType;
  5560. } else {
  5561. lastType = types[i];
  5562. }
  5563. }
  5564. lastType = sor;
  5565. var t;
  5566. for (i = 0; i < strLength; ++i) {
  5567. t = types[i];
  5568. if (t === 'EN') {
  5569. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  5570. } else if (t === 'R' || t === 'L' || t === 'AL') {
  5571. lastType = t;
  5572. }
  5573. }
  5574. for (i = 0; i < strLength; ++i) {
  5575. t = types[i];
  5576. if (t === 'AL') {
  5577. types[i] = 'R';
  5578. }
  5579. }
  5580. for (i = 1; i < strLength - 1; ++i) {
  5581. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  5582. types[i] = 'EN';
  5583. }
  5584. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  5585. types[i] = types[i - 1];
  5586. }
  5587. }
  5588. for (i = 0; i < strLength; ++i) {
  5589. if (types[i] === 'EN') {
  5590. var j;
  5591. for (j = i - 1; j >= 0; --j) {
  5592. if (types[j] !== 'ET') {
  5593. break;
  5594. }
  5595. types[j] = 'EN';
  5596. }
  5597. for (j = i + 1; j < strLength; ++j) {
  5598. if (types[j] !== 'ET') {
  5599. break;
  5600. }
  5601. types[j] = 'EN';
  5602. }
  5603. }
  5604. }
  5605. for (i = 0; i < strLength; ++i) {
  5606. t = types[i];
  5607. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  5608. types[i] = 'ON';
  5609. }
  5610. }
  5611. lastType = sor;
  5612. for (i = 0; i < strLength; ++i) {
  5613. t = types[i];
  5614. if (t === 'EN') {
  5615. types[i] = lastType === 'L' ? 'L' : 'EN';
  5616. } else if (t === 'R' || t === 'L') {
  5617. lastType = t;
  5618. }
  5619. }
  5620. for (i = 0; i < strLength; ++i) {
  5621. if (types[i] === 'ON') {
  5622. var end = findUnequal(types, i + 1, 'ON');
  5623. var before = sor;
  5624. if (i > 0) {
  5625. before = types[i - 1];
  5626. }
  5627. var after = eor;
  5628. if (end + 1 < strLength) {
  5629. after = types[end + 1];
  5630. }
  5631. if (before !== 'L') {
  5632. before = 'R';
  5633. }
  5634. if (after !== 'L') {
  5635. after = 'R';
  5636. }
  5637. if (before === after) {
  5638. setValues(types, i, end, before);
  5639. }
  5640. i = end - 1;
  5641. }
  5642. }
  5643. for (i = 0; i < strLength; ++i) {
  5644. if (types[i] === 'ON') {
  5645. types[i] = e;
  5646. }
  5647. }
  5648. for (i = 0; i < strLength; ++i) {
  5649. t = types[i];
  5650. if (isEven(levels[i])) {
  5651. if (t === 'R') {
  5652. levels[i] += 1;
  5653. } else if (t === 'AN' || t === 'EN') {
  5654. levels[i] += 2;
  5655. }
  5656. } else {
  5657. if (t === 'L' || t === 'AN' || t === 'EN') {
  5658. levels[i] += 1;
  5659. }
  5660. }
  5661. }
  5662. var highestLevel = -1;
  5663. var lowestOddLevel = 99;
  5664. var level;
  5665. for (i = 0, ii = levels.length; i < ii; ++i) {
  5666. level = levels[i];
  5667. if (highestLevel < level) {
  5668. highestLevel = level;
  5669. }
  5670. if (lowestOddLevel > level && isOdd(level)) {
  5671. lowestOddLevel = level;
  5672. }
  5673. }
  5674. for (level = highestLevel; level >= lowestOddLevel; --level) {
  5675. var start = -1;
  5676. for (i = 0, ii = levels.length; i < ii; ++i) {
  5677. if (levels[i] < level) {
  5678. if (start >= 0) {
  5679. reverseValues(chars, start, i);
  5680. start = -1;
  5681. }
  5682. } else if (start < 0) {
  5683. start = i;
  5684. }
  5685. }
  5686. if (start >= 0) {
  5687. reverseValues(chars, start, levels.length);
  5688. }
  5689. }
  5690. for (i = 0, ii = chars.length; i < ii; ++i) {
  5691. var ch = chars[i];
  5692. if (ch === '<' || ch === '>') {
  5693. chars[i] = '';
  5694. }
  5695. }
  5696. return createBidiText(chars.join(''), isLTR);
  5697. }
  5698. exports.bidi = bidi;
  5699. }));
  5700. (function (root, factory) {
  5701. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5702. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5703. var error = sharedUtil.error;
  5704. var info = sharedUtil.info;
  5705. var bytesToString = sharedUtil.bytesToString;
  5706. var warn = sharedUtil.warn;
  5707. var isArray = sharedUtil.isArray;
  5708. var Util = sharedUtil.Util;
  5709. var stringToBytes = sharedUtil.stringToBytes;
  5710. var assert = sharedUtil.assert;
  5711. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5712. var ExpertCharset = coreCharsets.ExpertCharset;
  5713. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5714. var StandardEncoding = coreEncodings.StandardEncoding;
  5715. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5716. var MAX_SUBR_NESTING = 10;
  5717. var CFFStandardStrings = [
  5718. '.notdef',
  5719. 'space',
  5720. 'exclam',
  5721. 'quotedbl',
  5722. 'numbersign',
  5723. 'dollar',
  5724. 'percent',
  5725. 'ampersand',
  5726. 'quoteright',
  5727. 'parenleft',
  5728. 'parenright',
  5729. 'asterisk',
  5730. 'plus',
  5731. 'comma',
  5732. 'hyphen',
  5733. 'period',
  5734. 'slash',
  5735. 'zero',
  5736. 'one',
  5737. 'two',
  5738. 'three',
  5739. 'four',
  5740. 'five',
  5741. 'six',
  5742. 'seven',
  5743. 'eight',
  5744. 'nine',
  5745. 'colon',
  5746. 'semicolon',
  5747. 'less',
  5748. 'equal',
  5749. 'greater',
  5750. 'question',
  5751. 'at',
  5752. 'A',
  5753. 'B',
  5754. 'C',
  5755. 'D',
  5756. 'E',
  5757. 'F',
  5758. 'G',
  5759. 'H',
  5760. 'I',
  5761. 'J',
  5762. 'K',
  5763. 'L',
  5764. 'M',
  5765. 'N',
  5766. 'O',
  5767. 'P',
  5768. 'Q',
  5769. 'R',
  5770. 'S',
  5771. 'T',
  5772. 'U',
  5773. 'V',
  5774. 'W',
  5775. 'X',
  5776. 'Y',
  5777. 'Z',
  5778. 'bracketleft',
  5779. 'backslash',
  5780. 'bracketright',
  5781. 'asciicircum',
  5782. 'underscore',
  5783. 'quoteleft',
  5784. 'a',
  5785. 'b',
  5786. 'c',
  5787. 'd',
  5788. 'e',
  5789. 'f',
  5790. 'g',
  5791. 'h',
  5792. 'i',
  5793. 'j',
  5794. 'k',
  5795. 'l',
  5796. 'm',
  5797. 'n',
  5798. 'o',
  5799. 'p',
  5800. 'q',
  5801. 'r',
  5802. 's',
  5803. 't',
  5804. 'u',
  5805. 'v',
  5806. 'w',
  5807. 'x',
  5808. 'y',
  5809. 'z',
  5810. 'braceleft',
  5811. 'bar',
  5812. 'braceright',
  5813. 'asciitilde',
  5814. 'exclamdown',
  5815. 'cent',
  5816. 'sterling',
  5817. 'fraction',
  5818. 'yen',
  5819. 'florin',
  5820. 'section',
  5821. 'currency',
  5822. 'quotesingle',
  5823. 'quotedblleft',
  5824. 'guillemotleft',
  5825. 'guilsinglleft',
  5826. 'guilsinglright',
  5827. 'fi',
  5828. 'fl',
  5829. 'endash',
  5830. 'dagger',
  5831. 'daggerdbl',
  5832. 'periodcentered',
  5833. 'paragraph',
  5834. 'bullet',
  5835. 'quotesinglbase',
  5836. 'quotedblbase',
  5837. 'quotedblright',
  5838. 'guillemotright',
  5839. 'ellipsis',
  5840. 'perthousand',
  5841. 'questiondown',
  5842. 'grave',
  5843. 'acute',
  5844. 'circumflex',
  5845. 'tilde',
  5846. 'macron',
  5847. 'breve',
  5848. 'dotaccent',
  5849. 'dieresis',
  5850. 'ring',
  5851. 'cedilla',
  5852. 'hungarumlaut',
  5853. 'ogonek',
  5854. 'caron',
  5855. 'emdash',
  5856. 'AE',
  5857. 'ordfeminine',
  5858. 'Lslash',
  5859. 'Oslash',
  5860. 'OE',
  5861. 'ordmasculine',
  5862. 'ae',
  5863. 'dotlessi',
  5864. 'lslash',
  5865. 'oslash',
  5866. 'oe',
  5867. 'germandbls',
  5868. 'onesuperior',
  5869. 'logicalnot',
  5870. 'mu',
  5871. 'trademark',
  5872. 'Eth',
  5873. 'onehalf',
  5874. 'plusminus',
  5875. 'Thorn',
  5876. 'onequarter',
  5877. 'divide',
  5878. 'brokenbar',
  5879. 'degree',
  5880. 'thorn',
  5881. 'threequarters',
  5882. 'twosuperior',
  5883. 'registered',
  5884. 'minus',
  5885. 'eth',
  5886. 'multiply',
  5887. 'threesuperior',
  5888. 'copyright',
  5889. 'Aacute',
  5890. 'Acircumflex',
  5891. 'Adieresis',
  5892. 'Agrave',
  5893. 'Aring',
  5894. 'Atilde',
  5895. 'Ccedilla',
  5896. 'Eacute',
  5897. 'Ecircumflex',
  5898. 'Edieresis',
  5899. 'Egrave',
  5900. 'Iacute',
  5901. 'Icircumflex',
  5902. 'Idieresis',
  5903. 'Igrave',
  5904. 'Ntilde',
  5905. 'Oacute',
  5906. 'Ocircumflex',
  5907. 'Odieresis',
  5908. 'Ograve',
  5909. 'Otilde',
  5910. 'Scaron',
  5911. 'Uacute',
  5912. 'Ucircumflex',
  5913. 'Udieresis',
  5914. 'Ugrave',
  5915. 'Yacute',
  5916. 'Ydieresis',
  5917. 'Zcaron',
  5918. 'aacute',
  5919. 'acircumflex',
  5920. 'adieresis',
  5921. 'agrave',
  5922. 'aring',
  5923. 'atilde',
  5924. 'ccedilla',
  5925. 'eacute',
  5926. 'ecircumflex',
  5927. 'edieresis',
  5928. 'egrave',
  5929. 'iacute',
  5930. 'icircumflex',
  5931. 'idieresis',
  5932. 'igrave',
  5933. 'ntilde',
  5934. 'oacute',
  5935. 'ocircumflex',
  5936. 'odieresis',
  5937. 'ograve',
  5938. 'otilde',
  5939. 'scaron',
  5940. 'uacute',
  5941. 'ucircumflex',
  5942. 'udieresis',
  5943. 'ugrave',
  5944. 'yacute',
  5945. 'ydieresis',
  5946. 'zcaron',
  5947. 'exclamsmall',
  5948. 'Hungarumlautsmall',
  5949. 'dollaroldstyle',
  5950. 'dollarsuperior',
  5951. 'ampersandsmall',
  5952. 'Acutesmall',
  5953. 'parenleftsuperior',
  5954. 'parenrightsuperior',
  5955. 'twodotenleader',
  5956. 'onedotenleader',
  5957. 'zerooldstyle',
  5958. 'oneoldstyle',
  5959. 'twooldstyle',
  5960. 'threeoldstyle',
  5961. 'fouroldstyle',
  5962. 'fiveoldstyle',
  5963. 'sixoldstyle',
  5964. 'sevenoldstyle',
  5965. 'eightoldstyle',
  5966. 'nineoldstyle',
  5967. 'commasuperior',
  5968. 'threequartersemdash',
  5969. 'periodsuperior',
  5970. 'questionsmall',
  5971. 'asuperior',
  5972. 'bsuperior',
  5973. 'centsuperior',
  5974. 'dsuperior',
  5975. 'esuperior',
  5976. 'isuperior',
  5977. 'lsuperior',
  5978. 'msuperior',
  5979. 'nsuperior',
  5980. 'osuperior',
  5981. 'rsuperior',
  5982. 'ssuperior',
  5983. 'tsuperior',
  5984. 'ff',
  5985. 'ffi',
  5986. 'ffl',
  5987. 'parenleftinferior',
  5988. 'parenrightinferior',
  5989. 'Circumflexsmall',
  5990. 'hyphensuperior',
  5991. 'Gravesmall',
  5992. 'Asmall',
  5993. 'Bsmall',
  5994. 'Csmall',
  5995. 'Dsmall',
  5996. 'Esmall',
  5997. 'Fsmall',
  5998. 'Gsmall',
  5999. 'Hsmall',
  6000. 'Ismall',
  6001. 'Jsmall',
  6002. 'Ksmall',
  6003. 'Lsmall',
  6004. 'Msmall',
  6005. 'Nsmall',
  6006. 'Osmall',
  6007. 'Psmall',
  6008. 'Qsmall',
  6009. 'Rsmall',
  6010. 'Ssmall',
  6011. 'Tsmall',
  6012. 'Usmall',
  6013. 'Vsmall',
  6014. 'Wsmall',
  6015. 'Xsmall',
  6016. 'Ysmall',
  6017. 'Zsmall',
  6018. 'colonmonetary',
  6019. 'onefitted',
  6020. 'rupiah',
  6021. 'Tildesmall',
  6022. 'exclamdownsmall',
  6023. 'centoldstyle',
  6024. 'Lslashsmall',
  6025. 'Scaronsmall',
  6026. 'Zcaronsmall',
  6027. 'Dieresissmall',
  6028. 'Brevesmall',
  6029. 'Caronsmall',
  6030. 'Dotaccentsmall',
  6031. 'Macronsmall',
  6032. 'figuredash',
  6033. 'hypheninferior',
  6034. 'Ogoneksmall',
  6035. 'Ringsmall',
  6036. 'Cedillasmall',
  6037. 'questiondownsmall',
  6038. 'oneeighth',
  6039. 'threeeighths',
  6040. 'fiveeighths',
  6041. 'seveneighths',
  6042. 'onethird',
  6043. 'twothirds',
  6044. 'zerosuperior',
  6045. 'foursuperior',
  6046. 'fivesuperior',
  6047. 'sixsuperior',
  6048. 'sevensuperior',
  6049. 'eightsuperior',
  6050. 'ninesuperior',
  6051. 'zeroinferior',
  6052. 'oneinferior',
  6053. 'twoinferior',
  6054. 'threeinferior',
  6055. 'fourinferior',
  6056. 'fiveinferior',
  6057. 'sixinferior',
  6058. 'seveninferior',
  6059. 'eightinferior',
  6060. 'nineinferior',
  6061. 'centinferior',
  6062. 'dollarinferior',
  6063. 'periodinferior',
  6064. 'commainferior',
  6065. 'Agravesmall',
  6066. 'Aacutesmall',
  6067. 'Acircumflexsmall',
  6068. 'Atildesmall',
  6069. 'Adieresissmall',
  6070. 'Aringsmall',
  6071. 'AEsmall',
  6072. 'Ccedillasmall',
  6073. 'Egravesmall',
  6074. 'Eacutesmall',
  6075. 'Ecircumflexsmall',
  6076. 'Edieresissmall',
  6077. 'Igravesmall',
  6078. 'Iacutesmall',
  6079. 'Icircumflexsmall',
  6080. 'Idieresissmall',
  6081. 'Ethsmall',
  6082. 'Ntildesmall',
  6083. 'Ogravesmall',
  6084. 'Oacutesmall',
  6085. 'Ocircumflexsmall',
  6086. 'Otildesmall',
  6087. 'Odieresissmall',
  6088. 'OEsmall',
  6089. 'Oslashsmall',
  6090. 'Ugravesmall',
  6091. 'Uacutesmall',
  6092. 'Ucircumflexsmall',
  6093. 'Udieresissmall',
  6094. 'Yacutesmall',
  6095. 'Thornsmall',
  6096. 'Ydieresissmall',
  6097. '001.000',
  6098. '001.001',
  6099. '001.002',
  6100. '001.003',
  6101. 'Black',
  6102. 'Bold',
  6103. 'Book',
  6104. 'Light',
  6105. 'Medium',
  6106. 'Regular',
  6107. 'Roman',
  6108. 'Semibold'
  6109. ];
  6110. var CFFParser = function CFFParserClosure() {
  6111. var CharstringValidationData = [
  6112. null,
  6113. {
  6114. id: 'hstem',
  6115. min: 2,
  6116. stackClearing: true,
  6117. stem: true
  6118. },
  6119. null,
  6120. {
  6121. id: 'vstem',
  6122. min: 2,
  6123. stackClearing: true,
  6124. stem: true
  6125. },
  6126. {
  6127. id: 'vmoveto',
  6128. min: 1,
  6129. stackClearing: true
  6130. },
  6131. {
  6132. id: 'rlineto',
  6133. min: 2,
  6134. resetStack: true
  6135. },
  6136. {
  6137. id: 'hlineto',
  6138. min: 1,
  6139. resetStack: true
  6140. },
  6141. {
  6142. id: 'vlineto',
  6143. min: 1,
  6144. resetStack: true
  6145. },
  6146. {
  6147. id: 'rrcurveto',
  6148. min: 6,
  6149. resetStack: true
  6150. },
  6151. null,
  6152. {
  6153. id: 'callsubr',
  6154. min: 1,
  6155. undefStack: true
  6156. },
  6157. {
  6158. id: 'return',
  6159. min: 0,
  6160. undefStack: true
  6161. },
  6162. null,
  6163. null,
  6164. {
  6165. id: 'endchar',
  6166. min: 0,
  6167. stackClearing: true
  6168. },
  6169. null,
  6170. null,
  6171. null,
  6172. {
  6173. id: 'hstemhm',
  6174. min: 2,
  6175. stackClearing: true,
  6176. stem: true
  6177. },
  6178. {
  6179. id: 'hintmask',
  6180. min: 0,
  6181. stackClearing: true
  6182. },
  6183. {
  6184. id: 'cntrmask',
  6185. min: 0,
  6186. stackClearing: true
  6187. },
  6188. {
  6189. id: 'rmoveto',
  6190. min: 2,
  6191. stackClearing: true
  6192. },
  6193. {
  6194. id: 'hmoveto',
  6195. min: 1,
  6196. stackClearing: true
  6197. },
  6198. {
  6199. id: 'vstemhm',
  6200. min: 2,
  6201. stackClearing: true,
  6202. stem: true
  6203. },
  6204. {
  6205. id: 'rcurveline',
  6206. min: 8,
  6207. resetStack: true
  6208. },
  6209. {
  6210. id: 'rlinecurve',
  6211. min: 8,
  6212. resetStack: true
  6213. },
  6214. {
  6215. id: 'vvcurveto',
  6216. min: 4,
  6217. resetStack: true
  6218. },
  6219. {
  6220. id: 'hhcurveto',
  6221. min: 4,
  6222. resetStack: true
  6223. },
  6224. null,
  6225. {
  6226. id: 'callgsubr',
  6227. min: 1,
  6228. undefStack: true
  6229. },
  6230. {
  6231. id: 'vhcurveto',
  6232. min: 4,
  6233. resetStack: true
  6234. },
  6235. {
  6236. id: 'hvcurveto',
  6237. min: 4,
  6238. resetStack: true
  6239. }
  6240. ];
  6241. var CharstringValidationData12 = [
  6242. null,
  6243. null,
  6244. null,
  6245. {
  6246. id: 'and',
  6247. min: 2,
  6248. stackDelta: -1
  6249. },
  6250. {
  6251. id: 'or',
  6252. min: 2,
  6253. stackDelta: -1
  6254. },
  6255. {
  6256. id: 'not',
  6257. min: 1,
  6258. stackDelta: 0
  6259. },
  6260. null,
  6261. null,
  6262. null,
  6263. {
  6264. id: 'abs',
  6265. min: 1,
  6266. stackDelta: 0
  6267. },
  6268. {
  6269. id: 'add',
  6270. min: 2,
  6271. stackDelta: -1,
  6272. stackFn: function stack_div(stack, index) {
  6273. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6274. }
  6275. },
  6276. {
  6277. id: 'sub',
  6278. min: 2,
  6279. stackDelta: -1,
  6280. stackFn: function stack_div(stack, index) {
  6281. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6282. }
  6283. },
  6284. {
  6285. id: 'div',
  6286. min: 2,
  6287. stackDelta: -1,
  6288. stackFn: function stack_div(stack, index) {
  6289. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6290. }
  6291. },
  6292. null,
  6293. {
  6294. id: 'neg',
  6295. min: 1,
  6296. stackDelta: 0,
  6297. stackFn: function stack_div(stack, index) {
  6298. stack[index - 1] = -stack[index - 1];
  6299. }
  6300. },
  6301. {
  6302. id: 'eq',
  6303. min: 2,
  6304. stackDelta: -1
  6305. },
  6306. null,
  6307. null,
  6308. {
  6309. id: 'drop',
  6310. min: 1,
  6311. stackDelta: -1
  6312. },
  6313. null,
  6314. {
  6315. id: 'put',
  6316. min: 2,
  6317. stackDelta: -2
  6318. },
  6319. {
  6320. id: 'get',
  6321. min: 1,
  6322. stackDelta: 0
  6323. },
  6324. {
  6325. id: 'ifelse',
  6326. min: 4,
  6327. stackDelta: -3
  6328. },
  6329. {
  6330. id: 'random',
  6331. min: 0,
  6332. stackDelta: 1
  6333. },
  6334. {
  6335. id: 'mul',
  6336. min: 2,
  6337. stackDelta: -1,
  6338. stackFn: function stack_div(stack, index) {
  6339. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6340. }
  6341. },
  6342. null,
  6343. {
  6344. id: 'sqrt',
  6345. min: 1,
  6346. stackDelta: 0
  6347. },
  6348. {
  6349. id: 'dup',
  6350. min: 1,
  6351. stackDelta: 1
  6352. },
  6353. {
  6354. id: 'exch',
  6355. min: 2,
  6356. stackDelta: 0
  6357. },
  6358. {
  6359. id: 'index',
  6360. min: 2,
  6361. stackDelta: 0
  6362. },
  6363. {
  6364. id: 'roll',
  6365. min: 3,
  6366. stackDelta: -2
  6367. },
  6368. null,
  6369. null,
  6370. null,
  6371. {
  6372. id: 'hflex',
  6373. min: 7,
  6374. resetStack: true
  6375. },
  6376. {
  6377. id: 'flex',
  6378. min: 13,
  6379. resetStack: true
  6380. },
  6381. {
  6382. id: 'hflex1',
  6383. min: 9,
  6384. resetStack: true
  6385. },
  6386. {
  6387. id: 'flex1',
  6388. min: 11,
  6389. resetStack: true
  6390. }
  6391. ];
  6392. function CFFParser(file, properties, seacAnalysisEnabled) {
  6393. this.bytes = file.getBytes();
  6394. this.properties = properties;
  6395. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6396. }
  6397. CFFParser.prototype = {
  6398. parse: function CFFParser_parse() {
  6399. var properties = this.properties;
  6400. var cff = new CFF();
  6401. this.cff = cff;
  6402. var header = this.parseHeader();
  6403. var nameIndex = this.parseIndex(header.endPos);
  6404. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6405. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6406. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6407. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6408. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6409. cff.header = header.obj;
  6410. cff.names = this.parseNameIndex(nameIndex.obj);
  6411. cff.strings = this.parseStringIndex(stringIndex.obj);
  6412. cff.topDict = topDict;
  6413. cff.globalSubrIndex = globalSubrIndex.obj;
  6414. this.parsePrivateDict(cff.topDict);
  6415. cff.isCIDFont = topDict.hasName('ROS');
  6416. var charStringOffset = topDict.getByName('CharStrings');
  6417. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6418. var fontMatrix = topDict.getByName('FontMatrix');
  6419. if (fontMatrix) {
  6420. properties.fontMatrix = fontMatrix;
  6421. }
  6422. var fontBBox = topDict.getByName('FontBBox');
  6423. if (fontBBox) {
  6424. properties.ascent = fontBBox[3];
  6425. properties.descent = fontBBox[1];
  6426. properties.ascentScaled = true;
  6427. }
  6428. var charset, encoding;
  6429. if (cff.isCIDFont) {
  6430. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6431. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6432. var dictRaw = fdArrayIndex.get(i);
  6433. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6434. this.parsePrivateDict(fontDict);
  6435. cff.fdArray.push(fontDict);
  6436. }
  6437. encoding = null;
  6438. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6439. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6440. } else {
  6441. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6442. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6443. }
  6444. cff.charset = charset;
  6445. cff.encoding = encoding;
  6446. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6447. cff.charStrings = charStringsAndSeacs.charStrings;
  6448. cff.seacs = charStringsAndSeacs.seacs;
  6449. cff.widths = charStringsAndSeacs.widths;
  6450. return cff;
  6451. },
  6452. parseHeader: function CFFParser_parseHeader() {
  6453. var bytes = this.bytes;
  6454. var bytesLength = bytes.length;
  6455. var offset = 0;
  6456. while (offset < bytesLength && bytes[offset] !== 1) {
  6457. ++offset;
  6458. }
  6459. if (offset >= bytesLength) {
  6460. error('Invalid CFF header');
  6461. } else if (offset !== 0) {
  6462. info('cff data is shifted');
  6463. bytes = bytes.subarray(offset);
  6464. this.bytes = bytes;
  6465. }
  6466. var major = bytes[0];
  6467. var minor = bytes[1];
  6468. var hdrSize = bytes[2];
  6469. var offSize = bytes[3];
  6470. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6471. return {
  6472. obj: header,
  6473. endPos: hdrSize
  6474. };
  6475. },
  6476. parseDict: function CFFParser_parseDict(dict) {
  6477. var pos = 0;
  6478. function parseOperand() {
  6479. var value = dict[pos++];
  6480. if (value === 30) {
  6481. return parseFloatOperand();
  6482. } else if (value === 28) {
  6483. value = dict[pos++];
  6484. value = (value << 24 | dict[pos++] << 16) >> 16;
  6485. return value;
  6486. } else if (value === 29) {
  6487. value = dict[pos++];
  6488. value = value << 8 | dict[pos++];
  6489. value = value << 8 | dict[pos++];
  6490. value = value << 8 | dict[pos++];
  6491. return value;
  6492. } else if (value >= 32 && value <= 246) {
  6493. return value - 139;
  6494. } else if (value >= 247 && value <= 250) {
  6495. return (value - 247) * 256 + dict[pos++] + 108;
  6496. } else if (value >= 251 && value <= 254) {
  6497. return -((value - 251) * 256) - dict[pos++] - 108;
  6498. }
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. function parseFloatOperand() {
  6503. var str = '';
  6504. var eof = 15;
  6505. var lookup = [
  6506. '0',
  6507. '1',
  6508. '2',
  6509. '3',
  6510. '4',
  6511. '5',
  6512. '6',
  6513. '7',
  6514. '8',
  6515. '9',
  6516. '.',
  6517. 'E',
  6518. 'E-',
  6519. null,
  6520. '-'
  6521. ];
  6522. var length = dict.length;
  6523. while (pos < length) {
  6524. var b = dict[pos++];
  6525. var b1 = b >> 4;
  6526. var b2 = b & 15;
  6527. if (b1 === eof) {
  6528. break;
  6529. }
  6530. str += lookup[b1];
  6531. if (b2 === eof) {
  6532. break;
  6533. }
  6534. str += lookup[b2];
  6535. }
  6536. return parseFloat(str);
  6537. }
  6538. var operands = [];
  6539. var entries = [];
  6540. pos = 0;
  6541. var end = dict.length;
  6542. while (pos < end) {
  6543. var b = dict[pos];
  6544. if (b <= 21) {
  6545. if (b === 12) {
  6546. b = b << 8 | dict[++pos];
  6547. }
  6548. entries.push([
  6549. b,
  6550. operands
  6551. ]);
  6552. operands = [];
  6553. ++pos;
  6554. } else {
  6555. operands.push(parseOperand());
  6556. }
  6557. }
  6558. return entries;
  6559. },
  6560. parseIndex: function CFFParser_parseIndex(pos) {
  6561. var cffIndex = new CFFIndex();
  6562. var bytes = this.bytes;
  6563. var count = bytes[pos++] << 8 | bytes[pos++];
  6564. var offsets = [];
  6565. var end = pos;
  6566. var i, ii;
  6567. if (count !== 0) {
  6568. var offsetSize = bytes[pos++];
  6569. var startPos = pos + (count + 1) * offsetSize - 1;
  6570. for (i = 0, ii = count + 1; i < ii; ++i) {
  6571. var offset = 0;
  6572. for (var j = 0; j < offsetSize; ++j) {
  6573. offset <<= 8;
  6574. offset += bytes[pos++];
  6575. }
  6576. offsets.push(startPos + offset);
  6577. }
  6578. end = offsets[count];
  6579. }
  6580. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6581. var offsetStart = offsets[i];
  6582. var offsetEnd = offsets[i + 1];
  6583. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6584. }
  6585. return {
  6586. obj: cffIndex,
  6587. endPos: end
  6588. };
  6589. },
  6590. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6591. var names = [];
  6592. for (var i = 0, ii = index.count; i < ii; ++i) {
  6593. var name = index.get(i);
  6594. var length = Math.min(name.length, 127);
  6595. var data = [];
  6596. for (var j = 0; j < length; ++j) {
  6597. var c = name[j];
  6598. if (j === 0 && c === 0) {
  6599. data[j] = c;
  6600. continue;
  6601. }
  6602. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35)
  6603. {
  6604. data[j] = 95;
  6605. continue;
  6606. }
  6607. data[j] = c;
  6608. }
  6609. names.push(bytesToString(data));
  6610. }
  6611. return names;
  6612. },
  6613. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6614. var strings = new CFFStrings();
  6615. for (var i = 0, ii = index.count; i < ii; ++i) {
  6616. var data = index.get(i);
  6617. strings.add(bytesToString(data));
  6618. }
  6619. return strings;
  6620. },
  6621. createDict: function CFFParser_createDict(Type, dict, strings) {
  6622. var cffDict = new Type(strings);
  6623. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6624. var pair = dict[i];
  6625. var key = pair[0];
  6626. var value = pair[1];
  6627. cffDict.setByKey(key, value);
  6628. }
  6629. return cffDict;
  6630. },
  6631. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6632. if (state.callDepth > MAX_SUBR_NESTING) {
  6633. return false;
  6634. }
  6635. var stackSize = state.stackSize;
  6636. var stack = state.stack;
  6637. var length = data.length;
  6638. for (var j = 0; j < length;) {
  6639. var value = data[j++];
  6640. var validationCommand = null;
  6641. if (value === 12) {
  6642. var q = data[j++];
  6643. if (q === 0) {
  6644. data[j - 2] = 139;
  6645. data[j - 1] = 22;
  6646. stackSize = 0;
  6647. } else {
  6648. validationCommand = CharstringValidationData12[q];
  6649. }
  6650. } else if (value === 28) {
  6651. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6652. j += 2;
  6653. stackSize++;
  6654. } else if (value === 14) {
  6655. if (stackSize >= 4) {
  6656. stackSize -= 4;
  6657. if (this.seacAnalysisEnabled) {
  6658. state.seac = stack.slice(stackSize, stackSize + 4);
  6659. return false;
  6660. }
  6661. }
  6662. validationCommand = CharstringValidationData[value];
  6663. } else if (value >= 32 && value <= 246) {
  6664. stack[stackSize] = value - 139;
  6665. stackSize++;
  6666. } else if (value >= 247 && value <= 254) {
  6667. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6668. j++;
  6669. stackSize++;
  6670. } else if (value === 255) {
  6671. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6672. j += 4;
  6673. stackSize++;
  6674. } else if (value === 19 || value === 20) {
  6675. state.hints += stackSize >> 1;
  6676. j += state.hints + 7 >> 3;
  6677. stackSize %= 2;
  6678. validationCommand = CharstringValidationData[value];
  6679. } else if (value === 10 || value === 29) {
  6680. var subrsIndex;
  6681. if (value === 10) {
  6682. subrsIndex = localSubrIndex;
  6683. } else {
  6684. subrsIndex = globalSubrIndex;
  6685. }
  6686. if (!subrsIndex) {
  6687. validationCommand = CharstringValidationData[value];
  6688. warn('Missing subrsIndex for ' + validationCommand.id);
  6689. return false;
  6690. }
  6691. var bias = 32768;
  6692. if (subrsIndex.count < 1240) {
  6693. bias = 107;
  6694. } else if (subrsIndex.count < 33900) {
  6695. bias = 1131;
  6696. }
  6697. var subrNumber = stack[--stackSize] + bias;
  6698. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6699. validationCommand = CharstringValidationData[value];
  6700. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6701. return false;
  6702. }
  6703. state.stackSize = stackSize;
  6704. state.callDepth++;
  6705. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6706. if (!valid) {
  6707. return false;
  6708. }
  6709. state.callDepth--;
  6710. stackSize = state.stackSize;
  6711. continue;
  6712. } else if (value === 11) {
  6713. state.stackSize = stackSize;
  6714. return true;
  6715. } else {
  6716. validationCommand = CharstringValidationData[value];
  6717. }
  6718. if (validationCommand) {
  6719. if (validationCommand.stem) {
  6720. state.hints += stackSize >> 1;
  6721. }
  6722. if ('min' in validationCommand) {
  6723. if (!state.undefStack && stackSize < validationCommand.min) {
  6724. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6725. return false;
  6726. }
  6727. }
  6728. if (state.firstStackClearing && validationCommand.stackClearing) {
  6729. state.firstStackClearing = false;
  6730. stackSize -= validationCommand.min;
  6731. if (stackSize >= 2 && validationCommand.stem) {
  6732. stackSize %= 2;
  6733. } else if (stackSize > 1) {
  6734. warn('Found too many parameters for stack-clearing command');
  6735. }
  6736. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6737. state.width = stack[stackSize - 1];
  6738. }
  6739. }
  6740. if ('stackDelta' in validationCommand) {
  6741. if ('stackFn' in validationCommand) {
  6742. validationCommand.stackFn(stack, stackSize);
  6743. }
  6744. stackSize += validationCommand.stackDelta;
  6745. } else if (validationCommand.stackClearing) {
  6746. stackSize = 0;
  6747. } else if (validationCommand.resetStack) {
  6748. stackSize = 0;
  6749. state.undefStack = false;
  6750. } else if (validationCommand.undefStack) {
  6751. stackSize = 0;
  6752. state.undefStack = true;
  6753. state.firstStackClearing = false;
  6754. }
  6755. }
  6756. }
  6757. state.stackSize = stackSize;
  6758. return true;
  6759. },
  6760. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6761. var seacs = [];
  6762. var widths = [];
  6763. var count = charStrings.count;
  6764. for (var i = 0; i < count; i++) {
  6765. var charstring = charStrings.get(i);
  6766. var state = {
  6767. callDepth: 0,
  6768. stackSize: 0,
  6769. stack: [],
  6770. undefStack: true,
  6771. hints: 0,
  6772. firstStackClearing: true,
  6773. seac: null,
  6774. width: null
  6775. };
  6776. var valid = true;
  6777. var localSubrToUse = null;
  6778. if (fdSelect && fdArray.length) {
  6779. var fdIndex = fdSelect.getFDIndex(i);
  6780. if (fdIndex === -1) {
  6781. warn('Glyph index is not in fd select.');
  6782. valid = false;
  6783. }
  6784. if (fdIndex >= fdArray.length) {
  6785. warn('Invalid fd index for glyph index.');
  6786. valid = false;
  6787. }
  6788. if (valid) {
  6789. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6790. }
  6791. } else if (localSubrIndex) {
  6792. localSubrToUse = localSubrIndex;
  6793. }
  6794. if (valid) {
  6795. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6796. }
  6797. if (state.width !== null) {
  6798. widths[i] = state.width;
  6799. }
  6800. if (state.seac !== null) {
  6801. seacs[i] = state.seac;
  6802. }
  6803. if (!valid) {
  6804. charStrings.set(i, new Uint8Array([14]));
  6805. }
  6806. }
  6807. return {
  6808. charStrings: charStrings,
  6809. seacs: seacs,
  6810. widths: widths
  6811. };
  6812. },
  6813. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6814. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6815. parentDict.setByKey(18, [
  6816. 0,
  6817. 0
  6818. ]);
  6819. parentDict.privateDict = privateDict;
  6820. },
  6821. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6822. if (!parentDict.hasName('Private')) {
  6823. this.emptyPrivateDictionary(parentDict);
  6824. return;
  6825. }
  6826. var privateOffset = parentDict.getByName('Private');
  6827. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6828. parentDict.removeByName('Private');
  6829. return;
  6830. }
  6831. var size = privateOffset[0];
  6832. var offset = privateOffset[1];
  6833. if (size === 0 || offset >= this.bytes.length) {
  6834. this.emptyPrivateDictionary(parentDict);
  6835. return;
  6836. }
  6837. var privateDictEnd = offset + size;
  6838. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6839. var dict = this.parseDict(dictData);
  6840. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6841. parentDict.privateDict = privateDict;
  6842. if (!privateDict.getByName('Subrs')) {
  6843. return;
  6844. }
  6845. var subrsOffset = privateDict.getByName('Subrs');
  6846. var relativeOffset = offset + subrsOffset;
  6847. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6848. this.emptyPrivateDictionary(parentDict);
  6849. return;
  6850. }
  6851. var subrsIndex = this.parseIndex(relativeOffset);
  6852. privateDict.subrsIndex = subrsIndex.obj;
  6853. },
  6854. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6855. if (pos === 0) {
  6856. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6857. } else if (pos === 1) {
  6858. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6859. } else if (pos === 2) {
  6860. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6861. }
  6862. var bytes = this.bytes;
  6863. var start = pos;
  6864. var format = bytes[pos++];
  6865. var charset = ['.notdef'];
  6866. var id, count, i;
  6867. length -= 1;
  6868. switch (format) {
  6869. case 0:
  6870. for (i = 0; i < length; i++) {
  6871. id = bytes[pos++] << 8 | bytes[pos++];
  6872. charset.push(cid ? id : strings.get(id));
  6873. }
  6874. break;
  6875. case 1:
  6876. while (charset.length <= length) {
  6877. id = bytes[pos++] << 8 | bytes[pos++];
  6878. count = bytes[pos++];
  6879. for (i = 0; i <= count; i++) {
  6880. charset.push(cid ? id++ : strings.get(id++));
  6881. }
  6882. }
  6883. break;
  6884. case 2:
  6885. while (charset.length <= length) {
  6886. id = bytes[pos++] << 8 | bytes[pos++];
  6887. count = bytes[pos++] << 8 | bytes[pos++];
  6888. for (i = 0; i <= count; i++) {
  6889. charset.push(cid ? id++ : strings.get(id++));
  6890. }
  6891. }
  6892. break;
  6893. default:
  6894. error('Unknown charset format');
  6895. }
  6896. var end = pos;
  6897. var raw = bytes.subarray(start, end);
  6898. return new CFFCharset(false, format, charset, raw);
  6899. },
  6900. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6901. var encoding = Object.create(null);
  6902. var bytes = this.bytes;
  6903. var predefined = false;
  6904. var format, i, ii;
  6905. var raw = null;
  6906. function readSupplement() {
  6907. var supplementsCount = bytes[pos++];
  6908. for (i = 0; i < supplementsCount; i++) {
  6909. var code = bytes[pos++];
  6910. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6911. encoding[code] = charset.indexOf(strings.get(sid));
  6912. }
  6913. }
  6914. if (pos === 0 || pos === 1) {
  6915. predefined = true;
  6916. format = pos;
  6917. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6918. for (i = 0, ii = charset.length; i < ii; i++) {
  6919. var index = baseEncoding.indexOf(charset[i]);
  6920. if (index !== -1) {
  6921. encoding[index] = i;
  6922. }
  6923. }
  6924. } else {
  6925. var dataStart = pos;
  6926. format = bytes[pos++];
  6927. switch (format & 0x7f) {
  6928. case 0:
  6929. var glyphsCount = bytes[pos++];
  6930. for (i = 1; i <= glyphsCount; i++) {
  6931. encoding[bytes[pos++]] = i;
  6932. }
  6933. break;
  6934. case 1:
  6935. var rangesCount = bytes[pos++];
  6936. var gid = 1;
  6937. for (i = 0; i < rangesCount; i++) {
  6938. var start = bytes[pos++];
  6939. var left = bytes[pos++];
  6940. for (var j = start; j <= start + left; j++) {
  6941. encoding[j] = gid++;
  6942. }
  6943. }
  6944. break;
  6945. default:
  6946. error('Unknown encoding format: ' + format + ' in CFF');
  6947. break;
  6948. }
  6949. var dataEnd = pos;
  6950. if (format & 0x80) {
  6951. bytes[dataStart] &= 0x7f;
  6952. readSupplement();
  6953. }
  6954. raw = bytes.subarray(dataStart, dataEnd);
  6955. }
  6956. format = format & 0x7f;
  6957. return new CFFEncoding(predefined, format, encoding, raw);
  6958. },
  6959. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6960. var start = pos;
  6961. var bytes = this.bytes;
  6962. var format = bytes[pos++];
  6963. var fdSelect = [], rawBytes;
  6964. var i, invalidFirstGID = false;
  6965. switch (format) {
  6966. case 0:
  6967. for (i = 0; i < length; ++i) {
  6968. var id = bytes[pos++];
  6969. fdSelect.push(id);
  6970. }
  6971. rawBytes = bytes.subarray(start, pos);
  6972. break;
  6973. case 3:
  6974. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6975. for (i = 0; i < rangesCount; ++i) {
  6976. var first = bytes[pos++] << 8 | bytes[pos++];
  6977. if (i === 0 && first !== 0) {
  6978. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6979. invalidFirstGID = true;
  6980. first = 0;
  6981. }
  6982. var fdIndex = bytes[pos++];
  6983. var next = bytes[pos] << 8 | bytes[pos + 1];
  6984. for (var j = first; j < next; ++j) {
  6985. fdSelect.push(fdIndex);
  6986. }
  6987. }
  6988. pos += 2;
  6989. rawBytes = bytes.subarray(start, pos);
  6990. if (invalidFirstGID) {
  6991. rawBytes[3] = rawBytes[4] = 0;
  6992. }
  6993. break;
  6994. default:
  6995. error('parseFDSelect: Unknown format "' + format + '".');
  6996. break;
  6997. }
  6998. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  6999. return new CFFFDSelect(fdSelect, rawBytes);
  7000. }
  7001. };
  7002. return CFFParser;
  7003. }();
  7004. var CFF = function CFFClosure() {
  7005. function CFF() {
  7006. this.header = null;
  7007. this.names = [];
  7008. this.topDict = null;
  7009. this.strings = new CFFStrings();
  7010. this.globalSubrIndex = null;
  7011. this.encoding = null;
  7012. this.charset = null;
  7013. this.charStrings = null;
  7014. this.fdArray = [];
  7015. this.fdSelect = null;
  7016. this.isCIDFont = false;
  7017. }
  7018. return CFF;
  7019. }();
  7020. var CFFHeader = function CFFHeaderClosure() {
  7021. function CFFHeader(major, minor, hdrSize, offSize) {
  7022. this.major = major;
  7023. this.minor = minor;
  7024. this.hdrSize = hdrSize;
  7025. this.offSize = offSize;
  7026. }
  7027. return CFFHeader;
  7028. }();
  7029. var CFFStrings = function CFFStringsClosure() {
  7030. function CFFStrings() {
  7031. this.strings = [];
  7032. }
  7033. CFFStrings.prototype = {
  7034. get: function CFFStrings_get(index) {
  7035. if (index >= 0 && index <= 390) {
  7036. return CFFStandardStrings[index];
  7037. }
  7038. if (index - 391 <= this.strings.length) {
  7039. return this.strings[index - 391];
  7040. }
  7041. return CFFStandardStrings[0];
  7042. },
  7043. add: function CFFStrings_add(value) {
  7044. this.strings.push(value);
  7045. },
  7046. get count() {
  7047. return this.strings.length;
  7048. }
  7049. };
  7050. return CFFStrings;
  7051. }();
  7052. var CFFIndex = function CFFIndexClosure() {
  7053. function CFFIndex() {
  7054. this.objects = [];
  7055. this.length = 0;
  7056. }
  7057. CFFIndex.prototype = {
  7058. add: function CFFIndex_add(data) {
  7059. this.length += data.length;
  7060. this.objects.push(data);
  7061. },
  7062. set: function CFFIndex_set(index, data) {
  7063. this.length += data.length - this.objects[index].length;
  7064. this.objects[index] = data;
  7065. },
  7066. get: function CFFIndex_get(index) {
  7067. return this.objects[index];
  7068. },
  7069. get count() {
  7070. return this.objects.length;
  7071. }
  7072. };
  7073. return CFFIndex;
  7074. }();
  7075. var CFFDict = function CFFDictClosure() {
  7076. function CFFDict(tables, strings) {
  7077. this.keyToNameMap = tables.keyToNameMap;
  7078. this.nameToKeyMap = tables.nameToKeyMap;
  7079. this.defaults = tables.defaults;
  7080. this.types = tables.types;
  7081. this.opcodes = tables.opcodes;
  7082. this.order = tables.order;
  7083. this.strings = strings;
  7084. this.values = Object.create(null);
  7085. }
  7086. CFFDict.prototype = {
  7087. setByKey: function CFFDict_setByKey(key, value) {
  7088. if (!(key in this.keyToNameMap)) {
  7089. return false;
  7090. }
  7091. var valueLength = value.length;
  7092. if (valueLength === 0) {
  7093. return true;
  7094. }
  7095. for (var i = 0; i < valueLength; i++) {
  7096. if (isNaN(value[i])) {
  7097. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7098. return true;
  7099. }
  7100. }
  7101. var type = this.types[key];
  7102. if (type === 'num' || type === 'sid' || type === 'offset') {
  7103. value = value[0];
  7104. }
  7105. this.values[key] = value;
  7106. return true;
  7107. },
  7108. setByName: function CFFDict_setByName(name, value) {
  7109. if (!(name in this.nameToKeyMap)) {
  7110. error('Invalid dictionary name "' + name + '"');
  7111. }
  7112. this.values[this.nameToKeyMap[name]] = value;
  7113. },
  7114. hasName: function CFFDict_hasName(name) {
  7115. return this.nameToKeyMap[name] in this.values;
  7116. },
  7117. getByName: function CFFDict_getByName(name) {
  7118. if (!(name in this.nameToKeyMap)) {
  7119. error('Invalid dictionary name "' + name + '"');
  7120. }
  7121. var key = this.nameToKeyMap[name];
  7122. if (!(key in this.values)) {
  7123. return this.defaults[key];
  7124. }
  7125. return this.values[key];
  7126. },
  7127. removeByName: function CFFDict_removeByName(name) {
  7128. delete this.values[this.nameToKeyMap[name]];
  7129. }
  7130. };
  7131. CFFDict.createTables = function CFFDict_createTables(layout) {
  7132. var tables = {
  7133. keyToNameMap: {},
  7134. nameToKeyMap: {},
  7135. defaults: {},
  7136. types: {},
  7137. opcodes: {},
  7138. order: []
  7139. };
  7140. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7141. var entry = layout[i];
  7142. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7143. tables.keyToNameMap[key] = entry[1];
  7144. tables.nameToKeyMap[entry[1]] = key;
  7145. tables.types[key] = entry[2];
  7146. tables.defaults[key] = entry[3];
  7147. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7148. tables.order.push(key);
  7149. }
  7150. return tables;
  7151. };
  7152. return CFFDict;
  7153. }();
  7154. var CFFTopDict = function CFFTopDictClosure() {
  7155. var layout = [
  7156. [
  7157. [
  7158. 12,
  7159. 30
  7160. ],
  7161. 'ROS',
  7162. [
  7163. 'sid',
  7164. 'sid',
  7165. 'num'
  7166. ],
  7167. null
  7168. ],
  7169. [
  7170. [
  7171. 12,
  7172. 20
  7173. ],
  7174. 'SyntheticBase',
  7175. 'num',
  7176. null
  7177. ],
  7178. [
  7179. 0,
  7180. 'version',
  7181. 'sid',
  7182. null
  7183. ],
  7184. [
  7185. 1,
  7186. 'Notice',
  7187. 'sid',
  7188. null
  7189. ],
  7190. [
  7191. [
  7192. 12,
  7193. 0
  7194. ],
  7195. 'Copyright',
  7196. 'sid',
  7197. null
  7198. ],
  7199. [
  7200. 2,
  7201. 'FullName',
  7202. 'sid',
  7203. null
  7204. ],
  7205. [
  7206. 3,
  7207. 'FamilyName',
  7208. 'sid',
  7209. null
  7210. ],
  7211. [
  7212. 4,
  7213. 'Weight',
  7214. 'sid',
  7215. null
  7216. ],
  7217. [
  7218. [
  7219. 12,
  7220. 1
  7221. ],
  7222. 'isFixedPitch',
  7223. 'num',
  7224. 0
  7225. ],
  7226. [
  7227. [
  7228. 12,
  7229. 2
  7230. ],
  7231. 'ItalicAngle',
  7232. 'num',
  7233. 0
  7234. ],
  7235. [
  7236. [
  7237. 12,
  7238. 3
  7239. ],
  7240. 'UnderlinePosition',
  7241. 'num',
  7242. -100
  7243. ],
  7244. [
  7245. [
  7246. 12,
  7247. 4
  7248. ],
  7249. 'UnderlineThickness',
  7250. 'num',
  7251. 50
  7252. ],
  7253. [
  7254. [
  7255. 12,
  7256. 5
  7257. ],
  7258. 'PaintType',
  7259. 'num',
  7260. 0
  7261. ],
  7262. [
  7263. [
  7264. 12,
  7265. 6
  7266. ],
  7267. 'CharstringType',
  7268. 'num',
  7269. 2
  7270. ],
  7271. [
  7272. [
  7273. 12,
  7274. 7
  7275. ],
  7276. 'FontMatrix',
  7277. [
  7278. 'num',
  7279. 'num',
  7280. 'num',
  7281. 'num',
  7282. 'num',
  7283. 'num'
  7284. ],
  7285. [
  7286. 0.001,
  7287. 0,
  7288. 0,
  7289. 0.001,
  7290. 0,
  7291. 0
  7292. ]
  7293. ],
  7294. [
  7295. 13,
  7296. 'UniqueID',
  7297. 'num',
  7298. null
  7299. ],
  7300. [
  7301. 5,
  7302. 'FontBBox',
  7303. [
  7304. 'num',
  7305. 'num',
  7306. 'num',
  7307. 'num'
  7308. ],
  7309. [
  7310. 0,
  7311. 0,
  7312. 0,
  7313. 0
  7314. ]
  7315. ],
  7316. [
  7317. [
  7318. 12,
  7319. 8
  7320. ],
  7321. 'StrokeWidth',
  7322. 'num',
  7323. 0
  7324. ],
  7325. [
  7326. 14,
  7327. 'XUID',
  7328. 'array',
  7329. null
  7330. ],
  7331. [
  7332. 15,
  7333. 'charset',
  7334. 'offset',
  7335. 0
  7336. ],
  7337. [
  7338. 16,
  7339. 'Encoding',
  7340. 'offset',
  7341. 0
  7342. ],
  7343. [
  7344. 17,
  7345. 'CharStrings',
  7346. 'offset',
  7347. 0
  7348. ],
  7349. [
  7350. 18,
  7351. 'Private',
  7352. [
  7353. 'offset',
  7354. 'offset'
  7355. ],
  7356. null
  7357. ],
  7358. [
  7359. [
  7360. 12,
  7361. 21
  7362. ],
  7363. 'PostScript',
  7364. 'sid',
  7365. null
  7366. ],
  7367. [
  7368. [
  7369. 12,
  7370. 22
  7371. ],
  7372. 'BaseFontName',
  7373. 'sid',
  7374. null
  7375. ],
  7376. [
  7377. [
  7378. 12,
  7379. 23
  7380. ],
  7381. 'BaseFontBlend',
  7382. 'delta',
  7383. null
  7384. ],
  7385. [
  7386. [
  7387. 12,
  7388. 31
  7389. ],
  7390. 'CIDFontVersion',
  7391. 'num',
  7392. 0
  7393. ],
  7394. [
  7395. [
  7396. 12,
  7397. 32
  7398. ],
  7399. 'CIDFontRevision',
  7400. 'num',
  7401. 0
  7402. ],
  7403. [
  7404. [
  7405. 12,
  7406. 33
  7407. ],
  7408. 'CIDFontType',
  7409. 'num',
  7410. 0
  7411. ],
  7412. [
  7413. [
  7414. 12,
  7415. 34
  7416. ],
  7417. 'CIDCount',
  7418. 'num',
  7419. 8720
  7420. ],
  7421. [
  7422. [
  7423. 12,
  7424. 35
  7425. ],
  7426. 'UIDBase',
  7427. 'num',
  7428. null
  7429. ],
  7430. [
  7431. [
  7432. 12,
  7433. 37
  7434. ],
  7435. 'FDSelect',
  7436. 'offset',
  7437. null
  7438. ],
  7439. [
  7440. [
  7441. 12,
  7442. 36
  7443. ],
  7444. 'FDArray',
  7445. 'offset',
  7446. null
  7447. ],
  7448. [
  7449. [
  7450. 12,
  7451. 38
  7452. ],
  7453. 'FontName',
  7454. 'sid',
  7455. null
  7456. ]
  7457. ];
  7458. var tables = null;
  7459. function CFFTopDict(strings) {
  7460. if (tables === null) {
  7461. tables = CFFDict.createTables(layout);
  7462. }
  7463. CFFDict.call(this, tables, strings);
  7464. this.privateDict = null;
  7465. }
  7466. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7467. return CFFTopDict;
  7468. }();
  7469. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7470. var layout = [
  7471. [
  7472. 6,
  7473. 'BlueValues',
  7474. 'delta',
  7475. null
  7476. ],
  7477. [
  7478. 7,
  7479. 'OtherBlues',
  7480. 'delta',
  7481. null
  7482. ],
  7483. [
  7484. 8,
  7485. 'FamilyBlues',
  7486. 'delta',
  7487. null
  7488. ],
  7489. [
  7490. 9,
  7491. 'FamilyOtherBlues',
  7492. 'delta',
  7493. null
  7494. ],
  7495. [
  7496. [
  7497. 12,
  7498. 9
  7499. ],
  7500. 'BlueScale',
  7501. 'num',
  7502. 0.039625
  7503. ],
  7504. [
  7505. [
  7506. 12,
  7507. 10
  7508. ],
  7509. 'BlueShift',
  7510. 'num',
  7511. 7
  7512. ],
  7513. [
  7514. [
  7515. 12,
  7516. 11
  7517. ],
  7518. 'BlueFuzz',
  7519. 'num',
  7520. 1
  7521. ],
  7522. [
  7523. 10,
  7524. 'StdHW',
  7525. 'num',
  7526. null
  7527. ],
  7528. [
  7529. 11,
  7530. 'StdVW',
  7531. 'num',
  7532. null
  7533. ],
  7534. [
  7535. [
  7536. 12,
  7537. 12
  7538. ],
  7539. 'StemSnapH',
  7540. 'delta',
  7541. null
  7542. ],
  7543. [
  7544. [
  7545. 12,
  7546. 13
  7547. ],
  7548. 'StemSnapV',
  7549. 'delta',
  7550. null
  7551. ],
  7552. [
  7553. [
  7554. 12,
  7555. 14
  7556. ],
  7557. 'ForceBold',
  7558. 'num',
  7559. 0
  7560. ],
  7561. [
  7562. [
  7563. 12,
  7564. 17
  7565. ],
  7566. 'LanguageGroup',
  7567. 'num',
  7568. 0
  7569. ],
  7570. [
  7571. [
  7572. 12,
  7573. 18
  7574. ],
  7575. 'ExpansionFactor',
  7576. 'num',
  7577. 0.06
  7578. ],
  7579. [
  7580. [
  7581. 12,
  7582. 19
  7583. ],
  7584. 'initialRandomSeed',
  7585. 'num',
  7586. 0
  7587. ],
  7588. [
  7589. 20,
  7590. 'defaultWidthX',
  7591. 'num',
  7592. 0
  7593. ],
  7594. [
  7595. 21,
  7596. 'nominalWidthX',
  7597. 'num',
  7598. 0
  7599. ],
  7600. [
  7601. 19,
  7602. 'Subrs',
  7603. 'offset',
  7604. null
  7605. ]
  7606. ];
  7607. var tables = null;
  7608. function CFFPrivateDict(strings) {
  7609. if (tables === null) {
  7610. tables = CFFDict.createTables(layout);
  7611. }
  7612. CFFDict.call(this, tables, strings);
  7613. this.subrsIndex = null;
  7614. }
  7615. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7616. return CFFPrivateDict;
  7617. }();
  7618. var CFFCharsetPredefinedTypes = {
  7619. ISO_ADOBE: 0,
  7620. EXPERT: 1,
  7621. EXPERT_SUBSET: 2
  7622. };
  7623. var CFFCharset = function CFFCharsetClosure() {
  7624. function CFFCharset(predefined, format, charset, raw) {
  7625. this.predefined = predefined;
  7626. this.format = format;
  7627. this.charset = charset;
  7628. this.raw = raw;
  7629. }
  7630. return CFFCharset;
  7631. }();
  7632. var CFFEncoding = function CFFEncodingClosure() {
  7633. function CFFEncoding(predefined, format, encoding, raw) {
  7634. this.predefined = predefined;
  7635. this.format = format;
  7636. this.encoding = encoding;
  7637. this.raw = raw;
  7638. }
  7639. return CFFEncoding;
  7640. }();
  7641. var CFFFDSelect = function CFFFDSelectClosure() {
  7642. function CFFFDSelect(fdSelect, raw) {
  7643. this.fdSelect = fdSelect;
  7644. this.raw = raw;
  7645. }
  7646. CFFFDSelect.prototype = {
  7647. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7648. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7649. return -1;
  7650. }
  7651. return this.fdSelect[glyphIndex];
  7652. }
  7653. };
  7654. return CFFFDSelect;
  7655. }();
  7656. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7657. function CFFOffsetTracker() {
  7658. this.offsets = Object.create(null);
  7659. }
  7660. CFFOffsetTracker.prototype = {
  7661. isTracking: function CFFOffsetTracker_isTracking(key) {
  7662. return key in this.offsets;
  7663. },
  7664. track: function CFFOffsetTracker_track(key, location) {
  7665. if (key in this.offsets) {
  7666. error('Already tracking location of ' + key);
  7667. }
  7668. this.offsets[key] = location;
  7669. },
  7670. offset: function CFFOffsetTracker_offset(value) {
  7671. for (var key in this.offsets) {
  7672. this.offsets[key] += value;
  7673. }
  7674. },
  7675. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7676. if (!(key in this.offsets)) {
  7677. error('Not tracking location of ' + key);
  7678. }
  7679. var data = output.data;
  7680. var dataOffset = this.offsets[key];
  7681. var size = 5;
  7682. for (var i = 0, ii = values.length; i < ii; ++i) {
  7683. var offset0 = i * size + dataOffset;
  7684. var offset1 = offset0 + 1;
  7685. var offset2 = offset0 + 2;
  7686. var offset3 = offset0 + 3;
  7687. var offset4 = offset0 + 4;
  7688. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7689. error('writing to an offset that is not empty');
  7690. }
  7691. var value = values[i];
  7692. data[offset0] = 0x1d;
  7693. data[offset1] = value >> 24 & 0xFF;
  7694. data[offset2] = value >> 16 & 0xFF;
  7695. data[offset3] = value >> 8 & 0xFF;
  7696. data[offset4] = value & 0xFF;
  7697. }
  7698. }
  7699. };
  7700. return CFFOffsetTracker;
  7701. }();
  7702. var CFFCompiler = function CFFCompilerClosure() {
  7703. function CFFCompiler(cff) {
  7704. this.cff = cff;
  7705. }
  7706. CFFCompiler.prototype = {
  7707. compile: function CFFCompiler_compile() {
  7708. var cff = this.cff;
  7709. var output = {
  7710. data: [],
  7711. length: 0,
  7712. add: function CFFCompiler_add(data) {
  7713. this.data = this.data.concat(data);
  7714. this.length = this.data.length;
  7715. }
  7716. };
  7717. var header = this.compileHeader(cff.header);
  7718. output.add(header);
  7719. var nameIndex = this.compileNameIndex(cff.names);
  7720. output.add(nameIndex);
  7721. if (cff.isCIDFont) {
  7722. if (cff.topDict.hasName('FontMatrix')) {
  7723. var base = cff.topDict.getByName('FontMatrix');
  7724. cff.topDict.removeByName('FontMatrix');
  7725. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7726. var subDict = cff.fdArray[i];
  7727. var matrix = base.slice(0);
  7728. if (subDict.hasName('FontMatrix')) {
  7729. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7730. }
  7731. subDict.setByName('FontMatrix', matrix);
  7732. }
  7733. }
  7734. }
  7735. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7736. output.add(compiled.output);
  7737. var topDictTracker = compiled.trackers[0];
  7738. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7739. output.add(stringIndex);
  7740. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7741. output.add(globalSubrIndex);
  7742. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7743. if (cff.encoding.predefined) {
  7744. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7745. } else {
  7746. var encoding = this.compileEncoding(cff.encoding);
  7747. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7748. output.add(encoding);
  7749. }
  7750. }
  7751. if (cff.charset && cff.topDict.hasName('charset')) {
  7752. if (cff.charset.predefined) {
  7753. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7754. } else {
  7755. var charset = this.compileCharset(cff.charset);
  7756. topDictTracker.setEntryLocation('charset', [output.length], output);
  7757. output.add(charset);
  7758. }
  7759. }
  7760. var charStrings = this.compileCharStrings(cff.charStrings);
  7761. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7762. output.add(charStrings);
  7763. if (cff.isCIDFont) {
  7764. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7765. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7766. output.add(fdSelect);
  7767. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7768. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7769. output.add(compiled.output);
  7770. var fontDictTrackers = compiled.trackers;
  7771. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7772. }
  7773. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7774. output.add([0]);
  7775. return output.data;
  7776. },
  7777. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7778. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7779. return this.encodeInteger(value);
  7780. }
  7781. return this.encodeFloat(value);
  7782. },
  7783. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7784. var value = num.toString();
  7785. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7786. if (m) {
  7787. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7788. value = (Math.round(num * epsilon) / epsilon).toString();
  7789. }
  7790. var nibbles = '';
  7791. var i, ii;
  7792. for (i = 0, ii = value.length; i < ii; ++i) {
  7793. var a = value[i];
  7794. if (a === 'e') {
  7795. nibbles += value[++i] === '-' ? 'c' : 'b';
  7796. } else if (a === '.') {
  7797. nibbles += 'a';
  7798. } else if (a === '-') {
  7799. nibbles += 'e';
  7800. } else {
  7801. nibbles += a;
  7802. }
  7803. }
  7804. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7805. var out = [30];
  7806. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7807. out.push(parseInt(nibbles.substr(i, 2), 16));
  7808. }
  7809. return out;
  7810. },
  7811. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7812. var code;
  7813. if (value >= -107 && value <= 107) {
  7814. code = [value + 139];
  7815. } else if (value >= 108 && value <= 1131) {
  7816. value = value - 108;
  7817. code = [
  7818. (value >> 8) + 247,
  7819. value & 0xFF
  7820. ];
  7821. } else if (value >= -1131 && value <= -108) {
  7822. value = -value - 108;
  7823. code = [
  7824. (value >> 8) + 251,
  7825. value & 0xFF
  7826. ];
  7827. } else if (value >= -32768 && value <= 32767) {
  7828. code = [
  7829. 0x1c,
  7830. value >> 8 & 0xFF,
  7831. value & 0xFF
  7832. ];
  7833. } else {
  7834. code = [
  7835. 0x1d,
  7836. value >> 24 & 0xFF,
  7837. value >> 16 & 0xFF,
  7838. value >> 8 & 0xFF,
  7839. value & 0xFF
  7840. ];
  7841. }
  7842. return code;
  7843. },
  7844. compileHeader: function CFFCompiler_compileHeader(header) {
  7845. return [
  7846. header.major,
  7847. header.minor,
  7848. header.hdrSize,
  7849. header.offSize
  7850. ];
  7851. },
  7852. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7853. var nameIndex = new CFFIndex();
  7854. for (var i = 0, ii = names.length; i < ii; ++i) {
  7855. nameIndex.add(stringToBytes(names[i]));
  7856. }
  7857. return this.compileIndex(nameIndex);
  7858. },
  7859. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7860. var fontDictTrackers = [];
  7861. var fdArrayIndex = new CFFIndex();
  7862. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7863. var fontDict = dicts[i];
  7864. if (removeCidKeys) {
  7865. fontDict.removeByName('CIDFontVersion');
  7866. fontDict.removeByName('CIDFontRevision');
  7867. fontDict.removeByName('CIDFontType');
  7868. fontDict.removeByName('CIDCount');
  7869. fontDict.removeByName('UIDBase');
  7870. }
  7871. var fontDictTracker = new CFFOffsetTracker();
  7872. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7873. fontDictTrackers.push(fontDictTracker);
  7874. fdArrayIndex.add(fontDictData);
  7875. fontDictTracker.offset(length);
  7876. }
  7877. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7878. return {
  7879. trackers: fontDictTrackers,
  7880. output: fdArrayIndex
  7881. };
  7882. },
  7883. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7884. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7885. var fontDict = dicts[i];
  7886. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7887. var privateDict = fontDict.privateDict;
  7888. var privateDictTracker = new CFFOffsetTracker();
  7889. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7890. var outputLength = output.length;
  7891. privateDictTracker.offset(outputLength);
  7892. if (!privateDictData.length) {
  7893. outputLength = 0;
  7894. }
  7895. trackers[i].setEntryLocation('Private', [
  7896. privateDictData.length,
  7897. outputLength
  7898. ], output);
  7899. output.add(privateDictData);
  7900. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7901. var subrs = this.compileIndex(privateDict.subrsIndex);
  7902. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7903. output.add(subrs);
  7904. }
  7905. }
  7906. },
  7907. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7908. var out = [];
  7909. var order = dict.order;
  7910. for (var i = 0; i < order.length; ++i) {
  7911. var key = order[i];
  7912. if (!(key in dict.values)) {
  7913. continue;
  7914. }
  7915. var values = dict.values[key];
  7916. var types = dict.types[key];
  7917. if (!isArray(types)) {
  7918. types = [types];
  7919. }
  7920. if (!isArray(values)) {
  7921. values = [values];
  7922. }
  7923. if (values.length === 0) {
  7924. continue;
  7925. }
  7926. for (var j = 0, jj = types.length; j < jj; ++j) {
  7927. var type = types[j];
  7928. var value = values[j];
  7929. switch (type) {
  7930. case 'num':
  7931. case 'sid':
  7932. out = out.concat(this.encodeNumber(value));
  7933. break;
  7934. case 'offset':
  7935. var name = dict.keyToNameMap[key];
  7936. if (!offsetTracker.isTracking(name)) {
  7937. offsetTracker.track(name, out.length);
  7938. }
  7939. out = out.concat([
  7940. 0x1d,
  7941. 0,
  7942. 0,
  7943. 0,
  7944. 0
  7945. ]);
  7946. break;
  7947. case 'array':
  7948. case 'delta':
  7949. out = out.concat(this.encodeNumber(value));
  7950. for (var k = 1, kk = values.length; k < kk; ++k) {
  7951. out = out.concat(this.encodeNumber(values[k]));
  7952. }
  7953. break;
  7954. default:
  7955. error('Unknown data type of ' + type);
  7956. break;
  7957. }
  7958. }
  7959. out = out.concat(dict.opcodes[key]);
  7960. }
  7961. return out;
  7962. },
  7963. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7964. var stringIndex = new CFFIndex();
  7965. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7966. stringIndex.add(stringToBytes(strings[i]));
  7967. }
  7968. return this.compileIndex(stringIndex);
  7969. },
  7970. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7971. var globalSubrIndex = this.cff.globalSubrIndex;
  7972. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7973. },
  7974. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7975. return this.compileIndex(charStrings);
  7976. },
  7977. compileCharset: function CFFCompiler_compileCharset(charset) {
  7978. return this.compileTypedArray(charset.raw);
  7979. },
  7980. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7981. return this.compileTypedArray(encoding.raw);
  7982. },
  7983. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7984. return this.compileTypedArray(fdSelect);
  7985. },
  7986. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7987. var out = [];
  7988. for (var i = 0, ii = data.length; i < ii; ++i) {
  7989. out[i] = data[i];
  7990. }
  7991. return out;
  7992. },
  7993. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7994. trackers = trackers || [];
  7995. var objects = index.objects;
  7996. var count = objects.length;
  7997. if (count === 0) {
  7998. return [
  7999. 0,
  8000. 0,
  8001. 0
  8002. ];
  8003. }
  8004. var data = [
  8005. count >> 8 & 0xFF,
  8006. count & 0xff
  8007. ];
  8008. var lastOffset = 1, i;
  8009. for (i = 0; i < count; ++i) {
  8010. lastOffset += objects[i].length;
  8011. }
  8012. var offsetSize;
  8013. if (lastOffset < 0x100) {
  8014. offsetSize = 1;
  8015. } else if (lastOffset < 0x10000) {
  8016. offsetSize = 2;
  8017. } else if (lastOffset < 0x1000000) {
  8018. offsetSize = 3;
  8019. } else {
  8020. offsetSize = 4;
  8021. }
  8022. data.push(offsetSize);
  8023. var relativeOffset = 1;
  8024. for (i = 0; i < count + 1; i++) {
  8025. if (offsetSize === 1) {
  8026. data.push(relativeOffset & 0xFF);
  8027. } else if (offsetSize === 2) {
  8028. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8029. } else if (offsetSize === 3) {
  8030. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8031. } else {
  8032. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. }
  8034. if (objects[i]) {
  8035. relativeOffset += objects[i].length;
  8036. }
  8037. }
  8038. for (i = 0; i < count; i++) {
  8039. if (trackers[i]) {
  8040. trackers[i].offset(data.length);
  8041. }
  8042. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8043. data.push(objects[i][j]);
  8044. }
  8045. }
  8046. return data;
  8047. }
  8048. };
  8049. return CFFCompiler;
  8050. }();
  8051. exports.CFFStandardStrings = CFFStandardStrings;
  8052. exports.CFFParser = CFFParser;
  8053. exports.CFF = CFF;
  8054. exports.CFFHeader = CFFHeader;
  8055. exports.CFFStrings = CFFStrings;
  8056. exports.CFFIndex = CFFIndex;
  8057. exports.CFFCharset = CFFCharset;
  8058. exports.CFFTopDict = CFFTopDict;
  8059. exports.CFFPrivateDict = CFFPrivateDict;
  8060. exports.CFFCompiler = CFFCompiler;
  8061. }));
  8062. (function (root, factory) {
  8063. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8064. }(this, function (exports, sharedUtil) {
  8065. var MissingDataException = sharedUtil.MissingDataException;
  8066. var arrayByteLength = sharedUtil.arrayByteLength;
  8067. var arraysToBytes = sharedUtil.arraysToBytes;
  8068. var assert = sharedUtil.assert;
  8069. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8070. var isInt = sharedUtil.isInt;
  8071. var isEmptyObj = sharedUtil.isEmptyObj;
  8072. var ChunkedStream = function ChunkedStreamClosure() {
  8073. function ChunkedStream(length, chunkSize, manager) {
  8074. this.bytes = new Uint8Array(length);
  8075. this.start = 0;
  8076. this.pos = 0;
  8077. this.end = length;
  8078. this.chunkSize = chunkSize;
  8079. this.loadedChunks = [];
  8080. this.numChunksLoaded = 0;
  8081. this.numChunks = Math.ceil(length / chunkSize);
  8082. this.manager = manager;
  8083. this.progressiveDataLength = 0;
  8084. this.lastSuccessfulEnsureByteChunk = -1;
  8085. }
  8086. ChunkedStream.prototype = {
  8087. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8088. var chunks = [];
  8089. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8090. if (!this.loadedChunks[chunk]) {
  8091. chunks.push(chunk);
  8092. }
  8093. }
  8094. return chunks;
  8095. },
  8096. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8097. return [this];
  8098. },
  8099. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8100. return this.numChunksLoaded === this.numChunks;
  8101. },
  8102. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8103. var end = begin + chunk.byteLength;
  8104. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8105. var length = this.bytes.length;
  8106. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8107. this.bytes.set(new Uint8Array(chunk), begin);
  8108. var chunkSize = this.chunkSize;
  8109. var beginChunk = Math.floor(begin / chunkSize);
  8110. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8111. var curChunk;
  8112. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8113. if (!this.loadedChunks[curChunk]) {
  8114. this.loadedChunks[curChunk] = true;
  8115. ++this.numChunksLoaded;
  8116. }
  8117. }
  8118. },
  8119. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8120. var position = this.progressiveDataLength;
  8121. var beginChunk = Math.floor(position / this.chunkSize);
  8122. this.bytes.set(new Uint8Array(data), position);
  8123. position += data.byteLength;
  8124. this.progressiveDataLength = position;
  8125. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8126. var curChunk;
  8127. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8128. if (!this.loadedChunks[curChunk]) {
  8129. this.loadedChunks[curChunk] = true;
  8130. ++this.numChunksLoaded;
  8131. }
  8132. }
  8133. },
  8134. ensureByte: function ChunkedStream_ensureByte(pos) {
  8135. var chunk = Math.floor(pos / this.chunkSize);
  8136. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8137. return;
  8138. }
  8139. if (!this.loadedChunks[chunk]) {
  8140. throw new MissingDataException(pos, pos + 1);
  8141. }
  8142. this.lastSuccessfulEnsureByteChunk = chunk;
  8143. },
  8144. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8145. if (begin >= end) {
  8146. return;
  8147. }
  8148. if (end <= this.progressiveDataLength) {
  8149. return;
  8150. }
  8151. var chunkSize = this.chunkSize;
  8152. var beginChunk = Math.floor(begin / chunkSize);
  8153. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8154. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8155. if (!this.loadedChunks[chunk]) {
  8156. throw new MissingDataException(begin, end);
  8157. }
  8158. }
  8159. },
  8160. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8161. var chunk, numChunks = this.numChunks;
  8162. for (var i = 0; i < numChunks; ++i) {
  8163. chunk = (beginChunk + i) % numChunks;
  8164. if (!this.loadedChunks[chunk]) {
  8165. return chunk;
  8166. }
  8167. }
  8168. return null;
  8169. },
  8170. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8171. return !!this.loadedChunks[chunk];
  8172. },
  8173. get length() {
  8174. return this.end - this.start;
  8175. },
  8176. get isEmpty() {
  8177. return this.length === 0;
  8178. },
  8179. getByte: function ChunkedStream_getByte() {
  8180. var pos = this.pos;
  8181. if (pos >= this.end) {
  8182. return -1;
  8183. }
  8184. this.ensureByte(pos);
  8185. return this.bytes[this.pos++];
  8186. },
  8187. getUint16: function ChunkedStream_getUint16() {
  8188. var b0 = this.getByte();
  8189. var b1 = this.getByte();
  8190. if (b0 === -1 || b1 === -1) {
  8191. return -1;
  8192. }
  8193. return (b0 << 8) + b1;
  8194. },
  8195. getInt32: function ChunkedStream_getInt32() {
  8196. var b0 = this.getByte();
  8197. var b1 = this.getByte();
  8198. var b2 = this.getByte();
  8199. var b3 = this.getByte();
  8200. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8201. },
  8202. getBytes: function ChunkedStream_getBytes(length) {
  8203. var bytes = this.bytes;
  8204. var pos = this.pos;
  8205. var strEnd = this.end;
  8206. if (!length) {
  8207. this.ensureRange(pos, strEnd);
  8208. return bytes.subarray(pos, strEnd);
  8209. }
  8210. var end = pos + length;
  8211. if (end > strEnd) {
  8212. end = strEnd;
  8213. }
  8214. this.ensureRange(pos, end);
  8215. this.pos = end;
  8216. return bytes.subarray(pos, end);
  8217. },
  8218. peekByte: function ChunkedStream_peekByte() {
  8219. var peekedByte = this.getByte();
  8220. this.pos--;
  8221. return peekedByte;
  8222. },
  8223. peekBytes: function ChunkedStream_peekBytes(length) {
  8224. var bytes = this.getBytes(length);
  8225. this.pos -= bytes.length;
  8226. return bytes;
  8227. },
  8228. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8229. this.ensureRange(begin, end);
  8230. return this.bytes.subarray(begin, end);
  8231. },
  8232. skip: function ChunkedStream_skip(n) {
  8233. if (!n) {
  8234. n = 1;
  8235. }
  8236. this.pos += n;
  8237. },
  8238. reset: function ChunkedStream_reset() {
  8239. this.pos = this.start;
  8240. },
  8241. moveStart: function ChunkedStream_moveStart() {
  8242. this.start = this.pos;
  8243. },
  8244. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8245. this.ensureRange(start, start + length);
  8246. function ChunkedStreamSubstream() {
  8247. }
  8248. ChunkedStreamSubstream.prototype = Object.create(this);
  8249. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8250. var chunkSize = this.chunkSize;
  8251. var beginChunk = Math.floor(this.start / chunkSize);
  8252. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8253. var missingChunks = [];
  8254. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8255. if (!this.loadedChunks[chunk]) {
  8256. missingChunks.push(chunk);
  8257. }
  8258. }
  8259. return missingChunks;
  8260. };
  8261. var subStream = new ChunkedStreamSubstream();
  8262. subStream.pos = subStream.start = start;
  8263. subStream.end = start + length || this.end;
  8264. subStream.dict = dict;
  8265. return subStream;
  8266. }
  8267. };
  8268. return ChunkedStream;
  8269. }();
  8270. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8271. function ChunkedStreamManager(pdfNetworkStream, args) {
  8272. var chunkSize = args.rangeChunkSize;
  8273. var length = args.length;
  8274. this.stream = new ChunkedStream(length, chunkSize, this);
  8275. this.length = length;
  8276. this.chunkSize = chunkSize;
  8277. this.pdfNetworkStream = pdfNetworkStream;
  8278. this.url = args.url;
  8279. this.disableAutoFetch = args.disableAutoFetch;
  8280. this.msgHandler = args.msgHandler;
  8281. this.currRequestId = 0;
  8282. this.chunksNeededByRequest = Object.create(null);
  8283. this.requestsByChunk = Object.create(null);
  8284. this.promisesByRequest = Object.create(null);
  8285. this.progressiveDataLength = 0;
  8286. this.aborted = false;
  8287. this._loadedStreamCapability = createPromiseCapability();
  8288. }
  8289. ChunkedStreamManager.prototype = {
  8290. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8291. return this._loadedStreamCapability.promise;
  8292. },
  8293. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8294. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8295. if (!rangeReader.isStreamingSupported) {
  8296. rangeReader.onProgress = this.onProgress.bind(this);
  8297. }
  8298. var chunks = [], loaded = 0;
  8299. var manager = this;
  8300. var promise = new Promise(function (resolve, reject) {
  8301. var readChunk = function (chunk) {
  8302. try {
  8303. if (!chunk.done) {
  8304. var data = chunk.value;
  8305. chunks.push(data);
  8306. loaded += arrayByteLength(data);
  8307. if (rangeReader.isStreamingSupported) {
  8308. manager.onProgress({ loaded: loaded });
  8309. }
  8310. rangeReader.read().then(readChunk, reject);
  8311. return;
  8312. }
  8313. var chunkData = arraysToBytes(chunks);
  8314. chunks = null;
  8315. resolve(chunkData);
  8316. } catch (e) {
  8317. reject(e);
  8318. }
  8319. };
  8320. rangeReader.read().then(readChunk, reject);
  8321. });
  8322. promise.then(function (data) {
  8323. if (this.aborted) {
  8324. return;
  8325. }
  8326. this.onReceiveData({
  8327. chunk: data,
  8328. begin: begin
  8329. });
  8330. }.bind(this));
  8331. },
  8332. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8333. var missingChunks = this.stream.getMissingChunks();
  8334. this._requestChunks(missingChunks);
  8335. return this._loadedStreamCapability.promise;
  8336. },
  8337. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8338. var requestId = this.currRequestId++;
  8339. var i, ii;
  8340. var chunksNeeded = Object.create(null);
  8341. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8342. for (i = 0, ii = chunks.length; i < ii; i++) {
  8343. if (!this.stream.hasChunk(chunks[i])) {
  8344. chunksNeeded[chunks[i]] = true;
  8345. }
  8346. }
  8347. if (isEmptyObj(chunksNeeded)) {
  8348. return Promise.resolve();
  8349. }
  8350. var capability = createPromiseCapability();
  8351. this.promisesByRequest[requestId] = capability;
  8352. var chunksToRequest = [];
  8353. for (var chunk in chunksNeeded) {
  8354. chunk = chunk | 0;
  8355. if (!(chunk in this.requestsByChunk)) {
  8356. this.requestsByChunk[chunk] = [];
  8357. chunksToRequest.push(chunk);
  8358. }
  8359. this.requestsByChunk[chunk].push(requestId);
  8360. }
  8361. if (!chunksToRequest.length) {
  8362. return capability.promise;
  8363. }
  8364. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8365. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8366. var groupedChunk = groupedChunksToRequest[i];
  8367. var begin = groupedChunk.beginChunk * this.chunkSize;
  8368. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8369. this.sendRequest(begin, end);
  8370. }
  8371. return capability.promise;
  8372. },
  8373. getStream: function ChunkedStreamManager_getStream() {
  8374. return this.stream;
  8375. },
  8376. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8377. end = Math.min(end, this.length);
  8378. var beginChunk = this.getBeginChunk(begin);
  8379. var endChunk = this.getEndChunk(end);
  8380. var chunks = [];
  8381. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8382. chunks.push(chunk);
  8383. }
  8384. return this._requestChunks(chunks);
  8385. },
  8386. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8387. ranges = ranges || [];
  8388. var chunksToRequest = [];
  8389. for (var i = 0; i < ranges.length; i++) {
  8390. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8391. var endChunk = this.getEndChunk(ranges[i].end);
  8392. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8393. if (chunksToRequest.indexOf(chunk) < 0) {
  8394. chunksToRequest.push(chunk);
  8395. }
  8396. }
  8397. }
  8398. chunksToRequest.sort(function (a, b) {
  8399. return a - b;
  8400. });
  8401. return this._requestChunks(chunksToRequest);
  8402. },
  8403. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8404. var groupedChunks = [];
  8405. var beginChunk = -1;
  8406. var prevChunk = -1;
  8407. for (var i = 0; i < chunks.length; ++i) {
  8408. var chunk = chunks[i];
  8409. if (beginChunk < 0) {
  8410. beginChunk = chunk;
  8411. }
  8412. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8413. groupedChunks.push({
  8414. beginChunk: beginChunk,
  8415. endChunk: prevChunk + 1
  8416. });
  8417. beginChunk = chunk;
  8418. }
  8419. if (i + 1 === chunks.length) {
  8420. groupedChunks.push({
  8421. beginChunk: beginChunk,
  8422. endChunk: chunk + 1
  8423. });
  8424. }
  8425. prevChunk = chunk;
  8426. }
  8427. return groupedChunks;
  8428. },
  8429. onProgress: function ChunkedStreamManager_onProgress(args) {
  8430. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8431. this.msgHandler.send('DocProgress', {
  8432. loaded: bytesLoaded,
  8433. total: this.length
  8434. });
  8435. },
  8436. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8437. var chunk = args.chunk;
  8438. var isProgressive = args.begin === undefined;
  8439. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8440. var end = begin + chunk.byteLength;
  8441. var beginChunk = Math.floor(begin / this.chunkSize);
  8442. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8443. if (isProgressive) {
  8444. this.stream.onReceiveProgressiveData(chunk);
  8445. this.progressiveDataLength = end;
  8446. } else {
  8447. this.stream.onReceiveData(begin, chunk);
  8448. }
  8449. if (this.stream.allChunksLoaded()) {
  8450. this._loadedStreamCapability.resolve(this.stream);
  8451. }
  8452. var loadedRequests = [];
  8453. var i, requestId;
  8454. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8455. var requestIds = this.requestsByChunk[chunk] || [];
  8456. delete this.requestsByChunk[chunk];
  8457. for (i = 0; i < requestIds.length; ++i) {
  8458. requestId = requestIds[i];
  8459. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8460. if (chunk in chunksNeeded) {
  8461. delete chunksNeeded[chunk];
  8462. }
  8463. if (!isEmptyObj(chunksNeeded)) {
  8464. continue;
  8465. }
  8466. loadedRequests.push(requestId);
  8467. }
  8468. }
  8469. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8470. var nextEmptyChunk;
  8471. if (this.stream.numChunksLoaded === 1) {
  8472. var lastChunk = this.stream.numChunks - 1;
  8473. if (!this.stream.hasChunk(lastChunk)) {
  8474. nextEmptyChunk = lastChunk;
  8475. }
  8476. } else {
  8477. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8478. }
  8479. if (isInt(nextEmptyChunk)) {
  8480. this._requestChunks([nextEmptyChunk]);
  8481. }
  8482. }
  8483. for (i = 0; i < loadedRequests.length; ++i) {
  8484. requestId = loadedRequests[i];
  8485. var capability = this.promisesByRequest[requestId];
  8486. delete this.promisesByRequest[requestId];
  8487. capability.resolve();
  8488. }
  8489. this.msgHandler.send('DocProgress', {
  8490. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8491. total: this.length
  8492. });
  8493. },
  8494. onError: function ChunkedStreamManager_onError(err) {
  8495. this._loadedStreamCapability.reject(err);
  8496. },
  8497. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8498. var chunk = Math.floor(begin / this.chunkSize);
  8499. return chunk;
  8500. },
  8501. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8502. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8503. return chunk;
  8504. },
  8505. abort: function ChunkedStreamManager_abort() {
  8506. this.aborted = true;
  8507. if (this.pdfNetworkStream) {
  8508. this.pdfNetworkStream.cancelAllRequests('abort');
  8509. }
  8510. for (var requestId in this.promisesByRequest) {
  8511. var capability = this.promisesByRequest[requestId];
  8512. capability.reject(new Error('Request was aborted'));
  8513. }
  8514. }
  8515. };
  8516. return ChunkedStreamManager;
  8517. }();
  8518. exports.ChunkedStream = ChunkedStream;
  8519. exports.ChunkedStreamManager = ChunkedStreamManager;
  8520. }));
  8521. (function (root, factory) {
  8522. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8523. }(this, function (exports, sharedUtil) {
  8524. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8525. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8526. t['A'] = 0x0041;
  8527. t['AE'] = 0x00C6;
  8528. t['AEacute'] = 0x01FC;
  8529. t['AEmacron'] = 0x01E2;
  8530. t['AEsmall'] = 0xF7E6;
  8531. t['Aacute'] = 0x00C1;
  8532. t['Aacutesmall'] = 0xF7E1;
  8533. t['Abreve'] = 0x0102;
  8534. t['Abreveacute'] = 0x1EAE;
  8535. t['Abrevecyrillic'] = 0x04D0;
  8536. t['Abrevedotbelow'] = 0x1EB6;
  8537. t['Abrevegrave'] = 0x1EB0;
  8538. t['Abrevehookabove'] = 0x1EB2;
  8539. t['Abrevetilde'] = 0x1EB4;
  8540. t['Acaron'] = 0x01CD;
  8541. t['Acircle'] = 0x24B6;
  8542. t['Acircumflex'] = 0x00C2;
  8543. t['Acircumflexacute'] = 0x1EA4;
  8544. t['Acircumflexdotbelow'] = 0x1EAC;
  8545. t['Acircumflexgrave'] = 0x1EA6;
  8546. t['Acircumflexhookabove'] = 0x1EA8;
  8547. t['Acircumflexsmall'] = 0xF7E2;
  8548. t['Acircumflextilde'] = 0x1EAA;
  8549. t['Acute'] = 0xF6C9;
  8550. t['Acutesmall'] = 0xF7B4;
  8551. t['Acyrillic'] = 0x0410;
  8552. t['Adblgrave'] = 0x0200;
  8553. t['Adieresis'] = 0x00C4;
  8554. t['Adieresiscyrillic'] = 0x04D2;
  8555. t['Adieresismacron'] = 0x01DE;
  8556. t['Adieresissmall'] = 0xF7E4;
  8557. t['Adotbelow'] = 0x1EA0;
  8558. t['Adotmacron'] = 0x01E0;
  8559. t['Agrave'] = 0x00C0;
  8560. t['Agravesmall'] = 0xF7E0;
  8561. t['Ahookabove'] = 0x1EA2;
  8562. t['Aiecyrillic'] = 0x04D4;
  8563. t['Ainvertedbreve'] = 0x0202;
  8564. t['Alpha'] = 0x0391;
  8565. t['Alphatonos'] = 0x0386;
  8566. t['Amacron'] = 0x0100;
  8567. t['Amonospace'] = 0xFF21;
  8568. t['Aogonek'] = 0x0104;
  8569. t['Aring'] = 0x00C5;
  8570. t['Aringacute'] = 0x01FA;
  8571. t['Aringbelow'] = 0x1E00;
  8572. t['Aringsmall'] = 0xF7E5;
  8573. t['Asmall'] = 0xF761;
  8574. t['Atilde'] = 0x00C3;
  8575. t['Atildesmall'] = 0xF7E3;
  8576. t['Aybarmenian'] = 0x0531;
  8577. t['B'] = 0x0042;
  8578. t['Bcircle'] = 0x24B7;
  8579. t['Bdotaccent'] = 0x1E02;
  8580. t['Bdotbelow'] = 0x1E04;
  8581. t['Becyrillic'] = 0x0411;
  8582. t['Benarmenian'] = 0x0532;
  8583. t['Beta'] = 0x0392;
  8584. t['Bhook'] = 0x0181;
  8585. t['Blinebelow'] = 0x1E06;
  8586. t['Bmonospace'] = 0xFF22;
  8587. t['Brevesmall'] = 0xF6F4;
  8588. t['Bsmall'] = 0xF762;
  8589. t['Btopbar'] = 0x0182;
  8590. t['C'] = 0x0043;
  8591. t['Caarmenian'] = 0x053E;
  8592. t['Cacute'] = 0x0106;
  8593. t['Caron'] = 0xF6CA;
  8594. t['Caronsmall'] = 0xF6F5;
  8595. t['Ccaron'] = 0x010C;
  8596. t['Ccedilla'] = 0x00C7;
  8597. t['Ccedillaacute'] = 0x1E08;
  8598. t['Ccedillasmall'] = 0xF7E7;
  8599. t['Ccircle'] = 0x24B8;
  8600. t['Ccircumflex'] = 0x0108;
  8601. t['Cdot'] = 0x010A;
  8602. t['Cdotaccent'] = 0x010A;
  8603. t['Cedillasmall'] = 0xF7B8;
  8604. t['Chaarmenian'] = 0x0549;
  8605. t['Cheabkhasiancyrillic'] = 0x04BC;
  8606. t['Checyrillic'] = 0x0427;
  8607. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8608. t['Chedescendercyrillic'] = 0x04B6;
  8609. t['Chedieresiscyrillic'] = 0x04F4;
  8610. t['Cheharmenian'] = 0x0543;
  8611. t['Chekhakassiancyrillic'] = 0x04CB;
  8612. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8613. t['Chi'] = 0x03A7;
  8614. t['Chook'] = 0x0187;
  8615. t['Circumflexsmall'] = 0xF6F6;
  8616. t['Cmonospace'] = 0xFF23;
  8617. t['Coarmenian'] = 0x0551;
  8618. t['Csmall'] = 0xF763;
  8619. t['D'] = 0x0044;
  8620. t['DZ'] = 0x01F1;
  8621. t['DZcaron'] = 0x01C4;
  8622. t['Daarmenian'] = 0x0534;
  8623. t['Dafrican'] = 0x0189;
  8624. t['Dcaron'] = 0x010E;
  8625. t['Dcedilla'] = 0x1E10;
  8626. t['Dcircle'] = 0x24B9;
  8627. t['Dcircumflexbelow'] = 0x1E12;
  8628. t['Dcroat'] = 0x0110;
  8629. t['Ddotaccent'] = 0x1E0A;
  8630. t['Ddotbelow'] = 0x1E0C;
  8631. t['Decyrillic'] = 0x0414;
  8632. t['Deicoptic'] = 0x03EE;
  8633. t['Delta'] = 0x2206;
  8634. t['Deltagreek'] = 0x0394;
  8635. t['Dhook'] = 0x018A;
  8636. t['Dieresis'] = 0xF6CB;
  8637. t['DieresisAcute'] = 0xF6CC;
  8638. t['DieresisGrave'] = 0xF6CD;
  8639. t['Dieresissmall'] = 0xF7A8;
  8640. t['Digammagreek'] = 0x03DC;
  8641. t['Djecyrillic'] = 0x0402;
  8642. t['Dlinebelow'] = 0x1E0E;
  8643. t['Dmonospace'] = 0xFF24;
  8644. t['Dotaccentsmall'] = 0xF6F7;
  8645. t['Dslash'] = 0x0110;
  8646. t['Dsmall'] = 0xF764;
  8647. t['Dtopbar'] = 0x018B;
  8648. t['Dz'] = 0x01F2;
  8649. t['Dzcaron'] = 0x01C5;
  8650. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8651. t['Dzecyrillic'] = 0x0405;
  8652. t['Dzhecyrillic'] = 0x040F;
  8653. t['E'] = 0x0045;
  8654. t['Eacute'] = 0x00C9;
  8655. t['Eacutesmall'] = 0xF7E9;
  8656. t['Ebreve'] = 0x0114;
  8657. t['Ecaron'] = 0x011A;
  8658. t['Ecedillabreve'] = 0x1E1C;
  8659. t['Echarmenian'] = 0x0535;
  8660. t['Ecircle'] = 0x24BA;
  8661. t['Ecircumflex'] = 0x00CA;
  8662. t['Ecircumflexacute'] = 0x1EBE;
  8663. t['Ecircumflexbelow'] = 0x1E18;
  8664. t['Ecircumflexdotbelow'] = 0x1EC6;
  8665. t['Ecircumflexgrave'] = 0x1EC0;
  8666. t['Ecircumflexhookabove'] = 0x1EC2;
  8667. t['Ecircumflexsmall'] = 0xF7EA;
  8668. t['Ecircumflextilde'] = 0x1EC4;
  8669. t['Ecyrillic'] = 0x0404;
  8670. t['Edblgrave'] = 0x0204;
  8671. t['Edieresis'] = 0x00CB;
  8672. t['Edieresissmall'] = 0xF7EB;
  8673. t['Edot'] = 0x0116;
  8674. t['Edotaccent'] = 0x0116;
  8675. t['Edotbelow'] = 0x1EB8;
  8676. t['Efcyrillic'] = 0x0424;
  8677. t['Egrave'] = 0x00C8;
  8678. t['Egravesmall'] = 0xF7E8;
  8679. t['Eharmenian'] = 0x0537;
  8680. t['Ehookabove'] = 0x1EBA;
  8681. t['Eightroman'] = 0x2167;
  8682. t['Einvertedbreve'] = 0x0206;
  8683. t['Eiotifiedcyrillic'] = 0x0464;
  8684. t['Elcyrillic'] = 0x041B;
  8685. t['Elevenroman'] = 0x216A;
  8686. t['Emacron'] = 0x0112;
  8687. t['Emacronacute'] = 0x1E16;
  8688. t['Emacrongrave'] = 0x1E14;
  8689. t['Emcyrillic'] = 0x041C;
  8690. t['Emonospace'] = 0xFF25;
  8691. t['Encyrillic'] = 0x041D;
  8692. t['Endescendercyrillic'] = 0x04A2;
  8693. t['Eng'] = 0x014A;
  8694. t['Enghecyrillic'] = 0x04A4;
  8695. t['Enhookcyrillic'] = 0x04C7;
  8696. t['Eogonek'] = 0x0118;
  8697. t['Eopen'] = 0x0190;
  8698. t['Epsilon'] = 0x0395;
  8699. t['Epsilontonos'] = 0x0388;
  8700. t['Ercyrillic'] = 0x0420;
  8701. t['Ereversed'] = 0x018E;
  8702. t['Ereversedcyrillic'] = 0x042D;
  8703. t['Escyrillic'] = 0x0421;
  8704. t['Esdescendercyrillic'] = 0x04AA;
  8705. t['Esh'] = 0x01A9;
  8706. t['Esmall'] = 0xF765;
  8707. t['Eta'] = 0x0397;
  8708. t['Etarmenian'] = 0x0538;
  8709. t['Etatonos'] = 0x0389;
  8710. t['Eth'] = 0x00D0;
  8711. t['Ethsmall'] = 0xF7F0;
  8712. t['Etilde'] = 0x1EBC;
  8713. t['Etildebelow'] = 0x1E1A;
  8714. t['Euro'] = 0x20AC;
  8715. t['Ezh'] = 0x01B7;
  8716. t['Ezhcaron'] = 0x01EE;
  8717. t['Ezhreversed'] = 0x01B8;
  8718. t['F'] = 0x0046;
  8719. t['Fcircle'] = 0x24BB;
  8720. t['Fdotaccent'] = 0x1E1E;
  8721. t['Feharmenian'] = 0x0556;
  8722. t['Feicoptic'] = 0x03E4;
  8723. t['Fhook'] = 0x0191;
  8724. t['Fitacyrillic'] = 0x0472;
  8725. t['Fiveroman'] = 0x2164;
  8726. t['Fmonospace'] = 0xFF26;
  8727. t['Fourroman'] = 0x2163;
  8728. t['Fsmall'] = 0xF766;
  8729. t['G'] = 0x0047;
  8730. t['GBsquare'] = 0x3387;
  8731. t['Gacute'] = 0x01F4;
  8732. t['Gamma'] = 0x0393;
  8733. t['Gammaafrican'] = 0x0194;
  8734. t['Gangiacoptic'] = 0x03EA;
  8735. t['Gbreve'] = 0x011E;
  8736. t['Gcaron'] = 0x01E6;
  8737. t['Gcedilla'] = 0x0122;
  8738. t['Gcircle'] = 0x24BC;
  8739. t['Gcircumflex'] = 0x011C;
  8740. t['Gcommaaccent'] = 0x0122;
  8741. t['Gdot'] = 0x0120;
  8742. t['Gdotaccent'] = 0x0120;
  8743. t['Gecyrillic'] = 0x0413;
  8744. t['Ghadarmenian'] = 0x0542;
  8745. t['Ghemiddlehookcyrillic'] = 0x0494;
  8746. t['Ghestrokecyrillic'] = 0x0492;
  8747. t['Gheupturncyrillic'] = 0x0490;
  8748. t['Ghook'] = 0x0193;
  8749. t['Gimarmenian'] = 0x0533;
  8750. t['Gjecyrillic'] = 0x0403;
  8751. t['Gmacron'] = 0x1E20;
  8752. t['Gmonospace'] = 0xFF27;
  8753. t['Grave'] = 0xF6CE;
  8754. t['Gravesmall'] = 0xF760;
  8755. t['Gsmall'] = 0xF767;
  8756. t['Gsmallhook'] = 0x029B;
  8757. t['Gstroke'] = 0x01E4;
  8758. t['H'] = 0x0048;
  8759. t['H18533'] = 0x25CF;
  8760. t['H18543'] = 0x25AA;
  8761. t['H18551'] = 0x25AB;
  8762. t['H22073'] = 0x25A1;
  8763. t['HPsquare'] = 0x33CB;
  8764. t['Haabkhasiancyrillic'] = 0x04A8;
  8765. t['Hadescendercyrillic'] = 0x04B2;
  8766. t['Hardsigncyrillic'] = 0x042A;
  8767. t['Hbar'] = 0x0126;
  8768. t['Hbrevebelow'] = 0x1E2A;
  8769. t['Hcedilla'] = 0x1E28;
  8770. t['Hcircle'] = 0x24BD;
  8771. t['Hcircumflex'] = 0x0124;
  8772. t['Hdieresis'] = 0x1E26;
  8773. t['Hdotaccent'] = 0x1E22;
  8774. t['Hdotbelow'] = 0x1E24;
  8775. t['Hmonospace'] = 0xFF28;
  8776. t['Hoarmenian'] = 0x0540;
  8777. t['Horicoptic'] = 0x03E8;
  8778. t['Hsmall'] = 0xF768;
  8779. t['Hungarumlaut'] = 0xF6CF;
  8780. t['Hungarumlautsmall'] = 0xF6F8;
  8781. t['Hzsquare'] = 0x3390;
  8782. t['I'] = 0x0049;
  8783. t['IAcyrillic'] = 0x042F;
  8784. t['IJ'] = 0x0132;
  8785. t['IUcyrillic'] = 0x042E;
  8786. t['Iacute'] = 0x00CD;
  8787. t['Iacutesmall'] = 0xF7ED;
  8788. t['Ibreve'] = 0x012C;
  8789. t['Icaron'] = 0x01CF;
  8790. t['Icircle'] = 0x24BE;
  8791. t['Icircumflex'] = 0x00CE;
  8792. t['Icircumflexsmall'] = 0xF7EE;
  8793. t['Icyrillic'] = 0x0406;
  8794. t['Idblgrave'] = 0x0208;
  8795. t['Idieresis'] = 0x00CF;
  8796. t['Idieresisacute'] = 0x1E2E;
  8797. t['Idieresiscyrillic'] = 0x04E4;
  8798. t['Idieresissmall'] = 0xF7EF;
  8799. t['Idot'] = 0x0130;
  8800. t['Idotaccent'] = 0x0130;
  8801. t['Idotbelow'] = 0x1ECA;
  8802. t['Iebrevecyrillic'] = 0x04D6;
  8803. t['Iecyrillic'] = 0x0415;
  8804. t['Ifraktur'] = 0x2111;
  8805. t['Igrave'] = 0x00CC;
  8806. t['Igravesmall'] = 0xF7EC;
  8807. t['Ihookabove'] = 0x1EC8;
  8808. t['Iicyrillic'] = 0x0418;
  8809. t['Iinvertedbreve'] = 0x020A;
  8810. t['Iishortcyrillic'] = 0x0419;
  8811. t['Imacron'] = 0x012A;
  8812. t['Imacroncyrillic'] = 0x04E2;
  8813. t['Imonospace'] = 0xFF29;
  8814. t['Iniarmenian'] = 0x053B;
  8815. t['Iocyrillic'] = 0x0401;
  8816. t['Iogonek'] = 0x012E;
  8817. t['Iota'] = 0x0399;
  8818. t['Iotaafrican'] = 0x0196;
  8819. t['Iotadieresis'] = 0x03AA;
  8820. t['Iotatonos'] = 0x038A;
  8821. t['Ismall'] = 0xF769;
  8822. t['Istroke'] = 0x0197;
  8823. t['Itilde'] = 0x0128;
  8824. t['Itildebelow'] = 0x1E2C;
  8825. t['Izhitsacyrillic'] = 0x0474;
  8826. t['Izhitsadblgravecyrillic'] = 0x0476;
  8827. t['J'] = 0x004A;
  8828. t['Jaarmenian'] = 0x0541;
  8829. t['Jcircle'] = 0x24BF;
  8830. t['Jcircumflex'] = 0x0134;
  8831. t['Jecyrillic'] = 0x0408;
  8832. t['Jheharmenian'] = 0x054B;
  8833. t['Jmonospace'] = 0xFF2A;
  8834. t['Jsmall'] = 0xF76A;
  8835. t['K'] = 0x004B;
  8836. t['KBsquare'] = 0x3385;
  8837. t['KKsquare'] = 0x33CD;
  8838. t['Kabashkircyrillic'] = 0x04A0;
  8839. t['Kacute'] = 0x1E30;
  8840. t['Kacyrillic'] = 0x041A;
  8841. t['Kadescendercyrillic'] = 0x049A;
  8842. t['Kahookcyrillic'] = 0x04C3;
  8843. t['Kappa'] = 0x039A;
  8844. t['Kastrokecyrillic'] = 0x049E;
  8845. t['Kaverticalstrokecyrillic'] = 0x049C;
  8846. t['Kcaron'] = 0x01E8;
  8847. t['Kcedilla'] = 0x0136;
  8848. t['Kcircle'] = 0x24C0;
  8849. t['Kcommaaccent'] = 0x0136;
  8850. t['Kdotbelow'] = 0x1E32;
  8851. t['Keharmenian'] = 0x0554;
  8852. t['Kenarmenian'] = 0x053F;
  8853. t['Khacyrillic'] = 0x0425;
  8854. t['Kheicoptic'] = 0x03E6;
  8855. t['Khook'] = 0x0198;
  8856. t['Kjecyrillic'] = 0x040C;
  8857. t['Klinebelow'] = 0x1E34;
  8858. t['Kmonospace'] = 0xFF2B;
  8859. t['Koppacyrillic'] = 0x0480;
  8860. t['Koppagreek'] = 0x03DE;
  8861. t['Ksicyrillic'] = 0x046E;
  8862. t['Ksmall'] = 0xF76B;
  8863. t['L'] = 0x004C;
  8864. t['LJ'] = 0x01C7;
  8865. t['LL'] = 0xF6BF;
  8866. t['Lacute'] = 0x0139;
  8867. t['Lambda'] = 0x039B;
  8868. t['Lcaron'] = 0x013D;
  8869. t['Lcedilla'] = 0x013B;
  8870. t['Lcircle'] = 0x24C1;
  8871. t['Lcircumflexbelow'] = 0x1E3C;
  8872. t['Lcommaaccent'] = 0x013B;
  8873. t['Ldot'] = 0x013F;
  8874. t['Ldotaccent'] = 0x013F;
  8875. t['Ldotbelow'] = 0x1E36;
  8876. t['Ldotbelowmacron'] = 0x1E38;
  8877. t['Liwnarmenian'] = 0x053C;
  8878. t['Lj'] = 0x01C8;
  8879. t['Ljecyrillic'] = 0x0409;
  8880. t['Llinebelow'] = 0x1E3A;
  8881. t['Lmonospace'] = 0xFF2C;
  8882. t['Lslash'] = 0x0141;
  8883. t['Lslashsmall'] = 0xF6F9;
  8884. t['Lsmall'] = 0xF76C;
  8885. t['M'] = 0x004D;
  8886. t['MBsquare'] = 0x3386;
  8887. t['Macron'] = 0xF6D0;
  8888. t['Macronsmall'] = 0xF7AF;
  8889. t['Macute'] = 0x1E3E;
  8890. t['Mcircle'] = 0x24C2;
  8891. t['Mdotaccent'] = 0x1E40;
  8892. t['Mdotbelow'] = 0x1E42;
  8893. t['Menarmenian'] = 0x0544;
  8894. t['Mmonospace'] = 0xFF2D;
  8895. t['Msmall'] = 0xF76D;
  8896. t['Mturned'] = 0x019C;
  8897. t['Mu'] = 0x039C;
  8898. t['N'] = 0x004E;
  8899. t['NJ'] = 0x01CA;
  8900. t['Nacute'] = 0x0143;
  8901. t['Ncaron'] = 0x0147;
  8902. t['Ncedilla'] = 0x0145;
  8903. t['Ncircle'] = 0x24C3;
  8904. t['Ncircumflexbelow'] = 0x1E4A;
  8905. t['Ncommaaccent'] = 0x0145;
  8906. t['Ndotaccent'] = 0x1E44;
  8907. t['Ndotbelow'] = 0x1E46;
  8908. t['Nhookleft'] = 0x019D;
  8909. t['Nineroman'] = 0x2168;
  8910. t['Nj'] = 0x01CB;
  8911. t['Njecyrillic'] = 0x040A;
  8912. t['Nlinebelow'] = 0x1E48;
  8913. t['Nmonospace'] = 0xFF2E;
  8914. t['Nowarmenian'] = 0x0546;
  8915. t['Nsmall'] = 0xF76E;
  8916. t['Ntilde'] = 0x00D1;
  8917. t['Ntildesmall'] = 0xF7F1;
  8918. t['Nu'] = 0x039D;
  8919. t['O'] = 0x004F;
  8920. t['OE'] = 0x0152;
  8921. t['OEsmall'] = 0xF6FA;
  8922. t['Oacute'] = 0x00D3;
  8923. t['Oacutesmall'] = 0xF7F3;
  8924. t['Obarredcyrillic'] = 0x04E8;
  8925. t['Obarreddieresiscyrillic'] = 0x04EA;
  8926. t['Obreve'] = 0x014E;
  8927. t['Ocaron'] = 0x01D1;
  8928. t['Ocenteredtilde'] = 0x019F;
  8929. t['Ocircle'] = 0x24C4;
  8930. t['Ocircumflex'] = 0x00D4;
  8931. t['Ocircumflexacute'] = 0x1ED0;
  8932. t['Ocircumflexdotbelow'] = 0x1ED8;
  8933. t['Ocircumflexgrave'] = 0x1ED2;
  8934. t['Ocircumflexhookabove'] = 0x1ED4;
  8935. t['Ocircumflexsmall'] = 0xF7F4;
  8936. t['Ocircumflextilde'] = 0x1ED6;
  8937. t['Ocyrillic'] = 0x041E;
  8938. t['Odblacute'] = 0x0150;
  8939. t['Odblgrave'] = 0x020C;
  8940. t['Odieresis'] = 0x00D6;
  8941. t['Odieresiscyrillic'] = 0x04E6;
  8942. t['Odieresissmall'] = 0xF7F6;
  8943. t['Odotbelow'] = 0x1ECC;
  8944. t['Ogoneksmall'] = 0xF6FB;
  8945. t['Ograve'] = 0x00D2;
  8946. t['Ogravesmall'] = 0xF7F2;
  8947. t['Oharmenian'] = 0x0555;
  8948. t['Ohm'] = 0x2126;
  8949. t['Ohookabove'] = 0x1ECE;
  8950. t['Ohorn'] = 0x01A0;
  8951. t['Ohornacute'] = 0x1EDA;
  8952. t['Ohorndotbelow'] = 0x1EE2;
  8953. t['Ohorngrave'] = 0x1EDC;
  8954. t['Ohornhookabove'] = 0x1EDE;
  8955. t['Ohorntilde'] = 0x1EE0;
  8956. t['Ohungarumlaut'] = 0x0150;
  8957. t['Oi'] = 0x01A2;
  8958. t['Oinvertedbreve'] = 0x020E;
  8959. t['Omacron'] = 0x014C;
  8960. t['Omacronacute'] = 0x1E52;
  8961. t['Omacrongrave'] = 0x1E50;
  8962. t['Omega'] = 0x2126;
  8963. t['Omegacyrillic'] = 0x0460;
  8964. t['Omegagreek'] = 0x03A9;
  8965. t['Omegaroundcyrillic'] = 0x047A;
  8966. t['Omegatitlocyrillic'] = 0x047C;
  8967. t['Omegatonos'] = 0x038F;
  8968. t['Omicron'] = 0x039F;
  8969. t['Omicrontonos'] = 0x038C;
  8970. t['Omonospace'] = 0xFF2F;
  8971. t['Oneroman'] = 0x2160;
  8972. t['Oogonek'] = 0x01EA;
  8973. t['Oogonekmacron'] = 0x01EC;
  8974. t['Oopen'] = 0x0186;
  8975. t['Oslash'] = 0x00D8;
  8976. t['Oslashacute'] = 0x01FE;
  8977. t['Oslashsmall'] = 0xF7F8;
  8978. t['Osmall'] = 0xF76F;
  8979. t['Ostrokeacute'] = 0x01FE;
  8980. t['Otcyrillic'] = 0x047E;
  8981. t['Otilde'] = 0x00D5;
  8982. t['Otildeacute'] = 0x1E4C;
  8983. t['Otildedieresis'] = 0x1E4E;
  8984. t['Otildesmall'] = 0xF7F5;
  8985. t['P'] = 0x0050;
  8986. t['Pacute'] = 0x1E54;
  8987. t['Pcircle'] = 0x24C5;
  8988. t['Pdotaccent'] = 0x1E56;
  8989. t['Pecyrillic'] = 0x041F;
  8990. t['Peharmenian'] = 0x054A;
  8991. t['Pemiddlehookcyrillic'] = 0x04A6;
  8992. t['Phi'] = 0x03A6;
  8993. t['Phook'] = 0x01A4;
  8994. t['Pi'] = 0x03A0;
  8995. t['Piwrarmenian'] = 0x0553;
  8996. t['Pmonospace'] = 0xFF30;
  8997. t['Psi'] = 0x03A8;
  8998. t['Psicyrillic'] = 0x0470;
  8999. t['Psmall'] = 0xF770;
  9000. t['Q'] = 0x0051;
  9001. t['Qcircle'] = 0x24C6;
  9002. t['Qmonospace'] = 0xFF31;
  9003. t['Qsmall'] = 0xF771;
  9004. t['R'] = 0x0052;
  9005. t['Raarmenian'] = 0x054C;
  9006. t['Racute'] = 0x0154;
  9007. t['Rcaron'] = 0x0158;
  9008. t['Rcedilla'] = 0x0156;
  9009. t['Rcircle'] = 0x24C7;
  9010. t['Rcommaaccent'] = 0x0156;
  9011. t['Rdblgrave'] = 0x0210;
  9012. t['Rdotaccent'] = 0x1E58;
  9013. t['Rdotbelow'] = 0x1E5A;
  9014. t['Rdotbelowmacron'] = 0x1E5C;
  9015. t['Reharmenian'] = 0x0550;
  9016. t['Rfraktur'] = 0x211C;
  9017. t['Rho'] = 0x03A1;
  9018. t['Ringsmall'] = 0xF6FC;
  9019. t['Rinvertedbreve'] = 0x0212;
  9020. t['Rlinebelow'] = 0x1E5E;
  9021. t['Rmonospace'] = 0xFF32;
  9022. t['Rsmall'] = 0xF772;
  9023. t['Rsmallinverted'] = 0x0281;
  9024. t['Rsmallinvertedsuperior'] = 0x02B6;
  9025. t['S'] = 0x0053;
  9026. t['SF010000'] = 0x250C;
  9027. t['SF020000'] = 0x2514;
  9028. t['SF030000'] = 0x2510;
  9029. t['SF040000'] = 0x2518;
  9030. t['SF050000'] = 0x253C;
  9031. t['SF060000'] = 0x252C;
  9032. t['SF070000'] = 0x2534;
  9033. t['SF080000'] = 0x251C;
  9034. t['SF090000'] = 0x2524;
  9035. t['SF100000'] = 0x2500;
  9036. t['SF110000'] = 0x2502;
  9037. t['SF190000'] = 0x2561;
  9038. t['SF200000'] = 0x2562;
  9039. t['SF210000'] = 0x2556;
  9040. t['SF220000'] = 0x2555;
  9041. t['SF230000'] = 0x2563;
  9042. t['SF240000'] = 0x2551;
  9043. t['SF250000'] = 0x2557;
  9044. t['SF260000'] = 0x255D;
  9045. t['SF270000'] = 0x255C;
  9046. t['SF280000'] = 0x255B;
  9047. t['SF360000'] = 0x255E;
  9048. t['SF370000'] = 0x255F;
  9049. t['SF380000'] = 0x255A;
  9050. t['SF390000'] = 0x2554;
  9051. t['SF400000'] = 0x2569;
  9052. t['SF410000'] = 0x2566;
  9053. t['SF420000'] = 0x2560;
  9054. t['SF430000'] = 0x2550;
  9055. t['SF440000'] = 0x256C;
  9056. t['SF450000'] = 0x2567;
  9057. t['SF460000'] = 0x2568;
  9058. t['SF470000'] = 0x2564;
  9059. t['SF480000'] = 0x2565;
  9060. t['SF490000'] = 0x2559;
  9061. t['SF500000'] = 0x2558;
  9062. t['SF510000'] = 0x2552;
  9063. t['SF520000'] = 0x2553;
  9064. t['SF530000'] = 0x256B;
  9065. t['SF540000'] = 0x256A;
  9066. t['Sacute'] = 0x015A;
  9067. t['Sacutedotaccent'] = 0x1E64;
  9068. t['Sampigreek'] = 0x03E0;
  9069. t['Scaron'] = 0x0160;
  9070. t['Scarondotaccent'] = 0x1E66;
  9071. t['Scaronsmall'] = 0xF6FD;
  9072. t['Scedilla'] = 0x015E;
  9073. t['Schwa'] = 0x018F;
  9074. t['Schwacyrillic'] = 0x04D8;
  9075. t['Schwadieresiscyrillic'] = 0x04DA;
  9076. t['Scircle'] = 0x24C8;
  9077. t['Scircumflex'] = 0x015C;
  9078. t['Scommaaccent'] = 0x0218;
  9079. t['Sdotaccent'] = 0x1E60;
  9080. t['Sdotbelow'] = 0x1E62;
  9081. t['Sdotbelowdotaccent'] = 0x1E68;
  9082. t['Seharmenian'] = 0x054D;
  9083. t['Sevenroman'] = 0x2166;
  9084. t['Shaarmenian'] = 0x0547;
  9085. t['Shacyrillic'] = 0x0428;
  9086. t['Shchacyrillic'] = 0x0429;
  9087. t['Sheicoptic'] = 0x03E2;
  9088. t['Shhacyrillic'] = 0x04BA;
  9089. t['Shimacoptic'] = 0x03EC;
  9090. t['Sigma'] = 0x03A3;
  9091. t['Sixroman'] = 0x2165;
  9092. t['Smonospace'] = 0xFF33;
  9093. t['Softsigncyrillic'] = 0x042C;
  9094. t['Ssmall'] = 0xF773;
  9095. t['Stigmagreek'] = 0x03DA;
  9096. t['T'] = 0x0054;
  9097. t['Tau'] = 0x03A4;
  9098. t['Tbar'] = 0x0166;
  9099. t['Tcaron'] = 0x0164;
  9100. t['Tcedilla'] = 0x0162;
  9101. t['Tcircle'] = 0x24C9;
  9102. t['Tcircumflexbelow'] = 0x1E70;
  9103. t['Tcommaaccent'] = 0x0162;
  9104. t['Tdotaccent'] = 0x1E6A;
  9105. t['Tdotbelow'] = 0x1E6C;
  9106. t['Tecyrillic'] = 0x0422;
  9107. t['Tedescendercyrillic'] = 0x04AC;
  9108. t['Tenroman'] = 0x2169;
  9109. t['Tetsecyrillic'] = 0x04B4;
  9110. t['Theta'] = 0x0398;
  9111. t['Thook'] = 0x01AC;
  9112. t['Thorn'] = 0x00DE;
  9113. t['Thornsmall'] = 0xF7FE;
  9114. t['Threeroman'] = 0x2162;
  9115. t['Tildesmall'] = 0xF6FE;
  9116. t['Tiwnarmenian'] = 0x054F;
  9117. t['Tlinebelow'] = 0x1E6E;
  9118. t['Tmonospace'] = 0xFF34;
  9119. t['Toarmenian'] = 0x0539;
  9120. t['Tonefive'] = 0x01BC;
  9121. t['Tonesix'] = 0x0184;
  9122. t['Tonetwo'] = 0x01A7;
  9123. t['Tretroflexhook'] = 0x01AE;
  9124. t['Tsecyrillic'] = 0x0426;
  9125. t['Tshecyrillic'] = 0x040B;
  9126. t['Tsmall'] = 0xF774;
  9127. t['Twelveroman'] = 0x216B;
  9128. t['Tworoman'] = 0x2161;
  9129. t['U'] = 0x0055;
  9130. t['Uacute'] = 0x00DA;
  9131. t['Uacutesmall'] = 0xF7FA;
  9132. t['Ubreve'] = 0x016C;
  9133. t['Ucaron'] = 0x01D3;
  9134. t['Ucircle'] = 0x24CA;
  9135. t['Ucircumflex'] = 0x00DB;
  9136. t['Ucircumflexbelow'] = 0x1E76;
  9137. t['Ucircumflexsmall'] = 0xF7FB;
  9138. t['Ucyrillic'] = 0x0423;
  9139. t['Udblacute'] = 0x0170;
  9140. t['Udblgrave'] = 0x0214;
  9141. t['Udieresis'] = 0x00DC;
  9142. t['Udieresisacute'] = 0x01D7;
  9143. t['Udieresisbelow'] = 0x1E72;
  9144. t['Udieresiscaron'] = 0x01D9;
  9145. t['Udieresiscyrillic'] = 0x04F0;
  9146. t['Udieresisgrave'] = 0x01DB;
  9147. t['Udieresismacron'] = 0x01D5;
  9148. t['Udieresissmall'] = 0xF7FC;
  9149. t['Udotbelow'] = 0x1EE4;
  9150. t['Ugrave'] = 0x00D9;
  9151. t['Ugravesmall'] = 0xF7F9;
  9152. t['Uhookabove'] = 0x1EE6;
  9153. t['Uhorn'] = 0x01AF;
  9154. t['Uhornacute'] = 0x1EE8;
  9155. t['Uhorndotbelow'] = 0x1EF0;
  9156. t['Uhorngrave'] = 0x1EEA;
  9157. t['Uhornhookabove'] = 0x1EEC;
  9158. t['Uhorntilde'] = 0x1EEE;
  9159. t['Uhungarumlaut'] = 0x0170;
  9160. t['Uhungarumlautcyrillic'] = 0x04F2;
  9161. t['Uinvertedbreve'] = 0x0216;
  9162. t['Ukcyrillic'] = 0x0478;
  9163. t['Umacron'] = 0x016A;
  9164. t['Umacroncyrillic'] = 0x04EE;
  9165. t['Umacrondieresis'] = 0x1E7A;
  9166. t['Umonospace'] = 0xFF35;
  9167. t['Uogonek'] = 0x0172;
  9168. t['Upsilon'] = 0x03A5;
  9169. t['Upsilon1'] = 0x03D2;
  9170. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9171. t['Upsilonafrican'] = 0x01B1;
  9172. t['Upsilondieresis'] = 0x03AB;
  9173. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9174. t['Upsilonhooksymbol'] = 0x03D2;
  9175. t['Upsilontonos'] = 0x038E;
  9176. t['Uring'] = 0x016E;
  9177. t['Ushortcyrillic'] = 0x040E;
  9178. t['Usmall'] = 0xF775;
  9179. t['Ustraightcyrillic'] = 0x04AE;
  9180. t['Ustraightstrokecyrillic'] = 0x04B0;
  9181. t['Utilde'] = 0x0168;
  9182. t['Utildeacute'] = 0x1E78;
  9183. t['Utildebelow'] = 0x1E74;
  9184. t['V'] = 0x0056;
  9185. t['Vcircle'] = 0x24CB;
  9186. t['Vdotbelow'] = 0x1E7E;
  9187. t['Vecyrillic'] = 0x0412;
  9188. t['Vewarmenian'] = 0x054E;
  9189. t['Vhook'] = 0x01B2;
  9190. t['Vmonospace'] = 0xFF36;
  9191. t['Voarmenian'] = 0x0548;
  9192. t['Vsmall'] = 0xF776;
  9193. t['Vtilde'] = 0x1E7C;
  9194. t['W'] = 0x0057;
  9195. t['Wacute'] = 0x1E82;
  9196. t['Wcircle'] = 0x24CC;
  9197. t['Wcircumflex'] = 0x0174;
  9198. t['Wdieresis'] = 0x1E84;
  9199. t['Wdotaccent'] = 0x1E86;
  9200. t['Wdotbelow'] = 0x1E88;
  9201. t['Wgrave'] = 0x1E80;
  9202. t['Wmonospace'] = 0xFF37;
  9203. t['Wsmall'] = 0xF777;
  9204. t['X'] = 0x0058;
  9205. t['Xcircle'] = 0x24CD;
  9206. t['Xdieresis'] = 0x1E8C;
  9207. t['Xdotaccent'] = 0x1E8A;
  9208. t['Xeharmenian'] = 0x053D;
  9209. t['Xi'] = 0x039E;
  9210. t['Xmonospace'] = 0xFF38;
  9211. t['Xsmall'] = 0xF778;
  9212. t['Y'] = 0x0059;
  9213. t['Yacute'] = 0x00DD;
  9214. t['Yacutesmall'] = 0xF7FD;
  9215. t['Yatcyrillic'] = 0x0462;
  9216. t['Ycircle'] = 0x24CE;
  9217. t['Ycircumflex'] = 0x0176;
  9218. t['Ydieresis'] = 0x0178;
  9219. t['Ydieresissmall'] = 0xF7FF;
  9220. t['Ydotaccent'] = 0x1E8E;
  9221. t['Ydotbelow'] = 0x1EF4;
  9222. t['Yericyrillic'] = 0x042B;
  9223. t['Yerudieresiscyrillic'] = 0x04F8;
  9224. t['Ygrave'] = 0x1EF2;
  9225. t['Yhook'] = 0x01B3;
  9226. t['Yhookabove'] = 0x1EF6;
  9227. t['Yiarmenian'] = 0x0545;
  9228. t['Yicyrillic'] = 0x0407;
  9229. t['Yiwnarmenian'] = 0x0552;
  9230. t['Ymonospace'] = 0xFF39;
  9231. t['Ysmall'] = 0xF779;
  9232. t['Ytilde'] = 0x1EF8;
  9233. t['Yusbigcyrillic'] = 0x046A;
  9234. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9235. t['Yuslittlecyrillic'] = 0x0466;
  9236. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9237. t['Z'] = 0x005A;
  9238. t['Zaarmenian'] = 0x0536;
  9239. t['Zacute'] = 0x0179;
  9240. t['Zcaron'] = 0x017D;
  9241. t['Zcaronsmall'] = 0xF6FF;
  9242. t['Zcircle'] = 0x24CF;
  9243. t['Zcircumflex'] = 0x1E90;
  9244. t['Zdot'] = 0x017B;
  9245. t['Zdotaccent'] = 0x017B;
  9246. t['Zdotbelow'] = 0x1E92;
  9247. t['Zecyrillic'] = 0x0417;
  9248. t['Zedescendercyrillic'] = 0x0498;
  9249. t['Zedieresiscyrillic'] = 0x04DE;
  9250. t['Zeta'] = 0x0396;
  9251. t['Zhearmenian'] = 0x053A;
  9252. t['Zhebrevecyrillic'] = 0x04C1;
  9253. t['Zhecyrillic'] = 0x0416;
  9254. t['Zhedescendercyrillic'] = 0x0496;
  9255. t['Zhedieresiscyrillic'] = 0x04DC;
  9256. t['Zlinebelow'] = 0x1E94;
  9257. t['Zmonospace'] = 0xFF3A;
  9258. t['Zsmall'] = 0xF77A;
  9259. t['Zstroke'] = 0x01B5;
  9260. t['a'] = 0x0061;
  9261. t['aabengali'] = 0x0986;
  9262. t['aacute'] = 0x00E1;
  9263. t['aadeva'] = 0x0906;
  9264. t['aagujarati'] = 0x0A86;
  9265. t['aagurmukhi'] = 0x0A06;
  9266. t['aamatragurmukhi'] = 0x0A3E;
  9267. t['aarusquare'] = 0x3303;
  9268. t['aavowelsignbengali'] = 0x09BE;
  9269. t['aavowelsigndeva'] = 0x093E;
  9270. t['aavowelsigngujarati'] = 0x0ABE;
  9271. t['abbreviationmarkarmenian'] = 0x055F;
  9272. t['abbreviationsigndeva'] = 0x0970;
  9273. t['abengali'] = 0x0985;
  9274. t['abopomofo'] = 0x311A;
  9275. t['abreve'] = 0x0103;
  9276. t['abreveacute'] = 0x1EAF;
  9277. t['abrevecyrillic'] = 0x04D1;
  9278. t['abrevedotbelow'] = 0x1EB7;
  9279. t['abrevegrave'] = 0x1EB1;
  9280. t['abrevehookabove'] = 0x1EB3;
  9281. t['abrevetilde'] = 0x1EB5;
  9282. t['acaron'] = 0x01CE;
  9283. t['acircle'] = 0x24D0;
  9284. t['acircumflex'] = 0x00E2;
  9285. t['acircumflexacute'] = 0x1EA5;
  9286. t['acircumflexdotbelow'] = 0x1EAD;
  9287. t['acircumflexgrave'] = 0x1EA7;
  9288. t['acircumflexhookabove'] = 0x1EA9;
  9289. t['acircumflextilde'] = 0x1EAB;
  9290. t['acute'] = 0x00B4;
  9291. t['acutebelowcmb'] = 0x0317;
  9292. t['acutecmb'] = 0x0301;
  9293. t['acutecomb'] = 0x0301;
  9294. t['acutedeva'] = 0x0954;
  9295. t['acutelowmod'] = 0x02CF;
  9296. t['acutetonecmb'] = 0x0341;
  9297. t['acyrillic'] = 0x0430;
  9298. t['adblgrave'] = 0x0201;
  9299. t['addakgurmukhi'] = 0x0A71;
  9300. t['adeva'] = 0x0905;
  9301. t['adieresis'] = 0x00E4;
  9302. t['adieresiscyrillic'] = 0x04D3;
  9303. t['adieresismacron'] = 0x01DF;
  9304. t['adotbelow'] = 0x1EA1;
  9305. t['adotmacron'] = 0x01E1;
  9306. t['ae'] = 0x00E6;
  9307. t['aeacute'] = 0x01FD;
  9308. t['aekorean'] = 0x3150;
  9309. t['aemacron'] = 0x01E3;
  9310. t['afii00208'] = 0x2015;
  9311. t['afii08941'] = 0x20A4;
  9312. t['afii10017'] = 0x0410;
  9313. t['afii10018'] = 0x0411;
  9314. t['afii10019'] = 0x0412;
  9315. t['afii10020'] = 0x0413;
  9316. t['afii10021'] = 0x0414;
  9317. t['afii10022'] = 0x0415;
  9318. t['afii10023'] = 0x0401;
  9319. t['afii10024'] = 0x0416;
  9320. t['afii10025'] = 0x0417;
  9321. t['afii10026'] = 0x0418;
  9322. t['afii10027'] = 0x0419;
  9323. t['afii10028'] = 0x041A;
  9324. t['afii10029'] = 0x041B;
  9325. t['afii10030'] = 0x041C;
  9326. t['afii10031'] = 0x041D;
  9327. t['afii10032'] = 0x041E;
  9328. t['afii10033'] = 0x041F;
  9329. t['afii10034'] = 0x0420;
  9330. t['afii10035'] = 0x0421;
  9331. t['afii10036'] = 0x0422;
  9332. t['afii10037'] = 0x0423;
  9333. t['afii10038'] = 0x0424;
  9334. t['afii10039'] = 0x0425;
  9335. t['afii10040'] = 0x0426;
  9336. t['afii10041'] = 0x0427;
  9337. t['afii10042'] = 0x0428;
  9338. t['afii10043'] = 0x0429;
  9339. t['afii10044'] = 0x042A;
  9340. t['afii10045'] = 0x042B;
  9341. t['afii10046'] = 0x042C;
  9342. t['afii10047'] = 0x042D;
  9343. t['afii10048'] = 0x042E;
  9344. t['afii10049'] = 0x042F;
  9345. t['afii10050'] = 0x0490;
  9346. t['afii10051'] = 0x0402;
  9347. t['afii10052'] = 0x0403;
  9348. t['afii10053'] = 0x0404;
  9349. t['afii10054'] = 0x0405;
  9350. t['afii10055'] = 0x0406;
  9351. t['afii10056'] = 0x0407;
  9352. t['afii10057'] = 0x0408;
  9353. t['afii10058'] = 0x0409;
  9354. t['afii10059'] = 0x040A;
  9355. t['afii10060'] = 0x040B;
  9356. t['afii10061'] = 0x040C;
  9357. t['afii10062'] = 0x040E;
  9358. t['afii10063'] = 0xF6C4;
  9359. t['afii10064'] = 0xF6C5;
  9360. t['afii10065'] = 0x0430;
  9361. t['afii10066'] = 0x0431;
  9362. t['afii10067'] = 0x0432;
  9363. t['afii10068'] = 0x0433;
  9364. t['afii10069'] = 0x0434;
  9365. t['afii10070'] = 0x0435;
  9366. t['afii10071'] = 0x0451;
  9367. t['afii10072'] = 0x0436;
  9368. t['afii10073'] = 0x0437;
  9369. t['afii10074'] = 0x0438;
  9370. t['afii10075'] = 0x0439;
  9371. t['afii10076'] = 0x043A;
  9372. t['afii10077'] = 0x043B;
  9373. t['afii10078'] = 0x043C;
  9374. t['afii10079'] = 0x043D;
  9375. t['afii10080'] = 0x043E;
  9376. t['afii10081'] = 0x043F;
  9377. t['afii10082'] = 0x0440;
  9378. t['afii10083'] = 0x0441;
  9379. t['afii10084'] = 0x0442;
  9380. t['afii10085'] = 0x0443;
  9381. t['afii10086'] = 0x0444;
  9382. t['afii10087'] = 0x0445;
  9383. t['afii10088'] = 0x0446;
  9384. t['afii10089'] = 0x0447;
  9385. t['afii10090'] = 0x0448;
  9386. t['afii10091'] = 0x0449;
  9387. t['afii10092'] = 0x044A;
  9388. t['afii10093'] = 0x044B;
  9389. t['afii10094'] = 0x044C;
  9390. t['afii10095'] = 0x044D;
  9391. t['afii10096'] = 0x044E;
  9392. t['afii10097'] = 0x044F;
  9393. t['afii10098'] = 0x0491;
  9394. t['afii10099'] = 0x0452;
  9395. t['afii10100'] = 0x0453;
  9396. t['afii10101'] = 0x0454;
  9397. t['afii10102'] = 0x0455;
  9398. t['afii10103'] = 0x0456;
  9399. t['afii10104'] = 0x0457;
  9400. t['afii10105'] = 0x0458;
  9401. t['afii10106'] = 0x0459;
  9402. t['afii10107'] = 0x045A;
  9403. t['afii10108'] = 0x045B;
  9404. t['afii10109'] = 0x045C;
  9405. t['afii10110'] = 0x045E;
  9406. t['afii10145'] = 0x040F;
  9407. t['afii10146'] = 0x0462;
  9408. t['afii10147'] = 0x0472;
  9409. t['afii10148'] = 0x0474;
  9410. t['afii10192'] = 0xF6C6;
  9411. t['afii10193'] = 0x045F;
  9412. t['afii10194'] = 0x0463;
  9413. t['afii10195'] = 0x0473;
  9414. t['afii10196'] = 0x0475;
  9415. t['afii10831'] = 0xF6C7;
  9416. t['afii10832'] = 0xF6C8;
  9417. t['afii10846'] = 0x04D9;
  9418. t['afii299'] = 0x200E;
  9419. t['afii300'] = 0x200F;
  9420. t['afii301'] = 0x200D;
  9421. t['afii57381'] = 0x066A;
  9422. t['afii57388'] = 0x060C;
  9423. t['afii57392'] = 0x0660;
  9424. t['afii57393'] = 0x0661;
  9425. t['afii57394'] = 0x0662;
  9426. t['afii57395'] = 0x0663;
  9427. t['afii57396'] = 0x0664;
  9428. t['afii57397'] = 0x0665;
  9429. t['afii57398'] = 0x0666;
  9430. t['afii57399'] = 0x0667;
  9431. t['afii57400'] = 0x0668;
  9432. t['afii57401'] = 0x0669;
  9433. t['afii57403'] = 0x061B;
  9434. t['afii57407'] = 0x061F;
  9435. t['afii57409'] = 0x0621;
  9436. t['afii57410'] = 0x0622;
  9437. t['afii57411'] = 0x0623;
  9438. t['afii57412'] = 0x0624;
  9439. t['afii57413'] = 0x0625;
  9440. t['afii57414'] = 0x0626;
  9441. t['afii57415'] = 0x0627;
  9442. t['afii57416'] = 0x0628;
  9443. t['afii57417'] = 0x0629;
  9444. t['afii57418'] = 0x062A;
  9445. t['afii57419'] = 0x062B;
  9446. t['afii57420'] = 0x062C;
  9447. t['afii57421'] = 0x062D;
  9448. t['afii57422'] = 0x062E;
  9449. t['afii57423'] = 0x062F;
  9450. t['afii57424'] = 0x0630;
  9451. t['afii57425'] = 0x0631;
  9452. t['afii57426'] = 0x0632;
  9453. t['afii57427'] = 0x0633;
  9454. t['afii57428'] = 0x0634;
  9455. t['afii57429'] = 0x0635;
  9456. t['afii57430'] = 0x0636;
  9457. t['afii57431'] = 0x0637;
  9458. t['afii57432'] = 0x0638;
  9459. t['afii57433'] = 0x0639;
  9460. t['afii57434'] = 0x063A;
  9461. t['afii57440'] = 0x0640;
  9462. t['afii57441'] = 0x0641;
  9463. t['afii57442'] = 0x0642;
  9464. t['afii57443'] = 0x0643;
  9465. t['afii57444'] = 0x0644;
  9466. t['afii57445'] = 0x0645;
  9467. t['afii57446'] = 0x0646;
  9468. t['afii57448'] = 0x0648;
  9469. t['afii57449'] = 0x0649;
  9470. t['afii57450'] = 0x064A;
  9471. t['afii57451'] = 0x064B;
  9472. t['afii57452'] = 0x064C;
  9473. t['afii57453'] = 0x064D;
  9474. t['afii57454'] = 0x064E;
  9475. t['afii57455'] = 0x064F;
  9476. t['afii57456'] = 0x0650;
  9477. t['afii57457'] = 0x0651;
  9478. t['afii57458'] = 0x0652;
  9479. t['afii57470'] = 0x0647;
  9480. t['afii57505'] = 0x06A4;
  9481. t['afii57506'] = 0x067E;
  9482. t['afii57507'] = 0x0686;
  9483. t['afii57508'] = 0x0698;
  9484. t['afii57509'] = 0x06AF;
  9485. t['afii57511'] = 0x0679;
  9486. t['afii57512'] = 0x0688;
  9487. t['afii57513'] = 0x0691;
  9488. t['afii57514'] = 0x06BA;
  9489. t['afii57519'] = 0x06D2;
  9490. t['afii57534'] = 0x06D5;
  9491. t['afii57636'] = 0x20AA;
  9492. t['afii57645'] = 0x05BE;
  9493. t['afii57658'] = 0x05C3;
  9494. t['afii57664'] = 0x05D0;
  9495. t['afii57665'] = 0x05D1;
  9496. t['afii57666'] = 0x05D2;
  9497. t['afii57667'] = 0x05D3;
  9498. t['afii57668'] = 0x05D4;
  9499. t['afii57669'] = 0x05D5;
  9500. t['afii57670'] = 0x05D6;
  9501. t['afii57671'] = 0x05D7;
  9502. t['afii57672'] = 0x05D8;
  9503. t['afii57673'] = 0x05D9;
  9504. t['afii57674'] = 0x05DA;
  9505. t['afii57675'] = 0x05DB;
  9506. t['afii57676'] = 0x05DC;
  9507. t['afii57677'] = 0x05DD;
  9508. t['afii57678'] = 0x05DE;
  9509. t['afii57679'] = 0x05DF;
  9510. t['afii57680'] = 0x05E0;
  9511. t['afii57681'] = 0x05E1;
  9512. t['afii57682'] = 0x05E2;
  9513. t['afii57683'] = 0x05E3;
  9514. t['afii57684'] = 0x05E4;
  9515. t['afii57685'] = 0x05E5;
  9516. t['afii57686'] = 0x05E6;
  9517. t['afii57687'] = 0x05E7;
  9518. t['afii57688'] = 0x05E8;
  9519. t['afii57689'] = 0x05E9;
  9520. t['afii57690'] = 0x05EA;
  9521. t['afii57694'] = 0xFB2A;
  9522. t['afii57695'] = 0xFB2B;
  9523. t['afii57700'] = 0xFB4B;
  9524. t['afii57705'] = 0xFB1F;
  9525. t['afii57716'] = 0x05F0;
  9526. t['afii57717'] = 0x05F1;
  9527. t['afii57718'] = 0x05F2;
  9528. t['afii57723'] = 0xFB35;
  9529. t['afii57793'] = 0x05B4;
  9530. t['afii57794'] = 0x05B5;
  9531. t['afii57795'] = 0x05B6;
  9532. t['afii57796'] = 0x05BB;
  9533. t['afii57797'] = 0x05B8;
  9534. t['afii57798'] = 0x05B7;
  9535. t['afii57799'] = 0x05B0;
  9536. t['afii57800'] = 0x05B2;
  9537. t['afii57801'] = 0x05B1;
  9538. t['afii57802'] = 0x05B3;
  9539. t['afii57803'] = 0x05C2;
  9540. t['afii57804'] = 0x05C1;
  9541. t['afii57806'] = 0x05B9;
  9542. t['afii57807'] = 0x05BC;
  9543. t['afii57839'] = 0x05BD;
  9544. t['afii57841'] = 0x05BF;
  9545. t['afii57842'] = 0x05C0;
  9546. t['afii57929'] = 0x02BC;
  9547. t['afii61248'] = 0x2105;
  9548. t['afii61289'] = 0x2113;
  9549. t['afii61352'] = 0x2116;
  9550. t['afii61573'] = 0x202C;
  9551. t['afii61574'] = 0x202D;
  9552. t['afii61575'] = 0x202E;
  9553. t['afii61664'] = 0x200C;
  9554. t['afii63167'] = 0x066D;
  9555. t['afii64937'] = 0x02BD;
  9556. t['agrave'] = 0x00E0;
  9557. t['agujarati'] = 0x0A85;
  9558. t['agurmukhi'] = 0x0A05;
  9559. t['ahiragana'] = 0x3042;
  9560. t['ahookabove'] = 0x1EA3;
  9561. t['aibengali'] = 0x0990;
  9562. t['aibopomofo'] = 0x311E;
  9563. t['aideva'] = 0x0910;
  9564. t['aiecyrillic'] = 0x04D5;
  9565. t['aigujarati'] = 0x0A90;
  9566. t['aigurmukhi'] = 0x0A10;
  9567. t['aimatragurmukhi'] = 0x0A48;
  9568. t['ainarabic'] = 0x0639;
  9569. t['ainfinalarabic'] = 0xFECA;
  9570. t['aininitialarabic'] = 0xFECB;
  9571. t['ainmedialarabic'] = 0xFECC;
  9572. t['ainvertedbreve'] = 0x0203;
  9573. t['aivowelsignbengali'] = 0x09C8;
  9574. t['aivowelsigndeva'] = 0x0948;
  9575. t['aivowelsigngujarati'] = 0x0AC8;
  9576. t['akatakana'] = 0x30A2;
  9577. t['akatakanahalfwidth'] = 0xFF71;
  9578. t['akorean'] = 0x314F;
  9579. t['alef'] = 0x05D0;
  9580. t['alefarabic'] = 0x0627;
  9581. t['alefdageshhebrew'] = 0xFB30;
  9582. t['aleffinalarabic'] = 0xFE8E;
  9583. t['alefhamzaabovearabic'] = 0x0623;
  9584. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9585. t['alefhamzabelowarabic'] = 0x0625;
  9586. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9587. t['alefhebrew'] = 0x05D0;
  9588. t['aleflamedhebrew'] = 0xFB4F;
  9589. t['alefmaddaabovearabic'] = 0x0622;
  9590. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9591. t['alefmaksuraarabic'] = 0x0649;
  9592. t['alefmaksurafinalarabic'] = 0xFEF0;
  9593. t['alefmaksurainitialarabic'] = 0xFEF3;
  9594. t['alefmaksuramedialarabic'] = 0xFEF4;
  9595. t['alefpatahhebrew'] = 0xFB2E;
  9596. t['alefqamatshebrew'] = 0xFB2F;
  9597. t['aleph'] = 0x2135;
  9598. t['allequal'] = 0x224C;
  9599. t['alpha'] = 0x03B1;
  9600. t['alphatonos'] = 0x03AC;
  9601. t['amacron'] = 0x0101;
  9602. t['amonospace'] = 0xFF41;
  9603. t['ampersand'] = 0x0026;
  9604. t['ampersandmonospace'] = 0xFF06;
  9605. t['ampersandsmall'] = 0xF726;
  9606. t['amsquare'] = 0x33C2;
  9607. t['anbopomofo'] = 0x3122;
  9608. t['angbopomofo'] = 0x3124;
  9609. t['angbracketleft'] = 0x3008;
  9610. t['angbracketright'] = 0x3009;
  9611. t['angkhankhuthai'] = 0x0E5A;
  9612. t['angle'] = 0x2220;
  9613. t['anglebracketleft'] = 0x3008;
  9614. t['anglebracketleftvertical'] = 0xFE3F;
  9615. t['anglebracketright'] = 0x3009;
  9616. t['anglebracketrightvertical'] = 0xFE40;
  9617. t['angleleft'] = 0x2329;
  9618. t['angleright'] = 0x232A;
  9619. t['angstrom'] = 0x212B;
  9620. t['anoteleia'] = 0x0387;
  9621. t['anudattadeva'] = 0x0952;
  9622. t['anusvarabengali'] = 0x0982;
  9623. t['anusvaradeva'] = 0x0902;
  9624. t['anusvaragujarati'] = 0x0A82;
  9625. t['aogonek'] = 0x0105;
  9626. t['apaatosquare'] = 0x3300;
  9627. t['aparen'] = 0x249C;
  9628. t['apostrophearmenian'] = 0x055A;
  9629. t['apostrophemod'] = 0x02BC;
  9630. t['apple'] = 0xF8FF;
  9631. t['approaches'] = 0x2250;
  9632. t['approxequal'] = 0x2248;
  9633. t['approxequalorimage'] = 0x2252;
  9634. t['approximatelyequal'] = 0x2245;
  9635. t['araeaekorean'] = 0x318E;
  9636. t['araeakorean'] = 0x318D;
  9637. t['arc'] = 0x2312;
  9638. t['arighthalfring'] = 0x1E9A;
  9639. t['aring'] = 0x00E5;
  9640. t['aringacute'] = 0x01FB;
  9641. t['aringbelow'] = 0x1E01;
  9642. t['arrowboth'] = 0x2194;
  9643. t['arrowdashdown'] = 0x21E3;
  9644. t['arrowdashleft'] = 0x21E0;
  9645. t['arrowdashright'] = 0x21E2;
  9646. t['arrowdashup'] = 0x21E1;
  9647. t['arrowdblboth'] = 0x21D4;
  9648. t['arrowdbldown'] = 0x21D3;
  9649. t['arrowdblleft'] = 0x21D0;
  9650. t['arrowdblright'] = 0x21D2;
  9651. t['arrowdblup'] = 0x21D1;
  9652. t['arrowdown'] = 0x2193;
  9653. t['arrowdownleft'] = 0x2199;
  9654. t['arrowdownright'] = 0x2198;
  9655. t['arrowdownwhite'] = 0x21E9;
  9656. t['arrowheaddownmod'] = 0x02C5;
  9657. t['arrowheadleftmod'] = 0x02C2;
  9658. t['arrowheadrightmod'] = 0x02C3;
  9659. t['arrowheadupmod'] = 0x02C4;
  9660. t['arrowhorizex'] = 0xF8E7;
  9661. t['arrowleft'] = 0x2190;
  9662. t['arrowleftdbl'] = 0x21D0;
  9663. t['arrowleftdblstroke'] = 0x21CD;
  9664. t['arrowleftoverright'] = 0x21C6;
  9665. t['arrowleftwhite'] = 0x21E6;
  9666. t['arrowright'] = 0x2192;
  9667. t['arrowrightdblstroke'] = 0x21CF;
  9668. t['arrowrightheavy'] = 0x279E;
  9669. t['arrowrightoverleft'] = 0x21C4;
  9670. t['arrowrightwhite'] = 0x21E8;
  9671. t['arrowtableft'] = 0x21E4;
  9672. t['arrowtabright'] = 0x21E5;
  9673. t['arrowup'] = 0x2191;
  9674. t['arrowupdn'] = 0x2195;
  9675. t['arrowupdnbse'] = 0x21A8;
  9676. t['arrowupdownbase'] = 0x21A8;
  9677. t['arrowupleft'] = 0x2196;
  9678. t['arrowupleftofdown'] = 0x21C5;
  9679. t['arrowupright'] = 0x2197;
  9680. t['arrowupwhite'] = 0x21E7;
  9681. t['arrowvertex'] = 0xF8E6;
  9682. t['asciicircum'] = 0x005E;
  9683. t['asciicircummonospace'] = 0xFF3E;
  9684. t['asciitilde'] = 0x007E;
  9685. t['asciitildemonospace'] = 0xFF5E;
  9686. t['ascript'] = 0x0251;
  9687. t['ascriptturned'] = 0x0252;
  9688. t['asmallhiragana'] = 0x3041;
  9689. t['asmallkatakana'] = 0x30A1;
  9690. t['asmallkatakanahalfwidth'] = 0xFF67;
  9691. t['asterisk'] = 0x002A;
  9692. t['asteriskaltonearabic'] = 0x066D;
  9693. t['asteriskarabic'] = 0x066D;
  9694. t['asteriskmath'] = 0x2217;
  9695. t['asteriskmonospace'] = 0xFF0A;
  9696. t['asterisksmall'] = 0xFE61;
  9697. t['asterism'] = 0x2042;
  9698. t['asuperior'] = 0xF6E9;
  9699. t['asymptoticallyequal'] = 0x2243;
  9700. t['at'] = 0x0040;
  9701. t['atilde'] = 0x00E3;
  9702. t['atmonospace'] = 0xFF20;
  9703. t['atsmall'] = 0xFE6B;
  9704. t['aturned'] = 0x0250;
  9705. t['aubengali'] = 0x0994;
  9706. t['aubopomofo'] = 0x3120;
  9707. t['audeva'] = 0x0914;
  9708. t['augujarati'] = 0x0A94;
  9709. t['augurmukhi'] = 0x0A14;
  9710. t['aulengthmarkbengali'] = 0x09D7;
  9711. t['aumatragurmukhi'] = 0x0A4C;
  9712. t['auvowelsignbengali'] = 0x09CC;
  9713. t['auvowelsigndeva'] = 0x094C;
  9714. t['auvowelsigngujarati'] = 0x0ACC;
  9715. t['avagrahadeva'] = 0x093D;
  9716. t['aybarmenian'] = 0x0561;
  9717. t['ayin'] = 0x05E2;
  9718. t['ayinaltonehebrew'] = 0xFB20;
  9719. t['ayinhebrew'] = 0x05E2;
  9720. t['b'] = 0x0062;
  9721. t['babengali'] = 0x09AC;
  9722. t['backslash'] = 0x005C;
  9723. t['backslashmonospace'] = 0xFF3C;
  9724. t['badeva'] = 0x092C;
  9725. t['bagujarati'] = 0x0AAC;
  9726. t['bagurmukhi'] = 0x0A2C;
  9727. t['bahiragana'] = 0x3070;
  9728. t['bahtthai'] = 0x0E3F;
  9729. t['bakatakana'] = 0x30D0;
  9730. t['bar'] = 0x007C;
  9731. t['barmonospace'] = 0xFF5C;
  9732. t['bbopomofo'] = 0x3105;
  9733. t['bcircle'] = 0x24D1;
  9734. t['bdotaccent'] = 0x1E03;
  9735. t['bdotbelow'] = 0x1E05;
  9736. t['beamedsixteenthnotes'] = 0x266C;
  9737. t['because'] = 0x2235;
  9738. t['becyrillic'] = 0x0431;
  9739. t['beharabic'] = 0x0628;
  9740. t['behfinalarabic'] = 0xFE90;
  9741. t['behinitialarabic'] = 0xFE91;
  9742. t['behiragana'] = 0x3079;
  9743. t['behmedialarabic'] = 0xFE92;
  9744. t['behmeeminitialarabic'] = 0xFC9F;
  9745. t['behmeemisolatedarabic'] = 0xFC08;
  9746. t['behnoonfinalarabic'] = 0xFC6D;
  9747. t['bekatakana'] = 0x30D9;
  9748. t['benarmenian'] = 0x0562;
  9749. t['bet'] = 0x05D1;
  9750. t['beta'] = 0x03B2;
  9751. t['betasymbolgreek'] = 0x03D0;
  9752. t['betdagesh'] = 0xFB31;
  9753. t['betdageshhebrew'] = 0xFB31;
  9754. t['bethebrew'] = 0x05D1;
  9755. t['betrafehebrew'] = 0xFB4C;
  9756. t['bhabengali'] = 0x09AD;
  9757. t['bhadeva'] = 0x092D;
  9758. t['bhagujarati'] = 0x0AAD;
  9759. t['bhagurmukhi'] = 0x0A2D;
  9760. t['bhook'] = 0x0253;
  9761. t['bihiragana'] = 0x3073;
  9762. t['bikatakana'] = 0x30D3;
  9763. t['bilabialclick'] = 0x0298;
  9764. t['bindigurmukhi'] = 0x0A02;
  9765. t['birusquare'] = 0x3331;
  9766. t['blackcircle'] = 0x25CF;
  9767. t['blackdiamond'] = 0x25C6;
  9768. t['blackdownpointingtriangle'] = 0x25BC;
  9769. t['blackleftpointingpointer'] = 0x25C4;
  9770. t['blackleftpointingtriangle'] = 0x25C0;
  9771. t['blacklenticularbracketleft'] = 0x3010;
  9772. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9773. t['blacklenticularbracketright'] = 0x3011;
  9774. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9775. t['blacklowerlefttriangle'] = 0x25E3;
  9776. t['blacklowerrighttriangle'] = 0x25E2;
  9777. t['blackrectangle'] = 0x25AC;
  9778. t['blackrightpointingpointer'] = 0x25BA;
  9779. t['blackrightpointingtriangle'] = 0x25B6;
  9780. t['blacksmallsquare'] = 0x25AA;
  9781. t['blacksmilingface'] = 0x263B;
  9782. t['blacksquare'] = 0x25A0;
  9783. t['blackstar'] = 0x2605;
  9784. t['blackupperlefttriangle'] = 0x25E4;
  9785. t['blackupperrighttriangle'] = 0x25E5;
  9786. t['blackuppointingsmalltriangle'] = 0x25B4;
  9787. t['blackuppointingtriangle'] = 0x25B2;
  9788. t['blank'] = 0x2423;
  9789. t['blinebelow'] = 0x1E07;
  9790. t['block'] = 0x2588;
  9791. t['bmonospace'] = 0xFF42;
  9792. t['bobaimaithai'] = 0x0E1A;
  9793. t['bohiragana'] = 0x307C;
  9794. t['bokatakana'] = 0x30DC;
  9795. t['bparen'] = 0x249D;
  9796. t['bqsquare'] = 0x33C3;
  9797. t['braceex'] = 0xF8F4;
  9798. t['braceleft'] = 0x007B;
  9799. t['braceleftbt'] = 0xF8F3;
  9800. t['braceleftmid'] = 0xF8F2;
  9801. t['braceleftmonospace'] = 0xFF5B;
  9802. t['braceleftsmall'] = 0xFE5B;
  9803. t['bracelefttp'] = 0xF8F1;
  9804. t['braceleftvertical'] = 0xFE37;
  9805. t['braceright'] = 0x007D;
  9806. t['bracerightbt'] = 0xF8FE;
  9807. t['bracerightmid'] = 0xF8FD;
  9808. t['bracerightmonospace'] = 0xFF5D;
  9809. t['bracerightsmall'] = 0xFE5C;
  9810. t['bracerighttp'] = 0xF8FC;
  9811. t['bracerightvertical'] = 0xFE38;
  9812. t['bracketleft'] = 0x005B;
  9813. t['bracketleftbt'] = 0xF8F0;
  9814. t['bracketleftex'] = 0xF8EF;
  9815. t['bracketleftmonospace'] = 0xFF3B;
  9816. t['bracketlefttp'] = 0xF8EE;
  9817. t['bracketright'] = 0x005D;
  9818. t['bracketrightbt'] = 0xF8FB;
  9819. t['bracketrightex'] = 0xF8FA;
  9820. t['bracketrightmonospace'] = 0xFF3D;
  9821. t['bracketrighttp'] = 0xF8F9;
  9822. t['breve'] = 0x02D8;
  9823. t['brevebelowcmb'] = 0x032E;
  9824. t['brevecmb'] = 0x0306;
  9825. t['breveinvertedbelowcmb'] = 0x032F;
  9826. t['breveinvertedcmb'] = 0x0311;
  9827. t['breveinverteddoublecmb'] = 0x0361;
  9828. t['bridgebelowcmb'] = 0x032A;
  9829. t['bridgeinvertedbelowcmb'] = 0x033A;
  9830. t['brokenbar'] = 0x00A6;
  9831. t['bstroke'] = 0x0180;
  9832. t['bsuperior'] = 0xF6EA;
  9833. t['btopbar'] = 0x0183;
  9834. t['buhiragana'] = 0x3076;
  9835. t['bukatakana'] = 0x30D6;
  9836. t['bullet'] = 0x2022;
  9837. t['bulletinverse'] = 0x25D8;
  9838. t['bulletoperator'] = 0x2219;
  9839. t['bullseye'] = 0x25CE;
  9840. t['c'] = 0x0063;
  9841. t['caarmenian'] = 0x056E;
  9842. t['cabengali'] = 0x099A;
  9843. t['cacute'] = 0x0107;
  9844. t['cadeva'] = 0x091A;
  9845. t['cagujarati'] = 0x0A9A;
  9846. t['cagurmukhi'] = 0x0A1A;
  9847. t['calsquare'] = 0x3388;
  9848. t['candrabindubengali'] = 0x0981;
  9849. t['candrabinducmb'] = 0x0310;
  9850. t['candrabindudeva'] = 0x0901;
  9851. t['candrabindugujarati'] = 0x0A81;
  9852. t['capslock'] = 0x21EA;
  9853. t['careof'] = 0x2105;
  9854. t['caron'] = 0x02C7;
  9855. t['caronbelowcmb'] = 0x032C;
  9856. t['caroncmb'] = 0x030C;
  9857. t['carriagereturn'] = 0x21B5;
  9858. t['cbopomofo'] = 0x3118;
  9859. t['ccaron'] = 0x010D;
  9860. t['ccedilla'] = 0x00E7;
  9861. t['ccedillaacute'] = 0x1E09;
  9862. t['ccircle'] = 0x24D2;
  9863. t['ccircumflex'] = 0x0109;
  9864. t['ccurl'] = 0x0255;
  9865. t['cdot'] = 0x010B;
  9866. t['cdotaccent'] = 0x010B;
  9867. t['cdsquare'] = 0x33C5;
  9868. t['cedilla'] = 0x00B8;
  9869. t['cedillacmb'] = 0x0327;
  9870. t['cent'] = 0x00A2;
  9871. t['centigrade'] = 0x2103;
  9872. t['centinferior'] = 0xF6DF;
  9873. t['centmonospace'] = 0xFFE0;
  9874. t['centoldstyle'] = 0xF7A2;
  9875. t['centsuperior'] = 0xF6E0;
  9876. t['chaarmenian'] = 0x0579;
  9877. t['chabengali'] = 0x099B;
  9878. t['chadeva'] = 0x091B;
  9879. t['chagujarati'] = 0x0A9B;
  9880. t['chagurmukhi'] = 0x0A1B;
  9881. t['chbopomofo'] = 0x3114;
  9882. t['cheabkhasiancyrillic'] = 0x04BD;
  9883. t['checkmark'] = 0x2713;
  9884. t['checyrillic'] = 0x0447;
  9885. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9886. t['chedescendercyrillic'] = 0x04B7;
  9887. t['chedieresiscyrillic'] = 0x04F5;
  9888. t['cheharmenian'] = 0x0573;
  9889. t['chekhakassiancyrillic'] = 0x04CC;
  9890. t['cheverticalstrokecyrillic'] = 0x04B9;
  9891. t['chi'] = 0x03C7;
  9892. t['chieuchacirclekorean'] = 0x3277;
  9893. t['chieuchaparenkorean'] = 0x3217;
  9894. t['chieuchcirclekorean'] = 0x3269;
  9895. t['chieuchkorean'] = 0x314A;
  9896. t['chieuchparenkorean'] = 0x3209;
  9897. t['chochangthai'] = 0x0E0A;
  9898. t['chochanthai'] = 0x0E08;
  9899. t['chochingthai'] = 0x0E09;
  9900. t['chochoethai'] = 0x0E0C;
  9901. t['chook'] = 0x0188;
  9902. t['cieucacirclekorean'] = 0x3276;
  9903. t['cieucaparenkorean'] = 0x3216;
  9904. t['cieuccirclekorean'] = 0x3268;
  9905. t['cieuckorean'] = 0x3148;
  9906. t['cieucparenkorean'] = 0x3208;
  9907. t['cieucuparenkorean'] = 0x321C;
  9908. t['circle'] = 0x25CB;
  9909. t['circlecopyrt'] = 0x00A9;
  9910. t['circlemultiply'] = 0x2297;
  9911. t['circleot'] = 0x2299;
  9912. t['circleplus'] = 0x2295;
  9913. t['circlepostalmark'] = 0x3036;
  9914. t['circlewithlefthalfblack'] = 0x25D0;
  9915. t['circlewithrighthalfblack'] = 0x25D1;
  9916. t['circumflex'] = 0x02C6;
  9917. t['circumflexbelowcmb'] = 0x032D;
  9918. t['circumflexcmb'] = 0x0302;
  9919. t['clear'] = 0x2327;
  9920. t['clickalveolar'] = 0x01C2;
  9921. t['clickdental'] = 0x01C0;
  9922. t['clicklateral'] = 0x01C1;
  9923. t['clickretroflex'] = 0x01C3;
  9924. t['club'] = 0x2663;
  9925. t['clubsuitblack'] = 0x2663;
  9926. t['clubsuitwhite'] = 0x2667;
  9927. t['cmcubedsquare'] = 0x33A4;
  9928. t['cmonospace'] = 0xFF43;
  9929. t['cmsquaredsquare'] = 0x33A0;
  9930. t['coarmenian'] = 0x0581;
  9931. t['colon'] = 0x003A;
  9932. t['colonmonetary'] = 0x20A1;
  9933. t['colonmonospace'] = 0xFF1A;
  9934. t['colonsign'] = 0x20A1;
  9935. t['colonsmall'] = 0xFE55;
  9936. t['colontriangularhalfmod'] = 0x02D1;
  9937. t['colontriangularmod'] = 0x02D0;
  9938. t['comma'] = 0x002C;
  9939. t['commaabovecmb'] = 0x0313;
  9940. t['commaaboverightcmb'] = 0x0315;
  9941. t['commaaccent'] = 0xF6C3;
  9942. t['commaarabic'] = 0x060C;
  9943. t['commaarmenian'] = 0x055D;
  9944. t['commainferior'] = 0xF6E1;
  9945. t['commamonospace'] = 0xFF0C;
  9946. t['commareversedabovecmb'] = 0x0314;
  9947. t['commareversedmod'] = 0x02BD;
  9948. t['commasmall'] = 0xFE50;
  9949. t['commasuperior'] = 0xF6E2;
  9950. t['commaturnedabovecmb'] = 0x0312;
  9951. t['commaturnedmod'] = 0x02BB;
  9952. t['compass'] = 0x263C;
  9953. t['congruent'] = 0x2245;
  9954. t['contourintegral'] = 0x222E;
  9955. t['control'] = 0x2303;
  9956. t['controlACK'] = 0x0006;
  9957. t['controlBEL'] = 0x0007;
  9958. t['controlBS'] = 0x0008;
  9959. t['controlCAN'] = 0x0018;
  9960. t['controlCR'] = 0x000D;
  9961. t['controlDC1'] = 0x0011;
  9962. t['controlDC2'] = 0x0012;
  9963. t['controlDC3'] = 0x0013;
  9964. t['controlDC4'] = 0x0014;
  9965. t['controlDEL'] = 0x007F;
  9966. t['controlDLE'] = 0x0010;
  9967. t['controlEM'] = 0x0019;
  9968. t['controlENQ'] = 0x0005;
  9969. t['controlEOT'] = 0x0004;
  9970. t['controlESC'] = 0x001B;
  9971. t['controlETB'] = 0x0017;
  9972. t['controlETX'] = 0x0003;
  9973. t['controlFF'] = 0x000C;
  9974. t['controlFS'] = 0x001C;
  9975. t['controlGS'] = 0x001D;
  9976. t['controlHT'] = 0x0009;
  9977. t['controlLF'] = 0x000A;
  9978. t['controlNAK'] = 0x0015;
  9979. t['controlNULL'] = 0x0000;
  9980. t['controlRS'] = 0x001E;
  9981. t['controlSI'] = 0x000F;
  9982. t['controlSO'] = 0x000E;
  9983. t['controlSOT'] = 0x0002;
  9984. t['controlSTX'] = 0x0001;
  9985. t['controlSUB'] = 0x001A;
  9986. t['controlSYN'] = 0x0016;
  9987. t['controlUS'] = 0x001F;
  9988. t['controlVT'] = 0x000B;
  9989. t['copyright'] = 0x00A9;
  9990. t['copyrightsans'] = 0xF8E9;
  9991. t['copyrightserif'] = 0xF6D9;
  9992. t['cornerbracketleft'] = 0x300C;
  9993. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9994. t['cornerbracketleftvertical'] = 0xFE41;
  9995. t['cornerbracketright'] = 0x300D;
  9996. t['cornerbracketrighthalfwidth'] = 0xFF63;
  9997. t['cornerbracketrightvertical'] = 0xFE42;
  9998. t['corporationsquare'] = 0x337F;
  9999. t['cosquare'] = 0x33C7;
  10000. t['coverkgsquare'] = 0x33C6;
  10001. t['cparen'] = 0x249E;
  10002. t['cruzeiro'] = 0x20A2;
  10003. t['cstretched'] = 0x0297;
  10004. t['curlyand'] = 0x22CF;
  10005. t['curlyor'] = 0x22CE;
  10006. t['currency'] = 0x00A4;
  10007. t['cyrBreve'] = 0xF6D1;
  10008. t['cyrFlex'] = 0xF6D2;
  10009. t['cyrbreve'] = 0xF6D4;
  10010. t['cyrflex'] = 0xF6D5;
  10011. t['d'] = 0x0064;
  10012. t['daarmenian'] = 0x0564;
  10013. t['dabengali'] = 0x09A6;
  10014. t['dadarabic'] = 0x0636;
  10015. t['dadeva'] = 0x0926;
  10016. t['dadfinalarabic'] = 0xFEBE;
  10017. t['dadinitialarabic'] = 0xFEBF;
  10018. t['dadmedialarabic'] = 0xFEC0;
  10019. t['dagesh'] = 0x05BC;
  10020. t['dageshhebrew'] = 0x05BC;
  10021. t['dagger'] = 0x2020;
  10022. t['daggerdbl'] = 0x2021;
  10023. t['dagujarati'] = 0x0AA6;
  10024. t['dagurmukhi'] = 0x0A26;
  10025. t['dahiragana'] = 0x3060;
  10026. t['dakatakana'] = 0x30C0;
  10027. t['dalarabic'] = 0x062F;
  10028. t['dalet'] = 0x05D3;
  10029. t['daletdagesh'] = 0xFB33;
  10030. t['daletdageshhebrew'] = 0xFB33;
  10031. t['dalethebrew'] = 0x05D3;
  10032. t['dalfinalarabic'] = 0xFEAA;
  10033. t['dammaarabic'] = 0x064F;
  10034. t['dammalowarabic'] = 0x064F;
  10035. t['dammatanaltonearabic'] = 0x064C;
  10036. t['dammatanarabic'] = 0x064C;
  10037. t['danda'] = 0x0964;
  10038. t['dargahebrew'] = 0x05A7;
  10039. t['dargalefthebrew'] = 0x05A7;
  10040. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10041. t['dblGrave'] = 0xF6D3;
  10042. t['dblanglebracketleft'] = 0x300A;
  10043. t['dblanglebracketleftvertical'] = 0xFE3D;
  10044. t['dblanglebracketright'] = 0x300B;
  10045. t['dblanglebracketrightvertical'] = 0xFE3E;
  10046. t['dblarchinvertedbelowcmb'] = 0x032B;
  10047. t['dblarrowleft'] = 0x21D4;
  10048. t['dblarrowright'] = 0x21D2;
  10049. t['dbldanda'] = 0x0965;
  10050. t['dblgrave'] = 0xF6D6;
  10051. t['dblgravecmb'] = 0x030F;
  10052. t['dblintegral'] = 0x222C;
  10053. t['dbllowline'] = 0x2017;
  10054. t['dbllowlinecmb'] = 0x0333;
  10055. t['dbloverlinecmb'] = 0x033F;
  10056. t['dblprimemod'] = 0x02BA;
  10057. t['dblverticalbar'] = 0x2016;
  10058. t['dblverticallineabovecmb'] = 0x030E;
  10059. t['dbopomofo'] = 0x3109;
  10060. t['dbsquare'] = 0x33C8;
  10061. t['dcaron'] = 0x010F;
  10062. t['dcedilla'] = 0x1E11;
  10063. t['dcircle'] = 0x24D3;
  10064. t['dcircumflexbelow'] = 0x1E13;
  10065. t['dcroat'] = 0x0111;
  10066. t['ddabengali'] = 0x09A1;
  10067. t['ddadeva'] = 0x0921;
  10068. t['ddagujarati'] = 0x0AA1;
  10069. t['ddagurmukhi'] = 0x0A21;
  10070. t['ddalarabic'] = 0x0688;
  10071. t['ddalfinalarabic'] = 0xFB89;
  10072. t['dddhadeva'] = 0x095C;
  10073. t['ddhabengali'] = 0x09A2;
  10074. t['ddhadeva'] = 0x0922;
  10075. t['ddhagujarati'] = 0x0AA2;
  10076. t['ddhagurmukhi'] = 0x0A22;
  10077. t['ddotaccent'] = 0x1E0B;
  10078. t['ddotbelow'] = 0x1E0D;
  10079. t['decimalseparatorarabic'] = 0x066B;
  10080. t['decimalseparatorpersian'] = 0x066B;
  10081. t['decyrillic'] = 0x0434;
  10082. t['degree'] = 0x00B0;
  10083. t['dehihebrew'] = 0x05AD;
  10084. t['dehiragana'] = 0x3067;
  10085. t['deicoptic'] = 0x03EF;
  10086. t['dekatakana'] = 0x30C7;
  10087. t['deleteleft'] = 0x232B;
  10088. t['deleteright'] = 0x2326;
  10089. t['delta'] = 0x03B4;
  10090. t['deltaturned'] = 0x018D;
  10091. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10092. t['dezh'] = 0x02A4;
  10093. t['dhabengali'] = 0x09A7;
  10094. t['dhadeva'] = 0x0927;
  10095. t['dhagujarati'] = 0x0AA7;
  10096. t['dhagurmukhi'] = 0x0A27;
  10097. t['dhook'] = 0x0257;
  10098. t['dialytikatonos'] = 0x0385;
  10099. t['dialytikatonoscmb'] = 0x0344;
  10100. t['diamond'] = 0x2666;
  10101. t['diamondsuitwhite'] = 0x2662;
  10102. t['dieresis'] = 0x00A8;
  10103. t['dieresisacute'] = 0xF6D7;
  10104. t['dieresisbelowcmb'] = 0x0324;
  10105. t['dieresiscmb'] = 0x0308;
  10106. t['dieresisgrave'] = 0xF6D8;
  10107. t['dieresistonos'] = 0x0385;
  10108. t['dihiragana'] = 0x3062;
  10109. t['dikatakana'] = 0x30C2;
  10110. t['dittomark'] = 0x3003;
  10111. t['divide'] = 0x00F7;
  10112. t['divides'] = 0x2223;
  10113. t['divisionslash'] = 0x2215;
  10114. t['djecyrillic'] = 0x0452;
  10115. t['dkshade'] = 0x2593;
  10116. t['dlinebelow'] = 0x1E0F;
  10117. t['dlsquare'] = 0x3397;
  10118. t['dmacron'] = 0x0111;
  10119. t['dmonospace'] = 0xFF44;
  10120. t['dnblock'] = 0x2584;
  10121. t['dochadathai'] = 0x0E0E;
  10122. t['dodekthai'] = 0x0E14;
  10123. t['dohiragana'] = 0x3069;
  10124. t['dokatakana'] = 0x30C9;
  10125. t['dollar'] = 0x0024;
  10126. t['dollarinferior'] = 0xF6E3;
  10127. t['dollarmonospace'] = 0xFF04;
  10128. t['dollaroldstyle'] = 0xF724;
  10129. t['dollarsmall'] = 0xFE69;
  10130. t['dollarsuperior'] = 0xF6E4;
  10131. t['dong'] = 0x20AB;
  10132. t['dorusquare'] = 0x3326;
  10133. t['dotaccent'] = 0x02D9;
  10134. t['dotaccentcmb'] = 0x0307;
  10135. t['dotbelowcmb'] = 0x0323;
  10136. t['dotbelowcomb'] = 0x0323;
  10137. t['dotkatakana'] = 0x30FB;
  10138. t['dotlessi'] = 0x0131;
  10139. t['dotlessj'] = 0xF6BE;
  10140. t['dotlessjstrokehook'] = 0x0284;
  10141. t['dotmath'] = 0x22C5;
  10142. t['dottedcircle'] = 0x25CC;
  10143. t['doubleyodpatah'] = 0xFB1F;
  10144. t['doubleyodpatahhebrew'] = 0xFB1F;
  10145. t['downtackbelowcmb'] = 0x031E;
  10146. t['downtackmod'] = 0x02D5;
  10147. t['dparen'] = 0x249F;
  10148. t['dsuperior'] = 0xF6EB;
  10149. t['dtail'] = 0x0256;
  10150. t['dtopbar'] = 0x018C;
  10151. t['duhiragana'] = 0x3065;
  10152. t['dukatakana'] = 0x30C5;
  10153. t['dz'] = 0x01F3;
  10154. t['dzaltone'] = 0x02A3;
  10155. t['dzcaron'] = 0x01C6;
  10156. t['dzcurl'] = 0x02A5;
  10157. t['dzeabkhasiancyrillic'] = 0x04E1;
  10158. t['dzecyrillic'] = 0x0455;
  10159. t['dzhecyrillic'] = 0x045F;
  10160. t['e'] = 0x0065;
  10161. t['eacute'] = 0x00E9;
  10162. t['earth'] = 0x2641;
  10163. t['ebengali'] = 0x098F;
  10164. t['ebopomofo'] = 0x311C;
  10165. t['ebreve'] = 0x0115;
  10166. t['ecandradeva'] = 0x090D;
  10167. t['ecandragujarati'] = 0x0A8D;
  10168. t['ecandravowelsigndeva'] = 0x0945;
  10169. t['ecandravowelsigngujarati'] = 0x0AC5;
  10170. t['ecaron'] = 0x011B;
  10171. t['ecedillabreve'] = 0x1E1D;
  10172. t['echarmenian'] = 0x0565;
  10173. t['echyiwnarmenian'] = 0x0587;
  10174. t['ecircle'] = 0x24D4;
  10175. t['ecircumflex'] = 0x00EA;
  10176. t['ecircumflexacute'] = 0x1EBF;
  10177. t['ecircumflexbelow'] = 0x1E19;
  10178. t['ecircumflexdotbelow'] = 0x1EC7;
  10179. t['ecircumflexgrave'] = 0x1EC1;
  10180. t['ecircumflexhookabove'] = 0x1EC3;
  10181. t['ecircumflextilde'] = 0x1EC5;
  10182. t['ecyrillic'] = 0x0454;
  10183. t['edblgrave'] = 0x0205;
  10184. t['edeva'] = 0x090F;
  10185. t['edieresis'] = 0x00EB;
  10186. t['edot'] = 0x0117;
  10187. t['edotaccent'] = 0x0117;
  10188. t['edotbelow'] = 0x1EB9;
  10189. t['eegurmukhi'] = 0x0A0F;
  10190. t['eematragurmukhi'] = 0x0A47;
  10191. t['efcyrillic'] = 0x0444;
  10192. t['egrave'] = 0x00E8;
  10193. t['egujarati'] = 0x0A8F;
  10194. t['eharmenian'] = 0x0567;
  10195. t['ehbopomofo'] = 0x311D;
  10196. t['ehiragana'] = 0x3048;
  10197. t['ehookabove'] = 0x1EBB;
  10198. t['eibopomofo'] = 0x311F;
  10199. t['eight'] = 0x0038;
  10200. t['eightarabic'] = 0x0668;
  10201. t['eightbengali'] = 0x09EE;
  10202. t['eightcircle'] = 0x2467;
  10203. t['eightcircleinversesansserif'] = 0x2791;
  10204. t['eightdeva'] = 0x096E;
  10205. t['eighteencircle'] = 0x2471;
  10206. t['eighteenparen'] = 0x2485;
  10207. t['eighteenperiod'] = 0x2499;
  10208. t['eightgujarati'] = 0x0AEE;
  10209. t['eightgurmukhi'] = 0x0A6E;
  10210. t['eighthackarabic'] = 0x0668;
  10211. t['eighthangzhou'] = 0x3028;
  10212. t['eighthnotebeamed'] = 0x266B;
  10213. t['eightideographicparen'] = 0x3227;
  10214. t['eightinferior'] = 0x2088;
  10215. t['eightmonospace'] = 0xFF18;
  10216. t['eightoldstyle'] = 0xF738;
  10217. t['eightparen'] = 0x247B;
  10218. t['eightperiod'] = 0x248F;
  10219. t['eightpersian'] = 0x06F8;
  10220. t['eightroman'] = 0x2177;
  10221. t['eightsuperior'] = 0x2078;
  10222. t['eightthai'] = 0x0E58;
  10223. t['einvertedbreve'] = 0x0207;
  10224. t['eiotifiedcyrillic'] = 0x0465;
  10225. t['ekatakana'] = 0x30A8;
  10226. t['ekatakanahalfwidth'] = 0xFF74;
  10227. t['ekonkargurmukhi'] = 0x0A74;
  10228. t['ekorean'] = 0x3154;
  10229. t['elcyrillic'] = 0x043B;
  10230. t['element'] = 0x2208;
  10231. t['elevencircle'] = 0x246A;
  10232. t['elevenparen'] = 0x247E;
  10233. t['elevenperiod'] = 0x2492;
  10234. t['elevenroman'] = 0x217A;
  10235. t['ellipsis'] = 0x2026;
  10236. t['ellipsisvertical'] = 0x22EE;
  10237. t['emacron'] = 0x0113;
  10238. t['emacronacute'] = 0x1E17;
  10239. t['emacrongrave'] = 0x1E15;
  10240. t['emcyrillic'] = 0x043C;
  10241. t['emdash'] = 0x2014;
  10242. t['emdashvertical'] = 0xFE31;
  10243. t['emonospace'] = 0xFF45;
  10244. t['emphasismarkarmenian'] = 0x055B;
  10245. t['emptyset'] = 0x2205;
  10246. t['enbopomofo'] = 0x3123;
  10247. t['encyrillic'] = 0x043D;
  10248. t['endash'] = 0x2013;
  10249. t['endashvertical'] = 0xFE32;
  10250. t['endescendercyrillic'] = 0x04A3;
  10251. t['eng'] = 0x014B;
  10252. t['engbopomofo'] = 0x3125;
  10253. t['enghecyrillic'] = 0x04A5;
  10254. t['enhookcyrillic'] = 0x04C8;
  10255. t['enspace'] = 0x2002;
  10256. t['eogonek'] = 0x0119;
  10257. t['eokorean'] = 0x3153;
  10258. t['eopen'] = 0x025B;
  10259. t['eopenclosed'] = 0x029A;
  10260. t['eopenreversed'] = 0x025C;
  10261. t['eopenreversedclosed'] = 0x025E;
  10262. t['eopenreversedhook'] = 0x025D;
  10263. t['eparen'] = 0x24A0;
  10264. t['epsilon'] = 0x03B5;
  10265. t['epsilontonos'] = 0x03AD;
  10266. t['equal'] = 0x003D;
  10267. t['equalmonospace'] = 0xFF1D;
  10268. t['equalsmall'] = 0xFE66;
  10269. t['equalsuperior'] = 0x207C;
  10270. t['equivalence'] = 0x2261;
  10271. t['erbopomofo'] = 0x3126;
  10272. t['ercyrillic'] = 0x0440;
  10273. t['ereversed'] = 0x0258;
  10274. t['ereversedcyrillic'] = 0x044D;
  10275. t['escyrillic'] = 0x0441;
  10276. t['esdescendercyrillic'] = 0x04AB;
  10277. t['esh'] = 0x0283;
  10278. t['eshcurl'] = 0x0286;
  10279. t['eshortdeva'] = 0x090E;
  10280. t['eshortvowelsigndeva'] = 0x0946;
  10281. t['eshreversedloop'] = 0x01AA;
  10282. t['eshsquatreversed'] = 0x0285;
  10283. t['esmallhiragana'] = 0x3047;
  10284. t['esmallkatakana'] = 0x30A7;
  10285. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10286. t['estimated'] = 0x212E;
  10287. t['esuperior'] = 0xF6EC;
  10288. t['eta'] = 0x03B7;
  10289. t['etarmenian'] = 0x0568;
  10290. t['etatonos'] = 0x03AE;
  10291. t['eth'] = 0x00F0;
  10292. t['etilde'] = 0x1EBD;
  10293. t['etildebelow'] = 0x1E1B;
  10294. t['etnahtafoukhhebrew'] = 0x0591;
  10295. t['etnahtafoukhlefthebrew'] = 0x0591;
  10296. t['etnahtahebrew'] = 0x0591;
  10297. t['etnahtalefthebrew'] = 0x0591;
  10298. t['eturned'] = 0x01DD;
  10299. t['eukorean'] = 0x3161;
  10300. t['euro'] = 0x20AC;
  10301. t['evowelsignbengali'] = 0x09C7;
  10302. t['evowelsigndeva'] = 0x0947;
  10303. t['evowelsigngujarati'] = 0x0AC7;
  10304. t['exclam'] = 0x0021;
  10305. t['exclamarmenian'] = 0x055C;
  10306. t['exclamdbl'] = 0x203C;
  10307. t['exclamdown'] = 0x00A1;
  10308. t['exclamdownsmall'] = 0xF7A1;
  10309. t['exclammonospace'] = 0xFF01;
  10310. t['exclamsmall'] = 0xF721;
  10311. t['existential'] = 0x2203;
  10312. t['ezh'] = 0x0292;
  10313. t['ezhcaron'] = 0x01EF;
  10314. t['ezhcurl'] = 0x0293;
  10315. t['ezhreversed'] = 0x01B9;
  10316. t['ezhtail'] = 0x01BA;
  10317. t['f'] = 0x0066;
  10318. t['fadeva'] = 0x095E;
  10319. t['fagurmukhi'] = 0x0A5E;
  10320. t['fahrenheit'] = 0x2109;
  10321. t['fathaarabic'] = 0x064E;
  10322. t['fathalowarabic'] = 0x064E;
  10323. t['fathatanarabic'] = 0x064B;
  10324. t['fbopomofo'] = 0x3108;
  10325. t['fcircle'] = 0x24D5;
  10326. t['fdotaccent'] = 0x1E1F;
  10327. t['feharabic'] = 0x0641;
  10328. t['feharmenian'] = 0x0586;
  10329. t['fehfinalarabic'] = 0xFED2;
  10330. t['fehinitialarabic'] = 0xFED3;
  10331. t['fehmedialarabic'] = 0xFED4;
  10332. t['feicoptic'] = 0x03E5;
  10333. t['female'] = 0x2640;
  10334. t['ff'] = 0xFB00;
  10335. t['ffi'] = 0xFB03;
  10336. t['ffl'] = 0xFB04;
  10337. t['fi'] = 0xFB01;
  10338. t['fifteencircle'] = 0x246E;
  10339. t['fifteenparen'] = 0x2482;
  10340. t['fifteenperiod'] = 0x2496;
  10341. t['figuredash'] = 0x2012;
  10342. t['filledbox'] = 0x25A0;
  10343. t['filledrect'] = 0x25AC;
  10344. t['finalkaf'] = 0x05DA;
  10345. t['finalkafdagesh'] = 0xFB3A;
  10346. t['finalkafdageshhebrew'] = 0xFB3A;
  10347. t['finalkafhebrew'] = 0x05DA;
  10348. t['finalmem'] = 0x05DD;
  10349. t['finalmemhebrew'] = 0x05DD;
  10350. t['finalnun'] = 0x05DF;
  10351. t['finalnunhebrew'] = 0x05DF;
  10352. t['finalpe'] = 0x05E3;
  10353. t['finalpehebrew'] = 0x05E3;
  10354. t['finaltsadi'] = 0x05E5;
  10355. t['finaltsadihebrew'] = 0x05E5;
  10356. t['firsttonechinese'] = 0x02C9;
  10357. t['fisheye'] = 0x25C9;
  10358. t['fitacyrillic'] = 0x0473;
  10359. t['five'] = 0x0035;
  10360. t['fivearabic'] = 0x0665;
  10361. t['fivebengali'] = 0x09EB;
  10362. t['fivecircle'] = 0x2464;
  10363. t['fivecircleinversesansserif'] = 0x278E;
  10364. t['fivedeva'] = 0x096B;
  10365. t['fiveeighths'] = 0x215D;
  10366. t['fivegujarati'] = 0x0AEB;
  10367. t['fivegurmukhi'] = 0x0A6B;
  10368. t['fivehackarabic'] = 0x0665;
  10369. t['fivehangzhou'] = 0x3025;
  10370. t['fiveideographicparen'] = 0x3224;
  10371. t['fiveinferior'] = 0x2085;
  10372. t['fivemonospace'] = 0xFF15;
  10373. t['fiveoldstyle'] = 0xF735;
  10374. t['fiveparen'] = 0x2478;
  10375. t['fiveperiod'] = 0x248C;
  10376. t['fivepersian'] = 0x06F5;
  10377. t['fiveroman'] = 0x2174;
  10378. t['fivesuperior'] = 0x2075;
  10379. t['fivethai'] = 0x0E55;
  10380. t['fl'] = 0xFB02;
  10381. t['florin'] = 0x0192;
  10382. t['fmonospace'] = 0xFF46;
  10383. t['fmsquare'] = 0x3399;
  10384. t['fofanthai'] = 0x0E1F;
  10385. t['fofathai'] = 0x0E1D;
  10386. t['fongmanthai'] = 0x0E4F;
  10387. t['forall'] = 0x2200;
  10388. t['four'] = 0x0034;
  10389. t['fourarabic'] = 0x0664;
  10390. t['fourbengali'] = 0x09EA;
  10391. t['fourcircle'] = 0x2463;
  10392. t['fourcircleinversesansserif'] = 0x278D;
  10393. t['fourdeva'] = 0x096A;
  10394. t['fourgujarati'] = 0x0AEA;
  10395. t['fourgurmukhi'] = 0x0A6A;
  10396. t['fourhackarabic'] = 0x0664;
  10397. t['fourhangzhou'] = 0x3024;
  10398. t['fourideographicparen'] = 0x3223;
  10399. t['fourinferior'] = 0x2084;
  10400. t['fourmonospace'] = 0xFF14;
  10401. t['fournumeratorbengali'] = 0x09F7;
  10402. t['fouroldstyle'] = 0xF734;
  10403. t['fourparen'] = 0x2477;
  10404. t['fourperiod'] = 0x248B;
  10405. t['fourpersian'] = 0x06F4;
  10406. t['fourroman'] = 0x2173;
  10407. t['foursuperior'] = 0x2074;
  10408. t['fourteencircle'] = 0x246D;
  10409. t['fourteenparen'] = 0x2481;
  10410. t['fourteenperiod'] = 0x2495;
  10411. t['fourthai'] = 0x0E54;
  10412. t['fourthtonechinese'] = 0x02CB;
  10413. t['fparen'] = 0x24A1;
  10414. t['fraction'] = 0x2044;
  10415. t['franc'] = 0x20A3;
  10416. t['g'] = 0x0067;
  10417. t['gabengali'] = 0x0997;
  10418. t['gacute'] = 0x01F5;
  10419. t['gadeva'] = 0x0917;
  10420. t['gafarabic'] = 0x06AF;
  10421. t['gaffinalarabic'] = 0xFB93;
  10422. t['gafinitialarabic'] = 0xFB94;
  10423. t['gafmedialarabic'] = 0xFB95;
  10424. t['gagujarati'] = 0x0A97;
  10425. t['gagurmukhi'] = 0x0A17;
  10426. t['gahiragana'] = 0x304C;
  10427. t['gakatakana'] = 0x30AC;
  10428. t['gamma'] = 0x03B3;
  10429. t['gammalatinsmall'] = 0x0263;
  10430. t['gammasuperior'] = 0x02E0;
  10431. t['gangiacoptic'] = 0x03EB;
  10432. t['gbopomofo'] = 0x310D;
  10433. t['gbreve'] = 0x011F;
  10434. t['gcaron'] = 0x01E7;
  10435. t['gcedilla'] = 0x0123;
  10436. t['gcircle'] = 0x24D6;
  10437. t['gcircumflex'] = 0x011D;
  10438. t['gcommaaccent'] = 0x0123;
  10439. t['gdot'] = 0x0121;
  10440. t['gdotaccent'] = 0x0121;
  10441. t['gecyrillic'] = 0x0433;
  10442. t['gehiragana'] = 0x3052;
  10443. t['gekatakana'] = 0x30B2;
  10444. t['geometricallyequal'] = 0x2251;
  10445. t['gereshaccenthebrew'] = 0x059C;
  10446. t['gereshhebrew'] = 0x05F3;
  10447. t['gereshmuqdamhebrew'] = 0x059D;
  10448. t['germandbls'] = 0x00DF;
  10449. t['gershayimaccenthebrew'] = 0x059E;
  10450. t['gershayimhebrew'] = 0x05F4;
  10451. t['getamark'] = 0x3013;
  10452. t['ghabengali'] = 0x0998;
  10453. t['ghadarmenian'] = 0x0572;
  10454. t['ghadeva'] = 0x0918;
  10455. t['ghagujarati'] = 0x0A98;
  10456. t['ghagurmukhi'] = 0x0A18;
  10457. t['ghainarabic'] = 0x063A;
  10458. t['ghainfinalarabic'] = 0xFECE;
  10459. t['ghaininitialarabic'] = 0xFECF;
  10460. t['ghainmedialarabic'] = 0xFED0;
  10461. t['ghemiddlehookcyrillic'] = 0x0495;
  10462. t['ghestrokecyrillic'] = 0x0493;
  10463. t['gheupturncyrillic'] = 0x0491;
  10464. t['ghhadeva'] = 0x095A;
  10465. t['ghhagurmukhi'] = 0x0A5A;
  10466. t['ghook'] = 0x0260;
  10467. t['ghzsquare'] = 0x3393;
  10468. t['gihiragana'] = 0x304E;
  10469. t['gikatakana'] = 0x30AE;
  10470. t['gimarmenian'] = 0x0563;
  10471. t['gimel'] = 0x05D2;
  10472. t['gimeldagesh'] = 0xFB32;
  10473. t['gimeldageshhebrew'] = 0xFB32;
  10474. t['gimelhebrew'] = 0x05D2;
  10475. t['gjecyrillic'] = 0x0453;
  10476. t['glottalinvertedstroke'] = 0x01BE;
  10477. t['glottalstop'] = 0x0294;
  10478. t['glottalstopinverted'] = 0x0296;
  10479. t['glottalstopmod'] = 0x02C0;
  10480. t['glottalstopreversed'] = 0x0295;
  10481. t['glottalstopreversedmod'] = 0x02C1;
  10482. t['glottalstopreversedsuperior'] = 0x02E4;
  10483. t['glottalstopstroke'] = 0x02A1;
  10484. t['glottalstopstrokereversed'] = 0x02A2;
  10485. t['gmacron'] = 0x1E21;
  10486. t['gmonospace'] = 0xFF47;
  10487. t['gohiragana'] = 0x3054;
  10488. t['gokatakana'] = 0x30B4;
  10489. t['gparen'] = 0x24A2;
  10490. t['gpasquare'] = 0x33AC;
  10491. t['gradient'] = 0x2207;
  10492. t['grave'] = 0x0060;
  10493. t['gravebelowcmb'] = 0x0316;
  10494. t['gravecmb'] = 0x0300;
  10495. t['gravecomb'] = 0x0300;
  10496. t['gravedeva'] = 0x0953;
  10497. t['gravelowmod'] = 0x02CE;
  10498. t['gravemonospace'] = 0xFF40;
  10499. t['gravetonecmb'] = 0x0340;
  10500. t['greater'] = 0x003E;
  10501. t['greaterequal'] = 0x2265;
  10502. t['greaterequalorless'] = 0x22DB;
  10503. t['greatermonospace'] = 0xFF1E;
  10504. t['greaterorequivalent'] = 0x2273;
  10505. t['greaterorless'] = 0x2277;
  10506. t['greateroverequal'] = 0x2267;
  10507. t['greatersmall'] = 0xFE65;
  10508. t['gscript'] = 0x0261;
  10509. t['gstroke'] = 0x01E5;
  10510. t['guhiragana'] = 0x3050;
  10511. t['guillemotleft'] = 0x00AB;
  10512. t['guillemotright'] = 0x00BB;
  10513. t['guilsinglleft'] = 0x2039;
  10514. t['guilsinglright'] = 0x203A;
  10515. t['gukatakana'] = 0x30B0;
  10516. t['guramusquare'] = 0x3318;
  10517. t['gysquare'] = 0x33C9;
  10518. t['h'] = 0x0068;
  10519. t['haabkhasiancyrillic'] = 0x04A9;
  10520. t['haaltonearabic'] = 0x06C1;
  10521. t['habengali'] = 0x09B9;
  10522. t['hadescendercyrillic'] = 0x04B3;
  10523. t['hadeva'] = 0x0939;
  10524. t['hagujarati'] = 0x0AB9;
  10525. t['hagurmukhi'] = 0x0A39;
  10526. t['haharabic'] = 0x062D;
  10527. t['hahfinalarabic'] = 0xFEA2;
  10528. t['hahinitialarabic'] = 0xFEA3;
  10529. t['hahiragana'] = 0x306F;
  10530. t['hahmedialarabic'] = 0xFEA4;
  10531. t['haitusquare'] = 0x332A;
  10532. t['hakatakana'] = 0x30CF;
  10533. t['hakatakanahalfwidth'] = 0xFF8A;
  10534. t['halantgurmukhi'] = 0x0A4D;
  10535. t['hamzaarabic'] = 0x0621;
  10536. t['hamzalowarabic'] = 0x0621;
  10537. t['hangulfiller'] = 0x3164;
  10538. t['hardsigncyrillic'] = 0x044A;
  10539. t['harpoonleftbarbup'] = 0x21BC;
  10540. t['harpoonrightbarbup'] = 0x21C0;
  10541. t['hasquare'] = 0x33CA;
  10542. t['hatafpatah'] = 0x05B2;
  10543. t['hatafpatah16'] = 0x05B2;
  10544. t['hatafpatah23'] = 0x05B2;
  10545. t['hatafpatah2f'] = 0x05B2;
  10546. t['hatafpatahhebrew'] = 0x05B2;
  10547. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10548. t['hatafpatahquarterhebrew'] = 0x05B2;
  10549. t['hatafpatahwidehebrew'] = 0x05B2;
  10550. t['hatafqamats'] = 0x05B3;
  10551. t['hatafqamats1b'] = 0x05B3;
  10552. t['hatafqamats28'] = 0x05B3;
  10553. t['hatafqamats34'] = 0x05B3;
  10554. t['hatafqamatshebrew'] = 0x05B3;
  10555. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10556. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10557. t['hatafqamatswidehebrew'] = 0x05B3;
  10558. t['hatafsegol'] = 0x05B1;
  10559. t['hatafsegol17'] = 0x05B1;
  10560. t['hatafsegol24'] = 0x05B1;
  10561. t['hatafsegol30'] = 0x05B1;
  10562. t['hatafsegolhebrew'] = 0x05B1;
  10563. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10564. t['hatafsegolquarterhebrew'] = 0x05B1;
  10565. t['hatafsegolwidehebrew'] = 0x05B1;
  10566. t['hbar'] = 0x0127;
  10567. t['hbopomofo'] = 0x310F;
  10568. t['hbrevebelow'] = 0x1E2B;
  10569. t['hcedilla'] = 0x1E29;
  10570. t['hcircle'] = 0x24D7;
  10571. t['hcircumflex'] = 0x0125;
  10572. t['hdieresis'] = 0x1E27;
  10573. t['hdotaccent'] = 0x1E23;
  10574. t['hdotbelow'] = 0x1E25;
  10575. t['he'] = 0x05D4;
  10576. t['heart'] = 0x2665;
  10577. t['heartsuitblack'] = 0x2665;
  10578. t['heartsuitwhite'] = 0x2661;
  10579. t['hedagesh'] = 0xFB34;
  10580. t['hedageshhebrew'] = 0xFB34;
  10581. t['hehaltonearabic'] = 0x06C1;
  10582. t['heharabic'] = 0x0647;
  10583. t['hehebrew'] = 0x05D4;
  10584. t['hehfinalaltonearabic'] = 0xFBA7;
  10585. t['hehfinalalttwoarabic'] = 0xFEEA;
  10586. t['hehfinalarabic'] = 0xFEEA;
  10587. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10588. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10589. t['hehinitialaltonearabic'] = 0xFBA8;
  10590. t['hehinitialarabic'] = 0xFEEB;
  10591. t['hehiragana'] = 0x3078;
  10592. t['hehmedialaltonearabic'] = 0xFBA9;
  10593. t['hehmedialarabic'] = 0xFEEC;
  10594. t['heiseierasquare'] = 0x337B;
  10595. t['hekatakana'] = 0x30D8;
  10596. t['hekatakanahalfwidth'] = 0xFF8D;
  10597. t['hekutaarusquare'] = 0x3336;
  10598. t['henghook'] = 0x0267;
  10599. t['herutusquare'] = 0x3339;
  10600. t['het'] = 0x05D7;
  10601. t['hethebrew'] = 0x05D7;
  10602. t['hhook'] = 0x0266;
  10603. t['hhooksuperior'] = 0x02B1;
  10604. t['hieuhacirclekorean'] = 0x327B;
  10605. t['hieuhaparenkorean'] = 0x321B;
  10606. t['hieuhcirclekorean'] = 0x326D;
  10607. t['hieuhkorean'] = 0x314E;
  10608. t['hieuhparenkorean'] = 0x320D;
  10609. t['hihiragana'] = 0x3072;
  10610. t['hikatakana'] = 0x30D2;
  10611. t['hikatakanahalfwidth'] = 0xFF8B;
  10612. t['hiriq'] = 0x05B4;
  10613. t['hiriq14'] = 0x05B4;
  10614. t['hiriq21'] = 0x05B4;
  10615. t['hiriq2d'] = 0x05B4;
  10616. t['hiriqhebrew'] = 0x05B4;
  10617. t['hiriqnarrowhebrew'] = 0x05B4;
  10618. t['hiriqquarterhebrew'] = 0x05B4;
  10619. t['hiriqwidehebrew'] = 0x05B4;
  10620. t['hlinebelow'] = 0x1E96;
  10621. t['hmonospace'] = 0xFF48;
  10622. t['hoarmenian'] = 0x0570;
  10623. t['hohipthai'] = 0x0E2B;
  10624. t['hohiragana'] = 0x307B;
  10625. t['hokatakana'] = 0x30DB;
  10626. t['hokatakanahalfwidth'] = 0xFF8E;
  10627. t['holam'] = 0x05B9;
  10628. t['holam19'] = 0x05B9;
  10629. t['holam26'] = 0x05B9;
  10630. t['holam32'] = 0x05B9;
  10631. t['holamhebrew'] = 0x05B9;
  10632. t['holamnarrowhebrew'] = 0x05B9;
  10633. t['holamquarterhebrew'] = 0x05B9;
  10634. t['holamwidehebrew'] = 0x05B9;
  10635. t['honokhukthai'] = 0x0E2E;
  10636. t['hookabovecomb'] = 0x0309;
  10637. t['hookcmb'] = 0x0309;
  10638. t['hookpalatalizedbelowcmb'] = 0x0321;
  10639. t['hookretroflexbelowcmb'] = 0x0322;
  10640. t['hoonsquare'] = 0x3342;
  10641. t['horicoptic'] = 0x03E9;
  10642. t['horizontalbar'] = 0x2015;
  10643. t['horncmb'] = 0x031B;
  10644. t['hotsprings'] = 0x2668;
  10645. t['house'] = 0x2302;
  10646. t['hparen'] = 0x24A3;
  10647. t['hsuperior'] = 0x02B0;
  10648. t['hturned'] = 0x0265;
  10649. t['huhiragana'] = 0x3075;
  10650. t['huiitosquare'] = 0x3333;
  10651. t['hukatakana'] = 0x30D5;
  10652. t['hukatakanahalfwidth'] = 0xFF8C;
  10653. t['hungarumlaut'] = 0x02DD;
  10654. t['hungarumlautcmb'] = 0x030B;
  10655. t['hv'] = 0x0195;
  10656. t['hyphen'] = 0x002D;
  10657. t['hypheninferior'] = 0xF6E5;
  10658. t['hyphenmonospace'] = 0xFF0D;
  10659. t['hyphensmall'] = 0xFE63;
  10660. t['hyphensuperior'] = 0xF6E6;
  10661. t['hyphentwo'] = 0x2010;
  10662. t['i'] = 0x0069;
  10663. t['iacute'] = 0x00ED;
  10664. t['iacyrillic'] = 0x044F;
  10665. t['ibengali'] = 0x0987;
  10666. t['ibopomofo'] = 0x3127;
  10667. t['ibreve'] = 0x012D;
  10668. t['icaron'] = 0x01D0;
  10669. t['icircle'] = 0x24D8;
  10670. t['icircumflex'] = 0x00EE;
  10671. t['icyrillic'] = 0x0456;
  10672. t['idblgrave'] = 0x0209;
  10673. t['ideographearthcircle'] = 0x328F;
  10674. t['ideographfirecircle'] = 0x328B;
  10675. t['ideographicallianceparen'] = 0x323F;
  10676. t['ideographiccallparen'] = 0x323A;
  10677. t['ideographiccentrecircle'] = 0x32A5;
  10678. t['ideographicclose'] = 0x3006;
  10679. t['ideographiccomma'] = 0x3001;
  10680. t['ideographiccommaleft'] = 0xFF64;
  10681. t['ideographiccongratulationparen'] = 0x3237;
  10682. t['ideographiccorrectcircle'] = 0x32A3;
  10683. t['ideographicearthparen'] = 0x322F;
  10684. t['ideographicenterpriseparen'] = 0x323D;
  10685. t['ideographicexcellentcircle'] = 0x329D;
  10686. t['ideographicfestivalparen'] = 0x3240;
  10687. t['ideographicfinancialcircle'] = 0x3296;
  10688. t['ideographicfinancialparen'] = 0x3236;
  10689. t['ideographicfireparen'] = 0x322B;
  10690. t['ideographichaveparen'] = 0x3232;
  10691. t['ideographichighcircle'] = 0x32A4;
  10692. t['ideographiciterationmark'] = 0x3005;
  10693. t['ideographiclaborcircle'] = 0x3298;
  10694. t['ideographiclaborparen'] = 0x3238;
  10695. t['ideographicleftcircle'] = 0x32A7;
  10696. t['ideographiclowcircle'] = 0x32A6;
  10697. t['ideographicmedicinecircle'] = 0x32A9;
  10698. t['ideographicmetalparen'] = 0x322E;
  10699. t['ideographicmoonparen'] = 0x322A;
  10700. t['ideographicnameparen'] = 0x3234;
  10701. t['ideographicperiod'] = 0x3002;
  10702. t['ideographicprintcircle'] = 0x329E;
  10703. t['ideographicreachparen'] = 0x3243;
  10704. t['ideographicrepresentparen'] = 0x3239;
  10705. t['ideographicresourceparen'] = 0x323E;
  10706. t['ideographicrightcircle'] = 0x32A8;
  10707. t['ideographicsecretcircle'] = 0x3299;
  10708. t['ideographicselfparen'] = 0x3242;
  10709. t['ideographicsocietyparen'] = 0x3233;
  10710. t['ideographicspace'] = 0x3000;
  10711. t['ideographicspecialparen'] = 0x3235;
  10712. t['ideographicstockparen'] = 0x3231;
  10713. t['ideographicstudyparen'] = 0x323B;
  10714. t['ideographicsunparen'] = 0x3230;
  10715. t['ideographicsuperviseparen'] = 0x323C;
  10716. t['ideographicwaterparen'] = 0x322C;
  10717. t['ideographicwoodparen'] = 0x322D;
  10718. t['ideographiczero'] = 0x3007;
  10719. t['ideographmetalcircle'] = 0x328E;
  10720. t['ideographmooncircle'] = 0x328A;
  10721. t['ideographnamecircle'] = 0x3294;
  10722. t['ideographsuncircle'] = 0x3290;
  10723. t['ideographwatercircle'] = 0x328C;
  10724. t['ideographwoodcircle'] = 0x328D;
  10725. t['ideva'] = 0x0907;
  10726. t['idieresis'] = 0x00EF;
  10727. t['idieresisacute'] = 0x1E2F;
  10728. t['idieresiscyrillic'] = 0x04E5;
  10729. t['idotbelow'] = 0x1ECB;
  10730. t['iebrevecyrillic'] = 0x04D7;
  10731. t['iecyrillic'] = 0x0435;
  10732. t['ieungacirclekorean'] = 0x3275;
  10733. t['ieungaparenkorean'] = 0x3215;
  10734. t['ieungcirclekorean'] = 0x3267;
  10735. t['ieungkorean'] = 0x3147;
  10736. t['ieungparenkorean'] = 0x3207;
  10737. t['igrave'] = 0x00EC;
  10738. t['igujarati'] = 0x0A87;
  10739. t['igurmukhi'] = 0x0A07;
  10740. t['ihiragana'] = 0x3044;
  10741. t['ihookabove'] = 0x1EC9;
  10742. t['iibengali'] = 0x0988;
  10743. t['iicyrillic'] = 0x0438;
  10744. t['iideva'] = 0x0908;
  10745. t['iigujarati'] = 0x0A88;
  10746. t['iigurmukhi'] = 0x0A08;
  10747. t['iimatragurmukhi'] = 0x0A40;
  10748. t['iinvertedbreve'] = 0x020B;
  10749. t['iishortcyrillic'] = 0x0439;
  10750. t['iivowelsignbengali'] = 0x09C0;
  10751. t['iivowelsigndeva'] = 0x0940;
  10752. t['iivowelsigngujarati'] = 0x0AC0;
  10753. t['ij'] = 0x0133;
  10754. t['ikatakana'] = 0x30A4;
  10755. t['ikatakanahalfwidth'] = 0xFF72;
  10756. t['ikorean'] = 0x3163;
  10757. t['ilde'] = 0x02DC;
  10758. t['iluyhebrew'] = 0x05AC;
  10759. t['imacron'] = 0x012B;
  10760. t['imacroncyrillic'] = 0x04E3;
  10761. t['imageorapproximatelyequal'] = 0x2253;
  10762. t['imatragurmukhi'] = 0x0A3F;
  10763. t['imonospace'] = 0xFF49;
  10764. t['increment'] = 0x2206;
  10765. t['infinity'] = 0x221E;
  10766. t['iniarmenian'] = 0x056B;
  10767. t['integral'] = 0x222B;
  10768. t['integralbottom'] = 0x2321;
  10769. t['integralbt'] = 0x2321;
  10770. t['integralex'] = 0xF8F5;
  10771. t['integraltop'] = 0x2320;
  10772. t['integraltp'] = 0x2320;
  10773. t['intersection'] = 0x2229;
  10774. t['intisquare'] = 0x3305;
  10775. t['invbullet'] = 0x25D8;
  10776. t['invcircle'] = 0x25D9;
  10777. t['invsmileface'] = 0x263B;
  10778. t['iocyrillic'] = 0x0451;
  10779. t['iogonek'] = 0x012F;
  10780. t['iota'] = 0x03B9;
  10781. t['iotadieresis'] = 0x03CA;
  10782. t['iotadieresistonos'] = 0x0390;
  10783. t['iotalatin'] = 0x0269;
  10784. t['iotatonos'] = 0x03AF;
  10785. t['iparen'] = 0x24A4;
  10786. t['irigurmukhi'] = 0x0A72;
  10787. t['ismallhiragana'] = 0x3043;
  10788. t['ismallkatakana'] = 0x30A3;
  10789. t['ismallkatakanahalfwidth'] = 0xFF68;
  10790. t['issharbengali'] = 0x09FA;
  10791. t['istroke'] = 0x0268;
  10792. t['isuperior'] = 0xF6ED;
  10793. t['iterationhiragana'] = 0x309D;
  10794. t['iterationkatakana'] = 0x30FD;
  10795. t['itilde'] = 0x0129;
  10796. t['itildebelow'] = 0x1E2D;
  10797. t['iubopomofo'] = 0x3129;
  10798. t['iucyrillic'] = 0x044E;
  10799. t['ivowelsignbengali'] = 0x09BF;
  10800. t['ivowelsigndeva'] = 0x093F;
  10801. t['ivowelsigngujarati'] = 0x0ABF;
  10802. t['izhitsacyrillic'] = 0x0475;
  10803. t['izhitsadblgravecyrillic'] = 0x0477;
  10804. t['j'] = 0x006A;
  10805. t['jaarmenian'] = 0x0571;
  10806. t['jabengali'] = 0x099C;
  10807. t['jadeva'] = 0x091C;
  10808. t['jagujarati'] = 0x0A9C;
  10809. t['jagurmukhi'] = 0x0A1C;
  10810. t['jbopomofo'] = 0x3110;
  10811. t['jcaron'] = 0x01F0;
  10812. t['jcircle'] = 0x24D9;
  10813. t['jcircumflex'] = 0x0135;
  10814. t['jcrossedtail'] = 0x029D;
  10815. t['jdotlessstroke'] = 0x025F;
  10816. t['jecyrillic'] = 0x0458;
  10817. t['jeemarabic'] = 0x062C;
  10818. t['jeemfinalarabic'] = 0xFE9E;
  10819. t['jeeminitialarabic'] = 0xFE9F;
  10820. t['jeemmedialarabic'] = 0xFEA0;
  10821. t['jeharabic'] = 0x0698;
  10822. t['jehfinalarabic'] = 0xFB8B;
  10823. t['jhabengali'] = 0x099D;
  10824. t['jhadeva'] = 0x091D;
  10825. t['jhagujarati'] = 0x0A9D;
  10826. t['jhagurmukhi'] = 0x0A1D;
  10827. t['jheharmenian'] = 0x057B;
  10828. t['jis'] = 0x3004;
  10829. t['jmonospace'] = 0xFF4A;
  10830. t['jparen'] = 0x24A5;
  10831. t['jsuperior'] = 0x02B2;
  10832. t['k'] = 0x006B;
  10833. t['kabashkircyrillic'] = 0x04A1;
  10834. t['kabengali'] = 0x0995;
  10835. t['kacute'] = 0x1E31;
  10836. t['kacyrillic'] = 0x043A;
  10837. t['kadescendercyrillic'] = 0x049B;
  10838. t['kadeva'] = 0x0915;
  10839. t['kaf'] = 0x05DB;
  10840. t['kafarabic'] = 0x0643;
  10841. t['kafdagesh'] = 0xFB3B;
  10842. t['kafdageshhebrew'] = 0xFB3B;
  10843. t['kaffinalarabic'] = 0xFEDA;
  10844. t['kafhebrew'] = 0x05DB;
  10845. t['kafinitialarabic'] = 0xFEDB;
  10846. t['kafmedialarabic'] = 0xFEDC;
  10847. t['kafrafehebrew'] = 0xFB4D;
  10848. t['kagujarati'] = 0x0A95;
  10849. t['kagurmukhi'] = 0x0A15;
  10850. t['kahiragana'] = 0x304B;
  10851. t['kahookcyrillic'] = 0x04C4;
  10852. t['kakatakana'] = 0x30AB;
  10853. t['kakatakanahalfwidth'] = 0xFF76;
  10854. t['kappa'] = 0x03BA;
  10855. t['kappasymbolgreek'] = 0x03F0;
  10856. t['kapyeounmieumkorean'] = 0x3171;
  10857. t['kapyeounphieuphkorean'] = 0x3184;
  10858. t['kapyeounpieupkorean'] = 0x3178;
  10859. t['kapyeounssangpieupkorean'] = 0x3179;
  10860. t['karoriisquare'] = 0x330D;
  10861. t['kashidaautoarabic'] = 0x0640;
  10862. t['kashidaautonosidebearingarabic'] = 0x0640;
  10863. t['kasmallkatakana'] = 0x30F5;
  10864. t['kasquare'] = 0x3384;
  10865. t['kasraarabic'] = 0x0650;
  10866. t['kasratanarabic'] = 0x064D;
  10867. t['kastrokecyrillic'] = 0x049F;
  10868. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10869. t['kaverticalstrokecyrillic'] = 0x049D;
  10870. t['kbopomofo'] = 0x310E;
  10871. t['kcalsquare'] = 0x3389;
  10872. t['kcaron'] = 0x01E9;
  10873. t['kcedilla'] = 0x0137;
  10874. t['kcircle'] = 0x24DA;
  10875. t['kcommaaccent'] = 0x0137;
  10876. t['kdotbelow'] = 0x1E33;
  10877. t['keharmenian'] = 0x0584;
  10878. t['kehiragana'] = 0x3051;
  10879. t['kekatakana'] = 0x30B1;
  10880. t['kekatakanahalfwidth'] = 0xFF79;
  10881. t['kenarmenian'] = 0x056F;
  10882. t['kesmallkatakana'] = 0x30F6;
  10883. t['kgreenlandic'] = 0x0138;
  10884. t['khabengali'] = 0x0996;
  10885. t['khacyrillic'] = 0x0445;
  10886. t['khadeva'] = 0x0916;
  10887. t['khagujarati'] = 0x0A96;
  10888. t['khagurmukhi'] = 0x0A16;
  10889. t['khaharabic'] = 0x062E;
  10890. t['khahfinalarabic'] = 0xFEA6;
  10891. t['khahinitialarabic'] = 0xFEA7;
  10892. t['khahmedialarabic'] = 0xFEA8;
  10893. t['kheicoptic'] = 0x03E7;
  10894. t['khhadeva'] = 0x0959;
  10895. t['khhagurmukhi'] = 0x0A59;
  10896. t['khieukhacirclekorean'] = 0x3278;
  10897. t['khieukhaparenkorean'] = 0x3218;
  10898. t['khieukhcirclekorean'] = 0x326A;
  10899. t['khieukhkorean'] = 0x314B;
  10900. t['khieukhparenkorean'] = 0x320A;
  10901. t['khokhaithai'] = 0x0E02;
  10902. t['khokhonthai'] = 0x0E05;
  10903. t['khokhuatthai'] = 0x0E03;
  10904. t['khokhwaithai'] = 0x0E04;
  10905. t['khomutthai'] = 0x0E5B;
  10906. t['khook'] = 0x0199;
  10907. t['khorakhangthai'] = 0x0E06;
  10908. t['khzsquare'] = 0x3391;
  10909. t['kihiragana'] = 0x304D;
  10910. t['kikatakana'] = 0x30AD;
  10911. t['kikatakanahalfwidth'] = 0xFF77;
  10912. t['kiroguramusquare'] = 0x3315;
  10913. t['kiromeetorusquare'] = 0x3316;
  10914. t['kirosquare'] = 0x3314;
  10915. t['kiyeokacirclekorean'] = 0x326E;
  10916. t['kiyeokaparenkorean'] = 0x320E;
  10917. t['kiyeokcirclekorean'] = 0x3260;
  10918. t['kiyeokkorean'] = 0x3131;
  10919. t['kiyeokparenkorean'] = 0x3200;
  10920. t['kiyeoksioskorean'] = 0x3133;
  10921. t['kjecyrillic'] = 0x045C;
  10922. t['klinebelow'] = 0x1E35;
  10923. t['klsquare'] = 0x3398;
  10924. t['kmcubedsquare'] = 0x33A6;
  10925. t['kmonospace'] = 0xFF4B;
  10926. t['kmsquaredsquare'] = 0x33A2;
  10927. t['kohiragana'] = 0x3053;
  10928. t['kohmsquare'] = 0x33C0;
  10929. t['kokaithai'] = 0x0E01;
  10930. t['kokatakana'] = 0x30B3;
  10931. t['kokatakanahalfwidth'] = 0xFF7A;
  10932. t['kooposquare'] = 0x331E;
  10933. t['koppacyrillic'] = 0x0481;
  10934. t['koreanstandardsymbol'] = 0x327F;
  10935. t['koroniscmb'] = 0x0343;
  10936. t['kparen'] = 0x24A6;
  10937. t['kpasquare'] = 0x33AA;
  10938. t['ksicyrillic'] = 0x046F;
  10939. t['ktsquare'] = 0x33CF;
  10940. t['kturned'] = 0x029E;
  10941. t['kuhiragana'] = 0x304F;
  10942. t['kukatakana'] = 0x30AF;
  10943. t['kukatakanahalfwidth'] = 0xFF78;
  10944. t['kvsquare'] = 0x33B8;
  10945. t['kwsquare'] = 0x33BE;
  10946. t['l'] = 0x006C;
  10947. t['labengali'] = 0x09B2;
  10948. t['lacute'] = 0x013A;
  10949. t['ladeva'] = 0x0932;
  10950. t['lagujarati'] = 0x0AB2;
  10951. t['lagurmukhi'] = 0x0A32;
  10952. t['lakkhangyaothai'] = 0x0E45;
  10953. t['lamaleffinalarabic'] = 0xFEFC;
  10954. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10955. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10956. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10957. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10958. t['lamalefisolatedarabic'] = 0xFEFB;
  10959. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10960. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10961. t['lamarabic'] = 0x0644;
  10962. t['lambda'] = 0x03BB;
  10963. t['lambdastroke'] = 0x019B;
  10964. t['lamed'] = 0x05DC;
  10965. t['lameddagesh'] = 0xFB3C;
  10966. t['lameddageshhebrew'] = 0xFB3C;
  10967. t['lamedhebrew'] = 0x05DC;
  10968. t['lamfinalarabic'] = 0xFEDE;
  10969. t['lamhahinitialarabic'] = 0xFCCA;
  10970. t['laminitialarabic'] = 0xFEDF;
  10971. t['lamjeeminitialarabic'] = 0xFCC9;
  10972. t['lamkhahinitialarabic'] = 0xFCCB;
  10973. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10974. t['lammedialarabic'] = 0xFEE0;
  10975. t['lammeemhahinitialarabic'] = 0xFD88;
  10976. t['lammeeminitialarabic'] = 0xFCCC;
  10977. t['largecircle'] = 0x25EF;
  10978. t['lbar'] = 0x019A;
  10979. t['lbelt'] = 0x026C;
  10980. t['lbopomofo'] = 0x310C;
  10981. t['lcaron'] = 0x013E;
  10982. t['lcedilla'] = 0x013C;
  10983. t['lcircle'] = 0x24DB;
  10984. t['lcircumflexbelow'] = 0x1E3D;
  10985. t['lcommaaccent'] = 0x013C;
  10986. t['ldot'] = 0x0140;
  10987. t['ldotaccent'] = 0x0140;
  10988. t['ldotbelow'] = 0x1E37;
  10989. t['ldotbelowmacron'] = 0x1E39;
  10990. t['leftangleabovecmb'] = 0x031A;
  10991. t['lefttackbelowcmb'] = 0x0318;
  10992. t['less'] = 0x003C;
  10993. t['lessequal'] = 0x2264;
  10994. t['lessequalorgreater'] = 0x22DA;
  10995. t['lessmonospace'] = 0xFF1C;
  10996. t['lessorequivalent'] = 0x2272;
  10997. t['lessorgreater'] = 0x2276;
  10998. t['lessoverequal'] = 0x2266;
  10999. t['lesssmall'] = 0xFE64;
  11000. t['lezh'] = 0x026E;
  11001. t['lfblock'] = 0x258C;
  11002. t['lhookretroflex'] = 0x026D;
  11003. t['lira'] = 0x20A4;
  11004. t['liwnarmenian'] = 0x056C;
  11005. t['lj'] = 0x01C9;
  11006. t['ljecyrillic'] = 0x0459;
  11007. t['ll'] = 0xF6C0;
  11008. t['lladeva'] = 0x0933;
  11009. t['llagujarati'] = 0x0AB3;
  11010. t['llinebelow'] = 0x1E3B;
  11011. t['llladeva'] = 0x0934;
  11012. t['llvocalicbengali'] = 0x09E1;
  11013. t['llvocalicdeva'] = 0x0961;
  11014. t['llvocalicvowelsignbengali'] = 0x09E3;
  11015. t['llvocalicvowelsigndeva'] = 0x0963;
  11016. t['lmiddletilde'] = 0x026B;
  11017. t['lmonospace'] = 0xFF4C;
  11018. t['lmsquare'] = 0x33D0;
  11019. t['lochulathai'] = 0x0E2C;
  11020. t['logicaland'] = 0x2227;
  11021. t['logicalnot'] = 0x00AC;
  11022. t['logicalnotreversed'] = 0x2310;
  11023. t['logicalor'] = 0x2228;
  11024. t['lolingthai'] = 0x0E25;
  11025. t['longs'] = 0x017F;
  11026. t['lowlinecenterline'] = 0xFE4E;
  11027. t['lowlinecmb'] = 0x0332;
  11028. t['lowlinedashed'] = 0xFE4D;
  11029. t['lozenge'] = 0x25CA;
  11030. t['lparen'] = 0x24A7;
  11031. t['lslash'] = 0x0142;
  11032. t['lsquare'] = 0x2113;
  11033. t['lsuperior'] = 0xF6EE;
  11034. t['ltshade'] = 0x2591;
  11035. t['luthai'] = 0x0E26;
  11036. t['lvocalicbengali'] = 0x098C;
  11037. t['lvocalicdeva'] = 0x090C;
  11038. t['lvocalicvowelsignbengali'] = 0x09E2;
  11039. t['lvocalicvowelsigndeva'] = 0x0962;
  11040. t['lxsquare'] = 0x33D3;
  11041. t['m'] = 0x006D;
  11042. t['mabengali'] = 0x09AE;
  11043. t['macron'] = 0x00AF;
  11044. t['macronbelowcmb'] = 0x0331;
  11045. t['macroncmb'] = 0x0304;
  11046. t['macronlowmod'] = 0x02CD;
  11047. t['macronmonospace'] = 0xFFE3;
  11048. t['macute'] = 0x1E3F;
  11049. t['madeva'] = 0x092E;
  11050. t['magujarati'] = 0x0AAE;
  11051. t['magurmukhi'] = 0x0A2E;
  11052. t['mahapakhhebrew'] = 0x05A4;
  11053. t['mahapakhlefthebrew'] = 0x05A4;
  11054. t['mahiragana'] = 0x307E;
  11055. t['maichattawalowleftthai'] = 0xF895;
  11056. t['maichattawalowrightthai'] = 0xF894;
  11057. t['maichattawathai'] = 0x0E4B;
  11058. t['maichattawaupperleftthai'] = 0xF893;
  11059. t['maieklowleftthai'] = 0xF88C;
  11060. t['maieklowrightthai'] = 0xF88B;
  11061. t['maiekthai'] = 0x0E48;
  11062. t['maiekupperleftthai'] = 0xF88A;
  11063. t['maihanakatleftthai'] = 0xF884;
  11064. t['maihanakatthai'] = 0x0E31;
  11065. t['maitaikhuleftthai'] = 0xF889;
  11066. t['maitaikhuthai'] = 0x0E47;
  11067. t['maitholowleftthai'] = 0xF88F;
  11068. t['maitholowrightthai'] = 0xF88E;
  11069. t['maithothai'] = 0x0E49;
  11070. t['maithoupperleftthai'] = 0xF88D;
  11071. t['maitrilowleftthai'] = 0xF892;
  11072. t['maitrilowrightthai'] = 0xF891;
  11073. t['maitrithai'] = 0x0E4A;
  11074. t['maitriupperleftthai'] = 0xF890;
  11075. t['maiyamokthai'] = 0x0E46;
  11076. t['makatakana'] = 0x30DE;
  11077. t['makatakanahalfwidth'] = 0xFF8F;
  11078. t['male'] = 0x2642;
  11079. t['mansyonsquare'] = 0x3347;
  11080. t['maqafhebrew'] = 0x05BE;
  11081. t['mars'] = 0x2642;
  11082. t['masoracirclehebrew'] = 0x05AF;
  11083. t['masquare'] = 0x3383;
  11084. t['mbopomofo'] = 0x3107;
  11085. t['mbsquare'] = 0x33D4;
  11086. t['mcircle'] = 0x24DC;
  11087. t['mcubedsquare'] = 0x33A5;
  11088. t['mdotaccent'] = 0x1E41;
  11089. t['mdotbelow'] = 0x1E43;
  11090. t['meemarabic'] = 0x0645;
  11091. t['meemfinalarabic'] = 0xFEE2;
  11092. t['meeminitialarabic'] = 0xFEE3;
  11093. t['meemmedialarabic'] = 0xFEE4;
  11094. t['meemmeeminitialarabic'] = 0xFCD1;
  11095. t['meemmeemisolatedarabic'] = 0xFC48;
  11096. t['meetorusquare'] = 0x334D;
  11097. t['mehiragana'] = 0x3081;
  11098. t['meizierasquare'] = 0x337E;
  11099. t['mekatakana'] = 0x30E1;
  11100. t['mekatakanahalfwidth'] = 0xFF92;
  11101. t['mem'] = 0x05DE;
  11102. t['memdagesh'] = 0xFB3E;
  11103. t['memdageshhebrew'] = 0xFB3E;
  11104. t['memhebrew'] = 0x05DE;
  11105. t['menarmenian'] = 0x0574;
  11106. t['merkhahebrew'] = 0x05A5;
  11107. t['merkhakefulahebrew'] = 0x05A6;
  11108. t['merkhakefulalefthebrew'] = 0x05A6;
  11109. t['merkhalefthebrew'] = 0x05A5;
  11110. t['mhook'] = 0x0271;
  11111. t['mhzsquare'] = 0x3392;
  11112. t['middledotkatakanahalfwidth'] = 0xFF65;
  11113. t['middot'] = 0x00B7;
  11114. t['mieumacirclekorean'] = 0x3272;
  11115. t['mieumaparenkorean'] = 0x3212;
  11116. t['mieumcirclekorean'] = 0x3264;
  11117. t['mieumkorean'] = 0x3141;
  11118. t['mieumpansioskorean'] = 0x3170;
  11119. t['mieumparenkorean'] = 0x3204;
  11120. t['mieumpieupkorean'] = 0x316E;
  11121. t['mieumsioskorean'] = 0x316F;
  11122. t['mihiragana'] = 0x307F;
  11123. t['mikatakana'] = 0x30DF;
  11124. t['mikatakanahalfwidth'] = 0xFF90;
  11125. t['minus'] = 0x2212;
  11126. t['minusbelowcmb'] = 0x0320;
  11127. t['minuscircle'] = 0x2296;
  11128. t['minusmod'] = 0x02D7;
  11129. t['minusplus'] = 0x2213;
  11130. t['minute'] = 0x2032;
  11131. t['miribaarusquare'] = 0x334A;
  11132. t['mirisquare'] = 0x3349;
  11133. t['mlonglegturned'] = 0x0270;
  11134. t['mlsquare'] = 0x3396;
  11135. t['mmcubedsquare'] = 0x33A3;
  11136. t['mmonospace'] = 0xFF4D;
  11137. t['mmsquaredsquare'] = 0x339F;
  11138. t['mohiragana'] = 0x3082;
  11139. t['mohmsquare'] = 0x33C1;
  11140. t['mokatakana'] = 0x30E2;
  11141. t['mokatakanahalfwidth'] = 0xFF93;
  11142. t['molsquare'] = 0x33D6;
  11143. t['momathai'] = 0x0E21;
  11144. t['moverssquare'] = 0x33A7;
  11145. t['moverssquaredsquare'] = 0x33A8;
  11146. t['mparen'] = 0x24A8;
  11147. t['mpasquare'] = 0x33AB;
  11148. t['mssquare'] = 0x33B3;
  11149. t['msuperior'] = 0xF6EF;
  11150. t['mturned'] = 0x026F;
  11151. t['mu'] = 0x00B5;
  11152. t['mu1'] = 0x00B5;
  11153. t['muasquare'] = 0x3382;
  11154. t['muchgreater'] = 0x226B;
  11155. t['muchless'] = 0x226A;
  11156. t['mufsquare'] = 0x338C;
  11157. t['mugreek'] = 0x03BC;
  11158. t['mugsquare'] = 0x338D;
  11159. t['muhiragana'] = 0x3080;
  11160. t['mukatakana'] = 0x30E0;
  11161. t['mukatakanahalfwidth'] = 0xFF91;
  11162. t['mulsquare'] = 0x3395;
  11163. t['multiply'] = 0x00D7;
  11164. t['mumsquare'] = 0x339B;
  11165. t['munahhebrew'] = 0x05A3;
  11166. t['munahlefthebrew'] = 0x05A3;
  11167. t['musicalnote'] = 0x266A;
  11168. t['musicalnotedbl'] = 0x266B;
  11169. t['musicflatsign'] = 0x266D;
  11170. t['musicsharpsign'] = 0x266F;
  11171. t['mussquare'] = 0x33B2;
  11172. t['muvsquare'] = 0x33B6;
  11173. t['muwsquare'] = 0x33BC;
  11174. t['mvmegasquare'] = 0x33B9;
  11175. t['mvsquare'] = 0x33B7;
  11176. t['mwmegasquare'] = 0x33BF;
  11177. t['mwsquare'] = 0x33BD;
  11178. t['n'] = 0x006E;
  11179. t['nabengali'] = 0x09A8;
  11180. t['nabla'] = 0x2207;
  11181. t['nacute'] = 0x0144;
  11182. t['nadeva'] = 0x0928;
  11183. t['nagujarati'] = 0x0AA8;
  11184. t['nagurmukhi'] = 0x0A28;
  11185. t['nahiragana'] = 0x306A;
  11186. t['nakatakana'] = 0x30CA;
  11187. t['nakatakanahalfwidth'] = 0xFF85;
  11188. t['napostrophe'] = 0x0149;
  11189. t['nasquare'] = 0x3381;
  11190. t['nbopomofo'] = 0x310B;
  11191. t['nbspace'] = 0x00A0;
  11192. t['ncaron'] = 0x0148;
  11193. t['ncedilla'] = 0x0146;
  11194. t['ncircle'] = 0x24DD;
  11195. t['ncircumflexbelow'] = 0x1E4B;
  11196. t['ncommaaccent'] = 0x0146;
  11197. t['ndotaccent'] = 0x1E45;
  11198. t['ndotbelow'] = 0x1E47;
  11199. t['nehiragana'] = 0x306D;
  11200. t['nekatakana'] = 0x30CD;
  11201. t['nekatakanahalfwidth'] = 0xFF88;
  11202. t['newsheqelsign'] = 0x20AA;
  11203. t['nfsquare'] = 0x338B;
  11204. t['ngabengali'] = 0x0999;
  11205. t['ngadeva'] = 0x0919;
  11206. t['ngagujarati'] = 0x0A99;
  11207. t['ngagurmukhi'] = 0x0A19;
  11208. t['ngonguthai'] = 0x0E07;
  11209. t['nhiragana'] = 0x3093;
  11210. t['nhookleft'] = 0x0272;
  11211. t['nhookretroflex'] = 0x0273;
  11212. t['nieunacirclekorean'] = 0x326F;
  11213. t['nieunaparenkorean'] = 0x320F;
  11214. t['nieuncieuckorean'] = 0x3135;
  11215. t['nieuncirclekorean'] = 0x3261;
  11216. t['nieunhieuhkorean'] = 0x3136;
  11217. t['nieunkorean'] = 0x3134;
  11218. t['nieunpansioskorean'] = 0x3168;
  11219. t['nieunparenkorean'] = 0x3201;
  11220. t['nieunsioskorean'] = 0x3167;
  11221. t['nieuntikeutkorean'] = 0x3166;
  11222. t['nihiragana'] = 0x306B;
  11223. t['nikatakana'] = 0x30CB;
  11224. t['nikatakanahalfwidth'] = 0xFF86;
  11225. t['nikhahitleftthai'] = 0xF899;
  11226. t['nikhahitthai'] = 0x0E4D;
  11227. t['nine'] = 0x0039;
  11228. t['ninearabic'] = 0x0669;
  11229. t['ninebengali'] = 0x09EF;
  11230. t['ninecircle'] = 0x2468;
  11231. t['ninecircleinversesansserif'] = 0x2792;
  11232. t['ninedeva'] = 0x096F;
  11233. t['ninegujarati'] = 0x0AEF;
  11234. t['ninegurmukhi'] = 0x0A6F;
  11235. t['ninehackarabic'] = 0x0669;
  11236. t['ninehangzhou'] = 0x3029;
  11237. t['nineideographicparen'] = 0x3228;
  11238. t['nineinferior'] = 0x2089;
  11239. t['ninemonospace'] = 0xFF19;
  11240. t['nineoldstyle'] = 0xF739;
  11241. t['nineparen'] = 0x247C;
  11242. t['nineperiod'] = 0x2490;
  11243. t['ninepersian'] = 0x06F9;
  11244. t['nineroman'] = 0x2178;
  11245. t['ninesuperior'] = 0x2079;
  11246. t['nineteencircle'] = 0x2472;
  11247. t['nineteenparen'] = 0x2486;
  11248. t['nineteenperiod'] = 0x249A;
  11249. t['ninethai'] = 0x0E59;
  11250. t['nj'] = 0x01CC;
  11251. t['njecyrillic'] = 0x045A;
  11252. t['nkatakana'] = 0x30F3;
  11253. t['nkatakanahalfwidth'] = 0xFF9D;
  11254. t['nlegrightlong'] = 0x019E;
  11255. t['nlinebelow'] = 0x1E49;
  11256. t['nmonospace'] = 0xFF4E;
  11257. t['nmsquare'] = 0x339A;
  11258. t['nnabengali'] = 0x09A3;
  11259. t['nnadeva'] = 0x0923;
  11260. t['nnagujarati'] = 0x0AA3;
  11261. t['nnagurmukhi'] = 0x0A23;
  11262. t['nnnadeva'] = 0x0929;
  11263. t['nohiragana'] = 0x306E;
  11264. t['nokatakana'] = 0x30CE;
  11265. t['nokatakanahalfwidth'] = 0xFF89;
  11266. t['nonbreakingspace'] = 0x00A0;
  11267. t['nonenthai'] = 0x0E13;
  11268. t['nonuthai'] = 0x0E19;
  11269. t['noonarabic'] = 0x0646;
  11270. t['noonfinalarabic'] = 0xFEE6;
  11271. t['noonghunnaarabic'] = 0x06BA;
  11272. t['noonghunnafinalarabic'] = 0xFB9F;
  11273. t['nooninitialarabic'] = 0xFEE7;
  11274. t['noonjeeminitialarabic'] = 0xFCD2;
  11275. t['noonjeemisolatedarabic'] = 0xFC4B;
  11276. t['noonmedialarabic'] = 0xFEE8;
  11277. t['noonmeeminitialarabic'] = 0xFCD5;
  11278. t['noonmeemisolatedarabic'] = 0xFC4E;
  11279. t['noonnoonfinalarabic'] = 0xFC8D;
  11280. t['notcontains'] = 0x220C;
  11281. t['notelement'] = 0x2209;
  11282. t['notelementof'] = 0x2209;
  11283. t['notequal'] = 0x2260;
  11284. t['notgreater'] = 0x226F;
  11285. t['notgreaternorequal'] = 0x2271;
  11286. t['notgreaternorless'] = 0x2279;
  11287. t['notidentical'] = 0x2262;
  11288. t['notless'] = 0x226E;
  11289. t['notlessnorequal'] = 0x2270;
  11290. t['notparallel'] = 0x2226;
  11291. t['notprecedes'] = 0x2280;
  11292. t['notsubset'] = 0x2284;
  11293. t['notsucceeds'] = 0x2281;
  11294. t['notsuperset'] = 0x2285;
  11295. t['nowarmenian'] = 0x0576;
  11296. t['nparen'] = 0x24A9;
  11297. t['nssquare'] = 0x33B1;
  11298. t['nsuperior'] = 0x207F;
  11299. t['ntilde'] = 0x00F1;
  11300. t['nu'] = 0x03BD;
  11301. t['nuhiragana'] = 0x306C;
  11302. t['nukatakana'] = 0x30CC;
  11303. t['nukatakanahalfwidth'] = 0xFF87;
  11304. t['nuktabengali'] = 0x09BC;
  11305. t['nuktadeva'] = 0x093C;
  11306. t['nuktagujarati'] = 0x0ABC;
  11307. t['nuktagurmukhi'] = 0x0A3C;
  11308. t['numbersign'] = 0x0023;
  11309. t['numbersignmonospace'] = 0xFF03;
  11310. t['numbersignsmall'] = 0xFE5F;
  11311. t['numeralsigngreek'] = 0x0374;
  11312. t['numeralsignlowergreek'] = 0x0375;
  11313. t['numero'] = 0x2116;
  11314. t['nun'] = 0x05E0;
  11315. t['nundagesh'] = 0xFB40;
  11316. t['nundageshhebrew'] = 0xFB40;
  11317. t['nunhebrew'] = 0x05E0;
  11318. t['nvsquare'] = 0x33B5;
  11319. t['nwsquare'] = 0x33BB;
  11320. t['nyabengali'] = 0x099E;
  11321. t['nyadeva'] = 0x091E;
  11322. t['nyagujarati'] = 0x0A9E;
  11323. t['nyagurmukhi'] = 0x0A1E;
  11324. t['o'] = 0x006F;
  11325. t['oacute'] = 0x00F3;
  11326. t['oangthai'] = 0x0E2D;
  11327. t['obarred'] = 0x0275;
  11328. t['obarredcyrillic'] = 0x04E9;
  11329. t['obarreddieresiscyrillic'] = 0x04EB;
  11330. t['obengali'] = 0x0993;
  11331. t['obopomofo'] = 0x311B;
  11332. t['obreve'] = 0x014F;
  11333. t['ocandradeva'] = 0x0911;
  11334. t['ocandragujarati'] = 0x0A91;
  11335. t['ocandravowelsigndeva'] = 0x0949;
  11336. t['ocandravowelsigngujarati'] = 0x0AC9;
  11337. t['ocaron'] = 0x01D2;
  11338. t['ocircle'] = 0x24DE;
  11339. t['ocircumflex'] = 0x00F4;
  11340. t['ocircumflexacute'] = 0x1ED1;
  11341. t['ocircumflexdotbelow'] = 0x1ED9;
  11342. t['ocircumflexgrave'] = 0x1ED3;
  11343. t['ocircumflexhookabove'] = 0x1ED5;
  11344. t['ocircumflextilde'] = 0x1ED7;
  11345. t['ocyrillic'] = 0x043E;
  11346. t['odblacute'] = 0x0151;
  11347. t['odblgrave'] = 0x020D;
  11348. t['odeva'] = 0x0913;
  11349. t['odieresis'] = 0x00F6;
  11350. t['odieresiscyrillic'] = 0x04E7;
  11351. t['odotbelow'] = 0x1ECD;
  11352. t['oe'] = 0x0153;
  11353. t['oekorean'] = 0x315A;
  11354. t['ogonek'] = 0x02DB;
  11355. t['ogonekcmb'] = 0x0328;
  11356. t['ograve'] = 0x00F2;
  11357. t['ogujarati'] = 0x0A93;
  11358. t['oharmenian'] = 0x0585;
  11359. t['ohiragana'] = 0x304A;
  11360. t['ohookabove'] = 0x1ECF;
  11361. t['ohorn'] = 0x01A1;
  11362. t['ohornacute'] = 0x1EDB;
  11363. t['ohorndotbelow'] = 0x1EE3;
  11364. t['ohorngrave'] = 0x1EDD;
  11365. t['ohornhookabove'] = 0x1EDF;
  11366. t['ohorntilde'] = 0x1EE1;
  11367. t['ohungarumlaut'] = 0x0151;
  11368. t['oi'] = 0x01A3;
  11369. t['oinvertedbreve'] = 0x020F;
  11370. t['okatakana'] = 0x30AA;
  11371. t['okatakanahalfwidth'] = 0xFF75;
  11372. t['okorean'] = 0x3157;
  11373. t['olehebrew'] = 0x05AB;
  11374. t['omacron'] = 0x014D;
  11375. t['omacronacute'] = 0x1E53;
  11376. t['omacrongrave'] = 0x1E51;
  11377. t['omdeva'] = 0x0950;
  11378. t['omega'] = 0x03C9;
  11379. t['omega1'] = 0x03D6;
  11380. t['omegacyrillic'] = 0x0461;
  11381. t['omegalatinclosed'] = 0x0277;
  11382. t['omegaroundcyrillic'] = 0x047B;
  11383. t['omegatitlocyrillic'] = 0x047D;
  11384. t['omegatonos'] = 0x03CE;
  11385. t['omgujarati'] = 0x0AD0;
  11386. t['omicron'] = 0x03BF;
  11387. t['omicrontonos'] = 0x03CC;
  11388. t['omonospace'] = 0xFF4F;
  11389. t['one'] = 0x0031;
  11390. t['onearabic'] = 0x0661;
  11391. t['onebengali'] = 0x09E7;
  11392. t['onecircle'] = 0x2460;
  11393. t['onecircleinversesansserif'] = 0x278A;
  11394. t['onedeva'] = 0x0967;
  11395. t['onedotenleader'] = 0x2024;
  11396. t['oneeighth'] = 0x215B;
  11397. t['onefitted'] = 0xF6DC;
  11398. t['onegujarati'] = 0x0AE7;
  11399. t['onegurmukhi'] = 0x0A67;
  11400. t['onehackarabic'] = 0x0661;
  11401. t['onehalf'] = 0x00BD;
  11402. t['onehangzhou'] = 0x3021;
  11403. t['oneideographicparen'] = 0x3220;
  11404. t['oneinferior'] = 0x2081;
  11405. t['onemonospace'] = 0xFF11;
  11406. t['onenumeratorbengali'] = 0x09F4;
  11407. t['oneoldstyle'] = 0xF731;
  11408. t['oneparen'] = 0x2474;
  11409. t['oneperiod'] = 0x2488;
  11410. t['onepersian'] = 0x06F1;
  11411. t['onequarter'] = 0x00BC;
  11412. t['oneroman'] = 0x2170;
  11413. t['onesuperior'] = 0x00B9;
  11414. t['onethai'] = 0x0E51;
  11415. t['onethird'] = 0x2153;
  11416. t['oogonek'] = 0x01EB;
  11417. t['oogonekmacron'] = 0x01ED;
  11418. t['oogurmukhi'] = 0x0A13;
  11419. t['oomatragurmukhi'] = 0x0A4B;
  11420. t['oopen'] = 0x0254;
  11421. t['oparen'] = 0x24AA;
  11422. t['openbullet'] = 0x25E6;
  11423. t['option'] = 0x2325;
  11424. t['ordfeminine'] = 0x00AA;
  11425. t['ordmasculine'] = 0x00BA;
  11426. t['orthogonal'] = 0x221F;
  11427. t['oshortdeva'] = 0x0912;
  11428. t['oshortvowelsigndeva'] = 0x094A;
  11429. t['oslash'] = 0x00F8;
  11430. t['oslashacute'] = 0x01FF;
  11431. t['osmallhiragana'] = 0x3049;
  11432. t['osmallkatakana'] = 0x30A9;
  11433. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11434. t['ostrokeacute'] = 0x01FF;
  11435. t['osuperior'] = 0xF6F0;
  11436. t['otcyrillic'] = 0x047F;
  11437. t['otilde'] = 0x00F5;
  11438. t['otildeacute'] = 0x1E4D;
  11439. t['otildedieresis'] = 0x1E4F;
  11440. t['oubopomofo'] = 0x3121;
  11441. t['overline'] = 0x203E;
  11442. t['overlinecenterline'] = 0xFE4A;
  11443. t['overlinecmb'] = 0x0305;
  11444. t['overlinedashed'] = 0xFE49;
  11445. t['overlinedblwavy'] = 0xFE4C;
  11446. t['overlinewavy'] = 0xFE4B;
  11447. t['overscore'] = 0x00AF;
  11448. t['ovowelsignbengali'] = 0x09CB;
  11449. t['ovowelsigndeva'] = 0x094B;
  11450. t['ovowelsigngujarati'] = 0x0ACB;
  11451. t['p'] = 0x0070;
  11452. t['paampssquare'] = 0x3380;
  11453. t['paasentosquare'] = 0x332B;
  11454. t['pabengali'] = 0x09AA;
  11455. t['pacute'] = 0x1E55;
  11456. t['padeva'] = 0x092A;
  11457. t['pagedown'] = 0x21DF;
  11458. t['pageup'] = 0x21DE;
  11459. t['pagujarati'] = 0x0AAA;
  11460. t['pagurmukhi'] = 0x0A2A;
  11461. t['pahiragana'] = 0x3071;
  11462. t['paiyannoithai'] = 0x0E2F;
  11463. t['pakatakana'] = 0x30D1;
  11464. t['palatalizationcyrilliccmb'] = 0x0484;
  11465. t['palochkacyrillic'] = 0x04C0;
  11466. t['pansioskorean'] = 0x317F;
  11467. t['paragraph'] = 0x00B6;
  11468. t['parallel'] = 0x2225;
  11469. t['parenleft'] = 0x0028;
  11470. t['parenleftaltonearabic'] = 0xFD3E;
  11471. t['parenleftbt'] = 0xF8ED;
  11472. t['parenleftex'] = 0xF8EC;
  11473. t['parenleftinferior'] = 0x208D;
  11474. t['parenleftmonospace'] = 0xFF08;
  11475. t['parenleftsmall'] = 0xFE59;
  11476. t['parenleftsuperior'] = 0x207D;
  11477. t['parenlefttp'] = 0xF8EB;
  11478. t['parenleftvertical'] = 0xFE35;
  11479. t['parenright'] = 0x0029;
  11480. t['parenrightaltonearabic'] = 0xFD3F;
  11481. t['parenrightbt'] = 0xF8F8;
  11482. t['parenrightex'] = 0xF8F7;
  11483. t['parenrightinferior'] = 0x208E;
  11484. t['parenrightmonospace'] = 0xFF09;
  11485. t['parenrightsmall'] = 0xFE5A;
  11486. t['parenrightsuperior'] = 0x207E;
  11487. t['parenrighttp'] = 0xF8F6;
  11488. t['parenrightvertical'] = 0xFE36;
  11489. t['partialdiff'] = 0x2202;
  11490. t['paseqhebrew'] = 0x05C0;
  11491. t['pashtahebrew'] = 0x0599;
  11492. t['pasquare'] = 0x33A9;
  11493. t['patah'] = 0x05B7;
  11494. t['patah11'] = 0x05B7;
  11495. t['patah1d'] = 0x05B7;
  11496. t['patah2a'] = 0x05B7;
  11497. t['patahhebrew'] = 0x05B7;
  11498. t['patahnarrowhebrew'] = 0x05B7;
  11499. t['patahquarterhebrew'] = 0x05B7;
  11500. t['patahwidehebrew'] = 0x05B7;
  11501. t['pazerhebrew'] = 0x05A1;
  11502. t['pbopomofo'] = 0x3106;
  11503. t['pcircle'] = 0x24DF;
  11504. t['pdotaccent'] = 0x1E57;
  11505. t['pe'] = 0x05E4;
  11506. t['pecyrillic'] = 0x043F;
  11507. t['pedagesh'] = 0xFB44;
  11508. t['pedageshhebrew'] = 0xFB44;
  11509. t['peezisquare'] = 0x333B;
  11510. t['pefinaldageshhebrew'] = 0xFB43;
  11511. t['peharabic'] = 0x067E;
  11512. t['peharmenian'] = 0x057A;
  11513. t['pehebrew'] = 0x05E4;
  11514. t['pehfinalarabic'] = 0xFB57;
  11515. t['pehinitialarabic'] = 0xFB58;
  11516. t['pehiragana'] = 0x307A;
  11517. t['pehmedialarabic'] = 0xFB59;
  11518. t['pekatakana'] = 0x30DA;
  11519. t['pemiddlehookcyrillic'] = 0x04A7;
  11520. t['perafehebrew'] = 0xFB4E;
  11521. t['percent'] = 0x0025;
  11522. t['percentarabic'] = 0x066A;
  11523. t['percentmonospace'] = 0xFF05;
  11524. t['percentsmall'] = 0xFE6A;
  11525. t['period'] = 0x002E;
  11526. t['periodarmenian'] = 0x0589;
  11527. t['periodcentered'] = 0x00B7;
  11528. t['periodhalfwidth'] = 0xFF61;
  11529. t['periodinferior'] = 0xF6E7;
  11530. t['periodmonospace'] = 0xFF0E;
  11531. t['periodsmall'] = 0xFE52;
  11532. t['periodsuperior'] = 0xF6E8;
  11533. t['perispomenigreekcmb'] = 0x0342;
  11534. t['perpendicular'] = 0x22A5;
  11535. t['perthousand'] = 0x2030;
  11536. t['peseta'] = 0x20A7;
  11537. t['pfsquare'] = 0x338A;
  11538. t['phabengali'] = 0x09AB;
  11539. t['phadeva'] = 0x092B;
  11540. t['phagujarati'] = 0x0AAB;
  11541. t['phagurmukhi'] = 0x0A2B;
  11542. t['phi'] = 0x03C6;
  11543. t['phi1'] = 0x03D5;
  11544. t['phieuphacirclekorean'] = 0x327A;
  11545. t['phieuphaparenkorean'] = 0x321A;
  11546. t['phieuphcirclekorean'] = 0x326C;
  11547. t['phieuphkorean'] = 0x314D;
  11548. t['phieuphparenkorean'] = 0x320C;
  11549. t['philatin'] = 0x0278;
  11550. t['phinthuthai'] = 0x0E3A;
  11551. t['phisymbolgreek'] = 0x03D5;
  11552. t['phook'] = 0x01A5;
  11553. t['phophanthai'] = 0x0E1E;
  11554. t['phophungthai'] = 0x0E1C;
  11555. t['phosamphaothai'] = 0x0E20;
  11556. t['pi'] = 0x03C0;
  11557. t['pieupacirclekorean'] = 0x3273;
  11558. t['pieupaparenkorean'] = 0x3213;
  11559. t['pieupcieuckorean'] = 0x3176;
  11560. t['pieupcirclekorean'] = 0x3265;
  11561. t['pieupkiyeokkorean'] = 0x3172;
  11562. t['pieupkorean'] = 0x3142;
  11563. t['pieupparenkorean'] = 0x3205;
  11564. t['pieupsioskiyeokkorean'] = 0x3174;
  11565. t['pieupsioskorean'] = 0x3144;
  11566. t['pieupsiostikeutkorean'] = 0x3175;
  11567. t['pieupthieuthkorean'] = 0x3177;
  11568. t['pieuptikeutkorean'] = 0x3173;
  11569. t['pihiragana'] = 0x3074;
  11570. t['pikatakana'] = 0x30D4;
  11571. t['pisymbolgreek'] = 0x03D6;
  11572. t['piwrarmenian'] = 0x0583;
  11573. t['plus'] = 0x002B;
  11574. t['plusbelowcmb'] = 0x031F;
  11575. t['pluscircle'] = 0x2295;
  11576. t['plusminus'] = 0x00B1;
  11577. t['plusmod'] = 0x02D6;
  11578. t['plusmonospace'] = 0xFF0B;
  11579. t['plussmall'] = 0xFE62;
  11580. t['plussuperior'] = 0x207A;
  11581. t['pmonospace'] = 0xFF50;
  11582. t['pmsquare'] = 0x33D8;
  11583. t['pohiragana'] = 0x307D;
  11584. t['pointingindexdownwhite'] = 0x261F;
  11585. t['pointingindexleftwhite'] = 0x261C;
  11586. t['pointingindexrightwhite'] = 0x261E;
  11587. t['pointingindexupwhite'] = 0x261D;
  11588. t['pokatakana'] = 0x30DD;
  11589. t['poplathai'] = 0x0E1B;
  11590. t['postalmark'] = 0x3012;
  11591. t['postalmarkface'] = 0x3020;
  11592. t['pparen'] = 0x24AB;
  11593. t['precedes'] = 0x227A;
  11594. t['prescription'] = 0x211E;
  11595. t['primemod'] = 0x02B9;
  11596. t['primereversed'] = 0x2035;
  11597. t['product'] = 0x220F;
  11598. t['projective'] = 0x2305;
  11599. t['prolongedkana'] = 0x30FC;
  11600. t['propellor'] = 0x2318;
  11601. t['propersubset'] = 0x2282;
  11602. t['propersuperset'] = 0x2283;
  11603. t['proportion'] = 0x2237;
  11604. t['proportional'] = 0x221D;
  11605. t['psi'] = 0x03C8;
  11606. t['psicyrillic'] = 0x0471;
  11607. t['psilipneumatacyrilliccmb'] = 0x0486;
  11608. t['pssquare'] = 0x33B0;
  11609. t['puhiragana'] = 0x3077;
  11610. t['pukatakana'] = 0x30D7;
  11611. t['pvsquare'] = 0x33B4;
  11612. t['pwsquare'] = 0x33BA;
  11613. t['q'] = 0x0071;
  11614. t['qadeva'] = 0x0958;
  11615. t['qadmahebrew'] = 0x05A8;
  11616. t['qafarabic'] = 0x0642;
  11617. t['qaffinalarabic'] = 0xFED6;
  11618. t['qafinitialarabic'] = 0xFED7;
  11619. t['qafmedialarabic'] = 0xFED8;
  11620. t['qamats'] = 0x05B8;
  11621. t['qamats10'] = 0x05B8;
  11622. t['qamats1a'] = 0x05B8;
  11623. t['qamats1c'] = 0x05B8;
  11624. t['qamats27'] = 0x05B8;
  11625. t['qamats29'] = 0x05B8;
  11626. t['qamats33'] = 0x05B8;
  11627. t['qamatsde'] = 0x05B8;
  11628. t['qamatshebrew'] = 0x05B8;
  11629. t['qamatsnarrowhebrew'] = 0x05B8;
  11630. t['qamatsqatanhebrew'] = 0x05B8;
  11631. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11632. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11633. t['qamatsqatanwidehebrew'] = 0x05B8;
  11634. t['qamatsquarterhebrew'] = 0x05B8;
  11635. t['qamatswidehebrew'] = 0x05B8;
  11636. t['qarneyparahebrew'] = 0x059F;
  11637. t['qbopomofo'] = 0x3111;
  11638. t['qcircle'] = 0x24E0;
  11639. t['qhook'] = 0x02A0;
  11640. t['qmonospace'] = 0xFF51;
  11641. t['qof'] = 0x05E7;
  11642. t['qofdagesh'] = 0xFB47;
  11643. t['qofdageshhebrew'] = 0xFB47;
  11644. t['qofhebrew'] = 0x05E7;
  11645. t['qparen'] = 0x24AC;
  11646. t['quarternote'] = 0x2669;
  11647. t['qubuts'] = 0x05BB;
  11648. t['qubuts18'] = 0x05BB;
  11649. t['qubuts25'] = 0x05BB;
  11650. t['qubuts31'] = 0x05BB;
  11651. t['qubutshebrew'] = 0x05BB;
  11652. t['qubutsnarrowhebrew'] = 0x05BB;
  11653. t['qubutsquarterhebrew'] = 0x05BB;
  11654. t['qubutswidehebrew'] = 0x05BB;
  11655. t['question'] = 0x003F;
  11656. t['questionarabic'] = 0x061F;
  11657. t['questionarmenian'] = 0x055E;
  11658. t['questiondown'] = 0x00BF;
  11659. t['questiondownsmall'] = 0xF7BF;
  11660. t['questiongreek'] = 0x037E;
  11661. t['questionmonospace'] = 0xFF1F;
  11662. t['questionsmall'] = 0xF73F;
  11663. t['quotedbl'] = 0x0022;
  11664. t['quotedblbase'] = 0x201E;
  11665. t['quotedblleft'] = 0x201C;
  11666. t['quotedblmonospace'] = 0xFF02;
  11667. t['quotedblprime'] = 0x301E;
  11668. t['quotedblprimereversed'] = 0x301D;
  11669. t['quotedblright'] = 0x201D;
  11670. t['quoteleft'] = 0x2018;
  11671. t['quoteleftreversed'] = 0x201B;
  11672. t['quotereversed'] = 0x201B;
  11673. t['quoteright'] = 0x2019;
  11674. t['quoterightn'] = 0x0149;
  11675. t['quotesinglbase'] = 0x201A;
  11676. t['quotesingle'] = 0x0027;
  11677. t['quotesinglemonospace'] = 0xFF07;
  11678. t['r'] = 0x0072;
  11679. t['raarmenian'] = 0x057C;
  11680. t['rabengali'] = 0x09B0;
  11681. t['racute'] = 0x0155;
  11682. t['radeva'] = 0x0930;
  11683. t['radical'] = 0x221A;
  11684. t['radicalex'] = 0xF8E5;
  11685. t['radoverssquare'] = 0x33AE;
  11686. t['radoverssquaredsquare'] = 0x33AF;
  11687. t['radsquare'] = 0x33AD;
  11688. t['rafe'] = 0x05BF;
  11689. t['rafehebrew'] = 0x05BF;
  11690. t['ragujarati'] = 0x0AB0;
  11691. t['ragurmukhi'] = 0x0A30;
  11692. t['rahiragana'] = 0x3089;
  11693. t['rakatakana'] = 0x30E9;
  11694. t['rakatakanahalfwidth'] = 0xFF97;
  11695. t['ralowerdiagonalbengali'] = 0x09F1;
  11696. t['ramiddlediagonalbengali'] = 0x09F0;
  11697. t['ramshorn'] = 0x0264;
  11698. t['ratio'] = 0x2236;
  11699. t['rbopomofo'] = 0x3116;
  11700. t['rcaron'] = 0x0159;
  11701. t['rcedilla'] = 0x0157;
  11702. t['rcircle'] = 0x24E1;
  11703. t['rcommaaccent'] = 0x0157;
  11704. t['rdblgrave'] = 0x0211;
  11705. t['rdotaccent'] = 0x1E59;
  11706. t['rdotbelow'] = 0x1E5B;
  11707. t['rdotbelowmacron'] = 0x1E5D;
  11708. t['referencemark'] = 0x203B;
  11709. t['reflexsubset'] = 0x2286;
  11710. t['reflexsuperset'] = 0x2287;
  11711. t['registered'] = 0x00AE;
  11712. t['registersans'] = 0xF8E8;
  11713. t['registerserif'] = 0xF6DA;
  11714. t['reharabic'] = 0x0631;
  11715. t['reharmenian'] = 0x0580;
  11716. t['rehfinalarabic'] = 0xFEAE;
  11717. t['rehiragana'] = 0x308C;
  11718. t['rekatakana'] = 0x30EC;
  11719. t['rekatakanahalfwidth'] = 0xFF9A;
  11720. t['resh'] = 0x05E8;
  11721. t['reshdageshhebrew'] = 0xFB48;
  11722. t['reshhebrew'] = 0x05E8;
  11723. t['reversedtilde'] = 0x223D;
  11724. t['reviahebrew'] = 0x0597;
  11725. t['reviamugrashhebrew'] = 0x0597;
  11726. t['revlogicalnot'] = 0x2310;
  11727. t['rfishhook'] = 0x027E;
  11728. t['rfishhookreversed'] = 0x027F;
  11729. t['rhabengali'] = 0x09DD;
  11730. t['rhadeva'] = 0x095D;
  11731. t['rho'] = 0x03C1;
  11732. t['rhook'] = 0x027D;
  11733. t['rhookturned'] = 0x027B;
  11734. t['rhookturnedsuperior'] = 0x02B5;
  11735. t['rhosymbolgreek'] = 0x03F1;
  11736. t['rhotichookmod'] = 0x02DE;
  11737. t['rieulacirclekorean'] = 0x3271;
  11738. t['rieulaparenkorean'] = 0x3211;
  11739. t['rieulcirclekorean'] = 0x3263;
  11740. t['rieulhieuhkorean'] = 0x3140;
  11741. t['rieulkiyeokkorean'] = 0x313A;
  11742. t['rieulkiyeoksioskorean'] = 0x3169;
  11743. t['rieulkorean'] = 0x3139;
  11744. t['rieulmieumkorean'] = 0x313B;
  11745. t['rieulpansioskorean'] = 0x316C;
  11746. t['rieulparenkorean'] = 0x3203;
  11747. t['rieulphieuphkorean'] = 0x313F;
  11748. t['rieulpieupkorean'] = 0x313C;
  11749. t['rieulpieupsioskorean'] = 0x316B;
  11750. t['rieulsioskorean'] = 0x313D;
  11751. t['rieulthieuthkorean'] = 0x313E;
  11752. t['rieultikeutkorean'] = 0x316A;
  11753. t['rieulyeorinhieuhkorean'] = 0x316D;
  11754. t['rightangle'] = 0x221F;
  11755. t['righttackbelowcmb'] = 0x0319;
  11756. t['righttriangle'] = 0x22BF;
  11757. t['rihiragana'] = 0x308A;
  11758. t['rikatakana'] = 0x30EA;
  11759. t['rikatakanahalfwidth'] = 0xFF98;
  11760. t['ring'] = 0x02DA;
  11761. t['ringbelowcmb'] = 0x0325;
  11762. t['ringcmb'] = 0x030A;
  11763. t['ringhalfleft'] = 0x02BF;
  11764. t['ringhalfleftarmenian'] = 0x0559;
  11765. t['ringhalfleftbelowcmb'] = 0x031C;
  11766. t['ringhalfleftcentered'] = 0x02D3;
  11767. t['ringhalfright'] = 0x02BE;
  11768. t['ringhalfrightbelowcmb'] = 0x0339;
  11769. t['ringhalfrightcentered'] = 0x02D2;
  11770. t['rinvertedbreve'] = 0x0213;
  11771. t['rittorusquare'] = 0x3351;
  11772. t['rlinebelow'] = 0x1E5F;
  11773. t['rlongleg'] = 0x027C;
  11774. t['rlonglegturned'] = 0x027A;
  11775. t['rmonospace'] = 0xFF52;
  11776. t['rohiragana'] = 0x308D;
  11777. t['rokatakana'] = 0x30ED;
  11778. t['rokatakanahalfwidth'] = 0xFF9B;
  11779. t['roruathai'] = 0x0E23;
  11780. t['rparen'] = 0x24AD;
  11781. t['rrabengali'] = 0x09DC;
  11782. t['rradeva'] = 0x0931;
  11783. t['rragurmukhi'] = 0x0A5C;
  11784. t['rreharabic'] = 0x0691;
  11785. t['rrehfinalarabic'] = 0xFB8D;
  11786. t['rrvocalicbengali'] = 0x09E0;
  11787. t['rrvocalicdeva'] = 0x0960;
  11788. t['rrvocalicgujarati'] = 0x0AE0;
  11789. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11790. t['rrvocalicvowelsigndeva'] = 0x0944;
  11791. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11792. t['rsuperior'] = 0xF6F1;
  11793. t['rtblock'] = 0x2590;
  11794. t['rturned'] = 0x0279;
  11795. t['rturnedsuperior'] = 0x02B4;
  11796. t['ruhiragana'] = 0x308B;
  11797. t['rukatakana'] = 0x30EB;
  11798. t['rukatakanahalfwidth'] = 0xFF99;
  11799. t['rupeemarkbengali'] = 0x09F2;
  11800. t['rupeesignbengali'] = 0x09F3;
  11801. t['rupiah'] = 0xF6DD;
  11802. t['ruthai'] = 0x0E24;
  11803. t['rvocalicbengali'] = 0x098B;
  11804. t['rvocalicdeva'] = 0x090B;
  11805. t['rvocalicgujarati'] = 0x0A8B;
  11806. t['rvocalicvowelsignbengali'] = 0x09C3;
  11807. t['rvocalicvowelsigndeva'] = 0x0943;
  11808. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11809. t['s'] = 0x0073;
  11810. t['sabengali'] = 0x09B8;
  11811. t['sacute'] = 0x015B;
  11812. t['sacutedotaccent'] = 0x1E65;
  11813. t['sadarabic'] = 0x0635;
  11814. t['sadeva'] = 0x0938;
  11815. t['sadfinalarabic'] = 0xFEBA;
  11816. t['sadinitialarabic'] = 0xFEBB;
  11817. t['sadmedialarabic'] = 0xFEBC;
  11818. t['sagujarati'] = 0x0AB8;
  11819. t['sagurmukhi'] = 0x0A38;
  11820. t['sahiragana'] = 0x3055;
  11821. t['sakatakana'] = 0x30B5;
  11822. t['sakatakanahalfwidth'] = 0xFF7B;
  11823. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11824. t['samekh'] = 0x05E1;
  11825. t['samekhdagesh'] = 0xFB41;
  11826. t['samekhdageshhebrew'] = 0xFB41;
  11827. t['samekhhebrew'] = 0x05E1;
  11828. t['saraaathai'] = 0x0E32;
  11829. t['saraaethai'] = 0x0E41;
  11830. t['saraaimaimalaithai'] = 0x0E44;
  11831. t['saraaimaimuanthai'] = 0x0E43;
  11832. t['saraamthai'] = 0x0E33;
  11833. t['saraathai'] = 0x0E30;
  11834. t['saraethai'] = 0x0E40;
  11835. t['saraiileftthai'] = 0xF886;
  11836. t['saraiithai'] = 0x0E35;
  11837. t['saraileftthai'] = 0xF885;
  11838. t['saraithai'] = 0x0E34;
  11839. t['saraothai'] = 0x0E42;
  11840. t['saraueeleftthai'] = 0xF888;
  11841. t['saraueethai'] = 0x0E37;
  11842. t['saraueleftthai'] = 0xF887;
  11843. t['sarauethai'] = 0x0E36;
  11844. t['sarauthai'] = 0x0E38;
  11845. t['sarauuthai'] = 0x0E39;
  11846. t['sbopomofo'] = 0x3119;
  11847. t['scaron'] = 0x0161;
  11848. t['scarondotaccent'] = 0x1E67;
  11849. t['scedilla'] = 0x015F;
  11850. t['schwa'] = 0x0259;
  11851. t['schwacyrillic'] = 0x04D9;
  11852. t['schwadieresiscyrillic'] = 0x04DB;
  11853. t['schwahook'] = 0x025A;
  11854. t['scircle'] = 0x24E2;
  11855. t['scircumflex'] = 0x015D;
  11856. t['scommaaccent'] = 0x0219;
  11857. t['sdotaccent'] = 0x1E61;
  11858. t['sdotbelow'] = 0x1E63;
  11859. t['sdotbelowdotaccent'] = 0x1E69;
  11860. t['seagullbelowcmb'] = 0x033C;
  11861. t['second'] = 0x2033;
  11862. t['secondtonechinese'] = 0x02CA;
  11863. t['section'] = 0x00A7;
  11864. t['seenarabic'] = 0x0633;
  11865. t['seenfinalarabic'] = 0xFEB2;
  11866. t['seeninitialarabic'] = 0xFEB3;
  11867. t['seenmedialarabic'] = 0xFEB4;
  11868. t['segol'] = 0x05B6;
  11869. t['segol13'] = 0x05B6;
  11870. t['segol1f'] = 0x05B6;
  11871. t['segol2c'] = 0x05B6;
  11872. t['segolhebrew'] = 0x05B6;
  11873. t['segolnarrowhebrew'] = 0x05B6;
  11874. t['segolquarterhebrew'] = 0x05B6;
  11875. t['segoltahebrew'] = 0x0592;
  11876. t['segolwidehebrew'] = 0x05B6;
  11877. t['seharmenian'] = 0x057D;
  11878. t['sehiragana'] = 0x305B;
  11879. t['sekatakana'] = 0x30BB;
  11880. t['sekatakanahalfwidth'] = 0xFF7E;
  11881. t['semicolon'] = 0x003B;
  11882. t['semicolonarabic'] = 0x061B;
  11883. t['semicolonmonospace'] = 0xFF1B;
  11884. t['semicolonsmall'] = 0xFE54;
  11885. t['semivoicedmarkkana'] = 0x309C;
  11886. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11887. t['sentisquare'] = 0x3322;
  11888. t['sentosquare'] = 0x3323;
  11889. t['seven'] = 0x0037;
  11890. t['sevenarabic'] = 0x0667;
  11891. t['sevenbengali'] = 0x09ED;
  11892. t['sevencircle'] = 0x2466;
  11893. t['sevencircleinversesansserif'] = 0x2790;
  11894. t['sevendeva'] = 0x096D;
  11895. t['seveneighths'] = 0x215E;
  11896. t['sevengujarati'] = 0x0AED;
  11897. t['sevengurmukhi'] = 0x0A6D;
  11898. t['sevenhackarabic'] = 0x0667;
  11899. t['sevenhangzhou'] = 0x3027;
  11900. t['sevenideographicparen'] = 0x3226;
  11901. t['seveninferior'] = 0x2087;
  11902. t['sevenmonospace'] = 0xFF17;
  11903. t['sevenoldstyle'] = 0xF737;
  11904. t['sevenparen'] = 0x247A;
  11905. t['sevenperiod'] = 0x248E;
  11906. t['sevenpersian'] = 0x06F7;
  11907. t['sevenroman'] = 0x2176;
  11908. t['sevensuperior'] = 0x2077;
  11909. t['seventeencircle'] = 0x2470;
  11910. t['seventeenparen'] = 0x2484;
  11911. t['seventeenperiod'] = 0x2498;
  11912. t['seventhai'] = 0x0E57;
  11913. t['sfthyphen'] = 0x00AD;
  11914. t['shaarmenian'] = 0x0577;
  11915. t['shabengali'] = 0x09B6;
  11916. t['shacyrillic'] = 0x0448;
  11917. t['shaddaarabic'] = 0x0651;
  11918. t['shaddadammaarabic'] = 0xFC61;
  11919. t['shaddadammatanarabic'] = 0xFC5E;
  11920. t['shaddafathaarabic'] = 0xFC60;
  11921. t['shaddakasraarabic'] = 0xFC62;
  11922. t['shaddakasratanarabic'] = 0xFC5F;
  11923. t['shade'] = 0x2592;
  11924. t['shadedark'] = 0x2593;
  11925. t['shadelight'] = 0x2591;
  11926. t['shademedium'] = 0x2592;
  11927. t['shadeva'] = 0x0936;
  11928. t['shagujarati'] = 0x0AB6;
  11929. t['shagurmukhi'] = 0x0A36;
  11930. t['shalshelethebrew'] = 0x0593;
  11931. t['shbopomofo'] = 0x3115;
  11932. t['shchacyrillic'] = 0x0449;
  11933. t['sheenarabic'] = 0x0634;
  11934. t['sheenfinalarabic'] = 0xFEB6;
  11935. t['sheeninitialarabic'] = 0xFEB7;
  11936. t['sheenmedialarabic'] = 0xFEB8;
  11937. t['sheicoptic'] = 0x03E3;
  11938. t['sheqel'] = 0x20AA;
  11939. t['sheqelhebrew'] = 0x20AA;
  11940. t['sheva'] = 0x05B0;
  11941. t['sheva115'] = 0x05B0;
  11942. t['sheva15'] = 0x05B0;
  11943. t['sheva22'] = 0x05B0;
  11944. t['sheva2e'] = 0x05B0;
  11945. t['shevahebrew'] = 0x05B0;
  11946. t['shevanarrowhebrew'] = 0x05B0;
  11947. t['shevaquarterhebrew'] = 0x05B0;
  11948. t['shevawidehebrew'] = 0x05B0;
  11949. t['shhacyrillic'] = 0x04BB;
  11950. t['shimacoptic'] = 0x03ED;
  11951. t['shin'] = 0x05E9;
  11952. t['shindagesh'] = 0xFB49;
  11953. t['shindageshhebrew'] = 0xFB49;
  11954. t['shindageshshindot'] = 0xFB2C;
  11955. t['shindageshshindothebrew'] = 0xFB2C;
  11956. t['shindageshsindot'] = 0xFB2D;
  11957. t['shindageshsindothebrew'] = 0xFB2D;
  11958. t['shindothebrew'] = 0x05C1;
  11959. t['shinhebrew'] = 0x05E9;
  11960. t['shinshindot'] = 0xFB2A;
  11961. t['shinshindothebrew'] = 0xFB2A;
  11962. t['shinsindot'] = 0xFB2B;
  11963. t['shinsindothebrew'] = 0xFB2B;
  11964. t['shook'] = 0x0282;
  11965. t['sigma'] = 0x03C3;
  11966. t['sigma1'] = 0x03C2;
  11967. t['sigmafinal'] = 0x03C2;
  11968. t['sigmalunatesymbolgreek'] = 0x03F2;
  11969. t['sihiragana'] = 0x3057;
  11970. t['sikatakana'] = 0x30B7;
  11971. t['sikatakanahalfwidth'] = 0xFF7C;
  11972. t['siluqhebrew'] = 0x05BD;
  11973. t['siluqlefthebrew'] = 0x05BD;
  11974. t['similar'] = 0x223C;
  11975. t['sindothebrew'] = 0x05C2;
  11976. t['siosacirclekorean'] = 0x3274;
  11977. t['siosaparenkorean'] = 0x3214;
  11978. t['sioscieuckorean'] = 0x317E;
  11979. t['sioscirclekorean'] = 0x3266;
  11980. t['sioskiyeokkorean'] = 0x317A;
  11981. t['sioskorean'] = 0x3145;
  11982. t['siosnieunkorean'] = 0x317B;
  11983. t['siosparenkorean'] = 0x3206;
  11984. t['siospieupkorean'] = 0x317D;
  11985. t['siostikeutkorean'] = 0x317C;
  11986. t['six'] = 0x0036;
  11987. t['sixarabic'] = 0x0666;
  11988. t['sixbengali'] = 0x09EC;
  11989. t['sixcircle'] = 0x2465;
  11990. t['sixcircleinversesansserif'] = 0x278F;
  11991. t['sixdeva'] = 0x096C;
  11992. t['sixgujarati'] = 0x0AEC;
  11993. t['sixgurmukhi'] = 0x0A6C;
  11994. t['sixhackarabic'] = 0x0666;
  11995. t['sixhangzhou'] = 0x3026;
  11996. t['sixideographicparen'] = 0x3225;
  11997. t['sixinferior'] = 0x2086;
  11998. t['sixmonospace'] = 0xFF16;
  11999. t['sixoldstyle'] = 0xF736;
  12000. t['sixparen'] = 0x2479;
  12001. t['sixperiod'] = 0x248D;
  12002. t['sixpersian'] = 0x06F6;
  12003. t['sixroman'] = 0x2175;
  12004. t['sixsuperior'] = 0x2076;
  12005. t['sixteencircle'] = 0x246F;
  12006. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12007. t['sixteenparen'] = 0x2483;
  12008. t['sixteenperiod'] = 0x2497;
  12009. t['sixthai'] = 0x0E56;
  12010. t['slash'] = 0x002F;
  12011. t['slashmonospace'] = 0xFF0F;
  12012. t['slong'] = 0x017F;
  12013. t['slongdotaccent'] = 0x1E9B;
  12014. t['smileface'] = 0x263A;
  12015. t['smonospace'] = 0xFF53;
  12016. t['sofpasuqhebrew'] = 0x05C3;
  12017. t['softhyphen'] = 0x00AD;
  12018. t['softsigncyrillic'] = 0x044C;
  12019. t['sohiragana'] = 0x305D;
  12020. t['sokatakana'] = 0x30BD;
  12021. t['sokatakanahalfwidth'] = 0xFF7F;
  12022. t['soliduslongoverlaycmb'] = 0x0338;
  12023. t['solidusshortoverlaycmb'] = 0x0337;
  12024. t['sorusithai'] = 0x0E29;
  12025. t['sosalathai'] = 0x0E28;
  12026. t['sosothai'] = 0x0E0B;
  12027. t['sosuathai'] = 0x0E2A;
  12028. t['space'] = 0x0020;
  12029. t['spacehackarabic'] = 0x0020;
  12030. t['spade'] = 0x2660;
  12031. t['spadesuitblack'] = 0x2660;
  12032. t['spadesuitwhite'] = 0x2664;
  12033. t['sparen'] = 0x24AE;
  12034. t['squarebelowcmb'] = 0x033B;
  12035. t['squarecc'] = 0x33C4;
  12036. t['squarecm'] = 0x339D;
  12037. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12038. t['squarehorizontalfill'] = 0x25A4;
  12039. t['squarekg'] = 0x338F;
  12040. t['squarekm'] = 0x339E;
  12041. t['squarekmcapital'] = 0x33CE;
  12042. t['squareln'] = 0x33D1;
  12043. t['squarelog'] = 0x33D2;
  12044. t['squaremg'] = 0x338E;
  12045. t['squaremil'] = 0x33D5;
  12046. t['squaremm'] = 0x339C;
  12047. t['squaremsquared'] = 0x33A1;
  12048. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12049. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12050. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12051. t['squareverticalfill'] = 0x25A5;
  12052. t['squarewhitewithsmallblack'] = 0x25A3;
  12053. t['srsquare'] = 0x33DB;
  12054. t['ssabengali'] = 0x09B7;
  12055. t['ssadeva'] = 0x0937;
  12056. t['ssagujarati'] = 0x0AB7;
  12057. t['ssangcieuckorean'] = 0x3149;
  12058. t['ssanghieuhkorean'] = 0x3185;
  12059. t['ssangieungkorean'] = 0x3180;
  12060. t['ssangkiyeokkorean'] = 0x3132;
  12061. t['ssangnieunkorean'] = 0x3165;
  12062. t['ssangpieupkorean'] = 0x3143;
  12063. t['ssangsioskorean'] = 0x3146;
  12064. t['ssangtikeutkorean'] = 0x3138;
  12065. t['ssuperior'] = 0xF6F2;
  12066. t['sterling'] = 0x00A3;
  12067. t['sterlingmonospace'] = 0xFFE1;
  12068. t['strokelongoverlaycmb'] = 0x0336;
  12069. t['strokeshortoverlaycmb'] = 0x0335;
  12070. t['subset'] = 0x2282;
  12071. t['subsetnotequal'] = 0x228A;
  12072. t['subsetorequal'] = 0x2286;
  12073. t['succeeds'] = 0x227B;
  12074. t['suchthat'] = 0x220B;
  12075. t['suhiragana'] = 0x3059;
  12076. t['sukatakana'] = 0x30B9;
  12077. t['sukatakanahalfwidth'] = 0xFF7D;
  12078. t['sukunarabic'] = 0x0652;
  12079. t['summation'] = 0x2211;
  12080. t['sun'] = 0x263C;
  12081. t['superset'] = 0x2283;
  12082. t['supersetnotequal'] = 0x228B;
  12083. t['supersetorequal'] = 0x2287;
  12084. t['svsquare'] = 0x33DC;
  12085. t['syouwaerasquare'] = 0x337C;
  12086. t['t'] = 0x0074;
  12087. t['tabengali'] = 0x09A4;
  12088. t['tackdown'] = 0x22A4;
  12089. t['tackleft'] = 0x22A3;
  12090. t['tadeva'] = 0x0924;
  12091. t['tagujarati'] = 0x0AA4;
  12092. t['tagurmukhi'] = 0x0A24;
  12093. t['taharabic'] = 0x0637;
  12094. t['tahfinalarabic'] = 0xFEC2;
  12095. t['tahinitialarabic'] = 0xFEC3;
  12096. t['tahiragana'] = 0x305F;
  12097. t['tahmedialarabic'] = 0xFEC4;
  12098. t['taisyouerasquare'] = 0x337D;
  12099. t['takatakana'] = 0x30BF;
  12100. t['takatakanahalfwidth'] = 0xFF80;
  12101. t['tatweelarabic'] = 0x0640;
  12102. t['tau'] = 0x03C4;
  12103. t['tav'] = 0x05EA;
  12104. t['tavdages'] = 0xFB4A;
  12105. t['tavdagesh'] = 0xFB4A;
  12106. t['tavdageshhebrew'] = 0xFB4A;
  12107. t['tavhebrew'] = 0x05EA;
  12108. t['tbar'] = 0x0167;
  12109. t['tbopomofo'] = 0x310A;
  12110. t['tcaron'] = 0x0165;
  12111. t['tccurl'] = 0x02A8;
  12112. t['tcedilla'] = 0x0163;
  12113. t['tcheharabic'] = 0x0686;
  12114. t['tchehfinalarabic'] = 0xFB7B;
  12115. t['tchehinitialarabic'] = 0xFB7C;
  12116. t['tchehmedialarabic'] = 0xFB7D;
  12117. t['tcircle'] = 0x24E3;
  12118. t['tcircumflexbelow'] = 0x1E71;
  12119. t['tcommaaccent'] = 0x0163;
  12120. t['tdieresis'] = 0x1E97;
  12121. t['tdotaccent'] = 0x1E6B;
  12122. t['tdotbelow'] = 0x1E6D;
  12123. t['tecyrillic'] = 0x0442;
  12124. t['tedescendercyrillic'] = 0x04AD;
  12125. t['teharabic'] = 0x062A;
  12126. t['tehfinalarabic'] = 0xFE96;
  12127. t['tehhahinitialarabic'] = 0xFCA2;
  12128. t['tehhahisolatedarabic'] = 0xFC0C;
  12129. t['tehinitialarabic'] = 0xFE97;
  12130. t['tehiragana'] = 0x3066;
  12131. t['tehjeeminitialarabic'] = 0xFCA1;
  12132. t['tehjeemisolatedarabic'] = 0xFC0B;
  12133. t['tehmarbutaarabic'] = 0x0629;
  12134. t['tehmarbutafinalarabic'] = 0xFE94;
  12135. t['tehmedialarabic'] = 0xFE98;
  12136. t['tehmeeminitialarabic'] = 0xFCA4;
  12137. t['tehmeemisolatedarabic'] = 0xFC0E;
  12138. t['tehnoonfinalarabic'] = 0xFC73;
  12139. t['tekatakana'] = 0x30C6;
  12140. t['tekatakanahalfwidth'] = 0xFF83;
  12141. t['telephone'] = 0x2121;
  12142. t['telephoneblack'] = 0x260E;
  12143. t['telishagedolahebrew'] = 0x05A0;
  12144. t['telishaqetanahebrew'] = 0x05A9;
  12145. t['tencircle'] = 0x2469;
  12146. t['tenideographicparen'] = 0x3229;
  12147. t['tenparen'] = 0x247D;
  12148. t['tenperiod'] = 0x2491;
  12149. t['tenroman'] = 0x2179;
  12150. t['tesh'] = 0x02A7;
  12151. t['tet'] = 0x05D8;
  12152. t['tetdagesh'] = 0xFB38;
  12153. t['tetdageshhebrew'] = 0xFB38;
  12154. t['tethebrew'] = 0x05D8;
  12155. t['tetsecyrillic'] = 0x04B5;
  12156. t['tevirhebrew'] = 0x059B;
  12157. t['tevirlefthebrew'] = 0x059B;
  12158. t['thabengali'] = 0x09A5;
  12159. t['thadeva'] = 0x0925;
  12160. t['thagujarati'] = 0x0AA5;
  12161. t['thagurmukhi'] = 0x0A25;
  12162. t['thalarabic'] = 0x0630;
  12163. t['thalfinalarabic'] = 0xFEAC;
  12164. t['thanthakhatlowleftthai'] = 0xF898;
  12165. t['thanthakhatlowrightthai'] = 0xF897;
  12166. t['thanthakhatthai'] = 0x0E4C;
  12167. t['thanthakhatupperleftthai'] = 0xF896;
  12168. t['theharabic'] = 0x062B;
  12169. t['thehfinalarabic'] = 0xFE9A;
  12170. t['thehinitialarabic'] = 0xFE9B;
  12171. t['thehmedialarabic'] = 0xFE9C;
  12172. t['thereexists'] = 0x2203;
  12173. t['therefore'] = 0x2234;
  12174. t['theta'] = 0x03B8;
  12175. t['theta1'] = 0x03D1;
  12176. t['thetasymbolgreek'] = 0x03D1;
  12177. t['thieuthacirclekorean'] = 0x3279;
  12178. t['thieuthaparenkorean'] = 0x3219;
  12179. t['thieuthcirclekorean'] = 0x326B;
  12180. t['thieuthkorean'] = 0x314C;
  12181. t['thieuthparenkorean'] = 0x320B;
  12182. t['thirteencircle'] = 0x246C;
  12183. t['thirteenparen'] = 0x2480;
  12184. t['thirteenperiod'] = 0x2494;
  12185. t['thonangmonthothai'] = 0x0E11;
  12186. t['thook'] = 0x01AD;
  12187. t['thophuthaothai'] = 0x0E12;
  12188. t['thorn'] = 0x00FE;
  12189. t['thothahanthai'] = 0x0E17;
  12190. t['thothanthai'] = 0x0E10;
  12191. t['thothongthai'] = 0x0E18;
  12192. t['thothungthai'] = 0x0E16;
  12193. t['thousandcyrillic'] = 0x0482;
  12194. t['thousandsseparatorarabic'] = 0x066C;
  12195. t['thousandsseparatorpersian'] = 0x066C;
  12196. t['three'] = 0x0033;
  12197. t['threearabic'] = 0x0663;
  12198. t['threebengali'] = 0x09E9;
  12199. t['threecircle'] = 0x2462;
  12200. t['threecircleinversesansserif'] = 0x278C;
  12201. t['threedeva'] = 0x0969;
  12202. t['threeeighths'] = 0x215C;
  12203. t['threegujarati'] = 0x0AE9;
  12204. t['threegurmukhi'] = 0x0A69;
  12205. t['threehackarabic'] = 0x0663;
  12206. t['threehangzhou'] = 0x3023;
  12207. t['threeideographicparen'] = 0x3222;
  12208. t['threeinferior'] = 0x2083;
  12209. t['threemonospace'] = 0xFF13;
  12210. t['threenumeratorbengali'] = 0x09F6;
  12211. t['threeoldstyle'] = 0xF733;
  12212. t['threeparen'] = 0x2476;
  12213. t['threeperiod'] = 0x248A;
  12214. t['threepersian'] = 0x06F3;
  12215. t['threequarters'] = 0x00BE;
  12216. t['threequartersemdash'] = 0xF6DE;
  12217. t['threeroman'] = 0x2172;
  12218. t['threesuperior'] = 0x00B3;
  12219. t['threethai'] = 0x0E53;
  12220. t['thzsquare'] = 0x3394;
  12221. t['tihiragana'] = 0x3061;
  12222. t['tikatakana'] = 0x30C1;
  12223. t['tikatakanahalfwidth'] = 0xFF81;
  12224. t['tikeutacirclekorean'] = 0x3270;
  12225. t['tikeutaparenkorean'] = 0x3210;
  12226. t['tikeutcirclekorean'] = 0x3262;
  12227. t['tikeutkorean'] = 0x3137;
  12228. t['tikeutparenkorean'] = 0x3202;
  12229. t['tilde'] = 0x02DC;
  12230. t['tildebelowcmb'] = 0x0330;
  12231. t['tildecmb'] = 0x0303;
  12232. t['tildecomb'] = 0x0303;
  12233. t['tildedoublecmb'] = 0x0360;
  12234. t['tildeoperator'] = 0x223C;
  12235. t['tildeoverlaycmb'] = 0x0334;
  12236. t['tildeverticalcmb'] = 0x033E;
  12237. t['timescircle'] = 0x2297;
  12238. t['tipehahebrew'] = 0x0596;
  12239. t['tipehalefthebrew'] = 0x0596;
  12240. t['tippigurmukhi'] = 0x0A70;
  12241. t['titlocyrilliccmb'] = 0x0483;
  12242. t['tiwnarmenian'] = 0x057F;
  12243. t['tlinebelow'] = 0x1E6F;
  12244. t['tmonospace'] = 0xFF54;
  12245. t['toarmenian'] = 0x0569;
  12246. t['tohiragana'] = 0x3068;
  12247. t['tokatakana'] = 0x30C8;
  12248. t['tokatakanahalfwidth'] = 0xFF84;
  12249. t['tonebarextrahighmod'] = 0x02E5;
  12250. t['tonebarextralowmod'] = 0x02E9;
  12251. t['tonebarhighmod'] = 0x02E6;
  12252. t['tonebarlowmod'] = 0x02E8;
  12253. t['tonebarmidmod'] = 0x02E7;
  12254. t['tonefive'] = 0x01BD;
  12255. t['tonesix'] = 0x0185;
  12256. t['tonetwo'] = 0x01A8;
  12257. t['tonos'] = 0x0384;
  12258. t['tonsquare'] = 0x3327;
  12259. t['topatakthai'] = 0x0E0F;
  12260. t['tortoiseshellbracketleft'] = 0x3014;
  12261. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12262. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12263. t['tortoiseshellbracketright'] = 0x3015;
  12264. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12265. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12266. t['totaothai'] = 0x0E15;
  12267. t['tpalatalhook'] = 0x01AB;
  12268. t['tparen'] = 0x24AF;
  12269. t['trademark'] = 0x2122;
  12270. t['trademarksans'] = 0xF8EA;
  12271. t['trademarkserif'] = 0xF6DB;
  12272. t['tretroflexhook'] = 0x0288;
  12273. t['triagdn'] = 0x25BC;
  12274. t['triaglf'] = 0x25C4;
  12275. t['triagrt'] = 0x25BA;
  12276. t['triagup'] = 0x25B2;
  12277. t['ts'] = 0x02A6;
  12278. t['tsadi'] = 0x05E6;
  12279. t['tsadidagesh'] = 0xFB46;
  12280. t['tsadidageshhebrew'] = 0xFB46;
  12281. t['tsadihebrew'] = 0x05E6;
  12282. t['tsecyrillic'] = 0x0446;
  12283. t['tsere'] = 0x05B5;
  12284. t['tsere12'] = 0x05B5;
  12285. t['tsere1e'] = 0x05B5;
  12286. t['tsere2b'] = 0x05B5;
  12287. t['tserehebrew'] = 0x05B5;
  12288. t['tserenarrowhebrew'] = 0x05B5;
  12289. t['tserequarterhebrew'] = 0x05B5;
  12290. t['tserewidehebrew'] = 0x05B5;
  12291. t['tshecyrillic'] = 0x045B;
  12292. t['tsuperior'] = 0xF6F3;
  12293. t['ttabengali'] = 0x099F;
  12294. t['ttadeva'] = 0x091F;
  12295. t['ttagujarati'] = 0x0A9F;
  12296. t['ttagurmukhi'] = 0x0A1F;
  12297. t['tteharabic'] = 0x0679;
  12298. t['ttehfinalarabic'] = 0xFB67;
  12299. t['ttehinitialarabic'] = 0xFB68;
  12300. t['ttehmedialarabic'] = 0xFB69;
  12301. t['tthabengali'] = 0x09A0;
  12302. t['tthadeva'] = 0x0920;
  12303. t['tthagujarati'] = 0x0AA0;
  12304. t['tthagurmukhi'] = 0x0A20;
  12305. t['tturned'] = 0x0287;
  12306. t['tuhiragana'] = 0x3064;
  12307. t['tukatakana'] = 0x30C4;
  12308. t['tukatakanahalfwidth'] = 0xFF82;
  12309. t['tusmallhiragana'] = 0x3063;
  12310. t['tusmallkatakana'] = 0x30C3;
  12311. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12312. t['twelvecircle'] = 0x246B;
  12313. t['twelveparen'] = 0x247F;
  12314. t['twelveperiod'] = 0x2493;
  12315. t['twelveroman'] = 0x217B;
  12316. t['twentycircle'] = 0x2473;
  12317. t['twentyhangzhou'] = 0x5344;
  12318. t['twentyparen'] = 0x2487;
  12319. t['twentyperiod'] = 0x249B;
  12320. t['two'] = 0x0032;
  12321. t['twoarabic'] = 0x0662;
  12322. t['twobengali'] = 0x09E8;
  12323. t['twocircle'] = 0x2461;
  12324. t['twocircleinversesansserif'] = 0x278B;
  12325. t['twodeva'] = 0x0968;
  12326. t['twodotenleader'] = 0x2025;
  12327. t['twodotleader'] = 0x2025;
  12328. t['twodotleadervertical'] = 0xFE30;
  12329. t['twogujarati'] = 0x0AE8;
  12330. t['twogurmukhi'] = 0x0A68;
  12331. t['twohackarabic'] = 0x0662;
  12332. t['twohangzhou'] = 0x3022;
  12333. t['twoideographicparen'] = 0x3221;
  12334. t['twoinferior'] = 0x2082;
  12335. t['twomonospace'] = 0xFF12;
  12336. t['twonumeratorbengali'] = 0x09F5;
  12337. t['twooldstyle'] = 0xF732;
  12338. t['twoparen'] = 0x2475;
  12339. t['twoperiod'] = 0x2489;
  12340. t['twopersian'] = 0x06F2;
  12341. t['tworoman'] = 0x2171;
  12342. t['twostroke'] = 0x01BB;
  12343. t['twosuperior'] = 0x00B2;
  12344. t['twothai'] = 0x0E52;
  12345. t['twothirds'] = 0x2154;
  12346. t['u'] = 0x0075;
  12347. t['uacute'] = 0x00FA;
  12348. t['ubar'] = 0x0289;
  12349. t['ubengali'] = 0x0989;
  12350. t['ubopomofo'] = 0x3128;
  12351. t['ubreve'] = 0x016D;
  12352. t['ucaron'] = 0x01D4;
  12353. t['ucircle'] = 0x24E4;
  12354. t['ucircumflex'] = 0x00FB;
  12355. t['ucircumflexbelow'] = 0x1E77;
  12356. t['ucyrillic'] = 0x0443;
  12357. t['udattadeva'] = 0x0951;
  12358. t['udblacute'] = 0x0171;
  12359. t['udblgrave'] = 0x0215;
  12360. t['udeva'] = 0x0909;
  12361. t['udieresis'] = 0x00FC;
  12362. t['udieresisacute'] = 0x01D8;
  12363. t['udieresisbelow'] = 0x1E73;
  12364. t['udieresiscaron'] = 0x01DA;
  12365. t['udieresiscyrillic'] = 0x04F1;
  12366. t['udieresisgrave'] = 0x01DC;
  12367. t['udieresismacron'] = 0x01D6;
  12368. t['udotbelow'] = 0x1EE5;
  12369. t['ugrave'] = 0x00F9;
  12370. t['ugujarati'] = 0x0A89;
  12371. t['ugurmukhi'] = 0x0A09;
  12372. t['uhiragana'] = 0x3046;
  12373. t['uhookabove'] = 0x1EE7;
  12374. t['uhorn'] = 0x01B0;
  12375. t['uhornacute'] = 0x1EE9;
  12376. t['uhorndotbelow'] = 0x1EF1;
  12377. t['uhorngrave'] = 0x1EEB;
  12378. t['uhornhookabove'] = 0x1EED;
  12379. t['uhorntilde'] = 0x1EEF;
  12380. t['uhungarumlaut'] = 0x0171;
  12381. t['uhungarumlautcyrillic'] = 0x04F3;
  12382. t['uinvertedbreve'] = 0x0217;
  12383. t['ukatakana'] = 0x30A6;
  12384. t['ukatakanahalfwidth'] = 0xFF73;
  12385. t['ukcyrillic'] = 0x0479;
  12386. t['ukorean'] = 0x315C;
  12387. t['umacron'] = 0x016B;
  12388. t['umacroncyrillic'] = 0x04EF;
  12389. t['umacrondieresis'] = 0x1E7B;
  12390. t['umatragurmukhi'] = 0x0A41;
  12391. t['umonospace'] = 0xFF55;
  12392. t['underscore'] = 0x005F;
  12393. t['underscoredbl'] = 0x2017;
  12394. t['underscoremonospace'] = 0xFF3F;
  12395. t['underscorevertical'] = 0xFE33;
  12396. t['underscorewavy'] = 0xFE4F;
  12397. t['union'] = 0x222A;
  12398. t['universal'] = 0x2200;
  12399. t['uogonek'] = 0x0173;
  12400. t['uparen'] = 0x24B0;
  12401. t['upblock'] = 0x2580;
  12402. t['upperdothebrew'] = 0x05C4;
  12403. t['upsilon'] = 0x03C5;
  12404. t['upsilondieresis'] = 0x03CB;
  12405. t['upsilondieresistonos'] = 0x03B0;
  12406. t['upsilonlatin'] = 0x028A;
  12407. t['upsilontonos'] = 0x03CD;
  12408. t['uptackbelowcmb'] = 0x031D;
  12409. t['uptackmod'] = 0x02D4;
  12410. t['uragurmukhi'] = 0x0A73;
  12411. t['uring'] = 0x016F;
  12412. t['ushortcyrillic'] = 0x045E;
  12413. t['usmallhiragana'] = 0x3045;
  12414. t['usmallkatakana'] = 0x30A5;
  12415. t['usmallkatakanahalfwidth'] = 0xFF69;
  12416. t['ustraightcyrillic'] = 0x04AF;
  12417. t['ustraightstrokecyrillic'] = 0x04B1;
  12418. t['utilde'] = 0x0169;
  12419. t['utildeacute'] = 0x1E79;
  12420. t['utildebelow'] = 0x1E75;
  12421. t['uubengali'] = 0x098A;
  12422. t['uudeva'] = 0x090A;
  12423. t['uugujarati'] = 0x0A8A;
  12424. t['uugurmukhi'] = 0x0A0A;
  12425. t['uumatragurmukhi'] = 0x0A42;
  12426. t['uuvowelsignbengali'] = 0x09C2;
  12427. t['uuvowelsigndeva'] = 0x0942;
  12428. t['uuvowelsigngujarati'] = 0x0AC2;
  12429. t['uvowelsignbengali'] = 0x09C1;
  12430. t['uvowelsigndeva'] = 0x0941;
  12431. t['uvowelsigngujarati'] = 0x0AC1;
  12432. t['v'] = 0x0076;
  12433. t['vadeva'] = 0x0935;
  12434. t['vagujarati'] = 0x0AB5;
  12435. t['vagurmukhi'] = 0x0A35;
  12436. t['vakatakana'] = 0x30F7;
  12437. t['vav'] = 0x05D5;
  12438. t['vavdagesh'] = 0xFB35;
  12439. t['vavdagesh65'] = 0xFB35;
  12440. t['vavdageshhebrew'] = 0xFB35;
  12441. t['vavhebrew'] = 0x05D5;
  12442. t['vavholam'] = 0xFB4B;
  12443. t['vavholamhebrew'] = 0xFB4B;
  12444. t['vavvavhebrew'] = 0x05F0;
  12445. t['vavyodhebrew'] = 0x05F1;
  12446. t['vcircle'] = 0x24E5;
  12447. t['vdotbelow'] = 0x1E7F;
  12448. t['vecyrillic'] = 0x0432;
  12449. t['veharabic'] = 0x06A4;
  12450. t['vehfinalarabic'] = 0xFB6B;
  12451. t['vehinitialarabic'] = 0xFB6C;
  12452. t['vehmedialarabic'] = 0xFB6D;
  12453. t['vekatakana'] = 0x30F9;
  12454. t['venus'] = 0x2640;
  12455. t['verticalbar'] = 0x007C;
  12456. t['verticallineabovecmb'] = 0x030D;
  12457. t['verticallinebelowcmb'] = 0x0329;
  12458. t['verticallinelowmod'] = 0x02CC;
  12459. t['verticallinemod'] = 0x02C8;
  12460. t['vewarmenian'] = 0x057E;
  12461. t['vhook'] = 0x028B;
  12462. t['vikatakana'] = 0x30F8;
  12463. t['viramabengali'] = 0x09CD;
  12464. t['viramadeva'] = 0x094D;
  12465. t['viramagujarati'] = 0x0ACD;
  12466. t['visargabengali'] = 0x0983;
  12467. t['visargadeva'] = 0x0903;
  12468. t['visargagujarati'] = 0x0A83;
  12469. t['vmonospace'] = 0xFF56;
  12470. t['voarmenian'] = 0x0578;
  12471. t['voicediterationhiragana'] = 0x309E;
  12472. t['voicediterationkatakana'] = 0x30FE;
  12473. t['voicedmarkkana'] = 0x309B;
  12474. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12475. t['vokatakana'] = 0x30FA;
  12476. t['vparen'] = 0x24B1;
  12477. t['vtilde'] = 0x1E7D;
  12478. t['vturned'] = 0x028C;
  12479. t['vuhiragana'] = 0x3094;
  12480. t['vukatakana'] = 0x30F4;
  12481. t['w'] = 0x0077;
  12482. t['wacute'] = 0x1E83;
  12483. t['waekorean'] = 0x3159;
  12484. t['wahiragana'] = 0x308F;
  12485. t['wakatakana'] = 0x30EF;
  12486. t['wakatakanahalfwidth'] = 0xFF9C;
  12487. t['wakorean'] = 0x3158;
  12488. t['wasmallhiragana'] = 0x308E;
  12489. t['wasmallkatakana'] = 0x30EE;
  12490. t['wattosquare'] = 0x3357;
  12491. t['wavedash'] = 0x301C;
  12492. t['wavyunderscorevertical'] = 0xFE34;
  12493. t['wawarabic'] = 0x0648;
  12494. t['wawfinalarabic'] = 0xFEEE;
  12495. t['wawhamzaabovearabic'] = 0x0624;
  12496. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12497. t['wbsquare'] = 0x33DD;
  12498. t['wcircle'] = 0x24E6;
  12499. t['wcircumflex'] = 0x0175;
  12500. t['wdieresis'] = 0x1E85;
  12501. t['wdotaccent'] = 0x1E87;
  12502. t['wdotbelow'] = 0x1E89;
  12503. t['wehiragana'] = 0x3091;
  12504. t['weierstrass'] = 0x2118;
  12505. t['wekatakana'] = 0x30F1;
  12506. t['wekorean'] = 0x315E;
  12507. t['weokorean'] = 0x315D;
  12508. t['wgrave'] = 0x1E81;
  12509. t['whitebullet'] = 0x25E6;
  12510. t['whitecircle'] = 0x25CB;
  12511. t['whitecircleinverse'] = 0x25D9;
  12512. t['whitecornerbracketleft'] = 0x300E;
  12513. t['whitecornerbracketleftvertical'] = 0xFE43;
  12514. t['whitecornerbracketright'] = 0x300F;
  12515. t['whitecornerbracketrightvertical'] = 0xFE44;
  12516. t['whitediamond'] = 0x25C7;
  12517. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12518. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12519. t['whitedownpointingtriangle'] = 0x25BD;
  12520. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12521. t['whiteleftpointingtriangle'] = 0x25C1;
  12522. t['whitelenticularbracketleft'] = 0x3016;
  12523. t['whitelenticularbracketright'] = 0x3017;
  12524. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12525. t['whiterightpointingtriangle'] = 0x25B7;
  12526. t['whitesmallsquare'] = 0x25AB;
  12527. t['whitesmilingface'] = 0x263A;
  12528. t['whitesquare'] = 0x25A1;
  12529. t['whitestar'] = 0x2606;
  12530. t['whitetelephone'] = 0x260F;
  12531. t['whitetortoiseshellbracketleft'] = 0x3018;
  12532. t['whitetortoiseshellbracketright'] = 0x3019;
  12533. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12534. t['whiteuppointingtriangle'] = 0x25B3;
  12535. t['wihiragana'] = 0x3090;
  12536. t['wikatakana'] = 0x30F0;
  12537. t['wikorean'] = 0x315F;
  12538. t['wmonospace'] = 0xFF57;
  12539. t['wohiragana'] = 0x3092;
  12540. t['wokatakana'] = 0x30F2;
  12541. t['wokatakanahalfwidth'] = 0xFF66;
  12542. t['won'] = 0x20A9;
  12543. t['wonmonospace'] = 0xFFE6;
  12544. t['wowaenthai'] = 0x0E27;
  12545. t['wparen'] = 0x24B2;
  12546. t['wring'] = 0x1E98;
  12547. t['wsuperior'] = 0x02B7;
  12548. t['wturned'] = 0x028D;
  12549. t['wynn'] = 0x01BF;
  12550. t['x'] = 0x0078;
  12551. t['xabovecmb'] = 0x033D;
  12552. t['xbopomofo'] = 0x3112;
  12553. t['xcircle'] = 0x24E7;
  12554. t['xdieresis'] = 0x1E8D;
  12555. t['xdotaccent'] = 0x1E8B;
  12556. t['xeharmenian'] = 0x056D;
  12557. t['xi'] = 0x03BE;
  12558. t['xmonospace'] = 0xFF58;
  12559. t['xparen'] = 0x24B3;
  12560. t['xsuperior'] = 0x02E3;
  12561. t['y'] = 0x0079;
  12562. t['yaadosquare'] = 0x334E;
  12563. t['yabengali'] = 0x09AF;
  12564. t['yacute'] = 0x00FD;
  12565. t['yadeva'] = 0x092F;
  12566. t['yaekorean'] = 0x3152;
  12567. t['yagujarati'] = 0x0AAF;
  12568. t['yagurmukhi'] = 0x0A2F;
  12569. t['yahiragana'] = 0x3084;
  12570. t['yakatakana'] = 0x30E4;
  12571. t['yakatakanahalfwidth'] = 0xFF94;
  12572. t['yakorean'] = 0x3151;
  12573. t['yamakkanthai'] = 0x0E4E;
  12574. t['yasmallhiragana'] = 0x3083;
  12575. t['yasmallkatakana'] = 0x30E3;
  12576. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12577. t['yatcyrillic'] = 0x0463;
  12578. t['ycircle'] = 0x24E8;
  12579. t['ycircumflex'] = 0x0177;
  12580. t['ydieresis'] = 0x00FF;
  12581. t['ydotaccent'] = 0x1E8F;
  12582. t['ydotbelow'] = 0x1EF5;
  12583. t['yeharabic'] = 0x064A;
  12584. t['yehbarreearabic'] = 0x06D2;
  12585. t['yehbarreefinalarabic'] = 0xFBAF;
  12586. t['yehfinalarabic'] = 0xFEF2;
  12587. t['yehhamzaabovearabic'] = 0x0626;
  12588. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12589. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12590. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12591. t['yehinitialarabic'] = 0xFEF3;
  12592. t['yehmedialarabic'] = 0xFEF4;
  12593. t['yehmeeminitialarabic'] = 0xFCDD;
  12594. t['yehmeemisolatedarabic'] = 0xFC58;
  12595. t['yehnoonfinalarabic'] = 0xFC94;
  12596. t['yehthreedotsbelowarabic'] = 0x06D1;
  12597. t['yekorean'] = 0x3156;
  12598. t['yen'] = 0x00A5;
  12599. t['yenmonospace'] = 0xFFE5;
  12600. t['yeokorean'] = 0x3155;
  12601. t['yeorinhieuhkorean'] = 0x3186;
  12602. t['yerahbenyomohebrew'] = 0x05AA;
  12603. t['yerahbenyomolefthebrew'] = 0x05AA;
  12604. t['yericyrillic'] = 0x044B;
  12605. t['yerudieresiscyrillic'] = 0x04F9;
  12606. t['yesieungkorean'] = 0x3181;
  12607. t['yesieungpansioskorean'] = 0x3183;
  12608. t['yesieungsioskorean'] = 0x3182;
  12609. t['yetivhebrew'] = 0x059A;
  12610. t['ygrave'] = 0x1EF3;
  12611. t['yhook'] = 0x01B4;
  12612. t['yhookabove'] = 0x1EF7;
  12613. t['yiarmenian'] = 0x0575;
  12614. t['yicyrillic'] = 0x0457;
  12615. t['yikorean'] = 0x3162;
  12616. t['yinyang'] = 0x262F;
  12617. t['yiwnarmenian'] = 0x0582;
  12618. t['ymonospace'] = 0xFF59;
  12619. t['yod'] = 0x05D9;
  12620. t['yoddagesh'] = 0xFB39;
  12621. t['yoddageshhebrew'] = 0xFB39;
  12622. t['yodhebrew'] = 0x05D9;
  12623. t['yodyodhebrew'] = 0x05F2;
  12624. t['yodyodpatahhebrew'] = 0xFB1F;
  12625. t['yohiragana'] = 0x3088;
  12626. t['yoikorean'] = 0x3189;
  12627. t['yokatakana'] = 0x30E8;
  12628. t['yokatakanahalfwidth'] = 0xFF96;
  12629. t['yokorean'] = 0x315B;
  12630. t['yosmallhiragana'] = 0x3087;
  12631. t['yosmallkatakana'] = 0x30E7;
  12632. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12633. t['yotgreek'] = 0x03F3;
  12634. t['yoyaekorean'] = 0x3188;
  12635. t['yoyakorean'] = 0x3187;
  12636. t['yoyakthai'] = 0x0E22;
  12637. t['yoyingthai'] = 0x0E0D;
  12638. t['yparen'] = 0x24B4;
  12639. t['ypogegrammeni'] = 0x037A;
  12640. t['ypogegrammenigreekcmb'] = 0x0345;
  12641. t['yr'] = 0x01A6;
  12642. t['yring'] = 0x1E99;
  12643. t['ysuperior'] = 0x02B8;
  12644. t['ytilde'] = 0x1EF9;
  12645. t['yturned'] = 0x028E;
  12646. t['yuhiragana'] = 0x3086;
  12647. t['yuikorean'] = 0x318C;
  12648. t['yukatakana'] = 0x30E6;
  12649. t['yukatakanahalfwidth'] = 0xFF95;
  12650. t['yukorean'] = 0x3160;
  12651. t['yusbigcyrillic'] = 0x046B;
  12652. t['yusbigiotifiedcyrillic'] = 0x046D;
  12653. t['yuslittlecyrillic'] = 0x0467;
  12654. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12655. t['yusmallhiragana'] = 0x3085;
  12656. t['yusmallkatakana'] = 0x30E5;
  12657. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12658. t['yuyekorean'] = 0x318B;
  12659. t['yuyeokorean'] = 0x318A;
  12660. t['yyabengali'] = 0x09DF;
  12661. t['yyadeva'] = 0x095F;
  12662. t['z'] = 0x007A;
  12663. t['zaarmenian'] = 0x0566;
  12664. t['zacute'] = 0x017A;
  12665. t['zadeva'] = 0x095B;
  12666. t['zagurmukhi'] = 0x0A5B;
  12667. t['zaharabic'] = 0x0638;
  12668. t['zahfinalarabic'] = 0xFEC6;
  12669. t['zahinitialarabic'] = 0xFEC7;
  12670. t['zahiragana'] = 0x3056;
  12671. t['zahmedialarabic'] = 0xFEC8;
  12672. t['zainarabic'] = 0x0632;
  12673. t['zainfinalarabic'] = 0xFEB0;
  12674. t['zakatakana'] = 0x30B6;
  12675. t['zaqefgadolhebrew'] = 0x0595;
  12676. t['zaqefqatanhebrew'] = 0x0594;
  12677. t['zarqahebrew'] = 0x0598;
  12678. t['zayin'] = 0x05D6;
  12679. t['zayindagesh'] = 0xFB36;
  12680. t['zayindageshhebrew'] = 0xFB36;
  12681. t['zayinhebrew'] = 0x05D6;
  12682. t['zbopomofo'] = 0x3117;
  12683. t['zcaron'] = 0x017E;
  12684. t['zcircle'] = 0x24E9;
  12685. t['zcircumflex'] = 0x1E91;
  12686. t['zcurl'] = 0x0291;
  12687. t['zdot'] = 0x017C;
  12688. t['zdotaccent'] = 0x017C;
  12689. t['zdotbelow'] = 0x1E93;
  12690. t['zecyrillic'] = 0x0437;
  12691. t['zedescendercyrillic'] = 0x0499;
  12692. t['zedieresiscyrillic'] = 0x04DF;
  12693. t['zehiragana'] = 0x305C;
  12694. t['zekatakana'] = 0x30BC;
  12695. t['zero'] = 0x0030;
  12696. t['zeroarabic'] = 0x0660;
  12697. t['zerobengali'] = 0x09E6;
  12698. t['zerodeva'] = 0x0966;
  12699. t['zerogujarati'] = 0x0AE6;
  12700. t['zerogurmukhi'] = 0x0A66;
  12701. t['zerohackarabic'] = 0x0660;
  12702. t['zeroinferior'] = 0x2080;
  12703. t['zeromonospace'] = 0xFF10;
  12704. t['zerooldstyle'] = 0xF730;
  12705. t['zeropersian'] = 0x06F0;
  12706. t['zerosuperior'] = 0x2070;
  12707. t['zerothai'] = 0x0E50;
  12708. t['zerowidthjoiner'] = 0xFEFF;
  12709. t['zerowidthnonjoiner'] = 0x200C;
  12710. t['zerowidthspace'] = 0x200B;
  12711. t['zeta'] = 0x03B6;
  12712. t['zhbopomofo'] = 0x3113;
  12713. t['zhearmenian'] = 0x056A;
  12714. t['zhebrevecyrillic'] = 0x04C2;
  12715. t['zhecyrillic'] = 0x0436;
  12716. t['zhedescendercyrillic'] = 0x0497;
  12717. t['zhedieresiscyrillic'] = 0x04DD;
  12718. t['zihiragana'] = 0x3058;
  12719. t['zikatakana'] = 0x30B8;
  12720. t['zinorhebrew'] = 0x05AE;
  12721. t['zlinebelow'] = 0x1E95;
  12722. t['zmonospace'] = 0xFF5A;
  12723. t['zohiragana'] = 0x305E;
  12724. t['zokatakana'] = 0x30BE;
  12725. t['zparen'] = 0x24B5;
  12726. t['zretroflexhook'] = 0x0290;
  12727. t['zstroke'] = 0x01B6;
  12728. t['zuhiragana'] = 0x305A;
  12729. t['zukatakana'] = 0x30BA;
  12730. t['.notdef'] = 0x0000;
  12731. t['angbracketleftbig'] = 0x2329;
  12732. t['angbracketleftBig'] = 0x2329;
  12733. t['angbracketleftbigg'] = 0x2329;
  12734. t['angbracketleftBigg'] = 0x2329;
  12735. t['angbracketrightBig'] = 0x232A;
  12736. t['angbracketrightbig'] = 0x232A;
  12737. t['angbracketrightBigg'] = 0x232A;
  12738. t['angbracketrightbigg'] = 0x232A;
  12739. t['arrowhookleft'] = 0x21AA;
  12740. t['arrowhookright'] = 0x21A9;
  12741. t['arrowlefttophalf'] = 0x21BC;
  12742. t['arrowleftbothalf'] = 0x21BD;
  12743. t['arrownortheast'] = 0x2197;
  12744. t['arrownorthwest'] = 0x2196;
  12745. t['arrowrighttophalf'] = 0x21C0;
  12746. t['arrowrightbothalf'] = 0x21C1;
  12747. t['arrowsoutheast'] = 0x2198;
  12748. t['arrowsouthwest'] = 0x2199;
  12749. t['backslashbig'] = 0x2216;
  12750. t['backslashBig'] = 0x2216;
  12751. t['backslashBigg'] = 0x2216;
  12752. t['backslashbigg'] = 0x2216;
  12753. t['bardbl'] = 0x2016;
  12754. t['bracehtipdownleft'] = 0xFE37;
  12755. t['bracehtipdownright'] = 0xFE37;
  12756. t['bracehtipupleft'] = 0xFE38;
  12757. t['bracehtipupright'] = 0xFE38;
  12758. t['braceleftBig'] = 0x007B;
  12759. t['braceleftbig'] = 0x007B;
  12760. t['braceleftbigg'] = 0x007B;
  12761. t['braceleftBigg'] = 0x007B;
  12762. t['bracerightBig'] = 0x007D;
  12763. t['bracerightbig'] = 0x007D;
  12764. t['bracerightbigg'] = 0x007D;
  12765. t['bracerightBigg'] = 0x007D;
  12766. t['bracketleftbig'] = 0x005B;
  12767. t['bracketleftBig'] = 0x005B;
  12768. t['bracketleftbigg'] = 0x005B;
  12769. t['bracketleftBigg'] = 0x005B;
  12770. t['bracketrightBig'] = 0x005D;
  12771. t['bracketrightbig'] = 0x005D;
  12772. t['bracketrightbigg'] = 0x005D;
  12773. t['bracketrightBigg'] = 0x005D;
  12774. t['ceilingleftbig'] = 0x2308;
  12775. t['ceilingleftBig'] = 0x2308;
  12776. t['ceilingleftBigg'] = 0x2308;
  12777. t['ceilingleftbigg'] = 0x2308;
  12778. t['ceilingrightbig'] = 0x2309;
  12779. t['ceilingrightBig'] = 0x2309;
  12780. t['ceilingrightbigg'] = 0x2309;
  12781. t['ceilingrightBigg'] = 0x2309;
  12782. t['circledotdisplay'] = 0x2299;
  12783. t['circledottext'] = 0x2299;
  12784. t['circlemultiplydisplay'] = 0x2297;
  12785. t['circlemultiplytext'] = 0x2297;
  12786. t['circleplusdisplay'] = 0x2295;
  12787. t['circleplustext'] = 0x2295;
  12788. t['contintegraldisplay'] = 0x222E;
  12789. t['contintegraltext'] = 0x222E;
  12790. t['coproductdisplay'] = 0x2210;
  12791. t['coproducttext'] = 0x2210;
  12792. t['floorleftBig'] = 0x230A;
  12793. t['floorleftbig'] = 0x230A;
  12794. t['floorleftbigg'] = 0x230A;
  12795. t['floorleftBigg'] = 0x230A;
  12796. t['floorrightbig'] = 0x230B;
  12797. t['floorrightBig'] = 0x230B;
  12798. t['floorrightBigg'] = 0x230B;
  12799. t['floorrightbigg'] = 0x230B;
  12800. t['hatwide'] = 0x0302;
  12801. t['hatwider'] = 0x0302;
  12802. t['hatwidest'] = 0x0302;
  12803. t['intercal'] = 0x1D40;
  12804. t['integraldisplay'] = 0x222B;
  12805. t['integraltext'] = 0x222B;
  12806. t['intersectiondisplay'] = 0x22C2;
  12807. t['intersectiontext'] = 0x22C2;
  12808. t['logicalanddisplay'] = 0x2227;
  12809. t['logicalandtext'] = 0x2227;
  12810. t['logicalordisplay'] = 0x2228;
  12811. t['logicalortext'] = 0x2228;
  12812. t['parenleftBig'] = 0x0028;
  12813. t['parenleftbig'] = 0x0028;
  12814. t['parenleftBigg'] = 0x0028;
  12815. t['parenleftbigg'] = 0x0028;
  12816. t['parenrightBig'] = 0x0029;
  12817. t['parenrightbig'] = 0x0029;
  12818. t['parenrightBigg'] = 0x0029;
  12819. t['parenrightbigg'] = 0x0029;
  12820. t['prime'] = 0x2032;
  12821. t['productdisplay'] = 0x220F;
  12822. t['producttext'] = 0x220F;
  12823. t['radicalbig'] = 0x221A;
  12824. t['radicalBig'] = 0x221A;
  12825. t['radicalBigg'] = 0x221A;
  12826. t['radicalbigg'] = 0x221A;
  12827. t['radicalbt'] = 0x221A;
  12828. t['radicaltp'] = 0x221A;
  12829. t['radicalvertex'] = 0x221A;
  12830. t['slashbig'] = 0x002F;
  12831. t['slashBig'] = 0x002F;
  12832. t['slashBigg'] = 0x002F;
  12833. t['slashbigg'] = 0x002F;
  12834. t['summationdisplay'] = 0x2211;
  12835. t['summationtext'] = 0x2211;
  12836. t['tildewide'] = 0x02DC;
  12837. t['tildewider'] = 0x02DC;
  12838. t['tildewidest'] = 0x02DC;
  12839. t['uniondisplay'] = 0x22C3;
  12840. t['unionmultidisplay'] = 0x228E;
  12841. t['unionmultitext'] = 0x228E;
  12842. t['unionsqdisplay'] = 0x2294;
  12843. t['unionsqtext'] = 0x2294;
  12844. t['uniontext'] = 0x22C3;
  12845. t['vextenddouble'] = 0x2225;
  12846. t['vextendsingle'] = 0x2223;
  12847. });
  12848. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12849. t['space'] = 0x0020;
  12850. t['a1'] = 0x2701;
  12851. t['a2'] = 0x2702;
  12852. t['a202'] = 0x2703;
  12853. t['a3'] = 0x2704;
  12854. t['a4'] = 0x260E;
  12855. t['a5'] = 0x2706;
  12856. t['a119'] = 0x2707;
  12857. t['a118'] = 0x2708;
  12858. t['a117'] = 0x2709;
  12859. t['a11'] = 0x261B;
  12860. t['a12'] = 0x261E;
  12861. t['a13'] = 0x270C;
  12862. t['a14'] = 0x270D;
  12863. t['a15'] = 0x270E;
  12864. t['a16'] = 0x270F;
  12865. t['a105'] = 0x2710;
  12866. t['a17'] = 0x2711;
  12867. t['a18'] = 0x2712;
  12868. t['a19'] = 0x2713;
  12869. t['a20'] = 0x2714;
  12870. t['a21'] = 0x2715;
  12871. t['a22'] = 0x2716;
  12872. t['a23'] = 0x2717;
  12873. t['a24'] = 0x2718;
  12874. t['a25'] = 0x2719;
  12875. t['a26'] = 0x271A;
  12876. t['a27'] = 0x271B;
  12877. t['a28'] = 0x271C;
  12878. t['a6'] = 0x271D;
  12879. t['a7'] = 0x271E;
  12880. t['a8'] = 0x271F;
  12881. t['a9'] = 0x2720;
  12882. t['a10'] = 0x2721;
  12883. t['a29'] = 0x2722;
  12884. t['a30'] = 0x2723;
  12885. t['a31'] = 0x2724;
  12886. t['a32'] = 0x2725;
  12887. t['a33'] = 0x2726;
  12888. t['a34'] = 0x2727;
  12889. t['a35'] = 0x2605;
  12890. t['a36'] = 0x2729;
  12891. t['a37'] = 0x272A;
  12892. t['a38'] = 0x272B;
  12893. t['a39'] = 0x272C;
  12894. t['a40'] = 0x272D;
  12895. t['a41'] = 0x272E;
  12896. t['a42'] = 0x272F;
  12897. t['a43'] = 0x2730;
  12898. t['a44'] = 0x2731;
  12899. t['a45'] = 0x2732;
  12900. t['a46'] = 0x2733;
  12901. t['a47'] = 0x2734;
  12902. t['a48'] = 0x2735;
  12903. t['a49'] = 0x2736;
  12904. t['a50'] = 0x2737;
  12905. t['a51'] = 0x2738;
  12906. t['a52'] = 0x2739;
  12907. t['a53'] = 0x273A;
  12908. t['a54'] = 0x273B;
  12909. t['a55'] = 0x273C;
  12910. t['a56'] = 0x273D;
  12911. t['a57'] = 0x273E;
  12912. t['a58'] = 0x273F;
  12913. t['a59'] = 0x2740;
  12914. t['a60'] = 0x2741;
  12915. t['a61'] = 0x2742;
  12916. t['a62'] = 0x2743;
  12917. t['a63'] = 0x2744;
  12918. t['a64'] = 0x2745;
  12919. t['a65'] = 0x2746;
  12920. t['a66'] = 0x2747;
  12921. t['a67'] = 0x2748;
  12922. t['a68'] = 0x2749;
  12923. t['a69'] = 0x274A;
  12924. t['a70'] = 0x274B;
  12925. t['a71'] = 0x25CF;
  12926. t['a72'] = 0x274D;
  12927. t['a73'] = 0x25A0;
  12928. t['a74'] = 0x274F;
  12929. t['a203'] = 0x2750;
  12930. t['a75'] = 0x2751;
  12931. t['a204'] = 0x2752;
  12932. t['a76'] = 0x25B2;
  12933. t['a77'] = 0x25BC;
  12934. t['a78'] = 0x25C6;
  12935. t['a79'] = 0x2756;
  12936. t['a81'] = 0x25D7;
  12937. t['a82'] = 0x2758;
  12938. t['a83'] = 0x2759;
  12939. t['a84'] = 0x275A;
  12940. t['a97'] = 0x275B;
  12941. t['a98'] = 0x275C;
  12942. t['a99'] = 0x275D;
  12943. t['a100'] = 0x275E;
  12944. t['a101'] = 0x2761;
  12945. t['a102'] = 0x2762;
  12946. t['a103'] = 0x2763;
  12947. t['a104'] = 0x2764;
  12948. t['a106'] = 0x2765;
  12949. t['a107'] = 0x2766;
  12950. t['a108'] = 0x2767;
  12951. t['a112'] = 0x2663;
  12952. t['a111'] = 0x2666;
  12953. t['a110'] = 0x2665;
  12954. t['a109'] = 0x2660;
  12955. t['a120'] = 0x2460;
  12956. t['a121'] = 0x2461;
  12957. t['a122'] = 0x2462;
  12958. t['a123'] = 0x2463;
  12959. t['a124'] = 0x2464;
  12960. t['a125'] = 0x2465;
  12961. t['a126'] = 0x2466;
  12962. t['a127'] = 0x2467;
  12963. t['a128'] = 0x2468;
  12964. t['a129'] = 0x2469;
  12965. t['a130'] = 0x2776;
  12966. t['a131'] = 0x2777;
  12967. t['a132'] = 0x2778;
  12968. t['a133'] = 0x2779;
  12969. t['a134'] = 0x277A;
  12970. t['a135'] = 0x277B;
  12971. t['a136'] = 0x277C;
  12972. t['a137'] = 0x277D;
  12973. t['a138'] = 0x277E;
  12974. t['a139'] = 0x277F;
  12975. t['a140'] = 0x2780;
  12976. t['a141'] = 0x2781;
  12977. t['a142'] = 0x2782;
  12978. t['a143'] = 0x2783;
  12979. t['a144'] = 0x2784;
  12980. t['a145'] = 0x2785;
  12981. t['a146'] = 0x2786;
  12982. t['a147'] = 0x2787;
  12983. t['a148'] = 0x2788;
  12984. t['a149'] = 0x2789;
  12985. t['a150'] = 0x278A;
  12986. t['a151'] = 0x278B;
  12987. t['a152'] = 0x278C;
  12988. t['a153'] = 0x278D;
  12989. t['a154'] = 0x278E;
  12990. t['a155'] = 0x278F;
  12991. t['a156'] = 0x2790;
  12992. t['a157'] = 0x2791;
  12993. t['a158'] = 0x2792;
  12994. t['a159'] = 0x2793;
  12995. t['a160'] = 0x2794;
  12996. t['a161'] = 0x2192;
  12997. t['a163'] = 0x2194;
  12998. t['a164'] = 0x2195;
  12999. t['a196'] = 0x2798;
  13000. t['a165'] = 0x2799;
  13001. t['a192'] = 0x279A;
  13002. t['a166'] = 0x279B;
  13003. t['a167'] = 0x279C;
  13004. t['a168'] = 0x279D;
  13005. t['a169'] = 0x279E;
  13006. t['a170'] = 0x279F;
  13007. t['a171'] = 0x27A0;
  13008. t['a172'] = 0x27A1;
  13009. t['a173'] = 0x27A2;
  13010. t['a162'] = 0x27A3;
  13011. t['a174'] = 0x27A4;
  13012. t['a175'] = 0x27A5;
  13013. t['a176'] = 0x27A6;
  13014. t['a177'] = 0x27A7;
  13015. t['a178'] = 0x27A8;
  13016. t['a179'] = 0x27A9;
  13017. t['a193'] = 0x27AA;
  13018. t['a180'] = 0x27AB;
  13019. t['a199'] = 0x27AC;
  13020. t['a181'] = 0x27AD;
  13021. t['a200'] = 0x27AE;
  13022. t['a182'] = 0x27AF;
  13023. t['a201'] = 0x27B1;
  13024. t['a183'] = 0x27B2;
  13025. t['a184'] = 0x27B3;
  13026. t['a197'] = 0x27B4;
  13027. t['a185'] = 0x27B5;
  13028. t['a194'] = 0x27B6;
  13029. t['a198'] = 0x27B7;
  13030. t['a186'] = 0x27B8;
  13031. t['a195'] = 0x27B9;
  13032. t['a187'] = 0x27BA;
  13033. t['a188'] = 0x27BB;
  13034. t['a189'] = 0x27BC;
  13035. t['a190'] = 0x27BD;
  13036. t['a191'] = 0x27BE;
  13037. t['a89'] = 0x2768;
  13038. t['a90'] = 0x2769;
  13039. t['a93'] = 0x276A;
  13040. t['a94'] = 0x276B;
  13041. t['a91'] = 0x276C;
  13042. t['a92'] = 0x276D;
  13043. t['a205'] = 0x276E;
  13044. t['a85'] = 0x276F;
  13045. t['a206'] = 0x2770;
  13046. t['a86'] = 0x2771;
  13047. t['a87'] = 0x2772;
  13048. t['a88'] = 0x2773;
  13049. t['a95'] = 0x2774;
  13050. t['a96'] = 0x2775;
  13051. t['.notdef'] = 0x0000;
  13052. });
  13053. exports.getGlyphsUnicode = getGlyphsUnicode;
  13054. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  13055. }));
  13056. (function (root, factory) {
  13057. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  13058. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  13059. var error = sharedUtil.error;
  13060. var log2 = sharedUtil.log2;
  13061. var readInt8 = sharedUtil.readInt8;
  13062. var readUint16 = sharedUtil.readUint16;
  13063. var readUint32 = sharedUtil.readUint32;
  13064. var shadow = sharedUtil.shadow;
  13065. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  13066. var Jbig2Image = function Jbig2ImageClosure() {
  13067. function ContextCache() {
  13068. }
  13069. ContextCache.prototype = {
  13070. getContexts: function (id) {
  13071. if (id in this) {
  13072. return this[id];
  13073. }
  13074. return this[id] = new Int8Array(1 << 16);
  13075. }
  13076. };
  13077. function DecodingContext(data, start, end) {
  13078. this.data = data;
  13079. this.start = start;
  13080. this.end = end;
  13081. }
  13082. DecodingContext.prototype = {
  13083. get decoder() {
  13084. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  13085. return shadow(this, 'decoder', decoder);
  13086. },
  13087. get contextCache() {
  13088. var cache = new ContextCache();
  13089. return shadow(this, 'contextCache', cache);
  13090. }
  13091. };
  13092. function decodeInteger(contextCache, procedure, decoder) {
  13093. var contexts = contextCache.getContexts(procedure);
  13094. var prev = 1;
  13095. function readBits(length) {
  13096. var v = 0;
  13097. for (var i = 0; i < length; i++) {
  13098. var bit = decoder.readBit(contexts, prev);
  13099. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  13100. v = v << 1 | bit;
  13101. }
  13102. return v >>> 0;
  13103. }
  13104. var sign = readBits(1);
  13105. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  13106. return sign === 0 ? value : value > 0 ? -value : null;
  13107. }
  13108. function decodeIAID(contextCache, decoder, codeLength) {
  13109. var contexts = contextCache.getContexts('IAID');
  13110. var prev = 1;
  13111. for (var i = 0; i < codeLength; i++) {
  13112. var bit = decoder.readBit(contexts, prev);
  13113. prev = prev << 1 | bit;
  13114. }
  13115. if (codeLength < 31) {
  13116. return prev & (1 << codeLength) - 1;
  13117. }
  13118. return prev & 0x7FFFFFFF;
  13119. }
  13120. var SegmentTypes = [
  13121. 'SymbolDictionary',
  13122. null,
  13123. null,
  13124. null,
  13125. 'IntermediateTextRegion',
  13126. null,
  13127. 'ImmediateTextRegion',
  13128. 'ImmediateLosslessTextRegion',
  13129. null,
  13130. null,
  13131. null,
  13132. null,
  13133. null,
  13134. null,
  13135. null,
  13136. null,
  13137. 'patternDictionary',
  13138. null,
  13139. null,
  13140. null,
  13141. 'IntermediateHalftoneRegion',
  13142. null,
  13143. 'ImmediateHalftoneRegion',
  13144. 'ImmediateLosslessHalftoneRegion',
  13145. null,
  13146. null,
  13147. null,
  13148. null,
  13149. null,
  13150. null,
  13151. null,
  13152. null,
  13153. null,
  13154. null,
  13155. null,
  13156. null,
  13157. 'IntermediateGenericRegion',
  13158. null,
  13159. 'ImmediateGenericRegion',
  13160. 'ImmediateLosslessGenericRegion',
  13161. 'IntermediateGenericRefinementRegion',
  13162. null,
  13163. 'ImmediateGenericRefinementRegion',
  13164. 'ImmediateLosslessGenericRefinementRegion',
  13165. null,
  13166. null,
  13167. null,
  13168. null,
  13169. 'PageInformation',
  13170. 'EndOfPage',
  13171. 'EndOfStripe',
  13172. 'EndOfFile',
  13173. 'Profiles',
  13174. 'Tables',
  13175. null,
  13176. null,
  13177. null,
  13178. null,
  13179. null,
  13180. null,
  13181. null,
  13182. null,
  13183. 'Extension'
  13184. ];
  13185. var CodingTemplates = [
  13186. [
  13187. {
  13188. x: -1,
  13189. y: -2
  13190. },
  13191. {
  13192. x: 0,
  13193. y: -2
  13194. },
  13195. {
  13196. x: 1,
  13197. y: -2
  13198. },
  13199. {
  13200. x: -2,
  13201. y: -1
  13202. },
  13203. {
  13204. x: -1,
  13205. y: -1
  13206. },
  13207. {
  13208. x: 0,
  13209. y: -1
  13210. },
  13211. {
  13212. x: 1,
  13213. y: -1
  13214. },
  13215. {
  13216. x: 2,
  13217. y: -1
  13218. },
  13219. {
  13220. x: -4,
  13221. y: 0
  13222. },
  13223. {
  13224. x: -3,
  13225. y: 0
  13226. },
  13227. {
  13228. x: -2,
  13229. y: 0
  13230. },
  13231. {
  13232. x: -1,
  13233. y: 0
  13234. }
  13235. ],
  13236. [
  13237. {
  13238. x: -1,
  13239. y: -2
  13240. },
  13241. {
  13242. x: 0,
  13243. y: -2
  13244. },
  13245. {
  13246. x: 1,
  13247. y: -2
  13248. },
  13249. {
  13250. x: 2,
  13251. y: -2
  13252. },
  13253. {
  13254. x: -2,
  13255. y: -1
  13256. },
  13257. {
  13258. x: -1,
  13259. y: -1
  13260. },
  13261. {
  13262. x: 0,
  13263. y: -1
  13264. },
  13265. {
  13266. x: 1,
  13267. y: -1
  13268. },
  13269. {
  13270. x: 2,
  13271. y: -1
  13272. },
  13273. {
  13274. x: -3,
  13275. y: 0
  13276. },
  13277. {
  13278. x: -2,
  13279. y: 0
  13280. },
  13281. {
  13282. x: -1,
  13283. y: 0
  13284. }
  13285. ],
  13286. [
  13287. {
  13288. x: -1,
  13289. y: -2
  13290. },
  13291. {
  13292. x: 0,
  13293. y: -2
  13294. },
  13295. {
  13296. x: 1,
  13297. y: -2
  13298. },
  13299. {
  13300. x: -2,
  13301. y: -1
  13302. },
  13303. {
  13304. x: -1,
  13305. y: -1
  13306. },
  13307. {
  13308. x: 0,
  13309. y: -1
  13310. },
  13311. {
  13312. x: 1,
  13313. y: -1
  13314. },
  13315. {
  13316. x: -2,
  13317. y: 0
  13318. },
  13319. {
  13320. x: -1,
  13321. y: 0
  13322. }
  13323. ],
  13324. [
  13325. {
  13326. x: -3,
  13327. y: -1
  13328. },
  13329. {
  13330. x: -2,
  13331. y: -1
  13332. },
  13333. {
  13334. x: -1,
  13335. y: -1
  13336. },
  13337. {
  13338. x: 0,
  13339. y: -1
  13340. },
  13341. {
  13342. x: 1,
  13343. y: -1
  13344. },
  13345. {
  13346. x: -4,
  13347. y: 0
  13348. },
  13349. {
  13350. x: -3,
  13351. y: 0
  13352. },
  13353. {
  13354. x: -2,
  13355. y: 0
  13356. },
  13357. {
  13358. x: -1,
  13359. y: 0
  13360. }
  13361. ]
  13362. ];
  13363. var RefinementTemplates = [
  13364. {
  13365. coding: [
  13366. {
  13367. x: 0,
  13368. y: -1
  13369. },
  13370. {
  13371. x: 1,
  13372. y: -1
  13373. },
  13374. {
  13375. x: -1,
  13376. y: 0
  13377. }
  13378. ],
  13379. reference: [
  13380. {
  13381. x: 0,
  13382. y: -1
  13383. },
  13384. {
  13385. x: 1,
  13386. y: -1
  13387. },
  13388. {
  13389. x: -1,
  13390. y: 0
  13391. },
  13392. {
  13393. x: 0,
  13394. y: 0
  13395. },
  13396. {
  13397. x: 1,
  13398. y: 0
  13399. },
  13400. {
  13401. x: -1,
  13402. y: 1
  13403. },
  13404. {
  13405. x: 0,
  13406. y: 1
  13407. },
  13408. {
  13409. x: 1,
  13410. y: 1
  13411. }
  13412. ]
  13413. },
  13414. {
  13415. coding: [
  13416. {
  13417. x: -1,
  13418. y: -1
  13419. },
  13420. {
  13421. x: 0,
  13422. y: -1
  13423. },
  13424. {
  13425. x: 1,
  13426. y: -1
  13427. },
  13428. {
  13429. x: -1,
  13430. y: 0
  13431. }
  13432. ],
  13433. reference: [
  13434. {
  13435. x: 0,
  13436. y: -1
  13437. },
  13438. {
  13439. x: -1,
  13440. y: 0
  13441. },
  13442. {
  13443. x: 0,
  13444. y: 0
  13445. },
  13446. {
  13447. x: 1,
  13448. y: 0
  13449. },
  13450. {
  13451. x: 0,
  13452. y: 1
  13453. },
  13454. {
  13455. x: 1,
  13456. y: 1
  13457. }
  13458. ]
  13459. }
  13460. ];
  13461. var ReusedContexts = [
  13462. 0x9B25,
  13463. 0x0795,
  13464. 0x00E5,
  13465. 0x0195
  13466. ];
  13467. var RefinementReusedContexts = [
  13468. 0x0020,
  13469. 0x0008
  13470. ];
  13471. function decodeBitmapTemplate0(width, height, decodingContext) {
  13472. var decoder = decodingContext.decoder;
  13473. var contexts = decodingContext.contextCache.getContexts('GB');
  13474. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13475. var OLD_PIXEL_MASK = 0x7BF7;
  13476. for (i = 0; i < height; i++) {
  13477. row = bitmap[i] = new Uint8Array(width);
  13478. row1 = i < 1 ? row : bitmap[i - 1];
  13479. row2 = i < 2 ? row : bitmap[i - 2];
  13480. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13481. for (j = 0; j < width; j++) {
  13482. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13483. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13484. }
  13485. }
  13486. return bitmap;
  13487. }
  13488. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13489. if (mmr) {
  13490. error('JBIG2 error: MMR encoding is not supported');
  13491. }
  13492. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  13493. return decodeBitmapTemplate0(width, height, decodingContext);
  13494. }
  13495. var useskip = !!skip;
  13496. var template = CodingTemplates[templateIndex].concat(at);
  13497. template.sort(function (a, b) {
  13498. return a.y - b.y || a.x - b.x;
  13499. });
  13500. var templateLength = template.length;
  13501. var templateX = new Int8Array(templateLength);
  13502. var templateY = new Int8Array(templateLength);
  13503. var changingTemplateEntries = [];
  13504. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13505. var c, k;
  13506. for (k = 0; k < templateLength; k++) {
  13507. templateX[k] = template[k].x;
  13508. templateY[k] = template[k].y;
  13509. minX = Math.min(minX, template[k].x);
  13510. maxX = Math.max(maxX, template[k].x);
  13511. minY = Math.min(minY, template[k].y);
  13512. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13513. reuseMask |= 1 << templateLength - 1 - k;
  13514. } else {
  13515. changingTemplateEntries.push(k);
  13516. }
  13517. }
  13518. var changingEntriesLength = changingTemplateEntries.length;
  13519. var changingTemplateX = new Int8Array(changingEntriesLength);
  13520. var changingTemplateY = new Int8Array(changingEntriesLength);
  13521. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13522. for (c = 0; c < changingEntriesLength; c++) {
  13523. k = changingTemplateEntries[c];
  13524. changingTemplateX[c] = template[k].x;
  13525. changingTemplateY[c] = template[k].y;
  13526. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13527. }
  13528. var sbb_left = -minX;
  13529. var sbb_top = -minY;
  13530. var sbb_right = width - maxX;
  13531. var pseudoPixelContext = ReusedContexts[templateIndex];
  13532. var row = new Uint8Array(width);
  13533. var bitmap = [];
  13534. var decoder = decodingContext.decoder;
  13535. var contexts = decodingContext.contextCache.getContexts('GB');
  13536. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13537. for (var i = 0; i < height; i++) {
  13538. if (prediction) {
  13539. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13540. ltp ^= sltp;
  13541. if (ltp) {
  13542. bitmap.push(row);
  13543. continue;
  13544. }
  13545. }
  13546. row = new Uint8Array(row);
  13547. bitmap.push(row);
  13548. for (j = 0; j < width; j++) {
  13549. if (useskip && skip[i][j]) {
  13550. row[j] = 0;
  13551. continue;
  13552. }
  13553. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13554. contextLabel = contextLabel << 1 & reuseMask;
  13555. for (k = 0; k < changingEntriesLength; k++) {
  13556. i0 = i + changingTemplateY[k];
  13557. j0 = j + changingTemplateX[k];
  13558. bit = bitmap[i0][j0];
  13559. if (bit) {
  13560. bit = changingTemplateBit[k];
  13561. contextLabel |= bit;
  13562. }
  13563. }
  13564. } else {
  13565. contextLabel = 0;
  13566. shift = templateLength - 1;
  13567. for (k = 0; k < templateLength; k++, shift--) {
  13568. j0 = j + templateX[k];
  13569. if (j0 >= 0 && j0 < width) {
  13570. i0 = i + templateY[k];
  13571. if (i0 >= 0) {
  13572. bit = bitmap[i0][j0];
  13573. if (bit) {
  13574. contextLabel |= bit << shift;
  13575. }
  13576. }
  13577. }
  13578. }
  13579. }
  13580. var pixel = decoder.readBit(contexts, contextLabel);
  13581. row[j] = pixel;
  13582. }
  13583. }
  13584. return bitmap;
  13585. }
  13586. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13587. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13588. if (templateIndex === 0) {
  13589. codingTemplate = codingTemplate.concat([at[0]]);
  13590. }
  13591. var codingTemplateLength = codingTemplate.length;
  13592. var codingTemplateX = new Int32Array(codingTemplateLength);
  13593. var codingTemplateY = new Int32Array(codingTemplateLength);
  13594. var k;
  13595. for (k = 0; k < codingTemplateLength; k++) {
  13596. codingTemplateX[k] = codingTemplate[k].x;
  13597. codingTemplateY[k] = codingTemplate[k].y;
  13598. }
  13599. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13600. if (templateIndex === 0) {
  13601. referenceTemplate = referenceTemplate.concat([at[1]]);
  13602. }
  13603. var referenceTemplateLength = referenceTemplate.length;
  13604. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13605. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13606. for (k = 0; k < referenceTemplateLength; k++) {
  13607. referenceTemplateX[k] = referenceTemplate[k].x;
  13608. referenceTemplateY[k] = referenceTemplate[k].y;
  13609. }
  13610. var referenceWidth = referenceBitmap[0].length;
  13611. var referenceHeight = referenceBitmap.length;
  13612. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13613. var bitmap = [];
  13614. var decoder = decodingContext.decoder;
  13615. var contexts = decodingContext.contextCache.getContexts('GR');
  13616. var ltp = 0;
  13617. for (var i = 0; i < height; i++) {
  13618. if (prediction) {
  13619. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13620. ltp ^= sltp;
  13621. if (ltp) {
  13622. error('JBIG2 error: prediction is not supported');
  13623. }
  13624. }
  13625. var row = new Uint8Array(width);
  13626. bitmap.push(row);
  13627. for (var j = 0; j < width; j++) {
  13628. var i0, j0;
  13629. var contextLabel = 0;
  13630. for (k = 0; k < codingTemplateLength; k++) {
  13631. i0 = i + codingTemplateY[k];
  13632. j0 = j + codingTemplateX[k];
  13633. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13634. contextLabel <<= 1;
  13635. } else
  13636. {
  13637. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13638. }
  13639. }
  13640. for (k = 0; k < referenceTemplateLength; k++) {
  13641. i0 = i + referenceTemplateY[k] + offsetY;
  13642. j0 = j + referenceTemplateX[k] + offsetX;
  13643. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13644. contextLabel <<= 1;
  13645. } else
  13646. {
  13647. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13648. }
  13649. }
  13650. var pixel = decoder.readBit(contexts, contextLabel);
  13651. row[j] = pixel;
  13652. }
  13653. }
  13654. return bitmap;
  13655. }
  13656. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13657. if (huffman) {
  13658. error('JBIG2 error: huffman is not supported');
  13659. }
  13660. var newSymbols = [];
  13661. var currentHeight = 0;
  13662. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13663. var decoder = decodingContext.decoder;
  13664. var contextCache = decodingContext.contextCache;
  13665. while (newSymbols.length < numberOfNewSymbols) {
  13666. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13667. currentHeight += deltaHeight;
  13668. var currentWidth = 0;
  13669. while (true) {
  13670. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13671. if (deltaWidth === null) {
  13672. break;
  13673. }
  13674. currentWidth += deltaWidth;
  13675. var bitmap;
  13676. if (refinement) {
  13677. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13678. if (numberOfInstances > 1) {
  13679. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13680. } else {
  13681. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13682. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13683. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13684. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13685. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13686. }
  13687. } else {
  13688. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13689. }
  13690. newSymbols.push(bitmap);
  13691. }
  13692. }
  13693. var exportedSymbols = [];
  13694. var flags = [], currentFlag = false;
  13695. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13696. while (flags.length < totalSymbolsLength) {
  13697. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13698. while (runLength--) {
  13699. flags.push(currentFlag);
  13700. }
  13701. currentFlag = !currentFlag;
  13702. }
  13703. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13704. if (flags[i]) {
  13705. exportedSymbols.push(symbols[i]);
  13706. }
  13707. }
  13708. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13709. if (flags[i]) {
  13710. exportedSymbols.push(newSymbols[j]);
  13711. }
  13712. }
  13713. return exportedSymbols;
  13714. }
  13715. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13716. if (huffman) {
  13717. error('JBIG2 error: huffman is not supported');
  13718. }
  13719. var bitmap = [];
  13720. var i, row;
  13721. for (i = 0; i < height; i++) {
  13722. row = new Uint8Array(width);
  13723. if (defaultPixelValue) {
  13724. for (var j = 0; j < width; j++) {
  13725. row[j] = defaultPixelValue;
  13726. }
  13727. }
  13728. bitmap.push(row);
  13729. }
  13730. var decoder = decodingContext.decoder;
  13731. var contextCache = decodingContext.contextCache;
  13732. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13733. var firstS = 0;
  13734. i = 0;
  13735. while (i < numberOfSymbolInstances) {
  13736. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13737. stripT += deltaT;
  13738. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13739. firstS += deltaFirstS;
  13740. var currentS = firstS;
  13741. do {
  13742. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13743. var t = stripSize * stripT + currentT;
  13744. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13745. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13746. var symbolBitmap = inputSymbols[symbolId];
  13747. var symbolWidth = symbolBitmap[0].length;
  13748. var symbolHeight = symbolBitmap.length;
  13749. if (applyRefinement) {
  13750. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13751. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13752. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13753. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13754. symbolWidth += rdw;
  13755. symbolHeight += rdh;
  13756. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13757. }
  13758. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13759. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13760. var s2, t2, symbolRow;
  13761. if (transposed) {
  13762. for (s2 = 0; s2 < symbolHeight; s2++) {
  13763. row = bitmap[offsetS + s2];
  13764. if (!row) {
  13765. continue;
  13766. }
  13767. symbolRow = symbolBitmap[s2];
  13768. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13769. switch (combinationOperator) {
  13770. case 0:
  13771. for (t2 = 0; t2 < maxWidth; t2++) {
  13772. row[offsetT + t2] |= symbolRow[t2];
  13773. }
  13774. break;
  13775. case 2:
  13776. for (t2 = 0; t2 < maxWidth; t2++) {
  13777. row[offsetT + t2] ^= symbolRow[t2];
  13778. }
  13779. break;
  13780. default:
  13781. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13782. }
  13783. }
  13784. currentS += symbolHeight - 1;
  13785. } else {
  13786. for (t2 = 0; t2 < symbolHeight; t2++) {
  13787. row = bitmap[offsetT + t2];
  13788. if (!row) {
  13789. continue;
  13790. }
  13791. symbolRow = symbolBitmap[t2];
  13792. switch (combinationOperator) {
  13793. case 0:
  13794. for (s2 = 0; s2 < symbolWidth; s2++) {
  13795. row[offsetS + s2] |= symbolRow[s2];
  13796. }
  13797. break;
  13798. case 2:
  13799. for (s2 = 0; s2 < symbolWidth; s2++) {
  13800. row[offsetS + s2] ^= symbolRow[s2];
  13801. }
  13802. break;
  13803. default:
  13804. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13805. }
  13806. }
  13807. currentS += symbolWidth - 1;
  13808. }
  13809. i++;
  13810. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13811. if (deltaS === null) {
  13812. break;
  13813. }
  13814. currentS += deltaS + dsOffset;
  13815. } while (true);
  13816. }
  13817. return bitmap;
  13818. }
  13819. function readSegmentHeader(data, start) {
  13820. var segmentHeader = {};
  13821. segmentHeader.number = readUint32(data, start);
  13822. var flags = data[start + 4];
  13823. var segmentType = flags & 0x3F;
  13824. if (!SegmentTypes[segmentType]) {
  13825. error('JBIG2 error: invalid segment type: ' + segmentType);
  13826. }
  13827. segmentHeader.type = segmentType;
  13828. segmentHeader.typeName = SegmentTypes[segmentType];
  13829. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13830. var pageAssociationFieldSize = !!(flags & 0x40);
  13831. var referredFlags = data[start + 5];
  13832. var referredToCount = referredFlags >> 5 & 7;
  13833. var retainBits = [referredFlags & 31];
  13834. var position = start + 6;
  13835. if (referredFlags === 7) {
  13836. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13837. position += 3;
  13838. var bytes = referredToCount + 7 >> 3;
  13839. retainBits[0] = data[position++];
  13840. while (--bytes > 0) {
  13841. retainBits.push(data[position++]);
  13842. }
  13843. } else if (referredFlags === 5 || referredFlags === 6) {
  13844. error('JBIG2 error: invalid referred-to flags');
  13845. }
  13846. segmentHeader.retainBits = retainBits;
  13847. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13848. var referredTo = [];
  13849. var i, ii;
  13850. for (i = 0; i < referredToCount; i++) {
  13851. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13852. referredTo.push(number);
  13853. position += referredToSegmentNumberSize;
  13854. }
  13855. segmentHeader.referredTo = referredTo;
  13856. if (!pageAssociationFieldSize) {
  13857. segmentHeader.pageAssociation = data[position++];
  13858. } else {
  13859. segmentHeader.pageAssociation = readUint32(data, position);
  13860. position += 4;
  13861. }
  13862. segmentHeader.length = readUint32(data, position);
  13863. position += 4;
  13864. if (segmentHeader.length === 0xFFFFFFFF) {
  13865. if (segmentType === 38) {
  13866. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13867. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13868. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13869. var searchPatternLength = 6;
  13870. var searchPattern = new Uint8Array(searchPatternLength);
  13871. if (!genericRegionMmr) {
  13872. searchPattern[0] = 0xFF;
  13873. searchPattern[1] = 0xAC;
  13874. }
  13875. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13876. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13877. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13878. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13879. for (i = position, ii = data.length; i < ii; i++) {
  13880. var j = 0;
  13881. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13882. j++;
  13883. }
  13884. if (j === searchPatternLength) {
  13885. segmentHeader.length = i + searchPatternLength;
  13886. break;
  13887. }
  13888. }
  13889. if (segmentHeader.length === 0xFFFFFFFF) {
  13890. error('JBIG2 error: segment end was not found');
  13891. }
  13892. } else {
  13893. error('JBIG2 error: invalid unknown segment length');
  13894. }
  13895. }
  13896. segmentHeader.headerEnd = position;
  13897. return segmentHeader;
  13898. }
  13899. function readSegments(header, data, start, end) {
  13900. var segments = [];
  13901. var position = start;
  13902. while (position < end) {
  13903. var segmentHeader = readSegmentHeader(data, position);
  13904. position = segmentHeader.headerEnd;
  13905. var segment = {
  13906. header: segmentHeader,
  13907. data: data
  13908. };
  13909. if (!header.randomAccess) {
  13910. segment.start = position;
  13911. position += segmentHeader.length;
  13912. segment.end = position;
  13913. }
  13914. segments.push(segment);
  13915. if (segmentHeader.type === 51) {
  13916. break;
  13917. }
  13918. }
  13919. if (header.randomAccess) {
  13920. for (var i = 0, ii = segments.length; i < ii; i++) {
  13921. segments[i].start = position;
  13922. position += segments[i].header.length;
  13923. segments[i].end = position;
  13924. }
  13925. }
  13926. return segments;
  13927. }
  13928. function readRegionSegmentInformation(data, start) {
  13929. return {
  13930. width: readUint32(data, start),
  13931. height: readUint32(data, start + 4),
  13932. x: readUint32(data, start + 8),
  13933. y: readUint32(data, start + 12),
  13934. combinationOperator: data[start + 16] & 7
  13935. };
  13936. }
  13937. var RegionSegmentInformationFieldLength = 17;
  13938. function processSegment(segment, visitor) {
  13939. var header = segment.header;
  13940. var data = segment.data, position = segment.start, end = segment.end;
  13941. var args, at, i, atLength;
  13942. switch (header.type) {
  13943. case 0:
  13944. var dictionary = {};
  13945. var dictionaryFlags = readUint16(data, position);
  13946. dictionary.huffman = !!(dictionaryFlags & 1);
  13947. dictionary.refinement = !!(dictionaryFlags & 2);
  13948. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13949. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13950. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13951. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13952. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13953. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13954. dictionary.template = dictionaryFlags >> 10 & 3;
  13955. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13956. position += 2;
  13957. if (!dictionary.huffman) {
  13958. atLength = dictionary.template === 0 ? 4 : 1;
  13959. at = [];
  13960. for (i = 0; i < atLength; i++) {
  13961. at.push({
  13962. x: readInt8(data, position),
  13963. y: readInt8(data, position + 1)
  13964. });
  13965. position += 2;
  13966. }
  13967. dictionary.at = at;
  13968. }
  13969. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13970. at = [];
  13971. for (i = 0; i < 2; i++) {
  13972. at.push({
  13973. x: readInt8(data, position),
  13974. y: readInt8(data, position + 1)
  13975. });
  13976. position += 2;
  13977. }
  13978. dictionary.refinementAt = at;
  13979. }
  13980. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13981. position += 4;
  13982. dictionary.numberOfNewSymbols = readUint32(data, position);
  13983. position += 4;
  13984. args = [
  13985. dictionary,
  13986. header.number,
  13987. header.referredTo,
  13988. data,
  13989. position,
  13990. end
  13991. ];
  13992. break;
  13993. case 6:
  13994. case 7:
  13995. var textRegion = {};
  13996. textRegion.info = readRegionSegmentInformation(data, position);
  13997. position += RegionSegmentInformationFieldLength;
  13998. var textRegionSegmentFlags = readUint16(data, position);
  13999. position += 2;
  14000. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  14001. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  14002. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  14003. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  14004. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  14005. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  14006. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  14007. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  14008. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  14009. if (textRegion.huffman) {
  14010. var textRegionHuffmanFlags = readUint16(data, position);
  14011. position += 2;
  14012. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  14013. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  14014. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  14015. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  14016. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  14017. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  14018. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  14019. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  14020. }
  14021. if (textRegion.refinement && !textRegion.refinementTemplate) {
  14022. at = [];
  14023. for (i = 0; i < 2; i++) {
  14024. at.push({
  14025. x: readInt8(data, position),
  14026. y: readInt8(data, position + 1)
  14027. });
  14028. position += 2;
  14029. }
  14030. textRegion.refinementAt = at;
  14031. }
  14032. textRegion.numberOfSymbolInstances = readUint32(data, position);
  14033. position += 4;
  14034. if (textRegion.huffman) {
  14035. error('JBIG2 error: huffman is not supported');
  14036. }
  14037. args = [
  14038. textRegion,
  14039. header.referredTo,
  14040. data,
  14041. position,
  14042. end
  14043. ];
  14044. break;
  14045. case 38:
  14046. case 39:
  14047. var genericRegion = {};
  14048. genericRegion.info = readRegionSegmentInformation(data, position);
  14049. position += RegionSegmentInformationFieldLength;
  14050. var genericRegionSegmentFlags = data[position++];
  14051. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  14052. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  14053. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  14054. if (!genericRegion.mmr) {
  14055. atLength = genericRegion.template === 0 ? 4 : 1;
  14056. at = [];
  14057. for (i = 0; i < atLength; i++) {
  14058. at.push({
  14059. x: readInt8(data, position),
  14060. y: readInt8(data, position + 1)
  14061. });
  14062. position += 2;
  14063. }
  14064. genericRegion.at = at;
  14065. }
  14066. args = [
  14067. genericRegion,
  14068. data,
  14069. position,
  14070. end
  14071. ];
  14072. break;
  14073. case 48:
  14074. var pageInfo = {
  14075. width: readUint32(data, position),
  14076. height: readUint32(data, position + 4),
  14077. resolutionX: readUint32(data, position + 8),
  14078. resolutionY: readUint32(data, position + 12)
  14079. };
  14080. if (pageInfo.height === 0xFFFFFFFF) {
  14081. delete pageInfo.height;
  14082. }
  14083. var pageSegmentFlags = data[position + 16];
  14084. readUint16(data, position + 17);
  14085. pageInfo.lossless = !!(pageSegmentFlags & 1);
  14086. pageInfo.refinement = !!(pageSegmentFlags & 2);
  14087. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  14088. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  14089. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  14090. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  14091. args = [pageInfo];
  14092. break;
  14093. case 49:
  14094. break;
  14095. case 50:
  14096. break;
  14097. case 51:
  14098. break;
  14099. case 62:
  14100. break;
  14101. default:
  14102. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  14103. }
  14104. var callbackName = 'on' + header.typeName;
  14105. if (callbackName in visitor) {
  14106. visitor[callbackName].apply(visitor, args);
  14107. }
  14108. }
  14109. function processSegments(segments, visitor) {
  14110. for (var i = 0, ii = segments.length; i < ii; i++) {
  14111. processSegment(segments[i], visitor);
  14112. }
  14113. }
  14114. function parseJbig2(data, start, end) {
  14115. var position = start;
  14116. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  14117. error('JBIG2 error: invalid header');
  14118. }
  14119. var header = {};
  14120. position += 8;
  14121. var flags = data[position++];
  14122. header.randomAccess = !(flags & 1);
  14123. if (!(flags & 2)) {
  14124. header.numberOfPages = readUint32(data, position);
  14125. position += 4;
  14126. }
  14127. readSegments(header, data, position, end);
  14128. error('Not implemented');
  14129. }
  14130. function parseJbig2Chunks(chunks) {
  14131. var visitor = new SimpleSegmentVisitor();
  14132. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14133. var chunk = chunks[i];
  14134. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14135. processSegments(segments, visitor);
  14136. }
  14137. return visitor.buffer;
  14138. }
  14139. function SimpleSegmentVisitor() {
  14140. }
  14141. SimpleSegmentVisitor.prototype = {
  14142. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14143. this.currentPageInfo = info;
  14144. var rowSize = info.width + 7 >> 3;
  14145. var buffer = new Uint8Array(rowSize * info.height);
  14146. if (info.defaultPixelValue) {
  14147. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14148. buffer[i] = 0xFF;
  14149. }
  14150. }
  14151. this.buffer = buffer;
  14152. },
  14153. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14154. var pageInfo = this.currentPageInfo;
  14155. var width = regionInfo.width, height = regionInfo.height;
  14156. var rowSize = pageInfo.width + 7 >> 3;
  14157. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14158. var buffer = this.buffer;
  14159. var mask0 = 128 >> (regionInfo.x & 7);
  14160. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14161. var i, j, mask, offset;
  14162. switch (combinationOperator) {
  14163. case 0:
  14164. for (i = 0; i < height; i++) {
  14165. mask = mask0;
  14166. offset = offset0;
  14167. for (j = 0; j < width; j++) {
  14168. if (bitmap[i][j]) {
  14169. buffer[offset] |= mask;
  14170. }
  14171. mask >>= 1;
  14172. if (!mask) {
  14173. mask = 128;
  14174. offset++;
  14175. }
  14176. }
  14177. offset0 += rowSize;
  14178. }
  14179. break;
  14180. case 2:
  14181. for (i = 0; i < height; i++) {
  14182. mask = mask0;
  14183. offset = offset0;
  14184. for (j = 0; j < width; j++) {
  14185. if (bitmap[i][j]) {
  14186. buffer[offset] ^= mask;
  14187. }
  14188. mask >>= 1;
  14189. if (!mask) {
  14190. mask = 128;
  14191. offset++;
  14192. }
  14193. }
  14194. offset0 += rowSize;
  14195. }
  14196. break;
  14197. default:
  14198. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14199. }
  14200. },
  14201. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14202. var regionInfo = region.info;
  14203. var decodingContext = new DecodingContext(data, start, end);
  14204. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14205. this.drawBitmap(regionInfo, bitmap);
  14206. },
  14207. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14208. this.onImmediateGenericRegion.apply(this, arguments);
  14209. },
  14210. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14211. var huffmanTables;
  14212. if (dictionary.huffman) {
  14213. error('JBIG2 error: huffman is not supported');
  14214. }
  14215. var symbols = this.symbols;
  14216. if (!symbols) {
  14217. this.symbols = symbols = {};
  14218. }
  14219. var inputSymbols = [];
  14220. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14221. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14222. }
  14223. var decodingContext = new DecodingContext(data, start, end);
  14224. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14225. },
  14226. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14227. var regionInfo = region.info;
  14228. var huffmanTables;
  14229. var symbols = this.symbols;
  14230. var inputSymbols = [];
  14231. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14232. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14233. }
  14234. var symbolCodeLength = log2(inputSymbols.length);
  14235. var decodingContext = new DecodingContext(data, start, end);
  14236. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext);
  14237. this.drawBitmap(regionInfo, bitmap);
  14238. },
  14239. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14240. this.onImmediateTextRegion.apply(this, arguments);
  14241. }
  14242. };
  14243. function Jbig2Image() {
  14244. }
  14245. Jbig2Image.prototype = {
  14246. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14247. return parseJbig2Chunks(chunks);
  14248. }
  14249. };
  14250. return Jbig2Image;
  14251. }();
  14252. exports.Jbig2Image = Jbig2Image;
  14253. }));
  14254. (function (root, factory) {
  14255. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14256. }(this, function (exports, sharedUtil) {
  14257. var error = sharedUtil.error;
  14258. var JpegImage = function JpegImageClosure() {
  14259. var dctZigZag = new Uint8Array([
  14260. 0,
  14261. 1,
  14262. 8,
  14263. 16,
  14264. 9,
  14265. 2,
  14266. 3,
  14267. 10,
  14268. 17,
  14269. 24,
  14270. 32,
  14271. 25,
  14272. 18,
  14273. 11,
  14274. 4,
  14275. 5,
  14276. 12,
  14277. 19,
  14278. 26,
  14279. 33,
  14280. 40,
  14281. 48,
  14282. 41,
  14283. 34,
  14284. 27,
  14285. 20,
  14286. 13,
  14287. 6,
  14288. 7,
  14289. 14,
  14290. 21,
  14291. 28,
  14292. 35,
  14293. 42,
  14294. 49,
  14295. 56,
  14296. 57,
  14297. 50,
  14298. 43,
  14299. 36,
  14300. 29,
  14301. 22,
  14302. 15,
  14303. 23,
  14304. 30,
  14305. 37,
  14306. 44,
  14307. 51,
  14308. 58,
  14309. 59,
  14310. 52,
  14311. 45,
  14312. 38,
  14313. 31,
  14314. 39,
  14315. 46,
  14316. 53,
  14317. 60,
  14318. 61,
  14319. 54,
  14320. 47,
  14321. 55,
  14322. 62,
  14323. 63
  14324. ]);
  14325. var dctCos1 = 4017;
  14326. var dctSin1 = 799;
  14327. var dctCos3 = 3406;
  14328. var dctSin3 = 2276;
  14329. var dctCos6 = 1567;
  14330. var dctSin6 = 3784;
  14331. var dctSqrt2 = 5793;
  14332. var dctSqrt1d2 = 2896;
  14333. function JpegImage() {
  14334. this.decodeTransform = null;
  14335. this.colorTransform = -1;
  14336. }
  14337. function buildHuffmanTable(codeLengths, values) {
  14338. var k = 0, code = [], i, j, length = 16;
  14339. while (length > 0 && !codeLengths[length - 1]) {
  14340. length--;
  14341. }
  14342. code.push({
  14343. children: [],
  14344. index: 0
  14345. });
  14346. var p = code[0], q;
  14347. for (i = 0; i < length; i++) {
  14348. for (j = 0; j < codeLengths[i]; j++) {
  14349. p = code.pop();
  14350. p.children[p.index] = values[k];
  14351. while (p.index > 0) {
  14352. p = code.pop();
  14353. }
  14354. p.index++;
  14355. code.push(p);
  14356. while (code.length <= i) {
  14357. code.push(q = {
  14358. children: [],
  14359. index: 0
  14360. });
  14361. p.children[p.index] = q.children;
  14362. p = q;
  14363. }
  14364. k++;
  14365. }
  14366. if (i + 1 < length) {
  14367. code.push(q = {
  14368. children: [],
  14369. index: 0
  14370. });
  14371. p.children[p.index] = q.children;
  14372. p = q;
  14373. }
  14374. }
  14375. return code[0].children;
  14376. }
  14377. function getBlockBufferOffset(component, row, col) {
  14378. return 64 * ((component.blocksPerLine + 1) * row + col);
  14379. }
  14380. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14381. var mcusPerLine = frame.mcusPerLine;
  14382. var progressive = frame.progressive;
  14383. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14384. function readBit() {
  14385. if (bitsCount > 0) {
  14386. bitsCount--;
  14387. return bitsData >> bitsCount & 1;
  14388. }
  14389. bitsData = data[offset++];
  14390. if (bitsData === 0xFF) {
  14391. var nextByte = data[offset++];
  14392. if (nextByte) {
  14393. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14394. }
  14395. }
  14396. bitsCount = 7;
  14397. return bitsData >>> 7;
  14398. }
  14399. function decodeHuffman(tree) {
  14400. var node = tree;
  14401. while (true) {
  14402. node = node[readBit()];
  14403. if (typeof node === 'number') {
  14404. return node;
  14405. }
  14406. if (typeof node !== 'object') {
  14407. error('JPEG error: invalid huffman sequence');
  14408. }
  14409. }
  14410. }
  14411. function receive(length) {
  14412. var n = 0;
  14413. while (length > 0) {
  14414. n = n << 1 | readBit();
  14415. length--;
  14416. }
  14417. return n;
  14418. }
  14419. function receiveAndExtend(length) {
  14420. if (length === 1) {
  14421. return readBit() === 1 ? 1 : -1;
  14422. }
  14423. var n = receive(length);
  14424. if (n >= 1 << length - 1) {
  14425. return n;
  14426. }
  14427. return n + (-1 << length) + 1;
  14428. }
  14429. function decodeBaseline(component, offset) {
  14430. var t = decodeHuffman(component.huffmanTableDC);
  14431. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14432. component.blockData[offset] = component.pred += diff;
  14433. var k = 1;
  14434. while (k < 64) {
  14435. var rs = decodeHuffman(component.huffmanTableAC);
  14436. var s = rs & 15, r = rs >> 4;
  14437. if (s === 0) {
  14438. if (r < 15) {
  14439. break;
  14440. }
  14441. k += 16;
  14442. continue;
  14443. }
  14444. k += r;
  14445. var z = dctZigZag[k];
  14446. component.blockData[offset + z] = receiveAndExtend(s);
  14447. k++;
  14448. }
  14449. }
  14450. function decodeDCFirst(component, offset) {
  14451. var t = decodeHuffman(component.huffmanTableDC);
  14452. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14453. component.blockData[offset] = component.pred += diff;
  14454. }
  14455. function decodeDCSuccessive(component, offset) {
  14456. component.blockData[offset] |= readBit() << successive;
  14457. }
  14458. var eobrun = 0;
  14459. function decodeACFirst(component, offset) {
  14460. if (eobrun > 0) {
  14461. eobrun--;
  14462. return;
  14463. }
  14464. var k = spectralStart, e = spectralEnd;
  14465. while (k <= e) {
  14466. var rs = decodeHuffman(component.huffmanTableAC);
  14467. var s = rs & 15, r = rs >> 4;
  14468. if (s === 0) {
  14469. if (r < 15) {
  14470. eobrun = receive(r) + (1 << r) - 1;
  14471. break;
  14472. }
  14473. k += 16;
  14474. continue;
  14475. }
  14476. k += r;
  14477. var z = dctZigZag[k];
  14478. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14479. k++;
  14480. }
  14481. }
  14482. var successiveACState = 0, successiveACNextValue;
  14483. function decodeACSuccessive(component, offset) {
  14484. var k = spectralStart;
  14485. var e = spectralEnd;
  14486. var r = 0;
  14487. var s;
  14488. var rs;
  14489. while (k <= e) {
  14490. var z = dctZigZag[k];
  14491. switch (successiveACState) {
  14492. case 0:
  14493. rs = decodeHuffman(component.huffmanTableAC);
  14494. s = rs & 15;
  14495. r = rs >> 4;
  14496. if (s === 0) {
  14497. if (r < 15) {
  14498. eobrun = receive(r) + (1 << r);
  14499. successiveACState = 4;
  14500. } else {
  14501. r = 16;
  14502. successiveACState = 1;
  14503. }
  14504. } else {
  14505. if (s !== 1) {
  14506. error('JPEG error: invalid ACn encoding');
  14507. }
  14508. successiveACNextValue = receiveAndExtend(s);
  14509. successiveACState = r ? 2 : 3;
  14510. }
  14511. continue;
  14512. case 1:
  14513. case 2:
  14514. if (component.blockData[offset + z]) {
  14515. component.blockData[offset + z] += readBit() << successive;
  14516. } else {
  14517. r--;
  14518. if (r === 0) {
  14519. successiveACState = successiveACState === 2 ? 3 : 0;
  14520. }
  14521. }
  14522. break;
  14523. case 3:
  14524. if (component.blockData[offset + z]) {
  14525. component.blockData[offset + z] += readBit() << successive;
  14526. } else {
  14527. component.blockData[offset + z] = successiveACNextValue << successive;
  14528. successiveACState = 0;
  14529. }
  14530. break;
  14531. case 4:
  14532. if (component.blockData[offset + z]) {
  14533. component.blockData[offset + z] += readBit() << successive;
  14534. }
  14535. break;
  14536. }
  14537. k++;
  14538. }
  14539. if (successiveACState === 4) {
  14540. eobrun--;
  14541. if (eobrun === 0) {
  14542. successiveACState = 0;
  14543. }
  14544. }
  14545. }
  14546. function decodeMcu(component, decode, mcu, row, col) {
  14547. var mcuRow = mcu / mcusPerLine | 0;
  14548. var mcuCol = mcu % mcusPerLine;
  14549. var blockRow = mcuRow * component.v + row;
  14550. var blockCol = mcuCol * component.h + col;
  14551. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14552. decode(component, offset);
  14553. }
  14554. function decodeBlock(component, decode, mcu) {
  14555. var blockRow = mcu / component.blocksPerLine | 0;
  14556. var blockCol = mcu % component.blocksPerLine;
  14557. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14558. decode(component, offset);
  14559. }
  14560. var componentsLength = components.length;
  14561. var component, i, j, k, n;
  14562. var decodeFn;
  14563. if (progressive) {
  14564. if (spectralStart === 0) {
  14565. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14566. } else {
  14567. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14568. }
  14569. } else {
  14570. decodeFn = decodeBaseline;
  14571. }
  14572. var mcu = 0, marker;
  14573. var mcuExpected;
  14574. if (componentsLength === 1) {
  14575. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14576. } else {
  14577. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14578. }
  14579. if (!resetInterval) {
  14580. resetInterval = mcuExpected;
  14581. }
  14582. var h, v;
  14583. while (mcu < mcuExpected) {
  14584. for (i = 0; i < componentsLength; i++) {
  14585. components[i].pred = 0;
  14586. }
  14587. eobrun = 0;
  14588. if (componentsLength === 1) {
  14589. component = components[0];
  14590. for (n = 0; n < resetInterval; n++) {
  14591. decodeBlock(component, decodeFn, mcu);
  14592. mcu++;
  14593. }
  14594. } else {
  14595. for (n = 0; n < resetInterval; n++) {
  14596. for (i = 0; i < componentsLength; i++) {
  14597. component = components[i];
  14598. h = component.h;
  14599. v = component.v;
  14600. for (j = 0; j < v; j++) {
  14601. for (k = 0; k < h; k++) {
  14602. decodeMcu(component, decodeFn, mcu, j, k);
  14603. }
  14604. }
  14605. }
  14606. mcu++;
  14607. }
  14608. }
  14609. bitsCount = 0;
  14610. marker = data[offset] << 8 | data[offset + 1];
  14611. while (data[offset] === 0x00 && offset < data.length - 1) {
  14612. offset++;
  14613. marker = data[offset] << 8 | data[offset + 1];
  14614. }
  14615. if (marker <= 0xFF00) {
  14616. error('JPEG error: marker was not found');
  14617. }
  14618. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14619. offset += 2;
  14620. } else {
  14621. break;
  14622. }
  14623. }
  14624. return offset - startOffset;
  14625. }
  14626. function quantizeAndInverse(component, blockBufferOffset, p) {
  14627. var qt = component.quantizationTable, blockData = component.blockData;
  14628. var v0, v1, v2, v3, v4, v5, v6, v7;
  14629. var p0, p1, p2, p3, p4, p5, p6, p7;
  14630. var t;
  14631. if (!qt) {
  14632. error('JPEG error: missing required Quantization Table.');
  14633. }
  14634. for (var row = 0; row < 64; row += 8) {
  14635. p0 = blockData[blockBufferOffset + row];
  14636. p1 = blockData[blockBufferOffset + row + 1];
  14637. p2 = blockData[blockBufferOffset + row + 2];
  14638. p3 = blockData[blockBufferOffset + row + 3];
  14639. p4 = blockData[blockBufferOffset + row + 4];
  14640. p5 = blockData[blockBufferOffset + row + 5];
  14641. p6 = blockData[blockBufferOffset + row + 6];
  14642. p7 = blockData[blockBufferOffset + row + 7];
  14643. p0 *= qt[row];
  14644. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14645. t = dctSqrt2 * p0 + 512 >> 10;
  14646. p[row] = t;
  14647. p[row + 1] = t;
  14648. p[row + 2] = t;
  14649. p[row + 3] = t;
  14650. p[row + 4] = t;
  14651. p[row + 5] = t;
  14652. p[row + 6] = t;
  14653. p[row + 7] = t;
  14654. continue;
  14655. }
  14656. p1 *= qt[row + 1];
  14657. p2 *= qt[row + 2];
  14658. p3 *= qt[row + 3];
  14659. p4 *= qt[row + 4];
  14660. p5 *= qt[row + 5];
  14661. p6 *= qt[row + 6];
  14662. p7 *= qt[row + 7];
  14663. v0 = dctSqrt2 * p0 + 128 >> 8;
  14664. v1 = dctSqrt2 * p4 + 128 >> 8;
  14665. v2 = p2;
  14666. v3 = p6;
  14667. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14668. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14669. v5 = p3 << 4;
  14670. v6 = p5 << 4;
  14671. v0 = v0 + v1 + 1 >> 1;
  14672. v1 = v0 - v1;
  14673. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14674. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14675. v3 = t;
  14676. v4 = v4 + v6 + 1 >> 1;
  14677. v6 = v4 - v6;
  14678. v7 = v7 + v5 + 1 >> 1;
  14679. v5 = v7 - v5;
  14680. v0 = v0 + v3 + 1 >> 1;
  14681. v3 = v0 - v3;
  14682. v1 = v1 + v2 + 1 >> 1;
  14683. v2 = v1 - v2;
  14684. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14685. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14686. v7 = t;
  14687. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14688. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14689. v6 = t;
  14690. p[row] = v0 + v7;
  14691. p[row + 7] = v0 - v7;
  14692. p[row + 1] = v1 + v6;
  14693. p[row + 6] = v1 - v6;
  14694. p[row + 2] = v2 + v5;
  14695. p[row + 5] = v2 - v5;
  14696. p[row + 3] = v3 + v4;
  14697. p[row + 4] = v3 - v4;
  14698. }
  14699. for (var col = 0; col < 8; ++col) {
  14700. p0 = p[col];
  14701. p1 = p[col + 8];
  14702. p2 = p[col + 16];
  14703. p3 = p[col + 24];
  14704. p4 = p[col + 32];
  14705. p5 = p[col + 40];
  14706. p6 = p[col + 48];
  14707. p7 = p[col + 56];
  14708. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14709. t = dctSqrt2 * p0 + 8192 >> 14;
  14710. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14711. blockData[blockBufferOffset + col] = t;
  14712. blockData[blockBufferOffset + col + 8] = t;
  14713. blockData[blockBufferOffset + col + 16] = t;
  14714. blockData[blockBufferOffset + col + 24] = t;
  14715. blockData[blockBufferOffset + col + 32] = t;
  14716. blockData[blockBufferOffset + col + 40] = t;
  14717. blockData[blockBufferOffset + col + 48] = t;
  14718. blockData[blockBufferOffset + col + 56] = t;
  14719. continue;
  14720. }
  14721. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14722. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14723. v2 = p2;
  14724. v3 = p6;
  14725. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14726. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14727. v5 = p3;
  14728. v6 = p5;
  14729. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14730. v1 = v0 - v1;
  14731. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14732. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14733. v3 = t;
  14734. v4 = v4 + v6 + 1 >> 1;
  14735. v6 = v4 - v6;
  14736. v7 = v7 + v5 + 1 >> 1;
  14737. v5 = v7 - v5;
  14738. v0 = v0 + v3 + 1 >> 1;
  14739. v3 = v0 - v3;
  14740. v1 = v1 + v2 + 1 >> 1;
  14741. v2 = v1 - v2;
  14742. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14743. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14744. v7 = t;
  14745. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14746. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14747. v6 = t;
  14748. p0 = v0 + v7;
  14749. p7 = v0 - v7;
  14750. p1 = v1 + v6;
  14751. p6 = v1 - v6;
  14752. p2 = v2 + v5;
  14753. p5 = v2 - v5;
  14754. p3 = v3 + v4;
  14755. p4 = v3 - v4;
  14756. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14757. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14758. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14759. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14760. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14761. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14762. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14763. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14764. blockData[blockBufferOffset + col] = p0;
  14765. blockData[blockBufferOffset + col + 8] = p1;
  14766. blockData[blockBufferOffset + col + 16] = p2;
  14767. blockData[blockBufferOffset + col + 24] = p3;
  14768. blockData[blockBufferOffset + col + 32] = p4;
  14769. blockData[blockBufferOffset + col + 40] = p5;
  14770. blockData[blockBufferOffset + col + 48] = p6;
  14771. blockData[blockBufferOffset + col + 56] = p7;
  14772. }
  14773. }
  14774. function buildComponentData(frame, component) {
  14775. var blocksPerLine = component.blocksPerLine;
  14776. var blocksPerColumn = component.blocksPerColumn;
  14777. var computationBuffer = new Int16Array(64);
  14778. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14779. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14780. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14781. quantizeAndInverse(component, offset, computationBuffer);
  14782. }
  14783. }
  14784. return component.blockData;
  14785. }
  14786. function clamp0to255(a) {
  14787. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14788. }
  14789. JpegImage.prototype = {
  14790. parse: function parse(data) {
  14791. function readUint16() {
  14792. var value = data[offset] << 8 | data[offset + 1];
  14793. offset += 2;
  14794. return value;
  14795. }
  14796. function readDataBlock() {
  14797. var length = readUint16();
  14798. var array = data.subarray(offset, offset + length - 2);
  14799. offset += array.length;
  14800. return array;
  14801. }
  14802. function prepareComponents(frame) {
  14803. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14804. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14805. for (var i = 0; i < frame.components.length; i++) {
  14806. component = frame.components[i];
  14807. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14808. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14809. var blocksPerLineForMcu = mcusPerLine * component.h;
  14810. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14811. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14812. component.blockData = new Int16Array(blocksBufferSize);
  14813. component.blocksPerLine = blocksPerLine;
  14814. component.blocksPerColumn = blocksPerColumn;
  14815. }
  14816. frame.mcusPerLine = mcusPerLine;
  14817. frame.mcusPerColumn = mcusPerColumn;
  14818. }
  14819. var offset = 0;
  14820. var jfif = null;
  14821. var adobe = null;
  14822. var frame, resetInterval;
  14823. var quantizationTables = [];
  14824. var huffmanTablesAC = [], huffmanTablesDC = [];
  14825. var fileMarker = readUint16();
  14826. if (fileMarker !== 0xFFD8) {
  14827. error('JPEG error: SOI not found');
  14828. }
  14829. fileMarker = readUint16();
  14830. while (fileMarker !== 0xFFD9) {
  14831. var i, j, l;
  14832. switch (fileMarker) {
  14833. case 0xFFE0:
  14834. case 0xFFE1:
  14835. case 0xFFE2:
  14836. case 0xFFE3:
  14837. case 0xFFE4:
  14838. case 0xFFE5:
  14839. case 0xFFE6:
  14840. case 0xFFE7:
  14841. case 0xFFE8:
  14842. case 0xFFE9:
  14843. case 0xFFEA:
  14844. case 0xFFEB:
  14845. case 0xFFEC:
  14846. case 0xFFED:
  14847. case 0xFFEE:
  14848. case 0xFFEF:
  14849. case 0xFFFE:
  14850. var appData = readDataBlock();
  14851. if (fileMarker === 0xFFE0) {
  14852. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14853. jfif = {
  14854. version: {
  14855. major: appData[5],
  14856. minor: appData[6]
  14857. },
  14858. densityUnits: appData[7],
  14859. xDensity: appData[8] << 8 | appData[9],
  14860. yDensity: appData[10] << 8 | appData[11],
  14861. thumbWidth: appData[12],
  14862. thumbHeight: appData[13],
  14863. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14864. };
  14865. }
  14866. }
  14867. if (fileMarker === 0xFFEE) {
  14868. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14869. adobe = {
  14870. version: appData[5] << 8 | appData[6],
  14871. flags0: appData[7] << 8 | appData[8],
  14872. flags1: appData[9] << 8 | appData[10],
  14873. transformCode: appData[11]
  14874. };
  14875. }
  14876. }
  14877. break;
  14878. case 0xFFDB:
  14879. var quantizationTablesLength = readUint16();
  14880. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14881. var z;
  14882. while (offset < quantizationTablesEnd) {
  14883. var quantizationTableSpec = data[offset++];
  14884. var tableData = new Uint16Array(64);
  14885. if (quantizationTableSpec >> 4 === 0) {
  14886. for (j = 0; j < 64; j++) {
  14887. z = dctZigZag[j];
  14888. tableData[z] = data[offset++];
  14889. }
  14890. } else if (quantizationTableSpec >> 4 === 1) {
  14891. for (j = 0; j < 64; j++) {
  14892. z = dctZigZag[j];
  14893. tableData[z] = readUint16();
  14894. }
  14895. } else {
  14896. error('JPEG error: DQT - invalid table spec');
  14897. }
  14898. quantizationTables[quantizationTableSpec & 15] = tableData;
  14899. }
  14900. break;
  14901. case 0xFFC0:
  14902. case 0xFFC1:
  14903. case 0xFFC2:
  14904. if (frame) {
  14905. error('JPEG error: Only single frame JPEGs supported');
  14906. }
  14907. readUint16();
  14908. frame = {};
  14909. frame.extended = fileMarker === 0xFFC1;
  14910. frame.progressive = fileMarker === 0xFFC2;
  14911. frame.precision = data[offset++];
  14912. frame.scanLines = readUint16();
  14913. frame.samplesPerLine = readUint16();
  14914. frame.components = [];
  14915. frame.componentIds = {};
  14916. var componentsCount = data[offset++], componentId;
  14917. var maxH = 0, maxV = 0;
  14918. for (i = 0; i < componentsCount; i++) {
  14919. componentId = data[offset];
  14920. var h = data[offset + 1] >> 4;
  14921. var v = data[offset + 1] & 15;
  14922. if (maxH < h) {
  14923. maxH = h;
  14924. }
  14925. if (maxV < v) {
  14926. maxV = v;
  14927. }
  14928. var qId = data[offset + 2];
  14929. l = frame.components.push({
  14930. h: h,
  14931. v: v,
  14932. quantizationId: qId,
  14933. quantizationTable: null
  14934. });
  14935. frame.componentIds[componentId] = l - 1;
  14936. offset += 3;
  14937. }
  14938. frame.maxH = maxH;
  14939. frame.maxV = maxV;
  14940. prepareComponents(frame);
  14941. break;
  14942. case 0xFFC4:
  14943. var huffmanLength = readUint16();
  14944. for (i = 2; i < huffmanLength;) {
  14945. var huffmanTableSpec = data[offset++];
  14946. var codeLengths = new Uint8Array(16);
  14947. var codeLengthSum = 0;
  14948. for (j = 0; j < 16; j++, offset++) {
  14949. codeLengthSum += codeLengths[j] = data[offset];
  14950. }
  14951. var huffmanValues = new Uint8Array(codeLengthSum);
  14952. for (j = 0; j < codeLengthSum; j++, offset++) {
  14953. huffmanValues[j] = data[offset];
  14954. }
  14955. i += 17 + codeLengthSum;
  14956. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14957. }
  14958. break;
  14959. case 0xFFDD:
  14960. readUint16();
  14961. resetInterval = readUint16();
  14962. break;
  14963. case 0xFFDA:
  14964. readUint16();
  14965. var selectorsCount = data[offset++];
  14966. var components = [], component;
  14967. for (i = 0; i < selectorsCount; i++) {
  14968. var componentIndex = frame.componentIds[data[offset++]];
  14969. component = frame.components[componentIndex];
  14970. var tableSpec = data[offset++];
  14971. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14972. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14973. components.push(component);
  14974. }
  14975. var spectralStart = data[offset++];
  14976. var spectralEnd = data[offset++];
  14977. var successiveApproximation = data[offset++];
  14978. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14979. offset += processed;
  14980. break;
  14981. case 0xFFFF:
  14982. if (data[offset] !== 0xFF) {
  14983. offset--;
  14984. }
  14985. break;
  14986. default:
  14987. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14988. offset -= 3;
  14989. break;
  14990. }
  14991. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14992. }
  14993. fileMarker = readUint16();
  14994. }
  14995. this.width = frame.samplesPerLine;
  14996. this.height = frame.scanLines;
  14997. this.jfif = jfif;
  14998. this.adobe = adobe;
  14999. this.components = [];
  15000. for (i = 0; i < frame.components.length; i++) {
  15001. component = frame.components[i];
  15002. var quantizationTable = quantizationTables[component.quantizationId];
  15003. if (quantizationTable) {
  15004. component.quantizationTable = quantizationTable;
  15005. }
  15006. this.components.push({
  15007. output: buildComponentData(frame, component),
  15008. scaleX: component.h / frame.maxH,
  15009. scaleY: component.v / frame.maxV,
  15010. blocksPerLine: component.blocksPerLine,
  15011. blocksPerColumn: component.blocksPerColumn
  15012. });
  15013. }
  15014. this.numComponents = this.components.length;
  15015. },
  15016. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  15017. var scaleX = this.width / width, scaleY = this.height / height;
  15018. var component, componentScaleX, componentScaleY, blocksPerScanline;
  15019. var x, y, i, j, k;
  15020. var index;
  15021. var offset = 0;
  15022. var output;
  15023. var numComponents = this.components.length;
  15024. var dataLength = width * height * numComponents;
  15025. var data = new Uint8Array(dataLength);
  15026. var xScaleBlockOffset = new Uint32Array(width);
  15027. var mask3LSB = 0xfffffff8;
  15028. for (i = 0; i < numComponents; i++) {
  15029. component = this.components[i];
  15030. componentScaleX = component.scaleX * scaleX;
  15031. componentScaleY = component.scaleY * scaleY;
  15032. offset = i;
  15033. output = component.output;
  15034. blocksPerScanline = component.blocksPerLine + 1 << 3;
  15035. for (x = 0; x < width; x++) {
  15036. j = 0 | x * componentScaleX;
  15037. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  15038. }
  15039. for (y = 0; y < height; y++) {
  15040. j = 0 | y * componentScaleY;
  15041. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  15042. for (x = 0; x < width; x++) {
  15043. data[offset] = output[index + xScaleBlockOffset[x]];
  15044. offset += numComponents;
  15045. }
  15046. }
  15047. }
  15048. var transform = this.decodeTransform;
  15049. if (transform) {
  15050. for (i = 0; i < dataLength;) {
  15051. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  15052. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  15053. }
  15054. }
  15055. }
  15056. return data;
  15057. },
  15058. _isColorConversionNeeded: function isColorConversionNeeded() {
  15059. if (this.adobe && this.adobe.transformCode) {
  15060. return true;
  15061. } else if (this.numComponents === 3) {
  15062. if (!this.adobe && this.colorTransform === 0) {
  15063. return false;
  15064. }
  15065. return true;
  15066. }
  15067. if (!this.adobe && this.colorTransform === 1) {
  15068. return true;
  15069. }
  15070. return false;
  15071. },
  15072. _convertYccToRgb: function convertYccToRgb(data) {
  15073. var Y, Cb, Cr;
  15074. for (var i = 0, length = data.length; i < length; i += 3) {
  15075. Y = data[i];
  15076. Cb = data[i + 1];
  15077. Cr = data[i + 2];
  15078. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  15079. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  15080. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  15081. }
  15082. return data;
  15083. },
  15084. _convertYcckToRgb: function convertYcckToRgb(data) {
  15085. var Y, Cb, Cr, k;
  15086. var offset = 0;
  15087. for (var i = 0, length = data.length; i < length; i += 4) {
  15088. Y = data[i];
  15089. Cb = data[i + 1];
  15090. Cr = data[i + 2];
  15091. k = data[i + 3];
  15092. var r = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  15093. var g = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  15094. var b = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  15095. data[offset++] = clamp0to255(r);
  15096. data[offset++] = clamp0to255(g);
  15097. data[offset++] = clamp0to255(b);
  15098. }
  15099. return data;
  15100. },
  15101. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  15102. var Y, Cb, Cr;
  15103. for (var i = 0, length = data.length; i < length; i += 4) {
  15104. Y = data[i];
  15105. Cb = data[i + 1];
  15106. Cr = data[i + 2];
  15107. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  15108. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15109. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15110. }
  15111. return data;
  15112. },
  15113. _convertCmykToRgb: function convertCmykToRgb(data) {
  15114. var c, m, y, k;
  15115. var offset = 0;
  15116. var min = -255 * 255 * 255;
  15117. var scale = 1 / 255 / 255;
  15118. for (var i = 0, length = data.length; i < length; i += 4) {
  15119. c = data[i];
  15120. m = data[i + 1];
  15121. y = data[i + 2];
  15122. k = data[i + 3];
  15123. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 72734.4411664936) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 1401.7366389350734) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 4465.541406466231) - k * (21.86122147463605 * k + 48317.86113160301);
  15124. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 20220.756542821975) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 48691.05921601825) + y * (4.444339102852739 * y + 9.8632861493405 * k - 6341.191035517494) - k * (20.737325471181034 * k + 47890.15695978492);
  15125. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 3616.812083916688) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 28620.90484698408) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 49363.43385999684) - k * (22.33816807309886 * k + 45932.16563550634);
  15126. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15127. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15128. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15129. }
  15130. return data;
  15131. },
  15132. getData: function getData(width, height, forceRGBoutput) {
  15133. if (this.numComponents > 4) {
  15134. error('JPEG error: Unsupported color mode');
  15135. }
  15136. var data = this._getLinearizedBlockData(width, height);
  15137. if (this.numComponents === 1 && forceRGBoutput) {
  15138. var dataLength = data.length;
  15139. var rgbData = new Uint8Array(dataLength * 3);
  15140. var offset = 0;
  15141. for (var i = 0; i < dataLength; i++) {
  15142. var grayColor = data[i];
  15143. rgbData[offset++] = grayColor;
  15144. rgbData[offset++] = grayColor;
  15145. rgbData[offset++] = grayColor;
  15146. }
  15147. return rgbData;
  15148. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15149. return this._convertYccToRgb(data);
  15150. } else if (this.numComponents === 4) {
  15151. if (this._isColorConversionNeeded()) {
  15152. if (forceRGBoutput) {
  15153. return this._convertYcckToRgb(data);
  15154. }
  15155. return this._convertYcckToCmyk(data);
  15156. } else if (forceRGBoutput) {
  15157. return this._convertCmykToRgb(data);
  15158. }
  15159. }
  15160. return data;
  15161. }
  15162. };
  15163. return JpegImage;
  15164. }();
  15165. exports.JpegImage = JpegImage;
  15166. }));
  15167. (function (root, factory) {
  15168. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15169. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15170. var info = sharedUtil.info;
  15171. var warn = sharedUtil.warn;
  15172. var error = sharedUtil.error;
  15173. var log2 = sharedUtil.log2;
  15174. var readUint16 = sharedUtil.readUint16;
  15175. var readUint32 = sharedUtil.readUint32;
  15176. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15177. var JpxImage = function JpxImageClosure() {
  15178. var SubbandsGainLog2 = {
  15179. 'LL': 0,
  15180. 'LH': 1,
  15181. 'HL': 1,
  15182. 'HH': 2
  15183. };
  15184. function JpxImage() {
  15185. this.failOnCorruptedImage = false;
  15186. }
  15187. JpxImage.prototype = {
  15188. parse: function JpxImage_parse(data) {
  15189. var head = readUint16(data, 0);
  15190. if (head === 0xFF4F) {
  15191. this.parseCodestream(data, 0, data.length);
  15192. return;
  15193. }
  15194. var position = 0, length = data.length;
  15195. while (position < length) {
  15196. var headerSize = 8;
  15197. var lbox = readUint32(data, position);
  15198. var tbox = readUint32(data, position + 4);
  15199. position += headerSize;
  15200. if (lbox === 1) {
  15201. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15202. position += 8;
  15203. headerSize += 8;
  15204. }
  15205. if (lbox === 0) {
  15206. lbox = length - position + headerSize;
  15207. }
  15208. if (lbox < headerSize) {
  15209. error('JPX Error: Invalid box field size');
  15210. }
  15211. var dataLength = lbox - headerSize;
  15212. var jumpDataLength = true;
  15213. switch (tbox) {
  15214. case 0x6A703268:
  15215. jumpDataLength = false;
  15216. break;
  15217. case 0x636F6C72:
  15218. var method = data[position];
  15219. if (method === 1) {
  15220. var colorspace = readUint32(data, position + 3);
  15221. switch (colorspace) {
  15222. case 16:
  15223. case 17:
  15224. case 18:
  15225. break;
  15226. default:
  15227. warn('Unknown colorspace ' + colorspace);
  15228. break;
  15229. }
  15230. } else if (method === 2) {
  15231. info('ICC profile not supported');
  15232. }
  15233. break;
  15234. case 0x6A703263:
  15235. this.parseCodestream(data, position, position + dataLength);
  15236. break;
  15237. case 0x6A502020:
  15238. if (0x0d0a870a !== readUint32(data, position)) {
  15239. warn('Invalid JP2 signature');
  15240. }
  15241. break;
  15242. case 0x6A501A1A:
  15243. case 0x66747970:
  15244. case 0x72726571:
  15245. case 0x72657320:
  15246. case 0x69686472:
  15247. break;
  15248. default:
  15249. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15250. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15251. break;
  15252. }
  15253. if (jumpDataLength) {
  15254. position += dataLength;
  15255. }
  15256. }
  15257. },
  15258. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15259. var newByte = stream.getByte();
  15260. while (newByte >= 0) {
  15261. var oldByte = newByte;
  15262. newByte = stream.getByte();
  15263. var code = oldByte << 8 | newByte;
  15264. if (code === 0xFF51) {
  15265. stream.skip(4);
  15266. var Xsiz = stream.getInt32() >>> 0;
  15267. var Ysiz = stream.getInt32() >>> 0;
  15268. var XOsiz = stream.getInt32() >>> 0;
  15269. var YOsiz = stream.getInt32() >>> 0;
  15270. stream.skip(16);
  15271. var Csiz = stream.getUint16();
  15272. this.width = Xsiz - XOsiz;
  15273. this.height = Ysiz - YOsiz;
  15274. this.componentsCount = Csiz;
  15275. this.bitsPerComponent = 8;
  15276. return;
  15277. }
  15278. }
  15279. error('JPX Error: No size marker found in JPX stream');
  15280. },
  15281. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15282. var context = {};
  15283. var doNotRecover = false;
  15284. try {
  15285. var position = start;
  15286. while (position + 1 < end) {
  15287. var code = readUint16(data, position);
  15288. position += 2;
  15289. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15290. switch (code) {
  15291. case 0xFF4F:
  15292. context.mainHeader = true;
  15293. break;
  15294. case 0xFFD9:
  15295. break;
  15296. case 0xFF51:
  15297. length = readUint16(data, position);
  15298. var siz = {};
  15299. siz.Xsiz = readUint32(data, position + 4);
  15300. siz.Ysiz = readUint32(data, position + 8);
  15301. siz.XOsiz = readUint32(data, position + 12);
  15302. siz.YOsiz = readUint32(data, position + 16);
  15303. siz.XTsiz = readUint32(data, position + 20);
  15304. siz.YTsiz = readUint32(data, position + 24);
  15305. siz.XTOsiz = readUint32(data, position + 28);
  15306. siz.YTOsiz = readUint32(data, position + 32);
  15307. var componentsCount = readUint16(data, position + 36);
  15308. siz.Csiz = componentsCount;
  15309. var components = [];
  15310. j = position + 38;
  15311. for (var i = 0; i < componentsCount; i++) {
  15312. var component = {
  15313. precision: (data[j] & 0x7F) + 1,
  15314. isSigned: !!(data[j] & 0x80),
  15315. XRsiz: data[j + 1],
  15316. YRsiz: data[j + 1]
  15317. };
  15318. calculateComponentDimensions(component, siz);
  15319. components.push(component);
  15320. }
  15321. context.SIZ = siz;
  15322. context.components = components;
  15323. calculateTileGrids(context, components);
  15324. context.QCC = [];
  15325. context.COC = [];
  15326. break;
  15327. case 0xFF5C:
  15328. length = readUint16(data, position);
  15329. var qcd = {};
  15330. j = position + 2;
  15331. sqcd = data[j++];
  15332. switch (sqcd & 0x1F) {
  15333. case 0:
  15334. spqcdSize = 8;
  15335. scalarExpounded = true;
  15336. break;
  15337. case 1:
  15338. spqcdSize = 16;
  15339. scalarExpounded = false;
  15340. break;
  15341. case 2:
  15342. spqcdSize = 16;
  15343. scalarExpounded = true;
  15344. break;
  15345. default:
  15346. throw new Error('Invalid SQcd value ' + sqcd);
  15347. }
  15348. qcd.noQuantization = spqcdSize === 8;
  15349. qcd.scalarExpounded = scalarExpounded;
  15350. qcd.guardBits = sqcd >> 5;
  15351. spqcds = [];
  15352. while (j < length + position) {
  15353. var spqcd = {};
  15354. if (spqcdSize === 8) {
  15355. spqcd.epsilon = data[j++] >> 3;
  15356. spqcd.mu = 0;
  15357. } else {
  15358. spqcd.epsilon = data[j] >> 3;
  15359. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15360. j += 2;
  15361. }
  15362. spqcds.push(spqcd);
  15363. }
  15364. qcd.SPqcds = spqcds;
  15365. if (context.mainHeader) {
  15366. context.QCD = qcd;
  15367. } else {
  15368. context.currentTile.QCD = qcd;
  15369. context.currentTile.QCC = [];
  15370. }
  15371. break;
  15372. case 0xFF5D:
  15373. length = readUint16(data, position);
  15374. var qcc = {};
  15375. j = position + 2;
  15376. var cqcc;
  15377. if (context.SIZ.Csiz < 257) {
  15378. cqcc = data[j++];
  15379. } else {
  15380. cqcc = readUint16(data, j);
  15381. j += 2;
  15382. }
  15383. sqcd = data[j++];
  15384. switch (sqcd & 0x1F) {
  15385. case 0:
  15386. spqcdSize = 8;
  15387. scalarExpounded = true;
  15388. break;
  15389. case 1:
  15390. spqcdSize = 16;
  15391. scalarExpounded = false;
  15392. break;
  15393. case 2:
  15394. spqcdSize = 16;
  15395. scalarExpounded = true;
  15396. break;
  15397. default:
  15398. throw new Error('Invalid SQcd value ' + sqcd);
  15399. }
  15400. qcc.noQuantization = spqcdSize === 8;
  15401. qcc.scalarExpounded = scalarExpounded;
  15402. qcc.guardBits = sqcd >> 5;
  15403. spqcds = [];
  15404. while (j < length + position) {
  15405. spqcd = {};
  15406. if (spqcdSize === 8) {
  15407. spqcd.epsilon = data[j++] >> 3;
  15408. spqcd.mu = 0;
  15409. } else {
  15410. spqcd.epsilon = data[j] >> 3;
  15411. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15412. j += 2;
  15413. }
  15414. spqcds.push(spqcd);
  15415. }
  15416. qcc.SPqcds = spqcds;
  15417. if (context.mainHeader) {
  15418. context.QCC[cqcc] = qcc;
  15419. } else {
  15420. context.currentTile.QCC[cqcc] = qcc;
  15421. }
  15422. break;
  15423. case 0xFF52:
  15424. length = readUint16(data, position);
  15425. var cod = {};
  15426. j = position + 2;
  15427. var scod = data[j++];
  15428. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15429. cod.sopMarkerUsed = !!(scod & 2);
  15430. cod.ephMarkerUsed = !!(scod & 4);
  15431. cod.progressionOrder = data[j++];
  15432. cod.layersCount = readUint16(data, j);
  15433. j += 2;
  15434. cod.multipleComponentTransform = data[j++];
  15435. cod.decompositionLevelsCount = data[j++];
  15436. cod.xcb = (data[j++] & 0xF) + 2;
  15437. cod.ycb = (data[j++] & 0xF) + 2;
  15438. var blockStyle = data[j++];
  15439. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15440. cod.resetContextProbabilities = !!(blockStyle & 2);
  15441. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15442. cod.verticalyStripe = !!(blockStyle & 8);
  15443. cod.predictableTermination = !!(blockStyle & 16);
  15444. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15445. cod.reversibleTransformation = data[j++];
  15446. if (cod.entropyCoderWithCustomPrecincts) {
  15447. var precinctsSizes = [];
  15448. while (j < length + position) {
  15449. var precinctsSize = data[j++];
  15450. precinctsSizes.push({
  15451. PPx: precinctsSize & 0xF,
  15452. PPy: precinctsSize >> 4
  15453. });
  15454. }
  15455. cod.precinctsSizes = precinctsSizes;
  15456. }
  15457. var unsupported = [];
  15458. if (cod.selectiveArithmeticCodingBypass) {
  15459. unsupported.push('selectiveArithmeticCodingBypass');
  15460. }
  15461. if (cod.resetContextProbabilities) {
  15462. unsupported.push('resetContextProbabilities');
  15463. }
  15464. if (cod.terminationOnEachCodingPass) {
  15465. unsupported.push('terminationOnEachCodingPass');
  15466. }
  15467. if (cod.verticalyStripe) {
  15468. unsupported.push('verticalyStripe');
  15469. }
  15470. if (cod.predictableTermination) {
  15471. unsupported.push('predictableTermination');
  15472. }
  15473. if (unsupported.length > 0) {
  15474. doNotRecover = true;
  15475. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15476. }
  15477. if (context.mainHeader) {
  15478. context.COD = cod;
  15479. } else {
  15480. context.currentTile.COD = cod;
  15481. context.currentTile.COC = [];
  15482. }
  15483. break;
  15484. case 0xFF90:
  15485. length = readUint16(data, position);
  15486. tile = {};
  15487. tile.index = readUint16(data, position + 2);
  15488. tile.length = readUint32(data, position + 4);
  15489. tile.dataEnd = tile.length + position - 2;
  15490. tile.partIndex = data[position + 8];
  15491. tile.partsCount = data[position + 9];
  15492. context.mainHeader = false;
  15493. if (tile.partIndex === 0) {
  15494. tile.COD = context.COD;
  15495. tile.COC = context.COC.slice(0);
  15496. tile.QCD = context.QCD;
  15497. tile.QCC = context.QCC.slice(0);
  15498. }
  15499. context.currentTile = tile;
  15500. break;
  15501. case 0xFF93:
  15502. tile = context.currentTile;
  15503. if (tile.partIndex === 0) {
  15504. initializeTile(context, tile.index);
  15505. buildPackets(context);
  15506. }
  15507. length = tile.dataEnd - position;
  15508. parseTilePackets(context, data, position, length);
  15509. break;
  15510. case 0xFF55:
  15511. case 0xFF57:
  15512. case 0xFF58:
  15513. case 0xFF64:
  15514. length = readUint16(data, position);
  15515. break;
  15516. case 0xFF53:
  15517. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15518. default:
  15519. throw new Error('Unknown codestream code: ' + code.toString(16));
  15520. }
  15521. position += length;
  15522. }
  15523. } catch (e) {
  15524. if (doNotRecover || this.failOnCorruptedImage) {
  15525. error('JPX Error: ' + e.message);
  15526. } else {
  15527. warn('JPX: Trying to recover from: ' + e.message);
  15528. }
  15529. }
  15530. this.tiles = transformComponents(context);
  15531. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15532. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15533. this.componentsCount = context.SIZ.Csiz;
  15534. }
  15535. };
  15536. function calculateComponentDimensions(component, siz) {
  15537. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15538. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15539. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15540. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15541. component.width = component.x1 - component.x0;
  15542. component.height = component.y1 - component.y0;
  15543. }
  15544. function calculateTileGrids(context, components) {
  15545. var siz = context.SIZ;
  15546. var tile, tiles = [];
  15547. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15548. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15549. for (var q = 0; q < numYtiles; q++) {
  15550. for (var p = 0; p < numXtiles; p++) {
  15551. tile = {};
  15552. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15553. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15554. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15555. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15556. tile.width = tile.tx1 - tile.tx0;
  15557. tile.height = tile.ty1 - tile.ty0;
  15558. tile.components = [];
  15559. tiles.push(tile);
  15560. }
  15561. }
  15562. context.tiles = tiles;
  15563. var componentsCount = siz.Csiz;
  15564. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15565. var component = components[i];
  15566. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15567. var tileComponent = {};
  15568. tile = tiles[j];
  15569. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15570. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15571. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15572. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15573. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15574. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15575. tile.components[i] = tileComponent;
  15576. }
  15577. }
  15578. }
  15579. function getBlocksDimensions(context, component, r) {
  15580. var codOrCoc = component.codingStyleParameters;
  15581. var result = {};
  15582. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15583. result.PPx = 15;
  15584. result.PPy = 15;
  15585. } else {
  15586. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15587. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15588. }
  15589. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15590. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15591. return result;
  15592. }
  15593. function buildPrecincts(context, resolution, dimensions) {
  15594. var precinctWidth = 1 << dimensions.PPx;
  15595. var precinctHeight = 1 << dimensions.PPy;
  15596. var isZeroRes = resolution.resLevel === 0;
  15597. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15598. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15599. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15600. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15601. var numprecincts = numprecinctswide * numprecinctshigh;
  15602. resolution.precinctParameters = {
  15603. precinctWidth: precinctWidth,
  15604. precinctHeight: precinctHeight,
  15605. numprecinctswide: numprecinctswide,
  15606. numprecinctshigh: numprecinctshigh,
  15607. numprecincts: numprecincts,
  15608. precinctWidthInSubband: precinctWidthInSubband,
  15609. precinctHeightInSubband: precinctHeightInSubband
  15610. };
  15611. }
  15612. function buildCodeblocks(context, subband, dimensions) {
  15613. var xcb_ = dimensions.xcb_;
  15614. var ycb_ = dimensions.ycb_;
  15615. var codeblockWidth = 1 << xcb_;
  15616. var codeblockHeight = 1 << ycb_;
  15617. var cbx0 = subband.tbx0 >> xcb_;
  15618. var cby0 = subband.tby0 >> ycb_;
  15619. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15620. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15621. var precinctParameters = subband.resolution.precinctParameters;
  15622. var codeblocks = [];
  15623. var precincts = [];
  15624. var i, j, codeblock, precinctNumber;
  15625. for (j = cby0; j < cby1; j++) {
  15626. for (i = cbx0; i < cbx1; i++) {
  15627. codeblock = {
  15628. cbx: i,
  15629. cby: j,
  15630. tbx0: codeblockWidth * i,
  15631. tby0: codeblockHeight * j,
  15632. tbx1: codeblockWidth * (i + 1),
  15633. tby1: codeblockHeight * (j + 1)
  15634. };
  15635. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15636. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15637. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15638. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15639. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15640. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15641. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15642. codeblock.precinctNumber = precinctNumber;
  15643. codeblock.subbandType = subband.type;
  15644. codeblock.Lblock = 3;
  15645. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15646. continue;
  15647. }
  15648. codeblocks.push(codeblock);
  15649. var precinct = precincts[precinctNumber];
  15650. if (precinct !== undefined) {
  15651. if (i < precinct.cbxMin) {
  15652. precinct.cbxMin = i;
  15653. } else if (i > precinct.cbxMax) {
  15654. precinct.cbxMax = i;
  15655. }
  15656. if (j < precinct.cbyMin) {
  15657. precinct.cbxMin = j;
  15658. } else if (j > precinct.cbyMax) {
  15659. precinct.cbyMax = j;
  15660. }
  15661. } else {
  15662. precincts[precinctNumber] = precinct = {
  15663. cbxMin: i,
  15664. cbyMin: j,
  15665. cbxMax: i,
  15666. cbyMax: j
  15667. };
  15668. }
  15669. codeblock.precinct = precinct;
  15670. }
  15671. }
  15672. subband.codeblockParameters = {
  15673. codeblockWidth: xcb_,
  15674. codeblockHeight: ycb_,
  15675. numcodeblockwide: cbx1 - cbx0 + 1,
  15676. numcodeblockhigh: cby1 - cby0 + 1
  15677. };
  15678. subband.codeblocks = codeblocks;
  15679. subband.precincts = precincts;
  15680. }
  15681. function createPacket(resolution, precinctNumber, layerNumber) {
  15682. var precinctCodeblocks = [];
  15683. var subbands = resolution.subbands;
  15684. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15685. var subband = subbands[i];
  15686. var codeblocks = subband.codeblocks;
  15687. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15688. var codeblock = codeblocks[j];
  15689. if (codeblock.precinctNumber !== precinctNumber) {
  15690. continue;
  15691. }
  15692. precinctCodeblocks.push(codeblock);
  15693. }
  15694. }
  15695. return {
  15696. layerNumber: layerNumber,
  15697. codeblocks: precinctCodeblocks
  15698. };
  15699. }
  15700. function LayerResolutionComponentPositionIterator(context) {
  15701. var siz = context.SIZ;
  15702. var tileIndex = context.currentTile.index;
  15703. var tile = context.tiles[tileIndex];
  15704. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15705. var componentsCount = siz.Csiz;
  15706. var maxDecompositionLevelsCount = 0;
  15707. for (var q = 0; q < componentsCount; q++) {
  15708. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15709. }
  15710. var l = 0, r = 0, i = 0, k = 0;
  15711. this.nextPacket = function JpxImage_nextPacket() {
  15712. for (; l < layersCount; l++) {
  15713. for (; r <= maxDecompositionLevelsCount; r++) {
  15714. for (; i < componentsCount; i++) {
  15715. var component = tile.components[i];
  15716. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15717. continue;
  15718. }
  15719. var resolution = component.resolutions[r];
  15720. var numprecincts = resolution.precinctParameters.numprecincts;
  15721. for (; k < numprecincts;) {
  15722. var packet = createPacket(resolution, k, l);
  15723. k++;
  15724. return packet;
  15725. }
  15726. k = 0;
  15727. }
  15728. i = 0;
  15729. }
  15730. r = 0;
  15731. }
  15732. error('JPX Error: Out of packets');
  15733. };
  15734. }
  15735. function ResolutionLayerComponentPositionIterator(context) {
  15736. var siz = context.SIZ;
  15737. var tileIndex = context.currentTile.index;
  15738. var tile = context.tiles[tileIndex];
  15739. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15740. var componentsCount = siz.Csiz;
  15741. var maxDecompositionLevelsCount = 0;
  15742. for (var q = 0; q < componentsCount; q++) {
  15743. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15744. }
  15745. var r = 0, l = 0, i = 0, k = 0;
  15746. this.nextPacket = function JpxImage_nextPacket() {
  15747. for (; r <= maxDecompositionLevelsCount; r++) {
  15748. for (; l < layersCount; l++) {
  15749. for (; i < componentsCount; i++) {
  15750. var component = tile.components[i];
  15751. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15752. continue;
  15753. }
  15754. var resolution = component.resolutions[r];
  15755. var numprecincts = resolution.precinctParameters.numprecincts;
  15756. for (; k < numprecincts;) {
  15757. var packet = createPacket(resolution, k, l);
  15758. k++;
  15759. return packet;
  15760. }
  15761. k = 0;
  15762. }
  15763. i = 0;
  15764. }
  15765. l = 0;
  15766. }
  15767. error('JPX Error: Out of packets');
  15768. };
  15769. }
  15770. function ResolutionPositionComponentLayerIterator(context) {
  15771. var siz = context.SIZ;
  15772. var tileIndex = context.currentTile.index;
  15773. var tile = context.tiles[tileIndex];
  15774. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15775. var componentsCount = siz.Csiz;
  15776. var l, r, c, p;
  15777. var maxDecompositionLevelsCount = 0;
  15778. for (c = 0; c < componentsCount; c++) {
  15779. var component = tile.components[c];
  15780. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15781. }
  15782. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15783. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15784. var maxNumPrecincts = 0;
  15785. for (c = 0; c < componentsCount; ++c) {
  15786. var resolutions = tile.components[c].resolutions;
  15787. if (r < resolutions.length) {
  15788. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15789. }
  15790. }
  15791. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15792. }
  15793. l = 0;
  15794. r = 0;
  15795. c = 0;
  15796. p = 0;
  15797. this.nextPacket = function JpxImage_nextPacket() {
  15798. for (; r <= maxDecompositionLevelsCount; r++) {
  15799. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15800. for (; c < componentsCount; c++) {
  15801. var component = tile.components[c];
  15802. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15803. continue;
  15804. }
  15805. var resolution = component.resolutions[r];
  15806. var numprecincts = resolution.precinctParameters.numprecincts;
  15807. if (p >= numprecincts) {
  15808. continue;
  15809. }
  15810. for (; l < layersCount;) {
  15811. var packet = createPacket(resolution, p, l);
  15812. l++;
  15813. return packet;
  15814. }
  15815. l = 0;
  15816. }
  15817. c = 0;
  15818. }
  15819. p = 0;
  15820. }
  15821. error('JPX Error: Out of packets');
  15822. };
  15823. }
  15824. function PositionComponentResolutionLayerIterator(context) {
  15825. var siz = context.SIZ;
  15826. var tileIndex = context.currentTile.index;
  15827. var tile = context.tiles[tileIndex];
  15828. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15829. var componentsCount = siz.Csiz;
  15830. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15831. var precinctsIterationSizes = precinctsSizes;
  15832. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15833. this.nextPacket = function JpxImage_nextPacket() {
  15834. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15835. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15836. for (; c < componentsCount; c++) {
  15837. var component = tile.components[c];
  15838. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15839. for (; r <= decompositionLevelsCount; r++) {
  15840. var resolution = component.resolutions[r];
  15841. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15842. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15843. if (k === null) {
  15844. continue;
  15845. }
  15846. for (; l < layersCount;) {
  15847. var packet = createPacket(resolution, k, l);
  15848. l++;
  15849. return packet;
  15850. }
  15851. l = 0;
  15852. }
  15853. r = 0;
  15854. }
  15855. c = 0;
  15856. }
  15857. px = 0;
  15858. }
  15859. error('JPX Error: Out of packets');
  15860. };
  15861. }
  15862. function ComponentPositionResolutionLayerIterator(context) {
  15863. var siz = context.SIZ;
  15864. var tileIndex = context.currentTile.index;
  15865. var tile = context.tiles[tileIndex];
  15866. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15867. var componentsCount = siz.Csiz;
  15868. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15869. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15870. this.nextPacket = function JpxImage_nextPacket() {
  15871. for (; c < componentsCount; ++c) {
  15872. var component = tile.components[c];
  15873. var precinctsIterationSizes = precinctsSizes.components[c];
  15874. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15875. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15876. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15877. for (; r <= decompositionLevelsCount; r++) {
  15878. var resolution = component.resolutions[r];
  15879. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15880. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15881. if (k === null) {
  15882. continue;
  15883. }
  15884. for (; l < layersCount;) {
  15885. var packet = createPacket(resolution, k, l);
  15886. l++;
  15887. return packet;
  15888. }
  15889. l = 0;
  15890. }
  15891. r = 0;
  15892. }
  15893. px = 0;
  15894. }
  15895. py = 0;
  15896. }
  15897. error('JPX Error: Out of packets');
  15898. };
  15899. }
  15900. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15901. var posX = pxIndex * precinctIterationSizes.minWidth;
  15902. var posY = pyIndex * precinctIterationSizes.minHeight;
  15903. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15904. return null;
  15905. }
  15906. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15907. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15908. }
  15909. function getPrecinctSizesInImageScale(tile) {
  15910. var componentsCount = tile.components.length;
  15911. var minWidth = Number.MAX_VALUE;
  15912. var minHeight = Number.MAX_VALUE;
  15913. var maxNumWide = 0;
  15914. var maxNumHigh = 0;
  15915. var sizePerComponent = new Array(componentsCount);
  15916. for (var c = 0; c < componentsCount; c++) {
  15917. var component = tile.components[c];
  15918. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15919. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15920. var minWidthCurrentComponent = Number.MAX_VALUE;
  15921. var minHeightCurrentComponent = Number.MAX_VALUE;
  15922. var maxNumWideCurrentComponent = 0;
  15923. var maxNumHighCurrentComponent = 0;
  15924. var scale = 1;
  15925. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15926. var resolution = component.resolutions[r];
  15927. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15928. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15929. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15930. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15931. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15932. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15933. sizePerResolution[r] = {
  15934. width: widthCurrentResolution,
  15935. height: heightCurrentResolution
  15936. };
  15937. scale <<= 1;
  15938. }
  15939. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15940. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15941. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15942. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15943. sizePerComponent[c] = {
  15944. resolutions: sizePerResolution,
  15945. minWidth: minWidthCurrentComponent,
  15946. minHeight: minHeightCurrentComponent,
  15947. maxNumWide: maxNumWideCurrentComponent,
  15948. maxNumHigh: maxNumHighCurrentComponent
  15949. };
  15950. }
  15951. return {
  15952. components: sizePerComponent,
  15953. minWidth: minWidth,
  15954. minHeight: minHeight,
  15955. maxNumWide: maxNumWide,
  15956. maxNumHigh: maxNumHigh
  15957. };
  15958. }
  15959. function buildPackets(context) {
  15960. var siz = context.SIZ;
  15961. var tileIndex = context.currentTile.index;
  15962. var tile = context.tiles[tileIndex];
  15963. var componentsCount = siz.Csiz;
  15964. for (var c = 0; c < componentsCount; c++) {
  15965. var component = tile.components[c];
  15966. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15967. var resolutions = [];
  15968. var subbands = [];
  15969. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15970. var blocksDimensions = getBlocksDimensions(context, component, r);
  15971. var resolution = {};
  15972. var scale = 1 << decompositionLevelsCount - r;
  15973. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15974. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15975. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15976. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15977. resolution.resLevel = r;
  15978. buildPrecincts(context, resolution, blocksDimensions);
  15979. resolutions.push(resolution);
  15980. var subband;
  15981. if (r === 0) {
  15982. subband = {};
  15983. subband.type = 'LL';
  15984. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15985. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15986. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15987. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15988. subband.resolution = resolution;
  15989. buildCodeblocks(context, subband, blocksDimensions);
  15990. subbands.push(subband);
  15991. resolution.subbands = [subband];
  15992. } else {
  15993. var bscale = 1 << decompositionLevelsCount - r + 1;
  15994. var resolutionSubbands = [];
  15995. subband = {};
  15996. subband.type = 'HL';
  15997. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15998. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  15999. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16000. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  16001. subband.resolution = resolution;
  16002. buildCodeblocks(context, subband, blocksDimensions);
  16003. subbands.push(subband);
  16004. resolutionSubbands.push(subband);
  16005. subband = {};
  16006. subband.type = 'LH';
  16007. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  16008. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16009. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  16010. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16011. subband.resolution = resolution;
  16012. buildCodeblocks(context, subband, blocksDimensions);
  16013. subbands.push(subband);
  16014. resolutionSubbands.push(subband);
  16015. subband = {};
  16016. subband.type = 'HH';
  16017. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16018. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16019. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16020. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16021. subband.resolution = resolution;
  16022. buildCodeblocks(context, subband, blocksDimensions);
  16023. subbands.push(subband);
  16024. resolutionSubbands.push(subband);
  16025. resolution.subbands = resolutionSubbands;
  16026. }
  16027. }
  16028. component.resolutions = resolutions;
  16029. component.subbands = subbands;
  16030. }
  16031. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  16032. switch (progressionOrder) {
  16033. case 0:
  16034. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  16035. break;
  16036. case 1:
  16037. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  16038. break;
  16039. case 2:
  16040. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  16041. break;
  16042. case 3:
  16043. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  16044. break;
  16045. case 4:
  16046. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  16047. break;
  16048. default:
  16049. error('JPX Error: Unsupported progression order ' + progressionOrder);
  16050. }
  16051. }
  16052. function parseTilePackets(context, data, offset, dataLength) {
  16053. var position = 0;
  16054. var buffer, bufferSize = 0, skipNextBit = false;
  16055. function readBits(count) {
  16056. while (bufferSize < count) {
  16057. var b = data[offset + position];
  16058. position++;
  16059. if (skipNextBit) {
  16060. buffer = buffer << 7 | b;
  16061. bufferSize += 7;
  16062. skipNextBit = false;
  16063. } else {
  16064. buffer = buffer << 8 | b;
  16065. bufferSize += 8;
  16066. }
  16067. if (b === 0xFF) {
  16068. skipNextBit = true;
  16069. }
  16070. }
  16071. bufferSize -= count;
  16072. return buffer >>> bufferSize & (1 << count) - 1;
  16073. }
  16074. function skipMarkerIfEqual(value) {
  16075. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  16076. skipBytes(1);
  16077. return true;
  16078. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  16079. skipBytes(2);
  16080. return true;
  16081. }
  16082. return false;
  16083. }
  16084. function skipBytes(count) {
  16085. position += count;
  16086. }
  16087. function alignToByte() {
  16088. bufferSize = 0;
  16089. if (skipNextBit) {
  16090. position++;
  16091. skipNextBit = false;
  16092. }
  16093. }
  16094. function readCodingpasses() {
  16095. if (readBits(1) === 0) {
  16096. return 1;
  16097. }
  16098. if (readBits(1) === 0) {
  16099. return 2;
  16100. }
  16101. var value = readBits(2);
  16102. if (value < 3) {
  16103. return value + 3;
  16104. }
  16105. value = readBits(5);
  16106. if (value < 31) {
  16107. return value + 6;
  16108. }
  16109. value = readBits(7);
  16110. return value + 37;
  16111. }
  16112. var tileIndex = context.currentTile.index;
  16113. var tile = context.tiles[tileIndex];
  16114. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16115. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16116. var packetsIterator = tile.packetsIterator;
  16117. while (position < dataLength) {
  16118. alignToByte();
  16119. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16120. skipBytes(4);
  16121. }
  16122. var packet = packetsIterator.nextPacket();
  16123. if (!readBits(1)) {
  16124. continue;
  16125. }
  16126. var layerNumber = packet.layerNumber;
  16127. var queue = [], codeblock;
  16128. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16129. codeblock = packet.codeblocks[i];
  16130. var precinct = codeblock.precinct;
  16131. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16132. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16133. var codeblockIncluded = false;
  16134. var firstTimeInclusion = false;
  16135. var valueReady;
  16136. if (codeblock['included'] !== undefined) {
  16137. codeblockIncluded = !!readBits(1);
  16138. } else {
  16139. precinct = codeblock.precinct;
  16140. var inclusionTree, zeroBitPlanesTree;
  16141. if (precinct['inclusionTree'] !== undefined) {
  16142. inclusionTree = precinct.inclusionTree;
  16143. } else {
  16144. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16145. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16146. inclusionTree = new InclusionTree(width, height, layerNumber);
  16147. zeroBitPlanesTree = new TagTree(width, height);
  16148. precinct.inclusionTree = inclusionTree;
  16149. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16150. }
  16151. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16152. while (true) {
  16153. if (readBits(1)) {
  16154. valueReady = !inclusionTree.nextLevel();
  16155. if (valueReady) {
  16156. codeblock.included = true;
  16157. codeblockIncluded = firstTimeInclusion = true;
  16158. break;
  16159. }
  16160. } else {
  16161. inclusionTree.incrementValue(layerNumber);
  16162. break;
  16163. }
  16164. }
  16165. }
  16166. }
  16167. if (!codeblockIncluded) {
  16168. continue;
  16169. }
  16170. if (firstTimeInclusion) {
  16171. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16172. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16173. while (true) {
  16174. if (readBits(1)) {
  16175. valueReady = !zeroBitPlanesTree.nextLevel();
  16176. if (valueReady) {
  16177. break;
  16178. }
  16179. } else {
  16180. zeroBitPlanesTree.incrementValue();
  16181. }
  16182. }
  16183. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16184. }
  16185. var codingpasses = readCodingpasses();
  16186. while (readBits(1)) {
  16187. codeblock.Lblock++;
  16188. }
  16189. var codingpassesLog2 = log2(codingpasses);
  16190. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16191. var codedDataLength = readBits(bits);
  16192. queue.push({
  16193. codeblock: codeblock,
  16194. codingpasses: codingpasses,
  16195. dataLength: codedDataLength
  16196. });
  16197. }
  16198. alignToByte();
  16199. if (ephMarkerUsed) {
  16200. skipMarkerIfEqual(0x92);
  16201. }
  16202. while (queue.length > 0) {
  16203. var packetItem = queue.shift();
  16204. codeblock = packetItem.codeblock;
  16205. if (codeblock['data'] === undefined) {
  16206. codeblock.data = [];
  16207. }
  16208. codeblock.data.push({
  16209. data: data,
  16210. start: offset + position,
  16211. end: offset + position + packetItem.dataLength,
  16212. codingpasses: packetItem.codingpasses
  16213. });
  16214. position += packetItem.dataLength;
  16215. }
  16216. }
  16217. return position;
  16218. }
  16219. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16220. var x0 = subband.tbx0;
  16221. var y0 = subband.tby0;
  16222. var width = subband.tbx1 - subband.tbx0;
  16223. var codeblocks = subband.codeblocks;
  16224. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16225. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16226. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16227. var codeblock = codeblocks[i];
  16228. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16229. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16230. if (blockWidth === 0 || blockHeight === 0) {
  16231. continue;
  16232. }
  16233. if (codeblock['data'] === undefined) {
  16234. continue;
  16235. }
  16236. var bitModel, currentCodingpassType;
  16237. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16238. currentCodingpassType = 2;
  16239. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16240. var j, jj, dataItem;
  16241. for (j = 0, jj = data.length; j < jj; j++) {
  16242. dataItem = data[j];
  16243. totalLength += dataItem.end - dataItem.start;
  16244. codingpasses += dataItem.codingpasses;
  16245. }
  16246. var encodedData = new Uint8Array(totalLength);
  16247. var position = 0;
  16248. for (j = 0, jj = data.length; j < jj; j++) {
  16249. dataItem = data[j];
  16250. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16251. encodedData.set(chunk, position);
  16252. position += chunk.length;
  16253. }
  16254. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16255. bitModel.setDecoder(decoder);
  16256. for (j = 0; j < codingpasses; j++) {
  16257. switch (currentCodingpassType) {
  16258. case 0:
  16259. bitModel.runSignificancePropagationPass();
  16260. break;
  16261. case 1:
  16262. bitModel.runMagnitudeRefinementPass();
  16263. break;
  16264. case 2:
  16265. bitModel.runCleanupPass();
  16266. if (segmentationSymbolUsed) {
  16267. bitModel.checkSegmentationSymbol();
  16268. }
  16269. break;
  16270. }
  16271. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16272. }
  16273. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16274. var sign = bitModel.coefficentsSign;
  16275. var magnitude = bitModel.coefficentsMagnitude;
  16276. var bitsDecoded = bitModel.bitsDecoded;
  16277. var magnitudeCorrection = reversible ? 0 : 0.5;
  16278. var k, n, nb;
  16279. position = 0;
  16280. var interleave = subband.type !== 'LL';
  16281. for (j = 0; j < blockHeight; j++) {
  16282. var row = offset / width | 0;
  16283. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16284. for (k = 0; k < blockWidth; k++) {
  16285. n = magnitude[position];
  16286. if (n !== 0) {
  16287. n = (n + magnitudeCorrection) * delta;
  16288. if (sign[position] !== 0) {
  16289. n = -n;
  16290. }
  16291. nb = bitsDecoded[position];
  16292. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16293. if (reversible && nb >= mb) {
  16294. coefficients[pos] = n;
  16295. } else {
  16296. coefficients[pos] = n * (1 << mb - nb);
  16297. }
  16298. }
  16299. offset++;
  16300. position++;
  16301. }
  16302. offset += width - blockWidth;
  16303. }
  16304. }
  16305. }
  16306. function transformTile(context, tile, c) {
  16307. var component = tile.components[c];
  16308. var codingStyleParameters = component.codingStyleParameters;
  16309. var quantizationParameters = component.quantizationParameters;
  16310. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16311. var spqcds = quantizationParameters.SPqcds;
  16312. var scalarExpounded = quantizationParameters.scalarExpounded;
  16313. var guardBits = quantizationParameters.guardBits;
  16314. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16315. var precision = context.components[c].precision;
  16316. var reversible = codingStyleParameters.reversibleTransformation;
  16317. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16318. var subbandCoefficients = [];
  16319. var b = 0;
  16320. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16321. var resolution = component.resolutions[i];
  16322. var width = resolution.trx1 - resolution.trx0;
  16323. var height = resolution.try1 - resolution.try0;
  16324. var coefficients = new Float32Array(width * height);
  16325. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16326. var mu, epsilon;
  16327. if (!scalarExpounded) {
  16328. mu = spqcds[0].mu;
  16329. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16330. } else {
  16331. mu = spqcds[b].mu;
  16332. epsilon = spqcds[b].epsilon;
  16333. b++;
  16334. }
  16335. var subband = resolution.subbands[j];
  16336. var gainLog2 = SubbandsGainLog2[subband.type];
  16337. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16338. var mb = guardBits + epsilon - 1;
  16339. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16340. }
  16341. subbandCoefficients.push({
  16342. width: width,
  16343. height: height,
  16344. items: coefficients
  16345. });
  16346. }
  16347. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16348. return {
  16349. left: component.tcx0,
  16350. top: component.tcy0,
  16351. width: result.width,
  16352. height: result.height,
  16353. items: result.items
  16354. };
  16355. }
  16356. function transformComponents(context) {
  16357. var siz = context.SIZ;
  16358. var components = context.components;
  16359. var componentsCount = siz.Csiz;
  16360. var resultImages = [];
  16361. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16362. var tile = context.tiles[i];
  16363. var transformedTiles = [];
  16364. var c;
  16365. for (c = 0; c < componentsCount; c++) {
  16366. transformedTiles[c] = transformTile(context, tile, c);
  16367. }
  16368. var tile0 = transformedTiles[0];
  16369. var out = new Uint8Array(tile0.items.length * componentsCount);
  16370. var result = {
  16371. left: tile0.left,
  16372. top: tile0.top,
  16373. width: tile0.width,
  16374. height: tile0.height,
  16375. items: out
  16376. };
  16377. var shift, offset, max, min, maxK;
  16378. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16379. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16380. var fourComponents = componentsCount === 4;
  16381. var y0items = transformedTiles[0].items;
  16382. var y1items = transformedTiles[1].items;
  16383. var y2items = transformedTiles[2].items;
  16384. var y3items = fourComponents ? transformedTiles[3].items : null;
  16385. shift = components[0].precision - 8;
  16386. offset = (128 << shift) + 0.5;
  16387. max = 255 * (1 << shift);
  16388. maxK = max * 0.5;
  16389. min = -maxK;
  16390. var component0 = tile.components[0];
  16391. var alpha01 = componentsCount - 3;
  16392. jj = y0items.length;
  16393. if (!component0.codingStyleParameters.reversibleTransformation) {
  16394. for (j = 0; j < jj; j++, pos += alpha01) {
  16395. y0 = y0items[j] + offset;
  16396. y1 = y1items[j];
  16397. y2 = y2items[j];
  16398. r = y0 + 1.402 * y2;
  16399. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16400. b = y0 + 1.772 * y1;
  16401. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16402. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16403. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16404. }
  16405. } else {
  16406. for (j = 0; j < jj; j++, pos += alpha01) {
  16407. y0 = y0items[j] + offset;
  16408. y1 = y1items[j];
  16409. y2 = y2items[j];
  16410. g = y0 - (y2 + y1 >> 2);
  16411. r = g + y2;
  16412. b = g + y1;
  16413. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16414. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16415. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16416. }
  16417. }
  16418. if (fourComponents) {
  16419. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16420. k = y3items[j];
  16421. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16422. }
  16423. }
  16424. } else {
  16425. for (c = 0; c < componentsCount; c++) {
  16426. var items = transformedTiles[c].items;
  16427. shift = components[c].precision - 8;
  16428. offset = (128 << shift) + 0.5;
  16429. max = 127.5 * (1 << shift);
  16430. min = -max;
  16431. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16432. val = items[j];
  16433. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16434. pos += componentsCount;
  16435. }
  16436. }
  16437. }
  16438. resultImages.push(result);
  16439. }
  16440. return resultImages;
  16441. }
  16442. function initializeTile(context, tileIndex) {
  16443. var siz = context.SIZ;
  16444. var componentsCount = siz.Csiz;
  16445. var tile = context.tiles[tileIndex];
  16446. for (var c = 0; c < componentsCount; c++) {
  16447. var component = tile.components[c];
  16448. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16449. component.quantizationParameters = qcdOrQcc;
  16450. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16451. component.codingStyleParameters = codOrCoc;
  16452. }
  16453. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16454. }
  16455. var TagTree = function TagTreeClosure() {
  16456. function TagTree(width, height) {
  16457. var levelsLength = log2(Math.max(width, height)) + 1;
  16458. this.levels = [];
  16459. for (var i = 0; i < levelsLength; i++) {
  16460. var level = {
  16461. width: width,
  16462. height: height,
  16463. items: []
  16464. };
  16465. this.levels.push(level);
  16466. width = Math.ceil(width / 2);
  16467. height = Math.ceil(height / 2);
  16468. }
  16469. }
  16470. TagTree.prototype = {
  16471. reset: function TagTree_reset(i, j) {
  16472. var currentLevel = 0, value = 0, level;
  16473. while (currentLevel < this.levels.length) {
  16474. level = this.levels[currentLevel];
  16475. var index = i + j * level.width;
  16476. if (level.items[index] !== undefined) {
  16477. value = level.items[index];
  16478. break;
  16479. }
  16480. level.index = index;
  16481. i >>= 1;
  16482. j >>= 1;
  16483. currentLevel++;
  16484. }
  16485. currentLevel--;
  16486. level = this.levels[currentLevel];
  16487. level.items[level.index] = value;
  16488. this.currentLevel = currentLevel;
  16489. delete this.value;
  16490. },
  16491. incrementValue: function TagTree_incrementValue() {
  16492. var level = this.levels[this.currentLevel];
  16493. level.items[level.index]++;
  16494. },
  16495. nextLevel: function TagTree_nextLevel() {
  16496. var currentLevel = this.currentLevel;
  16497. var level = this.levels[currentLevel];
  16498. var value = level.items[level.index];
  16499. currentLevel--;
  16500. if (currentLevel < 0) {
  16501. this.value = value;
  16502. return false;
  16503. }
  16504. this.currentLevel = currentLevel;
  16505. level = this.levels[currentLevel];
  16506. level.items[level.index] = value;
  16507. return true;
  16508. }
  16509. };
  16510. return TagTree;
  16511. }();
  16512. var InclusionTree = function InclusionTreeClosure() {
  16513. function InclusionTree(width, height, defaultValue) {
  16514. var levelsLength = log2(Math.max(width, height)) + 1;
  16515. this.levels = [];
  16516. for (var i = 0; i < levelsLength; i++) {
  16517. var items = new Uint8Array(width * height);
  16518. for (var j = 0, jj = items.length; j < jj; j++) {
  16519. items[j] = defaultValue;
  16520. }
  16521. var level = {
  16522. width: width,
  16523. height: height,
  16524. items: items
  16525. };
  16526. this.levels.push(level);
  16527. width = Math.ceil(width / 2);
  16528. height = Math.ceil(height / 2);
  16529. }
  16530. }
  16531. InclusionTree.prototype = {
  16532. reset: function InclusionTree_reset(i, j, stopValue) {
  16533. var currentLevel = 0;
  16534. while (currentLevel < this.levels.length) {
  16535. var level = this.levels[currentLevel];
  16536. var index = i + j * level.width;
  16537. level.index = index;
  16538. var value = level.items[index];
  16539. if (value === 0xFF) {
  16540. break;
  16541. }
  16542. if (value > stopValue) {
  16543. this.currentLevel = currentLevel;
  16544. this.propagateValues();
  16545. return false;
  16546. }
  16547. i >>= 1;
  16548. j >>= 1;
  16549. currentLevel++;
  16550. }
  16551. this.currentLevel = currentLevel - 1;
  16552. return true;
  16553. },
  16554. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16555. var level = this.levels[this.currentLevel];
  16556. level.items[level.index] = stopValue + 1;
  16557. this.propagateValues();
  16558. },
  16559. propagateValues: function InclusionTree_propagateValues() {
  16560. var levelIndex = this.currentLevel;
  16561. var level = this.levels[levelIndex];
  16562. var currentValue = level.items[level.index];
  16563. while (--levelIndex >= 0) {
  16564. level = this.levels[levelIndex];
  16565. level.items[level.index] = currentValue;
  16566. }
  16567. },
  16568. nextLevel: function InclusionTree_nextLevel() {
  16569. var currentLevel = this.currentLevel;
  16570. var level = this.levels[currentLevel];
  16571. var value = level.items[level.index];
  16572. level.items[level.index] = 0xFF;
  16573. currentLevel--;
  16574. if (currentLevel < 0) {
  16575. return false;
  16576. }
  16577. this.currentLevel = currentLevel;
  16578. level = this.levels[currentLevel];
  16579. level.items[level.index] = value;
  16580. return true;
  16581. }
  16582. };
  16583. return InclusionTree;
  16584. }();
  16585. var BitModel = function BitModelClosure() {
  16586. var UNIFORM_CONTEXT = 17;
  16587. var RUNLENGTH_CONTEXT = 18;
  16588. var LLAndLHContextsLabel = new Uint8Array([
  16589. 0,
  16590. 5,
  16591. 8,
  16592. 0,
  16593. 3,
  16594. 7,
  16595. 8,
  16596. 0,
  16597. 4,
  16598. 7,
  16599. 8,
  16600. 0,
  16601. 0,
  16602. 0,
  16603. 0,
  16604. 0,
  16605. 1,
  16606. 6,
  16607. 8,
  16608. 0,
  16609. 3,
  16610. 7,
  16611. 8,
  16612. 0,
  16613. 4,
  16614. 7,
  16615. 8,
  16616. 0,
  16617. 0,
  16618. 0,
  16619. 0,
  16620. 0,
  16621. 2,
  16622. 6,
  16623. 8,
  16624. 0,
  16625. 3,
  16626. 7,
  16627. 8,
  16628. 0,
  16629. 4,
  16630. 7,
  16631. 8,
  16632. 0,
  16633. 0,
  16634. 0,
  16635. 0,
  16636. 0,
  16637. 2,
  16638. 6,
  16639. 8,
  16640. 0,
  16641. 3,
  16642. 7,
  16643. 8,
  16644. 0,
  16645. 4,
  16646. 7,
  16647. 8,
  16648. 0,
  16649. 0,
  16650. 0,
  16651. 0,
  16652. 0,
  16653. 2,
  16654. 6,
  16655. 8,
  16656. 0,
  16657. 3,
  16658. 7,
  16659. 8,
  16660. 0,
  16661. 4,
  16662. 7,
  16663. 8
  16664. ]);
  16665. var HLContextLabel = new Uint8Array([
  16666. 0,
  16667. 3,
  16668. 4,
  16669. 0,
  16670. 5,
  16671. 7,
  16672. 7,
  16673. 0,
  16674. 8,
  16675. 8,
  16676. 8,
  16677. 0,
  16678. 0,
  16679. 0,
  16680. 0,
  16681. 0,
  16682. 1,
  16683. 3,
  16684. 4,
  16685. 0,
  16686. 6,
  16687. 7,
  16688. 7,
  16689. 0,
  16690. 8,
  16691. 8,
  16692. 8,
  16693. 0,
  16694. 0,
  16695. 0,
  16696. 0,
  16697. 0,
  16698. 2,
  16699. 3,
  16700. 4,
  16701. 0,
  16702. 6,
  16703. 7,
  16704. 7,
  16705. 0,
  16706. 8,
  16707. 8,
  16708. 8,
  16709. 0,
  16710. 0,
  16711. 0,
  16712. 0,
  16713. 0,
  16714. 2,
  16715. 3,
  16716. 4,
  16717. 0,
  16718. 6,
  16719. 7,
  16720. 7,
  16721. 0,
  16722. 8,
  16723. 8,
  16724. 8,
  16725. 0,
  16726. 0,
  16727. 0,
  16728. 0,
  16729. 0,
  16730. 2,
  16731. 3,
  16732. 4,
  16733. 0,
  16734. 6,
  16735. 7,
  16736. 7,
  16737. 0,
  16738. 8,
  16739. 8,
  16740. 8
  16741. ]);
  16742. var HHContextLabel = new Uint8Array([
  16743. 0,
  16744. 1,
  16745. 2,
  16746. 0,
  16747. 1,
  16748. 2,
  16749. 2,
  16750. 0,
  16751. 2,
  16752. 2,
  16753. 2,
  16754. 0,
  16755. 0,
  16756. 0,
  16757. 0,
  16758. 0,
  16759. 3,
  16760. 4,
  16761. 5,
  16762. 0,
  16763. 4,
  16764. 5,
  16765. 5,
  16766. 0,
  16767. 5,
  16768. 5,
  16769. 5,
  16770. 0,
  16771. 0,
  16772. 0,
  16773. 0,
  16774. 0,
  16775. 6,
  16776. 7,
  16777. 7,
  16778. 0,
  16779. 7,
  16780. 7,
  16781. 7,
  16782. 0,
  16783. 7,
  16784. 7,
  16785. 7,
  16786. 0,
  16787. 0,
  16788. 0,
  16789. 0,
  16790. 0,
  16791. 8,
  16792. 8,
  16793. 8,
  16794. 0,
  16795. 8,
  16796. 8,
  16797. 8,
  16798. 0,
  16799. 8,
  16800. 8,
  16801. 8,
  16802. 0,
  16803. 0,
  16804. 0,
  16805. 0,
  16806. 0,
  16807. 8,
  16808. 8,
  16809. 8,
  16810. 0,
  16811. 8,
  16812. 8,
  16813. 8,
  16814. 0,
  16815. 8,
  16816. 8,
  16817. 8
  16818. ]);
  16819. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16820. this.width = width;
  16821. this.height = height;
  16822. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16823. var coefficientCount = width * height;
  16824. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16825. this.coefficentsSign = new Uint8Array(coefficientCount);
  16826. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16827. this.processingFlags = new Uint8Array(coefficientCount);
  16828. var bitsDecoded = new Uint8Array(coefficientCount);
  16829. if (zeroBitPlanes !== 0) {
  16830. for (var i = 0; i < coefficientCount; i++) {
  16831. bitsDecoded[i] = zeroBitPlanes;
  16832. }
  16833. }
  16834. this.bitsDecoded = bitsDecoded;
  16835. this.reset();
  16836. }
  16837. BitModel.prototype = {
  16838. setDecoder: function BitModel_setDecoder(decoder) {
  16839. this.decoder = decoder;
  16840. },
  16841. reset: function BitModel_reset() {
  16842. this.contexts = new Int8Array(19);
  16843. this.contexts[0] = 4 << 1 | 0;
  16844. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16845. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16846. },
  16847. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16848. var neighborsSignificance = this.neighborsSignificance;
  16849. var width = this.width, height = this.height;
  16850. var left = column > 0;
  16851. var right = column + 1 < width;
  16852. var i;
  16853. if (row > 0) {
  16854. i = index - width;
  16855. if (left) {
  16856. neighborsSignificance[i - 1] += 0x10;
  16857. }
  16858. if (right) {
  16859. neighborsSignificance[i + 1] += 0x10;
  16860. }
  16861. neighborsSignificance[i] += 0x04;
  16862. }
  16863. if (row + 1 < height) {
  16864. i = index + width;
  16865. if (left) {
  16866. neighborsSignificance[i - 1] += 0x10;
  16867. }
  16868. if (right) {
  16869. neighborsSignificance[i + 1] += 0x10;
  16870. }
  16871. neighborsSignificance[i] += 0x04;
  16872. }
  16873. if (left) {
  16874. neighborsSignificance[index - 1] += 0x01;
  16875. }
  16876. if (right) {
  16877. neighborsSignificance[index + 1] += 0x01;
  16878. }
  16879. neighborsSignificance[index] |= 0x80;
  16880. },
  16881. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16882. var decoder = this.decoder;
  16883. var width = this.width, height = this.height;
  16884. var coefficentsMagnitude = this.coefficentsMagnitude;
  16885. var coefficentsSign = this.coefficentsSign;
  16886. var neighborsSignificance = this.neighborsSignificance;
  16887. var processingFlags = this.processingFlags;
  16888. var contexts = this.contexts;
  16889. var labels = this.contextLabelTable;
  16890. var bitsDecoded = this.bitsDecoded;
  16891. var processedInverseMask = ~1;
  16892. var processedMask = 1;
  16893. var firstMagnitudeBitMask = 2;
  16894. for (var i0 = 0; i0 < height; i0 += 4) {
  16895. for (var j = 0; j < width; j++) {
  16896. var index = i0 * width + j;
  16897. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16898. var i = i0 + i1;
  16899. if (i >= height) {
  16900. break;
  16901. }
  16902. processingFlags[index] &= processedInverseMask;
  16903. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16904. continue;
  16905. }
  16906. var contextLabel = labels[neighborsSignificance[index]];
  16907. var decision = decoder.readBit(contexts, contextLabel);
  16908. if (decision) {
  16909. var sign = this.decodeSignBit(i, j, index);
  16910. coefficentsSign[index] = sign;
  16911. coefficentsMagnitude[index] = 1;
  16912. this.setNeighborsSignificance(i, j, index);
  16913. processingFlags[index] |= firstMagnitudeBitMask;
  16914. }
  16915. bitsDecoded[index]++;
  16916. processingFlags[index] |= processedMask;
  16917. }
  16918. }
  16919. }
  16920. },
  16921. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16922. var width = this.width, height = this.height;
  16923. var coefficentsMagnitude = this.coefficentsMagnitude;
  16924. var coefficentsSign = this.coefficentsSign;
  16925. var contribution, sign0, sign1, significance1;
  16926. var contextLabel, decoded;
  16927. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16928. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16929. sign1 = coefficentsSign[index + 1];
  16930. if (significance1) {
  16931. sign0 = coefficentsSign[index - 1];
  16932. contribution = 1 - sign1 - sign0;
  16933. } else {
  16934. contribution = 1 - sign1 - sign1;
  16935. }
  16936. } else if (significance1) {
  16937. sign0 = coefficentsSign[index - 1];
  16938. contribution = 1 - sign0 - sign0;
  16939. } else {
  16940. contribution = 0;
  16941. }
  16942. var horizontalContribution = 3 * contribution;
  16943. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16944. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16945. sign1 = coefficentsSign[index + width];
  16946. if (significance1) {
  16947. sign0 = coefficentsSign[index - width];
  16948. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16949. } else {
  16950. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16951. }
  16952. } else if (significance1) {
  16953. sign0 = coefficentsSign[index - width];
  16954. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16955. } else {
  16956. contribution = horizontalContribution;
  16957. }
  16958. if (contribution >= 0) {
  16959. contextLabel = 9 + contribution;
  16960. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16961. } else {
  16962. contextLabel = 9 - contribution;
  16963. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16964. }
  16965. return decoded;
  16966. },
  16967. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16968. var decoder = this.decoder;
  16969. var width = this.width, height = this.height;
  16970. var coefficentsMagnitude = this.coefficentsMagnitude;
  16971. var neighborsSignificance = this.neighborsSignificance;
  16972. var contexts = this.contexts;
  16973. var bitsDecoded = this.bitsDecoded;
  16974. var processingFlags = this.processingFlags;
  16975. var processedMask = 1;
  16976. var firstMagnitudeBitMask = 2;
  16977. var length = width * height;
  16978. var width4 = width * 4;
  16979. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16980. indexNext = Math.min(length, index0 + width4);
  16981. for (var j = 0; j < width; j++) {
  16982. for (var index = index0 + j; index < indexNext; index += width) {
  16983. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16984. continue;
  16985. }
  16986. var contextLabel = 16;
  16987. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16988. processingFlags[index] ^= firstMagnitudeBitMask;
  16989. var significance = neighborsSignificance[index] & 127;
  16990. contextLabel = significance === 0 ? 15 : 14;
  16991. }
  16992. var bit = decoder.readBit(contexts, contextLabel);
  16993. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16994. bitsDecoded[index]++;
  16995. processingFlags[index] |= processedMask;
  16996. }
  16997. }
  16998. }
  16999. },
  17000. runCleanupPass: function BitModel_runCleanupPass() {
  17001. var decoder = this.decoder;
  17002. var width = this.width, height = this.height;
  17003. var neighborsSignificance = this.neighborsSignificance;
  17004. var coefficentsMagnitude = this.coefficentsMagnitude;
  17005. var coefficentsSign = this.coefficentsSign;
  17006. var contexts = this.contexts;
  17007. var labels = this.contextLabelTable;
  17008. var bitsDecoded = this.bitsDecoded;
  17009. var processingFlags = this.processingFlags;
  17010. var processedMask = 1;
  17011. var firstMagnitudeBitMask = 2;
  17012. var oneRowDown = width;
  17013. var twoRowsDown = width * 2;
  17014. var threeRowsDown = width * 3;
  17015. var iNext;
  17016. for (var i0 = 0; i0 < height; i0 = iNext) {
  17017. iNext = Math.min(i0 + 4, height);
  17018. var indexBase = i0 * width;
  17019. var checkAllEmpty = i0 + 3 < height;
  17020. for (var j = 0; j < width; j++) {
  17021. var index0 = indexBase + j;
  17022. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  17023. var i1 = 0, index = index0;
  17024. var i = i0, sign;
  17025. if (allEmpty) {
  17026. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  17027. if (!hasSignificantCoefficent) {
  17028. bitsDecoded[index0]++;
  17029. bitsDecoded[index0 + oneRowDown]++;
  17030. bitsDecoded[index0 + twoRowsDown]++;
  17031. bitsDecoded[index0 + threeRowsDown]++;
  17032. continue;
  17033. }
  17034. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17035. if (i1 !== 0) {
  17036. i = i0 + i1;
  17037. index += i1 * width;
  17038. }
  17039. sign = this.decodeSignBit(i, j, index);
  17040. coefficentsSign[index] = sign;
  17041. coefficentsMagnitude[index] = 1;
  17042. this.setNeighborsSignificance(i, j, index);
  17043. processingFlags[index] |= firstMagnitudeBitMask;
  17044. index = index0;
  17045. for (var i2 = i0; i2 <= i; i2++, index += width) {
  17046. bitsDecoded[index]++;
  17047. }
  17048. i1++;
  17049. }
  17050. for (i = i0 + i1; i < iNext; i++, index += width) {
  17051. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  17052. continue;
  17053. }
  17054. var contextLabel = labels[neighborsSignificance[index]];
  17055. var decision = decoder.readBit(contexts, contextLabel);
  17056. if (decision === 1) {
  17057. sign = this.decodeSignBit(i, j, index);
  17058. coefficentsSign[index] = sign;
  17059. coefficentsMagnitude[index] = 1;
  17060. this.setNeighborsSignificance(i, j, index);
  17061. processingFlags[index] |= firstMagnitudeBitMask;
  17062. }
  17063. bitsDecoded[index]++;
  17064. }
  17065. }
  17066. }
  17067. },
  17068. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  17069. var decoder = this.decoder;
  17070. var contexts = this.contexts;
  17071. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17072. if (symbol !== 0xA) {
  17073. error('JPX Error: Invalid segmentation symbol');
  17074. }
  17075. }
  17076. };
  17077. return BitModel;
  17078. }();
  17079. var Transform = function TransformClosure() {
  17080. function Transform() {
  17081. }
  17082. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  17083. var ll = subbands[0];
  17084. for (var i = 1, ii = subbands.length; i < ii; i++) {
  17085. ll = this.iterate(ll, subbands[i], u0, v0);
  17086. }
  17087. return ll;
  17088. };
  17089. Transform.prototype.extend = function extend(buffer, offset, size) {
  17090. var i1 = offset - 1, j1 = offset + 1;
  17091. var i2 = offset + size - 2, j2 = offset + size;
  17092. buffer[i1--] = buffer[j1++];
  17093. buffer[j2++] = buffer[i2--];
  17094. buffer[i1--] = buffer[j1++];
  17095. buffer[j2++] = buffer[i2--];
  17096. buffer[i1--] = buffer[j1++];
  17097. buffer[j2++] = buffer[i2--];
  17098. buffer[i1] = buffer[j1];
  17099. buffer[j2] = buffer[i2];
  17100. };
  17101. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  17102. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  17103. var width = hl_lh_hh.width;
  17104. var height = hl_lh_hh.height;
  17105. var items = hl_lh_hh.items;
  17106. var i, j, k, l, u, v;
  17107. for (k = 0, i = 0; i < llHeight; i++) {
  17108. l = i * 2 * width;
  17109. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17110. items[l] = llItems[k];
  17111. }
  17112. }
  17113. llItems = ll.items = null;
  17114. var bufferPadding = 4;
  17115. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17116. if (width === 1) {
  17117. if ((u0 & 1) !== 0) {
  17118. for (v = 0, k = 0; v < height; v++, k += width) {
  17119. items[k] *= 0.5;
  17120. }
  17121. }
  17122. } else {
  17123. for (v = 0, k = 0; v < height; v++, k += width) {
  17124. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17125. this.extend(rowBuffer, bufferPadding, width);
  17126. this.filter(rowBuffer, bufferPadding, width);
  17127. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17128. }
  17129. }
  17130. var numBuffers = 16;
  17131. var colBuffers = [];
  17132. for (i = 0; i < numBuffers; i++) {
  17133. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17134. }
  17135. var b, currentBuffer = 0;
  17136. ll = bufferPadding + height;
  17137. if (height === 1) {
  17138. if ((v0 & 1) !== 0) {
  17139. for (u = 0; u < width; u++) {
  17140. items[u] *= 0.5;
  17141. }
  17142. }
  17143. } else {
  17144. for (u = 0; u < width; u++) {
  17145. if (currentBuffer === 0) {
  17146. numBuffers = Math.min(width - u, numBuffers);
  17147. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17148. for (b = 0; b < numBuffers; b++) {
  17149. colBuffers[b][l] = items[k + b];
  17150. }
  17151. }
  17152. currentBuffer = numBuffers;
  17153. }
  17154. currentBuffer--;
  17155. var buffer = colBuffers[currentBuffer];
  17156. this.extend(buffer, bufferPadding, height);
  17157. this.filter(buffer, bufferPadding, height);
  17158. if (currentBuffer === 0) {
  17159. k = u - numBuffers + 1;
  17160. for (l = bufferPadding; l < ll; k += width, l++) {
  17161. for (b = 0; b < numBuffers; b++) {
  17162. items[k + b] = colBuffers[b][l];
  17163. }
  17164. }
  17165. }
  17166. }
  17167. }
  17168. return {
  17169. width: width,
  17170. height: height,
  17171. items: items
  17172. };
  17173. };
  17174. return Transform;
  17175. }();
  17176. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17177. function IrreversibleTransform() {
  17178. Transform.call(this);
  17179. }
  17180. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17181. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17182. var len = length >> 1;
  17183. offset = offset | 0;
  17184. var j, n, current, next;
  17185. var alpha = -1.586134342059924;
  17186. var beta = -0.052980118572961;
  17187. var gamma = 0.882911075530934;
  17188. var delta = 0.443506852043971;
  17189. var K = 1.230174104914001;
  17190. var K_ = 1 / K;
  17191. j = offset - 3;
  17192. for (n = len + 4; n--; j += 2) {
  17193. x[j] *= K_;
  17194. }
  17195. j = offset - 2;
  17196. current = delta * x[j - 1];
  17197. for (n = len + 3; n--; j += 2) {
  17198. next = delta * x[j + 1];
  17199. x[j] = K * x[j] - current - next;
  17200. if (n--) {
  17201. j += 2;
  17202. current = delta * x[j + 1];
  17203. x[j] = K * x[j] - current - next;
  17204. } else {
  17205. break;
  17206. }
  17207. }
  17208. j = offset - 1;
  17209. current = gamma * x[j - 1];
  17210. for (n = len + 2; n--; j += 2) {
  17211. next = gamma * x[j + 1];
  17212. x[j] -= current + next;
  17213. if (n--) {
  17214. j += 2;
  17215. current = gamma * x[j + 1];
  17216. x[j] -= current + next;
  17217. } else {
  17218. break;
  17219. }
  17220. }
  17221. j = offset;
  17222. current = beta * x[j - 1];
  17223. for (n = len + 1; n--; j += 2) {
  17224. next = beta * x[j + 1];
  17225. x[j] -= current + next;
  17226. if (n--) {
  17227. j += 2;
  17228. current = beta * x[j + 1];
  17229. x[j] -= current + next;
  17230. } else {
  17231. break;
  17232. }
  17233. }
  17234. if (len !== 0) {
  17235. j = offset + 1;
  17236. current = alpha * x[j - 1];
  17237. for (n = len; n--; j += 2) {
  17238. next = alpha * x[j + 1];
  17239. x[j] -= current + next;
  17240. if (n--) {
  17241. j += 2;
  17242. current = alpha * x[j + 1];
  17243. x[j] -= current + next;
  17244. } else {
  17245. break;
  17246. }
  17247. }
  17248. }
  17249. };
  17250. return IrreversibleTransform;
  17251. }();
  17252. var ReversibleTransform = function ReversibleTransformClosure() {
  17253. function ReversibleTransform() {
  17254. Transform.call(this);
  17255. }
  17256. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17257. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17258. var len = length >> 1;
  17259. offset = offset | 0;
  17260. var j, n;
  17261. for (j = offset, n = len + 1; n--; j += 2) {
  17262. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17263. }
  17264. for (j = offset + 1, n = len; n--; j += 2) {
  17265. x[j] += x[j - 1] + x[j + 1] >> 1;
  17266. }
  17267. };
  17268. return ReversibleTransform;
  17269. }();
  17270. return JpxImage;
  17271. }();
  17272. exports.JpxImage = JpxImage;
  17273. }));
  17274. (function (root, factory) {
  17275. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17276. }(this, function (exports, sharedUtil) {
  17277. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17278. var getMetrics = getLookupTableFactory(function (t) {
  17279. t['Courier'] = 600;
  17280. t['Courier-Bold'] = 600;
  17281. t['Courier-BoldOblique'] = 600;
  17282. t['Courier-Oblique'] = 600;
  17283. t['Helvetica'] = getLookupTableFactory(function (t) {
  17284. t['space'] = 278;
  17285. t['exclam'] = 278;
  17286. t['quotedbl'] = 355;
  17287. t['numbersign'] = 556;
  17288. t['dollar'] = 556;
  17289. t['percent'] = 889;
  17290. t['ampersand'] = 667;
  17291. t['quoteright'] = 222;
  17292. t['parenleft'] = 333;
  17293. t['parenright'] = 333;
  17294. t['asterisk'] = 389;
  17295. t['plus'] = 584;
  17296. t['comma'] = 278;
  17297. t['hyphen'] = 333;
  17298. t['period'] = 278;
  17299. t['slash'] = 278;
  17300. t['zero'] = 556;
  17301. t['one'] = 556;
  17302. t['two'] = 556;
  17303. t['three'] = 556;
  17304. t['four'] = 556;
  17305. t['five'] = 556;
  17306. t['six'] = 556;
  17307. t['seven'] = 556;
  17308. t['eight'] = 556;
  17309. t['nine'] = 556;
  17310. t['colon'] = 278;
  17311. t['semicolon'] = 278;
  17312. t['less'] = 584;
  17313. t['equal'] = 584;
  17314. t['greater'] = 584;
  17315. t['question'] = 556;
  17316. t['at'] = 1015;
  17317. t['A'] = 667;
  17318. t['B'] = 667;
  17319. t['C'] = 722;
  17320. t['D'] = 722;
  17321. t['E'] = 667;
  17322. t['F'] = 611;
  17323. t['G'] = 778;
  17324. t['H'] = 722;
  17325. t['I'] = 278;
  17326. t['J'] = 500;
  17327. t['K'] = 667;
  17328. t['L'] = 556;
  17329. t['M'] = 833;
  17330. t['N'] = 722;
  17331. t['O'] = 778;
  17332. t['P'] = 667;
  17333. t['Q'] = 778;
  17334. t['R'] = 722;
  17335. t['S'] = 667;
  17336. t['T'] = 611;
  17337. t['U'] = 722;
  17338. t['V'] = 667;
  17339. t['W'] = 944;
  17340. t['X'] = 667;
  17341. t['Y'] = 667;
  17342. t['Z'] = 611;
  17343. t['bracketleft'] = 278;
  17344. t['backslash'] = 278;
  17345. t['bracketright'] = 278;
  17346. t['asciicircum'] = 469;
  17347. t['underscore'] = 556;
  17348. t['quoteleft'] = 222;
  17349. t['a'] = 556;
  17350. t['b'] = 556;
  17351. t['c'] = 500;
  17352. t['d'] = 556;
  17353. t['e'] = 556;
  17354. t['f'] = 278;
  17355. t['g'] = 556;
  17356. t['h'] = 556;
  17357. t['i'] = 222;
  17358. t['j'] = 222;
  17359. t['k'] = 500;
  17360. t['l'] = 222;
  17361. t['m'] = 833;
  17362. t['n'] = 556;
  17363. t['o'] = 556;
  17364. t['p'] = 556;
  17365. t['q'] = 556;
  17366. t['r'] = 333;
  17367. t['s'] = 500;
  17368. t['t'] = 278;
  17369. t['u'] = 556;
  17370. t['v'] = 500;
  17371. t['w'] = 722;
  17372. t['x'] = 500;
  17373. t['y'] = 500;
  17374. t['z'] = 500;
  17375. t['braceleft'] = 334;
  17376. t['bar'] = 260;
  17377. t['braceright'] = 334;
  17378. t['asciitilde'] = 584;
  17379. t['exclamdown'] = 333;
  17380. t['cent'] = 556;
  17381. t['sterling'] = 556;
  17382. t['fraction'] = 167;
  17383. t['yen'] = 556;
  17384. t['florin'] = 556;
  17385. t['section'] = 556;
  17386. t['currency'] = 556;
  17387. t['quotesingle'] = 191;
  17388. t['quotedblleft'] = 333;
  17389. t['guillemotleft'] = 556;
  17390. t['guilsinglleft'] = 333;
  17391. t['guilsinglright'] = 333;
  17392. t['fi'] = 500;
  17393. t['fl'] = 500;
  17394. t['endash'] = 556;
  17395. t['dagger'] = 556;
  17396. t['daggerdbl'] = 556;
  17397. t['periodcentered'] = 278;
  17398. t['paragraph'] = 537;
  17399. t['bullet'] = 350;
  17400. t['quotesinglbase'] = 222;
  17401. t['quotedblbase'] = 333;
  17402. t['quotedblright'] = 333;
  17403. t['guillemotright'] = 556;
  17404. t['ellipsis'] = 1000;
  17405. t['perthousand'] = 1000;
  17406. t['questiondown'] = 611;
  17407. t['grave'] = 333;
  17408. t['acute'] = 333;
  17409. t['circumflex'] = 333;
  17410. t['tilde'] = 333;
  17411. t['macron'] = 333;
  17412. t['breve'] = 333;
  17413. t['dotaccent'] = 333;
  17414. t['dieresis'] = 333;
  17415. t['ring'] = 333;
  17416. t['cedilla'] = 333;
  17417. t['hungarumlaut'] = 333;
  17418. t['ogonek'] = 333;
  17419. t['caron'] = 333;
  17420. t['emdash'] = 1000;
  17421. t['AE'] = 1000;
  17422. t['ordfeminine'] = 370;
  17423. t['Lslash'] = 556;
  17424. t['Oslash'] = 778;
  17425. t['OE'] = 1000;
  17426. t['ordmasculine'] = 365;
  17427. t['ae'] = 889;
  17428. t['dotlessi'] = 278;
  17429. t['lslash'] = 222;
  17430. t['oslash'] = 611;
  17431. t['oe'] = 944;
  17432. t['germandbls'] = 611;
  17433. t['Idieresis'] = 278;
  17434. t['eacute'] = 556;
  17435. t['abreve'] = 556;
  17436. t['uhungarumlaut'] = 556;
  17437. t['ecaron'] = 556;
  17438. t['Ydieresis'] = 667;
  17439. t['divide'] = 584;
  17440. t['Yacute'] = 667;
  17441. t['Acircumflex'] = 667;
  17442. t['aacute'] = 556;
  17443. t['Ucircumflex'] = 722;
  17444. t['yacute'] = 500;
  17445. t['scommaaccent'] = 500;
  17446. t['ecircumflex'] = 556;
  17447. t['Uring'] = 722;
  17448. t['Udieresis'] = 722;
  17449. t['aogonek'] = 556;
  17450. t['Uacute'] = 722;
  17451. t['uogonek'] = 556;
  17452. t['Edieresis'] = 667;
  17453. t['Dcroat'] = 722;
  17454. t['commaaccent'] = 250;
  17455. t['copyright'] = 737;
  17456. t['Emacron'] = 667;
  17457. t['ccaron'] = 500;
  17458. t['aring'] = 556;
  17459. t['Ncommaaccent'] = 722;
  17460. t['lacute'] = 222;
  17461. t['agrave'] = 556;
  17462. t['Tcommaaccent'] = 611;
  17463. t['Cacute'] = 722;
  17464. t['atilde'] = 556;
  17465. t['Edotaccent'] = 667;
  17466. t['scaron'] = 500;
  17467. t['scedilla'] = 500;
  17468. t['iacute'] = 278;
  17469. t['lozenge'] = 471;
  17470. t['Rcaron'] = 722;
  17471. t['Gcommaaccent'] = 778;
  17472. t['ucircumflex'] = 556;
  17473. t['acircumflex'] = 556;
  17474. t['Amacron'] = 667;
  17475. t['rcaron'] = 333;
  17476. t['ccedilla'] = 500;
  17477. t['Zdotaccent'] = 611;
  17478. t['Thorn'] = 667;
  17479. t['Omacron'] = 778;
  17480. t['Racute'] = 722;
  17481. t['Sacute'] = 667;
  17482. t['dcaron'] = 643;
  17483. t['Umacron'] = 722;
  17484. t['uring'] = 556;
  17485. t['threesuperior'] = 333;
  17486. t['Ograve'] = 778;
  17487. t['Agrave'] = 667;
  17488. t['Abreve'] = 667;
  17489. t['multiply'] = 584;
  17490. t['uacute'] = 556;
  17491. t['Tcaron'] = 611;
  17492. t['partialdiff'] = 476;
  17493. t['ydieresis'] = 500;
  17494. t['Nacute'] = 722;
  17495. t['icircumflex'] = 278;
  17496. t['Ecircumflex'] = 667;
  17497. t['adieresis'] = 556;
  17498. t['edieresis'] = 556;
  17499. t['cacute'] = 500;
  17500. t['nacute'] = 556;
  17501. t['umacron'] = 556;
  17502. t['Ncaron'] = 722;
  17503. t['Iacute'] = 278;
  17504. t['plusminus'] = 584;
  17505. t['brokenbar'] = 260;
  17506. t['registered'] = 737;
  17507. t['Gbreve'] = 778;
  17508. t['Idotaccent'] = 278;
  17509. t['summation'] = 600;
  17510. t['Egrave'] = 667;
  17511. t['racute'] = 333;
  17512. t['omacron'] = 556;
  17513. t['Zacute'] = 611;
  17514. t['Zcaron'] = 611;
  17515. t['greaterequal'] = 549;
  17516. t['Eth'] = 722;
  17517. t['Ccedilla'] = 722;
  17518. t['lcommaaccent'] = 222;
  17519. t['tcaron'] = 317;
  17520. t['eogonek'] = 556;
  17521. t['Uogonek'] = 722;
  17522. t['Aacute'] = 667;
  17523. t['Adieresis'] = 667;
  17524. t['egrave'] = 556;
  17525. t['zacute'] = 500;
  17526. t['iogonek'] = 222;
  17527. t['Oacute'] = 778;
  17528. t['oacute'] = 556;
  17529. t['amacron'] = 556;
  17530. t['sacute'] = 500;
  17531. t['idieresis'] = 278;
  17532. t['Ocircumflex'] = 778;
  17533. t['Ugrave'] = 722;
  17534. t['Delta'] = 612;
  17535. t['thorn'] = 556;
  17536. t['twosuperior'] = 333;
  17537. t['Odieresis'] = 778;
  17538. t['mu'] = 556;
  17539. t['igrave'] = 278;
  17540. t['ohungarumlaut'] = 556;
  17541. t['Eogonek'] = 667;
  17542. t['dcroat'] = 556;
  17543. t['threequarters'] = 834;
  17544. t['Scedilla'] = 667;
  17545. t['lcaron'] = 299;
  17546. t['Kcommaaccent'] = 667;
  17547. t['Lacute'] = 556;
  17548. t['trademark'] = 1000;
  17549. t['edotaccent'] = 556;
  17550. t['Igrave'] = 278;
  17551. t['Imacron'] = 278;
  17552. t['Lcaron'] = 556;
  17553. t['onehalf'] = 834;
  17554. t['lessequal'] = 549;
  17555. t['ocircumflex'] = 556;
  17556. t['ntilde'] = 556;
  17557. t['Uhungarumlaut'] = 722;
  17558. t['Eacute'] = 667;
  17559. t['emacron'] = 556;
  17560. t['gbreve'] = 556;
  17561. t['onequarter'] = 834;
  17562. t['Scaron'] = 667;
  17563. t['Scommaaccent'] = 667;
  17564. t['Ohungarumlaut'] = 778;
  17565. t['degree'] = 400;
  17566. t['ograve'] = 556;
  17567. t['Ccaron'] = 722;
  17568. t['ugrave'] = 556;
  17569. t['radical'] = 453;
  17570. t['Dcaron'] = 722;
  17571. t['rcommaaccent'] = 333;
  17572. t['Ntilde'] = 722;
  17573. t['otilde'] = 556;
  17574. t['Rcommaaccent'] = 722;
  17575. t['Lcommaaccent'] = 556;
  17576. t['Atilde'] = 667;
  17577. t['Aogonek'] = 667;
  17578. t['Aring'] = 667;
  17579. t['Otilde'] = 778;
  17580. t['zdotaccent'] = 500;
  17581. t['Ecaron'] = 667;
  17582. t['Iogonek'] = 278;
  17583. t['kcommaaccent'] = 500;
  17584. t['minus'] = 584;
  17585. t['Icircumflex'] = 278;
  17586. t['ncaron'] = 556;
  17587. t['tcommaaccent'] = 278;
  17588. t['logicalnot'] = 584;
  17589. t['odieresis'] = 556;
  17590. t['udieresis'] = 556;
  17591. t['notequal'] = 549;
  17592. t['gcommaaccent'] = 556;
  17593. t['eth'] = 556;
  17594. t['zcaron'] = 500;
  17595. t['ncommaaccent'] = 556;
  17596. t['onesuperior'] = 333;
  17597. t['imacron'] = 278;
  17598. t['Euro'] = 556;
  17599. });
  17600. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17601. t['space'] = 278;
  17602. t['exclam'] = 333;
  17603. t['quotedbl'] = 474;
  17604. t['numbersign'] = 556;
  17605. t['dollar'] = 556;
  17606. t['percent'] = 889;
  17607. t['ampersand'] = 722;
  17608. t['quoteright'] = 278;
  17609. t['parenleft'] = 333;
  17610. t['parenright'] = 333;
  17611. t['asterisk'] = 389;
  17612. t['plus'] = 584;
  17613. t['comma'] = 278;
  17614. t['hyphen'] = 333;
  17615. t['period'] = 278;
  17616. t['slash'] = 278;
  17617. t['zero'] = 556;
  17618. t['one'] = 556;
  17619. t['two'] = 556;
  17620. t['three'] = 556;
  17621. t['four'] = 556;
  17622. t['five'] = 556;
  17623. t['six'] = 556;
  17624. t['seven'] = 556;
  17625. t['eight'] = 556;
  17626. t['nine'] = 556;
  17627. t['colon'] = 333;
  17628. t['semicolon'] = 333;
  17629. t['less'] = 584;
  17630. t['equal'] = 584;
  17631. t['greater'] = 584;
  17632. t['question'] = 611;
  17633. t['at'] = 975;
  17634. t['A'] = 722;
  17635. t['B'] = 722;
  17636. t['C'] = 722;
  17637. t['D'] = 722;
  17638. t['E'] = 667;
  17639. t['F'] = 611;
  17640. t['G'] = 778;
  17641. t['H'] = 722;
  17642. t['I'] = 278;
  17643. t['J'] = 556;
  17644. t['K'] = 722;
  17645. t['L'] = 611;
  17646. t['M'] = 833;
  17647. t['N'] = 722;
  17648. t['O'] = 778;
  17649. t['P'] = 667;
  17650. t['Q'] = 778;
  17651. t['R'] = 722;
  17652. t['S'] = 667;
  17653. t['T'] = 611;
  17654. t['U'] = 722;
  17655. t['V'] = 667;
  17656. t['W'] = 944;
  17657. t['X'] = 667;
  17658. t['Y'] = 667;
  17659. t['Z'] = 611;
  17660. t['bracketleft'] = 333;
  17661. t['backslash'] = 278;
  17662. t['bracketright'] = 333;
  17663. t['asciicircum'] = 584;
  17664. t['underscore'] = 556;
  17665. t['quoteleft'] = 278;
  17666. t['a'] = 556;
  17667. t['b'] = 611;
  17668. t['c'] = 556;
  17669. t['d'] = 611;
  17670. t['e'] = 556;
  17671. t['f'] = 333;
  17672. t['g'] = 611;
  17673. t['h'] = 611;
  17674. t['i'] = 278;
  17675. t['j'] = 278;
  17676. t['k'] = 556;
  17677. t['l'] = 278;
  17678. t['m'] = 889;
  17679. t['n'] = 611;
  17680. t['o'] = 611;
  17681. t['p'] = 611;
  17682. t['q'] = 611;
  17683. t['r'] = 389;
  17684. t['s'] = 556;
  17685. t['t'] = 333;
  17686. t['u'] = 611;
  17687. t['v'] = 556;
  17688. t['w'] = 778;
  17689. t['x'] = 556;
  17690. t['y'] = 556;
  17691. t['z'] = 500;
  17692. t['braceleft'] = 389;
  17693. t['bar'] = 280;
  17694. t['braceright'] = 389;
  17695. t['asciitilde'] = 584;
  17696. t['exclamdown'] = 333;
  17697. t['cent'] = 556;
  17698. t['sterling'] = 556;
  17699. t['fraction'] = 167;
  17700. t['yen'] = 556;
  17701. t['florin'] = 556;
  17702. t['section'] = 556;
  17703. t['currency'] = 556;
  17704. t['quotesingle'] = 238;
  17705. t['quotedblleft'] = 500;
  17706. t['guillemotleft'] = 556;
  17707. t['guilsinglleft'] = 333;
  17708. t['guilsinglright'] = 333;
  17709. t['fi'] = 611;
  17710. t['fl'] = 611;
  17711. t['endash'] = 556;
  17712. t['dagger'] = 556;
  17713. t['daggerdbl'] = 556;
  17714. t['periodcentered'] = 278;
  17715. t['paragraph'] = 556;
  17716. t['bullet'] = 350;
  17717. t['quotesinglbase'] = 278;
  17718. t['quotedblbase'] = 500;
  17719. t['quotedblright'] = 500;
  17720. t['guillemotright'] = 556;
  17721. t['ellipsis'] = 1000;
  17722. t['perthousand'] = 1000;
  17723. t['questiondown'] = 611;
  17724. t['grave'] = 333;
  17725. t['acute'] = 333;
  17726. t['circumflex'] = 333;
  17727. t['tilde'] = 333;
  17728. t['macron'] = 333;
  17729. t['breve'] = 333;
  17730. t['dotaccent'] = 333;
  17731. t['dieresis'] = 333;
  17732. t['ring'] = 333;
  17733. t['cedilla'] = 333;
  17734. t['hungarumlaut'] = 333;
  17735. t['ogonek'] = 333;
  17736. t['caron'] = 333;
  17737. t['emdash'] = 1000;
  17738. t['AE'] = 1000;
  17739. t['ordfeminine'] = 370;
  17740. t['Lslash'] = 611;
  17741. t['Oslash'] = 778;
  17742. t['OE'] = 1000;
  17743. t['ordmasculine'] = 365;
  17744. t['ae'] = 889;
  17745. t['dotlessi'] = 278;
  17746. t['lslash'] = 278;
  17747. t['oslash'] = 611;
  17748. t['oe'] = 944;
  17749. t['germandbls'] = 611;
  17750. t['Idieresis'] = 278;
  17751. t['eacute'] = 556;
  17752. t['abreve'] = 556;
  17753. t['uhungarumlaut'] = 611;
  17754. t['ecaron'] = 556;
  17755. t['Ydieresis'] = 667;
  17756. t['divide'] = 584;
  17757. t['Yacute'] = 667;
  17758. t['Acircumflex'] = 722;
  17759. t['aacute'] = 556;
  17760. t['Ucircumflex'] = 722;
  17761. t['yacute'] = 556;
  17762. t['scommaaccent'] = 556;
  17763. t['ecircumflex'] = 556;
  17764. t['Uring'] = 722;
  17765. t['Udieresis'] = 722;
  17766. t['aogonek'] = 556;
  17767. t['Uacute'] = 722;
  17768. t['uogonek'] = 611;
  17769. t['Edieresis'] = 667;
  17770. t['Dcroat'] = 722;
  17771. t['commaaccent'] = 250;
  17772. t['copyright'] = 737;
  17773. t['Emacron'] = 667;
  17774. t['ccaron'] = 556;
  17775. t['aring'] = 556;
  17776. t['Ncommaaccent'] = 722;
  17777. t['lacute'] = 278;
  17778. t['agrave'] = 556;
  17779. t['Tcommaaccent'] = 611;
  17780. t['Cacute'] = 722;
  17781. t['atilde'] = 556;
  17782. t['Edotaccent'] = 667;
  17783. t['scaron'] = 556;
  17784. t['scedilla'] = 556;
  17785. t['iacute'] = 278;
  17786. t['lozenge'] = 494;
  17787. t['Rcaron'] = 722;
  17788. t['Gcommaaccent'] = 778;
  17789. t['ucircumflex'] = 611;
  17790. t['acircumflex'] = 556;
  17791. t['Amacron'] = 722;
  17792. t['rcaron'] = 389;
  17793. t['ccedilla'] = 556;
  17794. t['Zdotaccent'] = 611;
  17795. t['Thorn'] = 667;
  17796. t['Omacron'] = 778;
  17797. t['Racute'] = 722;
  17798. t['Sacute'] = 667;
  17799. t['dcaron'] = 743;
  17800. t['Umacron'] = 722;
  17801. t['uring'] = 611;
  17802. t['threesuperior'] = 333;
  17803. t['Ograve'] = 778;
  17804. t['Agrave'] = 722;
  17805. t['Abreve'] = 722;
  17806. t['multiply'] = 584;
  17807. t['uacute'] = 611;
  17808. t['Tcaron'] = 611;
  17809. t['partialdiff'] = 494;
  17810. t['ydieresis'] = 556;
  17811. t['Nacute'] = 722;
  17812. t['icircumflex'] = 278;
  17813. t['Ecircumflex'] = 667;
  17814. t['adieresis'] = 556;
  17815. t['edieresis'] = 556;
  17816. t['cacute'] = 556;
  17817. t['nacute'] = 611;
  17818. t['umacron'] = 611;
  17819. t['Ncaron'] = 722;
  17820. t['Iacute'] = 278;
  17821. t['plusminus'] = 584;
  17822. t['brokenbar'] = 280;
  17823. t['registered'] = 737;
  17824. t['Gbreve'] = 778;
  17825. t['Idotaccent'] = 278;
  17826. t['summation'] = 600;
  17827. t['Egrave'] = 667;
  17828. t['racute'] = 389;
  17829. t['omacron'] = 611;
  17830. t['Zacute'] = 611;
  17831. t['Zcaron'] = 611;
  17832. t['greaterequal'] = 549;
  17833. t['Eth'] = 722;
  17834. t['Ccedilla'] = 722;
  17835. t['lcommaaccent'] = 278;
  17836. t['tcaron'] = 389;
  17837. t['eogonek'] = 556;
  17838. t['Uogonek'] = 722;
  17839. t['Aacute'] = 722;
  17840. t['Adieresis'] = 722;
  17841. t['egrave'] = 556;
  17842. t['zacute'] = 500;
  17843. t['iogonek'] = 278;
  17844. t['Oacute'] = 778;
  17845. t['oacute'] = 611;
  17846. t['amacron'] = 556;
  17847. t['sacute'] = 556;
  17848. t['idieresis'] = 278;
  17849. t['Ocircumflex'] = 778;
  17850. t['Ugrave'] = 722;
  17851. t['Delta'] = 612;
  17852. t['thorn'] = 611;
  17853. t['twosuperior'] = 333;
  17854. t['Odieresis'] = 778;
  17855. t['mu'] = 611;
  17856. t['igrave'] = 278;
  17857. t['ohungarumlaut'] = 611;
  17858. t['Eogonek'] = 667;
  17859. t['dcroat'] = 611;
  17860. t['threequarters'] = 834;
  17861. t['Scedilla'] = 667;
  17862. t['lcaron'] = 400;
  17863. t['Kcommaaccent'] = 722;
  17864. t['Lacute'] = 611;
  17865. t['trademark'] = 1000;
  17866. t['edotaccent'] = 556;
  17867. t['Igrave'] = 278;
  17868. t['Imacron'] = 278;
  17869. t['Lcaron'] = 611;
  17870. t['onehalf'] = 834;
  17871. t['lessequal'] = 549;
  17872. t['ocircumflex'] = 611;
  17873. t['ntilde'] = 611;
  17874. t['Uhungarumlaut'] = 722;
  17875. t['Eacute'] = 667;
  17876. t['emacron'] = 556;
  17877. t['gbreve'] = 611;
  17878. t['onequarter'] = 834;
  17879. t['Scaron'] = 667;
  17880. t['Scommaaccent'] = 667;
  17881. t['Ohungarumlaut'] = 778;
  17882. t['degree'] = 400;
  17883. t['ograve'] = 611;
  17884. t['Ccaron'] = 722;
  17885. t['ugrave'] = 611;
  17886. t['radical'] = 549;
  17887. t['Dcaron'] = 722;
  17888. t['rcommaaccent'] = 389;
  17889. t['Ntilde'] = 722;
  17890. t['otilde'] = 611;
  17891. t['Rcommaaccent'] = 722;
  17892. t['Lcommaaccent'] = 611;
  17893. t['Atilde'] = 722;
  17894. t['Aogonek'] = 722;
  17895. t['Aring'] = 722;
  17896. t['Otilde'] = 778;
  17897. t['zdotaccent'] = 500;
  17898. t['Ecaron'] = 667;
  17899. t['Iogonek'] = 278;
  17900. t['kcommaaccent'] = 556;
  17901. t['minus'] = 584;
  17902. t['Icircumflex'] = 278;
  17903. t['ncaron'] = 611;
  17904. t['tcommaaccent'] = 333;
  17905. t['logicalnot'] = 584;
  17906. t['odieresis'] = 611;
  17907. t['udieresis'] = 611;
  17908. t['notequal'] = 549;
  17909. t['gcommaaccent'] = 611;
  17910. t['eth'] = 611;
  17911. t['zcaron'] = 500;
  17912. t['ncommaaccent'] = 611;
  17913. t['onesuperior'] = 333;
  17914. t['imacron'] = 278;
  17915. t['Euro'] = 556;
  17916. });
  17917. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17918. t['space'] = 278;
  17919. t['exclam'] = 333;
  17920. t['quotedbl'] = 474;
  17921. t['numbersign'] = 556;
  17922. t['dollar'] = 556;
  17923. t['percent'] = 889;
  17924. t['ampersand'] = 722;
  17925. t['quoteright'] = 278;
  17926. t['parenleft'] = 333;
  17927. t['parenright'] = 333;
  17928. t['asterisk'] = 389;
  17929. t['plus'] = 584;
  17930. t['comma'] = 278;
  17931. t['hyphen'] = 333;
  17932. t['period'] = 278;
  17933. t['slash'] = 278;
  17934. t['zero'] = 556;
  17935. t['one'] = 556;
  17936. t['two'] = 556;
  17937. t['three'] = 556;
  17938. t['four'] = 556;
  17939. t['five'] = 556;
  17940. t['six'] = 556;
  17941. t['seven'] = 556;
  17942. t['eight'] = 556;
  17943. t['nine'] = 556;
  17944. t['colon'] = 333;
  17945. t['semicolon'] = 333;
  17946. t['less'] = 584;
  17947. t['equal'] = 584;
  17948. t['greater'] = 584;
  17949. t['question'] = 611;
  17950. t['at'] = 975;
  17951. t['A'] = 722;
  17952. t['B'] = 722;
  17953. t['C'] = 722;
  17954. t['D'] = 722;
  17955. t['E'] = 667;
  17956. t['F'] = 611;
  17957. t['G'] = 778;
  17958. t['H'] = 722;
  17959. t['I'] = 278;
  17960. t['J'] = 556;
  17961. t['K'] = 722;
  17962. t['L'] = 611;
  17963. t['M'] = 833;
  17964. t['N'] = 722;
  17965. t['O'] = 778;
  17966. t['P'] = 667;
  17967. t['Q'] = 778;
  17968. t['R'] = 722;
  17969. t['S'] = 667;
  17970. t['T'] = 611;
  17971. t['U'] = 722;
  17972. t['V'] = 667;
  17973. t['W'] = 944;
  17974. t['X'] = 667;
  17975. t['Y'] = 667;
  17976. t['Z'] = 611;
  17977. t['bracketleft'] = 333;
  17978. t['backslash'] = 278;
  17979. t['bracketright'] = 333;
  17980. t['asciicircum'] = 584;
  17981. t['underscore'] = 556;
  17982. t['quoteleft'] = 278;
  17983. t['a'] = 556;
  17984. t['b'] = 611;
  17985. t['c'] = 556;
  17986. t['d'] = 611;
  17987. t['e'] = 556;
  17988. t['f'] = 333;
  17989. t['g'] = 611;
  17990. t['h'] = 611;
  17991. t['i'] = 278;
  17992. t['j'] = 278;
  17993. t['k'] = 556;
  17994. t['l'] = 278;
  17995. t['m'] = 889;
  17996. t['n'] = 611;
  17997. t['o'] = 611;
  17998. t['p'] = 611;
  17999. t['q'] = 611;
  18000. t['r'] = 389;
  18001. t['s'] = 556;
  18002. t['t'] = 333;
  18003. t['u'] = 611;
  18004. t['v'] = 556;
  18005. t['w'] = 778;
  18006. t['x'] = 556;
  18007. t['y'] = 556;
  18008. t['z'] = 500;
  18009. t['braceleft'] = 389;
  18010. t['bar'] = 280;
  18011. t['braceright'] = 389;
  18012. t['asciitilde'] = 584;
  18013. t['exclamdown'] = 333;
  18014. t['cent'] = 556;
  18015. t['sterling'] = 556;
  18016. t['fraction'] = 167;
  18017. t['yen'] = 556;
  18018. t['florin'] = 556;
  18019. t['section'] = 556;
  18020. t['currency'] = 556;
  18021. t['quotesingle'] = 238;
  18022. t['quotedblleft'] = 500;
  18023. t['guillemotleft'] = 556;
  18024. t['guilsinglleft'] = 333;
  18025. t['guilsinglright'] = 333;
  18026. t['fi'] = 611;
  18027. t['fl'] = 611;
  18028. t['endash'] = 556;
  18029. t['dagger'] = 556;
  18030. t['daggerdbl'] = 556;
  18031. t['periodcentered'] = 278;
  18032. t['paragraph'] = 556;
  18033. t['bullet'] = 350;
  18034. t['quotesinglbase'] = 278;
  18035. t['quotedblbase'] = 500;
  18036. t['quotedblright'] = 500;
  18037. t['guillemotright'] = 556;
  18038. t['ellipsis'] = 1000;
  18039. t['perthousand'] = 1000;
  18040. t['questiondown'] = 611;
  18041. t['grave'] = 333;
  18042. t['acute'] = 333;
  18043. t['circumflex'] = 333;
  18044. t['tilde'] = 333;
  18045. t['macron'] = 333;
  18046. t['breve'] = 333;
  18047. t['dotaccent'] = 333;
  18048. t['dieresis'] = 333;
  18049. t['ring'] = 333;
  18050. t['cedilla'] = 333;
  18051. t['hungarumlaut'] = 333;
  18052. t['ogonek'] = 333;
  18053. t['caron'] = 333;
  18054. t['emdash'] = 1000;
  18055. t['AE'] = 1000;
  18056. t['ordfeminine'] = 370;
  18057. t['Lslash'] = 611;
  18058. t['Oslash'] = 778;
  18059. t['OE'] = 1000;
  18060. t['ordmasculine'] = 365;
  18061. t['ae'] = 889;
  18062. t['dotlessi'] = 278;
  18063. t['lslash'] = 278;
  18064. t['oslash'] = 611;
  18065. t['oe'] = 944;
  18066. t['germandbls'] = 611;
  18067. t['Idieresis'] = 278;
  18068. t['eacute'] = 556;
  18069. t['abreve'] = 556;
  18070. t['uhungarumlaut'] = 611;
  18071. t['ecaron'] = 556;
  18072. t['Ydieresis'] = 667;
  18073. t['divide'] = 584;
  18074. t['Yacute'] = 667;
  18075. t['Acircumflex'] = 722;
  18076. t['aacute'] = 556;
  18077. t['Ucircumflex'] = 722;
  18078. t['yacute'] = 556;
  18079. t['scommaaccent'] = 556;
  18080. t['ecircumflex'] = 556;
  18081. t['Uring'] = 722;
  18082. t['Udieresis'] = 722;
  18083. t['aogonek'] = 556;
  18084. t['Uacute'] = 722;
  18085. t['uogonek'] = 611;
  18086. t['Edieresis'] = 667;
  18087. t['Dcroat'] = 722;
  18088. t['commaaccent'] = 250;
  18089. t['copyright'] = 737;
  18090. t['Emacron'] = 667;
  18091. t['ccaron'] = 556;
  18092. t['aring'] = 556;
  18093. t['Ncommaaccent'] = 722;
  18094. t['lacute'] = 278;
  18095. t['agrave'] = 556;
  18096. t['Tcommaaccent'] = 611;
  18097. t['Cacute'] = 722;
  18098. t['atilde'] = 556;
  18099. t['Edotaccent'] = 667;
  18100. t['scaron'] = 556;
  18101. t['scedilla'] = 556;
  18102. t['iacute'] = 278;
  18103. t['lozenge'] = 494;
  18104. t['Rcaron'] = 722;
  18105. t['Gcommaaccent'] = 778;
  18106. t['ucircumflex'] = 611;
  18107. t['acircumflex'] = 556;
  18108. t['Amacron'] = 722;
  18109. t['rcaron'] = 389;
  18110. t['ccedilla'] = 556;
  18111. t['Zdotaccent'] = 611;
  18112. t['Thorn'] = 667;
  18113. t['Omacron'] = 778;
  18114. t['Racute'] = 722;
  18115. t['Sacute'] = 667;
  18116. t['dcaron'] = 743;
  18117. t['Umacron'] = 722;
  18118. t['uring'] = 611;
  18119. t['threesuperior'] = 333;
  18120. t['Ograve'] = 778;
  18121. t['Agrave'] = 722;
  18122. t['Abreve'] = 722;
  18123. t['multiply'] = 584;
  18124. t['uacute'] = 611;
  18125. t['Tcaron'] = 611;
  18126. t['partialdiff'] = 494;
  18127. t['ydieresis'] = 556;
  18128. t['Nacute'] = 722;
  18129. t['icircumflex'] = 278;
  18130. t['Ecircumflex'] = 667;
  18131. t['adieresis'] = 556;
  18132. t['edieresis'] = 556;
  18133. t['cacute'] = 556;
  18134. t['nacute'] = 611;
  18135. t['umacron'] = 611;
  18136. t['Ncaron'] = 722;
  18137. t['Iacute'] = 278;
  18138. t['plusminus'] = 584;
  18139. t['brokenbar'] = 280;
  18140. t['registered'] = 737;
  18141. t['Gbreve'] = 778;
  18142. t['Idotaccent'] = 278;
  18143. t['summation'] = 600;
  18144. t['Egrave'] = 667;
  18145. t['racute'] = 389;
  18146. t['omacron'] = 611;
  18147. t['Zacute'] = 611;
  18148. t['Zcaron'] = 611;
  18149. t['greaterequal'] = 549;
  18150. t['Eth'] = 722;
  18151. t['Ccedilla'] = 722;
  18152. t['lcommaaccent'] = 278;
  18153. t['tcaron'] = 389;
  18154. t['eogonek'] = 556;
  18155. t['Uogonek'] = 722;
  18156. t['Aacute'] = 722;
  18157. t['Adieresis'] = 722;
  18158. t['egrave'] = 556;
  18159. t['zacute'] = 500;
  18160. t['iogonek'] = 278;
  18161. t['Oacute'] = 778;
  18162. t['oacute'] = 611;
  18163. t['amacron'] = 556;
  18164. t['sacute'] = 556;
  18165. t['idieresis'] = 278;
  18166. t['Ocircumflex'] = 778;
  18167. t['Ugrave'] = 722;
  18168. t['Delta'] = 612;
  18169. t['thorn'] = 611;
  18170. t['twosuperior'] = 333;
  18171. t['Odieresis'] = 778;
  18172. t['mu'] = 611;
  18173. t['igrave'] = 278;
  18174. t['ohungarumlaut'] = 611;
  18175. t['Eogonek'] = 667;
  18176. t['dcroat'] = 611;
  18177. t['threequarters'] = 834;
  18178. t['Scedilla'] = 667;
  18179. t['lcaron'] = 400;
  18180. t['Kcommaaccent'] = 722;
  18181. t['Lacute'] = 611;
  18182. t['trademark'] = 1000;
  18183. t['edotaccent'] = 556;
  18184. t['Igrave'] = 278;
  18185. t['Imacron'] = 278;
  18186. t['Lcaron'] = 611;
  18187. t['onehalf'] = 834;
  18188. t['lessequal'] = 549;
  18189. t['ocircumflex'] = 611;
  18190. t['ntilde'] = 611;
  18191. t['Uhungarumlaut'] = 722;
  18192. t['Eacute'] = 667;
  18193. t['emacron'] = 556;
  18194. t['gbreve'] = 611;
  18195. t['onequarter'] = 834;
  18196. t['Scaron'] = 667;
  18197. t['Scommaaccent'] = 667;
  18198. t['Ohungarumlaut'] = 778;
  18199. t['degree'] = 400;
  18200. t['ograve'] = 611;
  18201. t['Ccaron'] = 722;
  18202. t['ugrave'] = 611;
  18203. t['radical'] = 549;
  18204. t['Dcaron'] = 722;
  18205. t['rcommaaccent'] = 389;
  18206. t['Ntilde'] = 722;
  18207. t['otilde'] = 611;
  18208. t['Rcommaaccent'] = 722;
  18209. t['Lcommaaccent'] = 611;
  18210. t['Atilde'] = 722;
  18211. t['Aogonek'] = 722;
  18212. t['Aring'] = 722;
  18213. t['Otilde'] = 778;
  18214. t['zdotaccent'] = 500;
  18215. t['Ecaron'] = 667;
  18216. t['Iogonek'] = 278;
  18217. t['kcommaaccent'] = 556;
  18218. t['minus'] = 584;
  18219. t['Icircumflex'] = 278;
  18220. t['ncaron'] = 611;
  18221. t['tcommaaccent'] = 333;
  18222. t['logicalnot'] = 584;
  18223. t['odieresis'] = 611;
  18224. t['udieresis'] = 611;
  18225. t['notequal'] = 549;
  18226. t['gcommaaccent'] = 611;
  18227. t['eth'] = 611;
  18228. t['zcaron'] = 500;
  18229. t['ncommaaccent'] = 611;
  18230. t['onesuperior'] = 333;
  18231. t['imacron'] = 278;
  18232. t['Euro'] = 556;
  18233. });
  18234. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18235. t['space'] = 278;
  18236. t['exclam'] = 278;
  18237. t['quotedbl'] = 355;
  18238. t['numbersign'] = 556;
  18239. t['dollar'] = 556;
  18240. t['percent'] = 889;
  18241. t['ampersand'] = 667;
  18242. t['quoteright'] = 222;
  18243. t['parenleft'] = 333;
  18244. t['parenright'] = 333;
  18245. t['asterisk'] = 389;
  18246. t['plus'] = 584;
  18247. t['comma'] = 278;
  18248. t['hyphen'] = 333;
  18249. t['period'] = 278;
  18250. t['slash'] = 278;
  18251. t['zero'] = 556;
  18252. t['one'] = 556;
  18253. t['two'] = 556;
  18254. t['three'] = 556;
  18255. t['four'] = 556;
  18256. t['five'] = 556;
  18257. t['six'] = 556;
  18258. t['seven'] = 556;
  18259. t['eight'] = 556;
  18260. t['nine'] = 556;
  18261. t['colon'] = 278;
  18262. t['semicolon'] = 278;
  18263. t['less'] = 584;
  18264. t['equal'] = 584;
  18265. t['greater'] = 584;
  18266. t['question'] = 556;
  18267. t['at'] = 1015;
  18268. t['A'] = 667;
  18269. t['B'] = 667;
  18270. t['C'] = 722;
  18271. t['D'] = 722;
  18272. t['E'] = 667;
  18273. t['F'] = 611;
  18274. t['G'] = 778;
  18275. t['H'] = 722;
  18276. t['I'] = 278;
  18277. t['J'] = 500;
  18278. t['K'] = 667;
  18279. t['L'] = 556;
  18280. t['M'] = 833;
  18281. t['N'] = 722;
  18282. t['O'] = 778;
  18283. t['P'] = 667;
  18284. t['Q'] = 778;
  18285. t['R'] = 722;
  18286. t['S'] = 667;
  18287. t['T'] = 611;
  18288. t['U'] = 722;
  18289. t['V'] = 667;
  18290. t['W'] = 944;
  18291. t['X'] = 667;
  18292. t['Y'] = 667;
  18293. t['Z'] = 611;
  18294. t['bracketleft'] = 278;
  18295. t['backslash'] = 278;
  18296. t['bracketright'] = 278;
  18297. t['asciicircum'] = 469;
  18298. t['underscore'] = 556;
  18299. t['quoteleft'] = 222;
  18300. t['a'] = 556;
  18301. t['b'] = 556;
  18302. t['c'] = 500;
  18303. t['d'] = 556;
  18304. t['e'] = 556;
  18305. t['f'] = 278;
  18306. t['g'] = 556;
  18307. t['h'] = 556;
  18308. t['i'] = 222;
  18309. t['j'] = 222;
  18310. t['k'] = 500;
  18311. t['l'] = 222;
  18312. t['m'] = 833;
  18313. t['n'] = 556;
  18314. t['o'] = 556;
  18315. t['p'] = 556;
  18316. t['q'] = 556;
  18317. t['r'] = 333;
  18318. t['s'] = 500;
  18319. t['t'] = 278;
  18320. t['u'] = 556;
  18321. t['v'] = 500;
  18322. t['w'] = 722;
  18323. t['x'] = 500;
  18324. t['y'] = 500;
  18325. t['z'] = 500;
  18326. t['braceleft'] = 334;
  18327. t['bar'] = 260;
  18328. t['braceright'] = 334;
  18329. t['asciitilde'] = 584;
  18330. t['exclamdown'] = 333;
  18331. t['cent'] = 556;
  18332. t['sterling'] = 556;
  18333. t['fraction'] = 167;
  18334. t['yen'] = 556;
  18335. t['florin'] = 556;
  18336. t['section'] = 556;
  18337. t['currency'] = 556;
  18338. t['quotesingle'] = 191;
  18339. t['quotedblleft'] = 333;
  18340. t['guillemotleft'] = 556;
  18341. t['guilsinglleft'] = 333;
  18342. t['guilsinglright'] = 333;
  18343. t['fi'] = 500;
  18344. t['fl'] = 500;
  18345. t['endash'] = 556;
  18346. t['dagger'] = 556;
  18347. t['daggerdbl'] = 556;
  18348. t['periodcentered'] = 278;
  18349. t['paragraph'] = 537;
  18350. t['bullet'] = 350;
  18351. t['quotesinglbase'] = 222;
  18352. t['quotedblbase'] = 333;
  18353. t['quotedblright'] = 333;
  18354. t['guillemotright'] = 556;
  18355. t['ellipsis'] = 1000;
  18356. t['perthousand'] = 1000;
  18357. t['questiondown'] = 611;
  18358. t['grave'] = 333;
  18359. t['acute'] = 333;
  18360. t['circumflex'] = 333;
  18361. t['tilde'] = 333;
  18362. t['macron'] = 333;
  18363. t['breve'] = 333;
  18364. t['dotaccent'] = 333;
  18365. t['dieresis'] = 333;
  18366. t['ring'] = 333;
  18367. t['cedilla'] = 333;
  18368. t['hungarumlaut'] = 333;
  18369. t['ogonek'] = 333;
  18370. t['caron'] = 333;
  18371. t['emdash'] = 1000;
  18372. t['AE'] = 1000;
  18373. t['ordfeminine'] = 370;
  18374. t['Lslash'] = 556;
  18375. t['Oslash'] = 778;
  18376. t['OE'] = 1000;
  18377. t['ordmasculine'] = 365;
  18378. t['ae'] = 889;
  18379. t['dotlessi'] = 278;
  18380. t['lslash'] = 222;
  18381. t['oslash'] = 611;
  18382. t['oe'] = 944;
  18383. t['germandbls'] = 611;
  18384. t['Idieresis'] = 278;
  18385. t['eacute'] = 556;
  18386. t['abreve'] = 556;
  18387. t['uhungarumlaut'] = 556;
  18388. t['ecaron'] = 556;
  18389. t['Ydieresis'] = 667;
  18390. t['divide'] = 584;
  18391. t['Yacute'] = 667;
  18392. t['Acircumflex'] = 667;
  18393. t['aacute'] = 556;
  18394. t['Ucircumflex'] = 722;
  18395. t['yacute'] = 500;
  18396. t['scommaaccent'] = 500;
  18397. t['ecircumflex'] = 556;
  18398. t['Uring'] = 722;
  18399. t['Udieresis'] = 722;
  18400. t['aogonek'] = 556;
  18401. t['Uacute'] = 722;
  18402. t['uogonek'] = 556;
  18403. t['Edieresis'] = 667;
  18404. t['Dcroat'] = 722;
  18405. t['commaaccent'] = 250;
  18406. t['copyright'] = 737;
  18407. t['Emacron'] = 667;
  18408. t['ccaron'] = 500;
  18409. t['aring'] = 556;
  18410. t['Ncommaaccent'] = 722;
  18411. t['lacute'] = 222;
  18412. t['agrave'] = 556;
  18413. t['Tcommaaccent'] = 611;
  18414. t['Cacute'] = 722;
  18415. t['atilde'] = 556;
  18416. t['Edotaccent'] = 667;
  18417. t['scaron'] = 500;
  18418. t['scedilla'] = 500;
  18419. t['iacute'] = 278;
  18420. t['lozenge'] = 471;
  18421. t['Rcaron'] = 722;
  18422. t['Gcommaaccent'] = 778;
  18423. t['ucircumflex'] = 556;
  18424. t['acircumflex'] = 556;
  18425. t['Amacron'] = 667;
  18426. t['rcaron'] = 333;
  18427. t['ccedilla'] = 500;
  18428. t['Zdotaccent'] = 611;
  18429. t['Thorn'] = 667;
  18430. t['Omacron'] = 778;
  18431. t['Racute'] = 722;
  18432. t['Sacute'] = 667;
  18433. t['dcaron'] = 643;
  18434. t['Umacron'] = 722;
  18435. t['uring'] = 556;
  18436. t['threesuperior'] = 333;
  18437. t['Ograve'] = 778;
  18438. t['Agrave'] = 667;
  18439. t['Abreve'] = 667;
  18440. t['multiply'] = 584;
  18441. t['uacute'] = 556;
  18442. t['Tcaron'] = 611;
  18443. t['partialdiff'] = 476;
  18444. t['ydieresis'] = 500;
  18445. t['Nacute'] = 722;
  18446. t['icircumflex'] = 278;
  18447. t['Ecircumflex'] = 667;
  18448. t['adieresis'] = 556;
  18449. t['edieresis'] = 556;
  18450. t['cacute'] = 500;
  18451. t['nacute'] = 556;
  18452. t['umacron'] = 556;
  18453. t['Ncaron'] = 722;
  18454. t['Iacute'] = 278;
  18455. t['plusminus'] = 584;
  18456. t['brokenbar'] = 260;
  18457. t['registered'] = 737;
  18458. t['Gbreve'] = 778;
  18459. t['Idotaccent'] = 278;
  18460. t['summation'] = 600;
  18461. t['Egrave'] = 667;
  18462. t['racute'] = 333;
  18463. t['omacron'] = 556;
  18464. t['Zacute'] = 611;
  18465. t['Zcaron'] = 611;
  18466. t['greaterequal'] = 549;
  18467. t['Eth'] = 722;
  18468. t['Ccedilla'] = 722;
  18469. t['lcommaaccent'] = 222;
  18470. t['tcaron'] = 317;
  18471. t['eogonek'] = 556;
  18472. t['Uogonek'] = 722;
  18473. t['Aacute'] = 667;
  18474. t['Adieresis'] = 667;
  18475. t['egrave'] = 556;
  18476. t['zacute'] = 500;
  18477. t['iogonek'] = 222;
  18478. t['Oacute'] = 778;
  18479. t['oacute'] = 556;
  18480. t['amacron'] = 556;
  18481. t['sacute'] = 500;
  18482. t['idieresis'] = 278;
  18483. t['Ocircumflex'] = 778;
  18484. t['Ugrave'] = 722;
  18485. t['Delta'] = 612;
  18486. t['thorn'] = 556;
  18487. t['twosuperior'] = 333;
  18488. t['Odieresis'] = 778;
  18489. t['mu'] = 556;
  18490. t['igrave'] = 278;
  18491. t['ohungarumlaut'] = 556;
  18492. t['Eogonek'] = 667;
  18493. t['dcroat'] = 556;
  18494. t['threequarters'] = 834;
  18495. t['Scedilla'] = 667;
  18496. t['lcaron'] = 299;
  18497. t['Kcommaaccent'] = 667;
  18498. t['Lacute'] = 556;
  18499. t['trademark'] = 1000;
  18500. t['edotaccent'] = 556;
  18501. t['Igrave'] = 278;
  18502. t['Imacron'] = 278;
  18503. t['Lcaron'] = 556;
  18504. t['onehalf'] = 834;
  18505. t['lessequal'] = 549;
  18506. t['ocircumflex'] = 556;
  18507. t['ntilde'] = 556;
  18508. t['Uhungarumlaut'] = 722;
  18509. t['Eacute'] = 667;
  18510. t['emacron'] = 556;
  18511. t['gbreve'] = 556;
  18512. t['onequarter'] = 834;
  18513. t['Scaron'] = 667;
  18514. t['Scommaaccent'] = 667;
  18515. t['Ohungarumlaut'] = 778;
  18516. t['degree'] = 400;
  18517. t['ograve'] = 556;
  18518. t['Ccaron'] = 722;
  18519. t['ugrave'] = 556;
  18520. t['radical'] = 453;
  18521. t['Dcaron'] = 722;
  18522. t['rcommaaccent'] = 333;
  18523. t['Ntilde'] = 722;
  18524. t['otilde'] = 556;
  18525. t['Rcommaaccent'] = 722;
  18526. t['Lcommaaccent'] = 556;
  18527. t['Atilde'] = 667;
  18528. t['Aogonek'] = 667;
  18529. t['Aring'] = 667;
  18530. t['Otilde'] = 778;
  18531. t['zdotaccent'] = 500;
  18532. t['Ecaron'] = 667;
  18533. t['Iogonek'] = 278;
  18534. t['kcommaaccent'] = 500;
  18535. t['minus'] = 584;
  18536. t['Icircumflex'] = 278;
  18537. t['ncaron'] = 556;
  18538. t['tcommaaccent'] = 278;
  18539. t['logicalnot'] = 584;
  18540. t['odieresis'] = 556;
  18541. t['udieresis'] = 556;
  18542. t['notequal'] = 549;
  18543. t['gcommaaccent'] = 556;
  18544. t['eth'] = 556;
  18545. t['zcaron'] = 500;
  18546. t['ncommaaccent'] = 556;
  18547. t['onesuperior'] = 333;
  18548. t['imacron'] = 278;
  18549. t['Euro'] = 556;
  18550. });
  18551. t['Symbol'] = getLookupTableFactory(function (t) {
  18552. t['space'] = 250;
  18553. t['exclam'] = 333;
  18554. t['universal'] = 713;
  18555. t['numbersign'] = 500;
  18556. t['existential'] = 549;
  18557. t['percent'] = 833;
  18558. t['ampersand'] = 778;
  18559. t['suchthat'] = 439;
  18560. t['parenleft'] = 333;
  18561. t['parenright'] = 333;
  18562. t['asteriskmath'] = 500;
  18563. t['plus'] = 549;
  18564. t['comma'] = 250;
  18565. t['minus'] = 549;
  18566. t['period'] = 250;
  18567. t['slash'] = 278;
  18568. t['zero'] = 500;
  18569. t['one'] = 500;
  18570. t['two'] = 500;
  18571. t['three'] = 500;
  18572. t['four'] = 500;
  18573. t['five'] = 500;
  18574. t['six'] = 500;
  18575. t['seven'] = 500;
  18576. t['eight'] = 500;
  18577. t['nine'] = 500;
  18578. t['colon'] = 278;
  18579. t['semicolon'] = 278;
  18580. t['less'] = 549;
  18581. t['equal'] = 549;
  18582. t['greater'] = 549;
  18583. t['question'] = 444;
  18584. t['congruent'] = 549;
  18585. t['Alpha'] = 722;
  18586. t['Beta'] = 667;
  18587. t['Chi'] = 722;
  18588. t['Delta'] = 612;
  18589. t['Epsilon'] = 611;
  18590. t['Phi'] = 763;
  18591. t['Gamma'] = 603;
  18592. t['Eta'] = 722;
  18593. t['Iota'] = 333;
  18594. t['theta1'] = 631;
  18595. t['Kappa'] = 722;
  18596. t['Lambda'] = 686;
  18597. t['Mu'] = 889;
  18598. t['Nu'] = 722;
  18599. t['Omicron'] = 722;
  18600. t['Pi'] = 768;
  18601. t['Theta'] = 741;
  18602. t['Rho'] = 556;
  18603. t['Sigma'] = 592;
  18604. t['Tau'] = 611;
  18605. t['Upsilon'] = 690;
  18606. t['sigma1'] = 439;
  18607. t['Omega'] = 768;
  18608. t['Xi'] = 645;
  18609. t['Psi'] = 795;
  18610. t['Zeta'] = 611;
  18611. t['bracketleft'] = 333;
  18612. t['therefore'] = 863;
  18613. t['bracketright'] = 333;
  18614. t['perpendicular'] = 658;
  18615. t['underscore'] = 500;
  18616. t['radicalex'] = 500;
  18617. t['alpha'] = 631;
  18618. t['beta'] = 549;
  18619. t['chi'] = 549;
  18620. t['delta'] = 494;
  18621. t['epsilon'] = 439;
  18622. t['phi'] = 521;
  18623. t['gamma'] = 411;
  18624. t['eta'] = 603;
  18625. t['iota'] = 329;
  18626. t['phi1'] = 603;
  18627. t['kappa'] = 549;
  18628. t['lambda'] = 549;
  18629. t['mu'] = 576;
  18630. t['nu'] = 521;
  18631. t['omicron'] = 549;
  18632. t['pi'] = 549;
  18633. t['theta'] = 521;
  18634. t['rho'] = 549;
  18635. t['sigma'] = 603;
  18636. t['tau'] = 439;
  18637. t['upsilon'] = 576;
  18638. t['omega1'] = 713;
  18639. t['omega'] = 686;
  18640. t['xi'] = 493;
  18641. t['psi'] = 686;
  18642. t['zeta'] = 494;
  18643. t['braceleft'] = 480;
  18644. t['bar'] = 200;
  18645. t['braceright'] = 480;
  18646. t['similar'] = 549;
  18647. t['Euro'] = 750;
  18648. t['Upsilon1'] = 620;
  18649. t['minute'] = 247;
  18650. t['lessequal'] = 549;
  18651. t['fraction'] = 167;
  18652. t['infinity'] = 713;
  18653. t['florin'] = 500;
  18654. t['club'] = 753;
  18655. t['diamond'] = 753;
  18656. t['heart'] = 753;
  18657. t['spade'] = 753;
  18658. t['arrowboth'] = 1042;
  18659. t['arrowleft'] = 987;
  18660. t['arrowup'] = 603;
  18661. t['arrowright'] = 987;
  18662. t['arrowdown'] = 603;
  18663. t['degree'] = 400;
  18664. t['plusminus'] = 549;
  18665. t['second'] = 411;
  18666. t['greaterequal'] = 549;
  18667. t['multiply'] = 549;
  18668. t['proportional'] = 713;
  18669. t['partialdiff'] = 494;
  18670. t['bullet'] = 460;
  18671. t['divide'] = 549;
  18672. t['notequal'] = 549;
  18673. t['equivalence'] = 549;
  18674. t['approxequal'] = 549;
  18675. t['ellipsis'] = 1000;
  18676. t['arrowvertex'] = 603;
  18677. t['arrowhorizex'] = 1000;
  18678. t['carriagereturn'] = 658;
  18679. t['aleph'] = 823;
  18680. t['Ifraktur'] = 686;
  18681. t['Rfraktur'] = 795;
  18682. t['weierstrass'] = 987;
  18683. t['circlemultiply'] = 768;
  18684. t['circleplus'] = 768;
  18685. t['emptyset'] = 823;
  18686. t['intersection'] = 768;
  18687. t['union'] = 768;
  18688. t['propersuperset'] = 713;
  18689. t['reflexsuperset'] = 713;
  18690. t['notsubset'] = 713;
  18691. t['propersubset'] = 713;
  18692. t['reflexsubset'] = 713;
  18693. t['element'] = 713;
  18694. t['notelement'] = 713;
  18695. t['angle'] = 768;
  18696. t['gradient'] = 713;
  18697. t['registerserif'] = 790;
  18698. t['copyrightserif'] = 790;
  18699. t['trademarkserif'] = 890;
  18700. t['product'] = 823;
  18701. t['radical'] = 549;
  18702. t['dotmath'] = 250;
  18703. t['logicalnot'] = 713;
  18704. t['logicaland'] = 603;
  18705. t['logicalor'] = 603;
  18706. t['arrowdblboth'] = 1042;
  18707. t['arrowdblleft'] = 987;
  18708. t['arrowdblup'] = 603;
  18709. t['arrowdblright'] = 987;
  18710. t['arrowdbldown'] = 603;
  18711. t['lozenge'] = 494;
  18712. t['angleleft'] = 329;
  18713. t['registersans'] = 790;
  18714. t['copyrightsans'] = 790;
  18715. t['trademarksans'] = 786;
  18716. t['summation'] = 713;
  18717. t['parenlefttp'] = 384;
  18718. t['parenleftex'] = 384;
  18719. t['parenleftbt'] = 384;
  18720. t['bracketlefttp'] = 384;
  18721. t['bracketleftex'] = 384;
  18722. t['bracketleftbt'] = 384;
  18723. t['bracelefttp'] = 494;
  18724. t['braceleftmid'] = 494;
  18725. t['braceleftbt'] = 494;
  18726. t['braceex'] = 494;
  18727. t['angleright'] = 329;
  18728. t['integral'] = 274;
  18729. t['integraltp'] = 686;
  18730. t['integralex'] = 686;
  18731. t['integralbt'] = 686;
  18732. t['parenrighttp'] = 384;
  18733. t['parenrightex'] = 384;
  18734. t['parenrightbt'] = 384;
  18735. t['bracketrighttp'] = 384;
  18736. t['bracketrightex'] = 384;
  18737. t['bracketrightbt'] = 384;
  18738. t['bracerighttp'] = 494;
  18739. t['bracerightmid'] = 494;
  18740. t['bracerightbt'] = 494;
  18741. t['apple'] = 790;
  18742. });
  18743. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18744. t['space'] = 250;
  18745. t['exclam'] = 333;
  18746. t['quotedbl'] = 408;
  18747. t['numbersign'] = 500;
  18748. t['dollar'] = 500;
  18749. t['percent'] = 833;
  18750. t['ampersand'] = 778;
  18751. t['quoteright'] = 333;
  18752. t['parenleft'] = 333;
  18753. t['parenright'] = 333;
  18754. t['asterisk'] = 500;
  18755. t['plus'] = 564;
  18756. t['comma'] = 250;
  18757. t['hyphen'] = 333;
  18758. t['period'] = 250;
  18759. t['slash'] = 278;
  18760. t['zero'] = 500;
  18761. t['one'] = 500;
  18762. t['two'] = 500;
  18763. t['three'] = 500;
  18764. t['four'] = 500;
  18765. t['five'] = 500;
  18766. t['six'] = 500;
  18767. t['seven'] = 500;
  18768. t['eight'] = 500;
  18769. t['nine'] = 500;
  18770. t['colon'] = 278;
  18771. t['semicolon'] = 278;
  18772. t['less'] = 564;
  18773. t['equal'] = 564;
  18774. t['greater'] = 564;
  18775. t['question'] = 444;
  18776. t['at'] = 921;
  18777. t['A'] = 722;
  18778. t['B'] = 667;
  18779. t['C'] = 667;
  18780. t['D'] = 722;
  18781. t['E'] = 611;
  18782. t['F'] = 556;
  18783. t['G'] = 722;
  18784. t['H'] = 722;
  18785. t['I'] = 333;
  18786. t['J'] = 389;
  18787. t['K'] = 722;
  18788. t['L'] = 611;
  18789. t['M'] = 889;
  18790. t['N'] = 722;
  18791. t['O'] = 722;
  18792. t['P'] = 556;
  18793. t['Q'] = 722;
  18794. t['R'] = 667;
  18795. t['S'] = 556;
  18796. t['T'] = 611;
  18797. t['U'] = 722;
  18798. t['V'] = 722;
  18799. t['W'] = 944;
  18800. t['X'] = 722;
  18801. t['Y'] = 722;
  18802. t['Z'] = 611;
  18803. t['bracketleft'] = 333;
  18804. t['backslash'] = 278;
  18805. t['bracketright'] = 333;
  18806. t['asciicircum'] = 469;
  18807. t['underscore'] = 500;
  18808. t['quoteleft'] = 333;
  18809. t['a'] = 444;
  18810. t['b'] = 500;
  18811. t['c'] = 444;
  18812. t['d'] = 500;
  18813. t['e'] = 444;
  18814. t['f'] = 333;
  18815. t['g'] = 500;
  18816. t['h'] = 500;
  18817. t['i'] = 278;
  18818. t['j'] = 278;
  18819. t['k'] = 500;
  18820. t['l'] = 278;
  18821. t['m'] = 778;
  18822. t['n'] = 500;
  18823. t['o'] = 500;
  18824. t['p'] = 500;
  18825. t['q'] = 500;
  18826. t['r'] = 333;
  18827. t['s'] = 389;
  18828. t['t'] = 278;
  18829. t['u'] = 500;
  18830. t['v'] = 500;
  18831. t['w'] = 722;
  18832. t['x'] = 500;
  18833. t['y'] = 500;
  18834. t['z'] = 444;
  18835. t['braceleft'] = 480;
  18836. t['bar'] = 200;
  18837. t['braceright'] = 480;
  18838. t['asciitilde'] = 541;
  18839. t['exclamdown'] = 333;
  18840. t['cent'] = 500;
  18841. t['sterling'] = 500;
  18842. t['fraction'] = 167;
  18843. t['yen'] = 500;
  18844. t['florin'] = 500;
  18845. t['section'] = 500;
  18846. t['currency'] = 500;
  18847. t['quotesingle'] = 180;
  18848. t['quotedblleft'] = 444;
  18849. t['guillemotleft'] = 500;
  18850. t['guilsinglleft'] = 333;
  18851. t['guilsinglright'] = 333;
  18852. t['fi'] = 556;
  18853. t['fl'] = 556;
  18854. t['endash'] = 500;
  18855. t['dagger'] = 500;
  18856. t['daggerdbl'] = 500;
  18857. t['periodcentered'] = 250;
  18858. t['paragraph'] = 453;
  18859. t['bullet'] = 350;
  18860. t['quotesinglbase'] = 333;
  18861. t['quotedblbase'] = 444;
  18862. t['quotedblright'] = 444;
  18863. t['guillemotright'] = 500;
  18864. t['ellipsis'] = 1000;
  18865. t['perthousand'] = 1000;
  18866. t['questiondown'] = 444;
  18867. t['grave'] = 333;
  18868. t['acute'] = 333;
  18869. t['circumflex'] = 333;
  18870. t['tilde'] = 333;
  18871. t['macron'] = 333;
  18872. t['breve'] = 333;
  18873. t['dotaccent'] = 333;
  18874. t['dieresis'] = 333;
  18875. t['ring'] = 333;
  18876. t['cedilla'] = 333;
  18877. t['hungarumlaut'] = 333;
  18878. t['ogonek'] = 333;
  18879. t['caron'] = 333;
  18880. t['emdash'] = 1000;
  18881. t['AE'] = 889;
  18882. t['ordfeminine'] = 276;
  18883. t['Lslash'] = 611;
  18884. t['Oslash'] = 722;
  18885. t['OE'] = 889;
  18886. t['ordmasculine'] = 310;
  18887. t['ae'] = 667;
  18888. t['dotlessi'] = 278;
  18889. t['lslash'] = 278;
  18890. t['oslash'] = 500;
  18891. t['oe'] = 722;
  18892. t['germandbls'] = 500;
  18893. t['Idieresis'] = 333;
  18894. t['eacute'] = 444;
  18895. t['abreve'] = 444;
  18896. t['uhungarumlaut'] = 500;
  18897. t['ecaron'] = 444;
  18898. t['Ydieresis'] = 722;
  18899. t['divide'] = 564;
  18900. t['Yacute'] = 722;
  18901. t['Acircumflex'] = 722;
  18902. t['aacute'] = 444;
  18903. t['Ucircumflex'] = 722;
  18904. t['yacute'] = 500;
  18905. t['scommaaccent'] = 389;
  18906. t['ecircumflex'] = 444;
  18907. t['Uring'] = 722;
  18908. t['Udieresis'] = 722;
  18909. t['aogonek'] = 444;
  18910. t['Uacute'] = 722;
  18911. t['uogonek'] = 500;
  18912. t['Edieresis'] = 611;
  18913. t['Dcroat'] = 722;
  18914. t['commaaccent'] = 250;
  18915. t['copyright'] = 760;
  18916. t['Emacron'] = 611;
  18917. t['ccaron'] = 444;
  18918. t['aring'] = 444;
  18919. t['Ncommaaccent'] = 722;
  18920. t['lacute'] = 278;
  18921. t['agrave'] = 444;
  18922. t['Tcommaaccent'] = 611;
  18923. t['Cacute'] = 667;
  18924. t['atilde'] = 444;
  18925. t['Edotaccent'] = 611;
  18926. t['scaron'] = 389;
  18927. t['scedilla'] = 389;
  18928. t['iacute'] = 278;
  18929. t['lozenge'] = 471;
  18930. t['Rcaron'] = 667;
  18931. t['Gcommaaccent'] = 722;
  18932. t['ucircumflex'] = 500;
  18933. t['acircumflex'] = 444;
  18934. t['Amacron'] = 722;
  18935. t['rcaron'] = 333;
  18936. t['ccedilla'] = 444;
  18937. t['Zdotaccent'] = 611;
  18938. t['Thorn'] = 556;
  18939. t['Omacron'] = 722;
  18940. t['Racute'] = 667;
  18941. t['Sacute'] = 556;
  18942. t['dcaron'] = 588;
  18943. t['Umacron'] = 722;
  18944. t['uring'] = 500;
  18945. t['threesuperior'] = 300;
  18946. t['Ograve'] = 722;
  18947. t['Agrave'] = 722;
  18948. t['Abreve'] = 722;
  18949. t['multiply'] = 564;
  18950. t['uacute'] = 500;
  18951. t['Tcaron'] = 611;
  18952. t['partialdiff'] = 476;
  18953. t['ydieresis'] = 500;
  18954. t['Nacute'] = 722;
  18955. t['icircumflex'] = 278;
  18956. t['Ecircumflex'] = 611;
  18957. t['adieresis'] = 444;
  18958. t['edieresis'] = 444;
  18959. t['cacute'] = 444;
  18960. t['nacute'] = 500;
  18961. t['umacron'] = 500;
  18962. t['Ncaron'] = 722;
  18963. t['Iacute'] = 333;
  18964. t['plusminus'] = 564;
  18965. t['brokenbar'] = 200;
  18966. t['registered'] = 760;
  18967. t['Gbreve'] = 722;
  18968. t['Idotaccent'] = 333;
  18969. t['summation'] = 600;
  18970. t['Egrave'] = 611;
  18971. t['racute'] = 333;
  18972. t['omacron'] = 500;
  18973. t['Zacute'] = 611;
  18974. t['Zcaron'] = 611;
  18975. t['greaterequal'] = 549;
  18976. t['Eth'] = 722;
  18977. t['Ccedilla'] = 667;
  18978. t['lcommaaccent'] = 278;
  18979. t['tcaron'] = 326;
  18980. t['eogonek'] = 444;
  18981. t['Uogonek'] = 722;
  18982. t['Aacute'] = 722;
  18983. t['Adieresis'] = 722;
  18984. t['egrave'] = 444;
  18985. t['zacute'] = 444;
  18986. t['iogonek'] = 278;
  18987. t['Oacute'] = 722;
  18988. t['oacute'] = 500;
  18989. t['amacron'] = 444;
  18990. t['sacute'] = 389;
  18991. t['idieresis'] = 278;
  18992. t['Ocircumflex'] = 722;
  18993. t['Ugrave'] = 722;
  18994. t['Delta'] = 612;
  18995. t['thorn'] = 500;
  18996. t['twosuperior'] = 300;
  18997. t['Odieresis'] = 722;
  18998. t['mu'] = 500;
  18999. t['igrave'] = 278;
  19000. t['ohungarumlaut'] = 500;
  19001. t['Eogonek'] = 611;
  19002. t['dcroat'] = 500;
  19003. t['threequarters'] = 750;
  19004. t['Scedilla'] = 556;
  19005. t['lcaron'] = 344;
  19006. t['Kcommaaccent'] = 722;
  19007. t['Lacute'] = 611;
  19008. t['trademark'] = 980;
  19009. t['edotaccent'] = 444;
  19010. t['Igrave'] = 333;
  19011. t['Imacron'] = 333;
  19012. t['Lcaron'] = 611;
  19013. t['onehalf'] = 750;
  19014. t['lessequal'] = 549;
  19015. t['ocircumflex'] = 500;
  19016. t['ntilde'] = 500;
  19017. t['Uhungarumlaut'] = 722;
  19018. t['Eacute'] = 611;
  19019. t['emacron'] = 444;
  19020. t['gbreve'] = 500;
  19021. t['onequarter'] = 750;
  19022. t['Scaron'] = 556;
  19023. t['Scommaaccent'] = 556;
  19024. t['Ohungarumlaut'] = 722;
  19025. t['degree'] = 400;
  19026. t['ograve'] = 500;
  19027. t['Ccaron'] = 667;
  19028. t['ugrave'] = 500;
  19029. t['radical'] = 453;
  19030. t['Dcaron'] = 722;
  19031. t['rcommaaccent'] = 333;
  19032. t['Ntilde'] = 722;
  19033. t['otilde'] = 500;
  19034. t['Rcommaaccent'] = 667;
  19035. t['Lcommaaccent'] = 611;
  19036. t['Atilde'] = 722;
  19037. t['Aogonek'] = 722;
  19038. t['Aring'] = 722;
  19039. t['Otilde'] = 722;
  19040. t['zdotaccent'] = 444;
  19041. t['Ecaron'] = 611;
  19042. t['Iogonek'] = 333;
  19043. t['kcommaaccent'] = 500;
  19044. t['minus'] = 564;
  19045. t['Icircumflex'] = 333;
  19046. t['ncaron'] = 500;
  19047. t['tcommaaccent'] = 278;
  19048. t['logicalnot'] = 564;
  19049. t['odieresis'] = 500;
  19050. t['udieresis'] = 500;
  19051. t['notequal'] = 549;
  19052. t['gcommaaccent'] = 500;
  19053. t['eth'] = 500;
  19054. t['zcaron'] = 444;
  19055. t['ncommaaccent'] = 500;
  19056. t['onesuperior'] = 300;
  19057. t['imacron'] = 278;
  19058. t['Euro'] = 500;
  19059. });
  19060. t['Times-Bold'] = getLookupTableFactory(function (t) {
  19061. t['space'] = 250;
  19062. t['exclam'] = 333;
  19063. t['quotedbl'] = 555;
  19064. t['numbersign'] = 500;
  19065. t['dollar'] = 500;
  19066. t['percent'] = 1000;
  19067. t['ampersand'] = 833;
  19068. t['quoteright'] = 333;
  19069. t['parenleft'] = 333;
  19070. t['parenright'] = 333;
  19071. t['asterisk'] = 500;
  19072. t['plus'] = 570;
  19073. t['comma'] = 250;
  19074. t['hyphen'] = 333;
  19075. t['period'] = 250;
  19076. t['slash'] = 278;
  19077. t['zero'] = 500;
  19078. t['one'] = 500;
  19079. t['two'] = 500;
  19080. t['three'] = 500;
  19081. t['four'] = 500;
  19082. t['five'] = 500;
  19083. t['six'] = 500;
  19084. t['seven'] = 500;
  19085. t['eight'] = 500;
  19086. t['nine'] = 500;
  19087. t['colon'] = 333;
  19088. t['semicolon'] = 333;
  19089. t['less'] = 570;
  19090. t['equal'] = 570;
  19091. t['greater'] = 570;
  19092. t['question'] = 500;
  19093. t['at'] = 930;
  19094. t['A'] = 722;
  19095. t['B'] = 667;
  19096. t['C'] = 722;
  19097. t['D'] = 722;
  19098. t['E'] = 667;
  19099. t['F'] = 611;
  19100. t['G'] = 778;
  19101. t['H'] = 778;
  19102. t['I'] = 389;
  19103. t['J'] = 500;
  19104. t['K'] = 778;
  19105. t['L'] = 667;
  19106. t['M'] = 944;
  19107. t['N'] = 722;
  19108. t['O'] = 778;
  19109. t['P'] = 611;
  19110. t['Q'] = 778;
  19111. t['R'] = 722;
  19112. t['S'] = 556;
  19113. t['T'] = 667;
  19114. t['U'] = 722;
  19115. t['V'] = 722;
  19116. t['W'] = 1000;
  19117. t['X'] = 722;
  19118. t['Y'] = 722;
  19119. t['Z'] = 667;
  19120. t['bracketleft'] = 333;
  19121. t['backslash'] = 278;
  19122. t['bracketright'] = 333;
  19123. t['asciicircum'] = 581;
  19124. t['underscore'] = 500;
  19125. t['quoteleft'] = 333;
  19126. t['a'] = 500;
  19127. t['b'] = 556;
  19128. t['c'] = 444;
  19129. t['d'] = 556;
  19130. t['e'] = 444;
  19131. t['f'] = 333;
  19132. t['g'] = 500;
  19133. t['h'] = 556;
  19134. t['i'] = 278;
  19135. t['j'] = 333;
  19136. t['k'] = 556;
  19137. t['l'] = 278;
  19138. t['m'] = 833;
  19139. t['n'] = 556;
  19140. t['o'] = 500;
  19141. t['p'] = 556;
  19142. t['q'] = 556;
  19143. t['r'] = 444;
  19144. t['s'] = 389;
  19145. t['t'] = 333;
  19146. t['u'] = 556;
  19147. t['v'] = 500;
  19148. t['w'] = 722;
  19149. t['x'] = 500;
  19150. t['y'] = 500;
  19151. t['z'] = 444;
  19152. t['braceleft'] = 394;
  19153. t['bar'] = 220;
  19154. t['braceright'] = 394;
  19155. t['asciitilde'] = 520;
  19156. t['exclamdown'] = 333;
  19157. t['cent'] = 500;
  19158. t['sterling'] = 500;
  19159. t['fraction'] = 167;
  19160. t['yen'] = 500;
  19161. t['florin'] = 500;
  19162. t['section'] = 500;
  19163. t['currency'] = 500;
  19164. t['quotesingle'] = 278;
  19165. t['quotedblleft'] = 500;
  19166. t['guillemotleft'] = 500;
  19167. t['guilsinglleft'] = 333;
  19168. t['guilsinglright'] = 333;
  19169. t['fi'] = 556;
  19170. t['fl'] = 556;
  19171. t['endash'] = 500;
  19172. t['dagger'] = 500;
  19173. t['daggerdbl'] = 500;
  19174. t['periodcentered'] = 250;
  19175. t['paragraph'] = 540;
  19176. t['bullet'] = 350;
  19177. t['quotesinglbase'] = 333;
  19178. t['quotedblbase'] = 500;
  19179. t['quotedblright'] = 500;
  19180. t['guillemotright'] = 500;
  19181. t['ellipsis'] = 1000;
  19182. t['perthousand'] = 1000;
  19183. t['questiondown'] = 500;
  19184. t['grave'] = 333;
  19185. t['acute'] = 333;
  19186. t['circumflex'] = 333;
  19187. t['tilde'] = 333;
  19188. t['macron'] = 333;
  19189. t['breve'] = 333;
  19190. t['dotaccent'] = 333;
  19191. t['dieresis'] = 333;
  19192. t['ring'] = 333;
  19193. t['cedilla'] = 333;
  19194. t['hungarumlaut'] = 333;
  19195. t['ogonek'] = 333;
  19196. t['caron'] = 333;
  19197. t['emdash'] = 1000;
  19198. t['AE'] = 1000;
  19199. t['ordfeminine'] = 300;
  19200. t['Lslash'] = 667;
  19201. t['Oslash'] = 778;
  19202. t['OE'] = 1000;
  19203. t['ordmasculine'] = 330;
  19204. t['ae'] = 722;
  19205. t['dotlessi'] = 278;
  19206. t['lslash'] = 278;
  19207. t['oslash'] = 500;
  19208. t['oe'] = 722;
  19209. t['germandbls'] = 556;
  19210. t['Idieresis'] = 389;
  19211. t['eacute'] = 444;
  19212. t['abreve'] = 500;
  19213. t['uhungarumlaut'] = 556;
  19214. t['ecaron'] = 444;
  19215. t['Ydieresis'] = 722;
  19216. t['divide'] = 570;
  19217. t['Yacute'] = 722;
  19218. t['Acircumflex'] = 722;
  19219. t['aacute'] = 500;
  19220. t['Ucircumflex'] = 722;
  19221. t['yacute'] = 500;
  19222. t['scommaaccent'] = 389;
  19223. t['ecircumflex'] = 444;
  19224. t['Uring'] = 722;
  19225. t['Udieresis'] = 722;
  19226. t['aogonek'] = 500;
  19227. t['Uacute'] = 722;
  19228. t['uogonek'] = 556;
  19229. t['Edieresis'] = 667;
  19230. t['Dcroat'] = 722;
  19231. t['commaaccent'] = 250;
  19232. t['copyright'] = 747;
  19233. t['Emacron'] = 667;
  19234. t['ccaron'] = 444;
  19235. t['aring'] = 500;
  19236. t['Ncommaaccent'] = 722;
  19237. t['lacute'] = 278;
  19238. t['agrave'] = 500;
  19239. t['Tcommaaccent'] = 667;
  19240. t['Cacute'] = 722;
  19241. t['atilde'] = 500;
  19242. t['Edotaccent'] = 667;
  19243. t['scaron'] = 389;
  19244. t['scedilla'] = 389;
  19245. t['iacute'] = 278;
  19246. t['lozenge'] = 494;
  19247. t['Rcaron'] = 722;
  19248. t['Gcommaaccent'] = 778;
  19249. t['ucircumflex'] = 556;
  19250. t['acircumflex'] = 500;
  19251. t['Amacron'] = 722;
  19252. t['rcaron'] = 444;
  19253. t['ccedilla'] = 444;
  19254. t['Zdotaccent'] = 667;
  19255. t['Thorn'] = 611;
  19256. t['Omacron'] = 778;
  19257. t['Racute'] = 722;
  19258. t['Sacute'] = 556;
  19259. t['dcaron'] = 672;
  19260. t['Umacron'] = 722;
  19261. t['uring'] = 556;
  19262. t['threesuperior'] = 300;
  19263. t['Ograve'] = 778;
  19264. t['Agrave'] = 722;
  19265. t['Abreve'] = 722;
  19266. t['multiply'] = 570;
  19267. t['uacute'] = 556;
  19268. t['Tcaron'] = 667;
  19269. t['partialdiff'] = 494;
  19270. t['ydieresis'] = 500;
  19271. t['Nacute'] = 722;
  19272. t['icircumflex'] = 278;
  19273. t['Ecircumflex'] = 667;
  19274. t['adieresis'] = 500;
  19275. t['edieresis'] = 444;
  19276. t['cacute'] = 444;
  19277. t['nacute'] = 556;
  19278. t['umacron'] = 556;
  19279. t['Ncaron'] = 722;
  19280. t['Iacute'] = 389;
  19281. t['plusminus'] = 570;
  19282. t['brokenbar'] = 220;
  19283. t['registered'] = 747;
  19284. t['Gbreve'] = 778;
  19285. t['Idotaccent'] = 389;
  19286. t['summation'] = 600;
  19287. t['Egrave'] = 667;
  19288. t['racute'] = 444;
  19289. t['omacron'] = 500;
  19290. t['Zacute'] = 667;
  19291. t['Zcaron'] = 667;
  19292. t['greaterequal'] = 549;
  19293. t['Eth'] = 722;
  19294. t['Ccedilla'] = 722;
  19295. t['lcommaaccent'] = 278;
  19296. t['tcaron'] = 416;
  19297. t['eogonek'] = 444;
  19298. t['Uogonek'] = 722;
  19299. t['Aacute'] = 722;
  19300. t['Adieresis'] = 722;
  19301. t['egrave'] = 444;
  19302. t['zacute'] = 444;
  19303. t['iogonek'] = 278;
  19304. t['Oacute'] = 778;
  19305. t['oacute'] = 500;
  19306. t['amacron'] = 500;
  19307. t['sacute'] = 389;
  19308. t['idieresis'] = 278;
  19309. t['Ocircumflex'] = 778;
  19310. t['Ugrave'] = 722;
  19311. t['Delta'] = 612;
  19312. t['thorn'] = 556;
  19313. t['twosuperior'] = 300;
  19314. t['Odieresis'] = 778;
  19315. t['mu'] = 556;
  19316. t['igrave'] = 278;
  19317. t['ohungarumlaut'] = 500;
  19318. t['Eogonek'] = 667;
  19319. t['dcroat'] = 556;
  19320. t['threequarters'] = 750;
  19321. t['Scedilla'] = 556;
  19322. t['lcaron'] = 394;
  19323. t['Kcommaaccent'] = 778;
  19324. t['Lacute'] = 667;
  19325. t['trademark'] = 1000;
  19326. t['edotaccent'] = 444;
  19327. t['Igrave'] = 389;
  19328. t['Imacron'] = 389;
  19329. t['Lcaron'] = 667;
  19330. t['onehalf'] = 750;
  19331. t['lessequal'] = 549;
  19332. t['ocircumflex'] = 500;
  19333. t['ntilde'] = 556;
  19334. t['Uhungarumlaut'] = 722;
  19335. t['Eacute'] = 667;
  19336. t['emacron'] = 444;
  19337. t['gbreve'] = 500;
  19338. t['onequarter'] = 750;
  19339. t['Scaron'] = 556;
  19340. t['Scommaaccent'] = 556;
  19341. t['Ohungarumlaut'] = 778;
  19342. t['degree'] = 400;
  19343. t['ograve'] = 500;
  19344. t['Ccaron'] = 722;
  19345. t['ugrave'] = 556;
  19346. t['radical'] = 549;
  19347. t['Dcaron'] = 722;
  19348. t['rcommaaccent'] = 444;
  19349. t['Ntilde'] = 722;
  19350. t['otilde'] = 500;
  19351. t['Rcommaaccent'] = 722;
  19352. t['Lcommaaccent'] = 667;
  19353. t['Atilde'] = 722;
  19354. t['Aogonek'] = 722;
  19355. t['Aring'] = 722;
  19356. t['Otilde'] = 778;
  19357. t['zdotaccent'] = 444;
  19358. t['Ecaron'] = 667;
  19359. t['Iogonek'] = 389;
  19360. t['kcommaaccent'] = 556;
  19361. t['minus'] = 570;
  19362. t['Icircumflex'] = 389;
  19363. t['ncaron'] = 556;
  19364. t['tcommaaccent'] = 333;
  19365. t['logicalnot'] = 570;
  19366. t['odieresis'] = 500;
  19367. t['udieresis'] = 556;
  19368. t['notequal'] = 549;
  19369. t['gcommaaccent'] = 500;
  19370. t['eth'] = 500;
  19371. t['zcaron'] = 444;
  19372. t['ncommaaccent'] = 556;
  19373. t['onesuperior'] = 300;
  19374. t['imacron'] = 278;
  19375. t['Euro'] = 500;
  19376. });
  19377. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19378. t['space'] = 250;
  19379. t['exclam'] = 389;
  19380. t['quotedbl'] = 555;
  19381. t['numbersign'] = 500;
  19382. t['dollar'] = 500;
  19383. t['percent'] = 833;
  19384. t['ampersand'] = 778;
  19385. t['quoteright'] = 333;
  19386. t['parenleft'] = 333;
  19387. t['parenright'] = 333;
  19388. t['asterisk'] = 500;
  19389. t['plus'] = 570;
  19390. t['comma'] = 250;
  19391. t['hyphen'] = 333;
  19392. t['period'] = 250;
  19393. t['slash'] = 278;
  19394. t['zero'] = 500;
  19395. t['one'] = 500;
  19396. t['two'] = 500;
  19397. t['three'] = 500;
  19398. t['four'] = 500;
  19399. t['five'] = 500;
  19400. t['six'] = 500;
  19401. t['seven'] = 500;
  19402. t['eight'] = 500;
  19403. t['nine'] = 500;
  19404. t['colon'] = 333;
  19405. t['semicolon'] = 333;
  19406. t['less'] = 570;
  19407. t['equal'] = 570;
  19408. t['greater'] = 570;
  19409. t['question'] = 500;
  19410. t['at'] = 832;
  19411. t['A'] = 667;
  19412. t['B'] = 667;
  19413. t['C'] = 667;
  19414. t['D'] = 722;
  19415. t['E'] = 667;
  19416. t['F'] = 667;
  19417. t['G'] = 722;
  19418. t['H'] = 778;
  19419. t['I'] = 389;
  19420. t['J'] = 500;
  19421. t['K'] = 667;
  19422. t['L'] = 611;
  19423. t['M'] = 889;
  19424. t['N'] = 722;
  19425. t['O'] = 722;
  19426. t['P'] = 611;
  19427. t['Q'] = 722;
  19428. t['R'] = 667;
  19429. t['S'] = 556;
  19430. t['T'] = 611;
  19431. t['U'] = 722;
  19432. t['V'] = 667;
  19433. t['W'] = 889;
  19434. t['X'] = 667;
  19435. t['Y'] = 611;
  19436. t['Z'] = 611;
  19437. t['bracketleft'] = 333;
  19438. t['backslash'] = 278;
  19439. t['bracketright'] = 333;
  19440. t['asciicircum'] = 570;
  19441. t['underscore'] = 500;
  19442. t['quoteleft'] = 333;
  19443. t['a'] = 500;
  19444. t['b'] = 500;
  19445. t['c'] = 444;
  19446. t['d'] = 500;
  19447. t['e'] = 444;
  19448. t['f'] = 333;
  19449. t['g'] = 500;
  19450. t['h'] = 556;
  19451. t['i'] = 278;
  19452. t['j'] = 278;
  19453. t['k'] = 500;
  19454. t['l'] = 278;
  19455. t['m'] = 778;
  19456. t['n'] = 556;
  19457. t['o'] = 500;
  19458. t['p'] = 500;
  19459. t['q'] = 500;
  19460. t['r'] = 389;
  19461. t['s'] = 389;
  19462. t['t'] = 278;
  19463. t['u'] = 556;
  19464. t['v'] = 444;
  19465. t['w'] = 667;
  19466. t['x'] = 500;
  19467. t['y'] = 444;
  19468. t['z'] = 389;
  19469. t['braceleft'] = 348;
  19470. t['bar'] = 220;
  19471. t['braceright'] = 348;
  19472. t['asciitilde'] = 570;
  19473. t['exclamdown'] = 389;
  19474. t['cent'] = 500;
  19475. t['sterling'] = 500;
  19476. t['fraction'] = 167;
  19477. t['yen'] = 500;
  19478. t['florin'] = 500;
  19479. t['section'] = 500;
  19480. t['currency'] = 500;
  19481. t['quotesingle'] = 278;
  19482. t['quotedblleft'] = 500;
  19483. t['guillemotleft'] = 500;
  19484. t['guilsinglleft'] = 333;
  19485. t['guilsinglright'] = 333;
  19486. t['fi'] = 556;
  19487. t['fl'] = 556;
  19488. t['endash'] = 500;
  19489. t['dagger'] = 500;
  19490. t['daggerdbl'] = 500;
  19491. t['periodcentered'] = 250;
  19492. t['paragraph'] = 500;
  19493. t['bullet'] = 350;
  19494. t['quotesinglbase'] = 333;
  19495. t['quotedblbase'] = 500;
  19496. t['quotedblright'] = 500;
  19497. t['guillemotright'] = 500;
  19498. t['ellipsis'] = 1000;
  19499. t['perthousand'] = 1000;
  19500. t['questiondown'] = 500;
  19501. t['grave'] = 333;
  19502. t['acute'] = 333;
  19503. t['circumflex'] = 333;
  19504. t['tilde'] = 333;
  19505. t['macron'] = 333;
  19506. t['breve'] = 333;
  19507. t['dotaccent'] = 333;
  19508. t['dieresis'] = 333;
  19509. t['ring'] = 333;
  19510. t['cedilla'] = 333;
  19511. t['hungarumlaut'] = 333;
  19512. t['ogonek'] = 333;
  19513. t['caron'] = 333;
  19514. t['emdash'] = 1000;
  19515. t['AE'] = 944;
  19516. t['ordfeminine'] = 266;
  19517. t['Lslash'] = 611;
  19518. t['Oslash'] = 722;
  19519. t['OE'] = 944;
  19520. t['ordmasculine'] = 300;
  19521. t['ae'] = 722;
  19522. t['dotlessi'] = 278;
  19523. t['lslash'] = 278;
  19524. t['oslash'] = 500;
  19525. t['oe'] = 722;
  19526. t['germandbls'] = 500;
  19527. t['Idieresis'] = 389;
  19528. t['eacute'] = 444;
  19529. t['abreve'] = 500;
  19530. t['uhungarumlaut'] = 556;
  19531. t['ecaron'] = 444;
  19532. t['Ydieresis'] = 611;
  19533. t['divide'] = 570;
  19534. t['Yacute'] = 611;
  19535. t['Acircumflex'] = 667;
  19536. t['aacute'] = 500;
  19537. t['Ucircumflex'] = 722;
  19538. t['yacute'] = 444;
  19539. t['scommaaccent'] = 389;
  19540. t['ecircumflex'] = 444;
  19541. t['Uring'] = 722;
  19542. t['Udieresis'] = 722;
  19543. t['aogonek'] = 500;
  19544. t['Uacute'] = 722;
  19545. t['uogonek'] = 556;
  19546. t['Edieresis'] = 667;
  19547. t['Dcroat'] = 722;
  19548. t['commaaccent'] = 250;
  19549. t['copyright'] = 747;
  19550. t['Emacron'] = 667;
  19551. t['ccaron'] = 444;
  19552. t['aring'] = 500;
  19553. t['Ncommaaccent'] = 722;
  19554. t['lacute'] = 278;
  19555. t['agrave'] = 500;
  19556. t['Tcommaaccent'] = 611;
  19557. t['Cacute'] = 667;
  19558. t['atilde'] = 500;
  19559. t['Edotaccent'] = 667;
  19560. t['scaron'] = 389;
  19561. t['scedilla'] = 389;
  19562. t['iacute'] = 278;
  19563. t['lozenge'] = 494;
  19564. t['Rcaron'] = 667;
  19565. t['Gcommaaccent'] = 722;
  19566. t['ucircumflex'] = 556;
  19567. t['acircumflex'] = 500;
  19568. t['Amacron'] = 667;
  19569. t['rcaron'] = 389;
  19570. t['ccedilla'] = 444;
  19571. t['Zdotaccent'] = 611;
  19572. t['Thorn'] = 611;
  19573. t['Omacron'] = 722;
  19574. t['Racute'] = 667;
  19575. t['Sacute'] = 556;
  19576. t['dcaron'] = 608;
  19577. t['Umacron'] = 722;
  19578. t['uring'] = 556;
  19579. t['threesuperior'] = 300;
  19580. t['Ograve'] = 722;
  19581. t['Agrave'] = 667;
  19582. t['Abreve'] = 667;
  19583. t['multiply'] = 570;
  19584. t['uacute'] = 556;
  19585. t['Tcaron'] = 611;
  19586. t['partialdiff'] = 494;
  19587. t['ydieresis'] = 444;
  19588. t['Nacute'] = 722;
  19589. t['icircumflex'] = 278;
  19590. t['Ecircumflex'] = 667;
  19591. t['adieresis'] = 500;
  19592. t['edieresis'] = 444;
  19593. t['cacute'] = 444;
  19594. t['nacute'] = 556;
  19595. t['umacron'] = 556;
  19596. t['Ncaron'] = 722;
  19597. t['Iacute'] = 389;
  19598. t['plusminus'] = 570;
  19599. t['brokenbar'] = 220;
  19600. t['registered'] = 747;
  19601. t['Gbreve'] = 722;
  19602. t['Idotaccent'] = 389;
  19603. t['summation'] = 600;
  19604. t['Egrave'] = 667;
  19605. t['racute'] = 389;
  19606. t['omacron'] = 500;
  19607. t['Zacute'] = 611;
  19608. t['Zcaron'] = 611;
  19609. t['greaterequal'] = 549;
  19610. t['Eth'] = 722;
  19611. t['Ccedilla'] = 667;
  19612. t['lcommaaccent'] = 278;
  19613. t['tcaron'] = 366;
  19614. t['eogonek'] = 444;
  19615. t['Uogonek'] = 722;
  19616. t['Aacute'] = 667;
  19617. t['Adieresis'] = 667;
  19618. t['egrave'] = 444;
  19619. t['zacute'] = 389;
  19620. t['iogonek'] = 278;
  19621. t['Oacute'] = 722;
  19622. t['oacute'] = 500;
  19623. t['amacron'] = 500;
  19624. t['sacute'] = 389;
  19625. t['idieresis'] = 278;
  19626. t['Ocircumflex'] = 722;
  19627. t['Ugrave'] = 722;
  19628. t['Delta'] = 612;
  19629. t['thorn'] = 500;
  19630. t['twosuperior'] = 300;
  19631. t['Odieresis'] = 722;
  19632. t['mu'] = 576;
  19633. t['igrave'] = 278;
  19634. t['ohungarumlaut'] = 500;
  19635. t['Eogonek'] = 667;
  19636. t['dcroat'] = 500;
  19637. t['threequarters'] = 750;
  19638. t['Scedilla'] = 556;
  19639. t['lcaron'] = 382;
  19640. t['Kcommaaccent'] = 667;
  19641. t['Lacute'] = 611;
  19642. t['trademark'] = 1000;
  19643. t['edotaccent'] = 444;
  19644. t['Igrave'] = 389;
  19645. t['Imacron'] = 389;
  19646. t['Lcaron'] = 611;
  19647. t['onehalf'] = 750;
  19648. t['lessequal'] = 549;
  19649. t['ocircumflex'] = 500;
  19650. t['ntilde'] = 556;
  19651. t['Uhungarumlaut'] = 722;
  19652. t['Eacute'] = 667;
  19653. t['emacron'] = 444;
  19654. t['gbreve'] = 500;
  19655. t['onequarter'] = 750;
  19656. t['Scaron'] = 556;
  19657. t['Scommaaccent'] = 556;
  19658. t['Ohungarumlaut'] = 722;
  19659. t['degree'] = 400;
  19660. t['ograve'] = 500;
  19661. t['Ccaron'] = 667;
  19662. t['ugrave'] = 556;
  19663. t['radical'] = 549;
  19664. t['Dcaron'] = 722;
  19665. t['rcommaaccent'] = 389;
  19666. t['Ntilde'] = 722;
  19667. t['otilde'] = 500;
  19668. t['Rcommaaccent'] = 667;
  19669. t['Lcommaaccent'] = 611;
  19670. t['Atilde'] = 667;
  19671. t['Aogonek'] = 667;
  19672. t['Aring'] = 667;
  19673. t['Otilde'] = 722;
  19674. t['zdotaccent'] = 389;
  19675. t['Ecaron'] = 667;
  19676. t['Iogonek'] = 389;
  19677. t['kcommaaccent'] = 500;
  19678. t['minus'] = 606;
  19679. t['Icircumflex'] = 389;
  19680. t['ncaron'] = 556;
  19681. t['tcommaaccent'] = 278;
  19682. t['logicalnot'] = 606;
  19683. t['odieresis'] = 500;
  19684. t['udieresis'] = 556;
  19685. t['notequal'] = 549;
  19686. t['gcommaaccent'] = 500;
  19687. t['eth'] = 500;
  19688. t['zcaron'] = 389;
  19689. t['ncommaaccent'] = 556;
  19690. t['onesuperior'] = 300;
  19691. t['imacron'] = 278;
  19692. t['Euro'] = 500;
  19693. });
  19694. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19695. t['space'] = 250;
  19696. t['exclam'] = 333;
  19697. t['quotedbl'] = 420;
  19698. t['numbersign'] = 500;
  19699. t['dollar'] = 500;
  19700. t['percent'] = 833;
  19701. t['ampersand'] = 778;
  19702. t['quoteright'] = 333;
  19703. t['parenleft'] = 333;
  19704. t['parenright'] = 333;
  19705. t['asterisk'] = 500;
  19706. t['plus'] = 675;
  19707. t['comma'] = 250;
  19708. t['hyphen'] = 333;
  19709. t['period'] = 250;
  19710. t['slash'] = 278;
  19711. t['zero'] = 500;
  19712. t['one'] = 500;
  19713. t['two'] = 500;
  19714. t['three'] = 500;
  19715. t['four'] = 500;
  19716. t['five'] = 500;
  19717. t['six'] = 500;
  19718. t['seven'] = 500;
  19719. t['eight'] = 500;
  19720. t['nine'] = 500;
  19721. t['colon'] = 333;
  19722. t['semicolon'] = 333;
  19723. t['less'] = 675;
  19724. t['equal'] = 675;
  19725. t['greater'] = 675;
  19726. t['question'] = 500;
  19727. t['at'] = 920;
  19728. t['A'] = 611;
  19729. t['B'] = 611;
  19730. t['C'] = 667;
  19731. t['D'] = 722;
  19732. t['E'] = 611;
  19733. t['F'] = 611;
  19734. t['G'] = 722;
  19735. t['H'] = 722;
  19736. t['I'] = 333;
  19737. t['J'] = 444;
  19738. t['K'] = 667;
  19739. t['L'] = 556;
  19740. t['M'] = 833;
  19741. t['N'] = 667;
  19742. t['O'] = 722;
  19743. t['P'] = 611;
  19744. t['Q'] = 722;
  19745. t['R'] = 611;
  19746. t['S'] = 500;
  19747. t['T'] = 556;
  19748. t['U'] = 722;
  19749. t['V'] = 611;
  19750. t['W'] = 833;
  19751. t['X'] = 611;
  19752. t['Y'] = 556;
  19753. t['Z'] = 556;
  19754. t['bracketleft'] = 389;
  19755. t['backslash'] = 278;
  19756. t['bracketright'] = 389;
  19757. t['asciicircum'] = 422;
  19758. t['underscore'] = 500;
  19759. t['quoteleft'] = 333;
  19760. t['a'] = 500;
  19761. t['b'] = 500;
  19762. t['c'] = 444;
  19763. t['d'] = 500;
  19764. t['e'] = 444;
  19765. t['f'] = 278;
  19766. t['g'] = 500;
  19767. t['h'] = 500;
  19768. t['i'] = 278;
  19769. t['j'] = 278;
  19770. t['k'] = 444;
  19771. t['l'] = 278;
  19772. t['m'] = 722;
  19773. t['n'] = 500;
  19774. t['o'] = 500;
  19775. t['p'] = 500;
  19776. t['q'] = 500;
  19777. t['r'] = 389;
  19778. t['s'] = 389;
  19779. t['t'] = 278;
  19780. t['u'] = 500;
  19781. t['v'] = 444;
  19782. t['w'] = 667;
  19783. t['x'] = 444;
  19784. t['y'] = 444;
  19785. t['z'] = 389;
  19786. t['braceleft'] = 400;
  19787. t['bar'] = 275;
  19788. t['braceright'] = 400;
  19789. t['asciitilde'] = 541;
  19790. t['exclamdown'] = 389;
  19791. t['cent'] = 500;
  19792. t['sterling'] = 500;
  19793. t['fraction'] = 167;
  19794. t['yen'] = 500;
  19795. t['florin'] = 500;
  19796. t['section'] = 500;
  19797. t['currency'] = 500;
  19798. t['quotesingle'] = 214;
  19799. t['quotedblleft'] = 556;
  19800. t['guillemotleft'] = 500;
  19801. t['guilsinglleft'] = 333;
  19802. t['guilsinglright'] = 333;
  19803. t['fi'] = 500;
  19804. t['fl'] = 500;
  19805. t['endash'] = 500;
  19806. t['dagger'] = 500;
  19807. t['daggerdbl'] = 500;
  19808. t['periodcentered'] = 250;
  19809. t['paragraph'] = 523;
  19810. t['bullet'] = 350;
  19811. t['quotesinglbase'] = 333;
  19812. t['quotedblbase'] = 556;
  19813. t['quotedblright'] = 556;
  19814. t['guillemotright'] = 500;
  19815. t['ellipsis'] = 889;
  19816. t['perthousand'] = 1000;
  19817. t['questiondown'] = 500;
  19818. t['grave'] = 333;
  19819. t['acute'] = 333;
  19820. t['circumflex'] = 333;
  19821. t['tilde'] = 333;
  19822. t['macron'] = 333;
  19823. t['breve'] = 333;
  19824. t['dotaccent'] = 333;
  19825. t['dieresis'] = 333;
  19826. t['ring'] = 333;
  19827. t['cedilla'] = 333;
  19828. t['hungarumlaut'] = 333;
  19829. t['ogonek'] = 333;
  19830. t['caron'] = 333;
  19831. t['emdash'] = 889;
  19832. t['AE'] = 889;
  19833. t['ordfeminine'] = 276;
  19834. t['Lslash'] = 556;
  19835. t['Oslash'] = 722;
  19836. t['OE'] = 944;
  19837. t['ordmasculine'] = 310;
  19838. t['ae'] = 667;
  19839. t['dotlessi'] = 278;
  19840. t['lslash'] = 278;
  19841. t['oslash'] = 500;
  19842. t['oe'] = 667;
  19843. t['germandbls'] = 500;
  19844. t['Idieresis'] = 333;
  19845. t['eacute'] = 444;
  19846. t['abreve'] = 500;
  19847. t['uhungarumlaut'] = 500;
  19848. t['ecaron'] = 444;
  19849. t['Ydieresis'] = 556;
  19850. t['divide'] = 675;
  19851. t['Yacute'] = 556;
  19852. t['Acircumflex'] = 611;
  19853. t['aacute'] = 500;
  19854. t['Ucircumflex'] = 722;
  19855. t['yacute'] = 444;
  19856. t['scommaaccent'] = 389;
  19857. t['ecircumflex'] = 444;
  19858. t['Uring'] = 722;
  19859. t['Udieresis'] = 722;
  19860. t['aogonek'] = 500;
  19861. t['Uacute'] = 722;
  19862. t['uogonek'] = 500;
  19863. t['Edieresis'] = 611;
  19864. t['Dcroat'] = 722;
  19865. t['commaaccent'] = 250;
  19866. t['copyright'] = 760;
  19867. t['Emacron'] = 611;
  19868. t['ccaron'] = 444;
  19869. t['aring'] = 500;
  19870. t['Ncommaaccent'] = 667;
  19871. t['lacute'] = 278;
  19872. t['agrave'] = 500;
  19873. t['Tcommaaccent'] = 556;
  19874. t['Cacute'] = 667;
  19875. t['atilde'] = 500;
  19876. t['Edotaccent'] = 611;
  19877. t['scaron'] = 389;
  19878. t['scedilla'] = 389;
  19879. t['iacute'] = 278;
  19880. t['lozenge'] = 471;
  19881. t['Rcaron'] = 611;
  19882. t['Gcommaaccent'] = 722;
  19883. t['ucircumflex'] = 500;
  19884. t['acircumflex'] = 500;
  19885. t['Amacron'] = 611;
  19886. t['rcaron'] = 389;
  19887. t['ccedilla'] = 444;
  19888. t['Zdotaccent'] = 556;
  19889. t['Thorn'] = 611;
  19890. t['Omacron'] = 722;
  19891. t['Racute'] = 611;
  19892. t['Sacute'] = 500;
  19893. t['dcaron'] = 544;
  19894. t['Umacron'] = 722;
  19895. t['uring'] = 500;
  19896. t['threesuperior'] = 300;
  19897. t['Ograve'] = 722;
  19898. t['Agrave'] = 611;
  19899. t['Abreve'] = 611;
  19900. t['multiply'] = 675;
  19901. t['uacute'] = 500;
  19902. t['Tcaron'] = 556;
  19903. t['partialdiff'] = 476;
  19904. t['ydieresis'] = 444;
  19905. t['Nacute'] = 667;
  19906. t['icircumflex'] = 278;
  19907. t['Ecircumflex'] = 611;
  19908. t['adieresis'] = 500;
  19909. t['edieresis'] = 444;
  19910. t['cacute'] = 444;
  19911. t['nacute'] = 500;
  19912. t['umacron'] = 500;
  19913. t['Ncaron'] = 667;
  19914. t['Iacute'] = 333;
  19915. t['plusminus'] = 675;
  19916. t['brokenbar'] = 275;
  19917. t['registered'] = 760;
  19918. t['Gbreve'] = 722;
  19919. t['Idotaccent'] = 333;
  19920. t['summation'] = 600;
  19921. t['Egrave'] = 611;
  19922. t['racute'] = 389;
  19923. t['omacron'] = 500;
  19924. t['Zacute'] = 556;
  19925. t['Zcaron'] = 556;
  19926. t['greaterequal'] = 549;
  19927. t['Eth'] = 722;
  19928. t['Ccedilla'] = 667;
  19929. t['lcommaaccent'] = 278;
  19930. t['tcaron'] = 300;
  19931. t['eogonek'] = 444;
  19932. t['Uogonek'] = 722;
  19933. t['Aacute'] = 611;
  19934. t['Adieresis'] = 611;
  19935. t['egrave'] = 444;
  19936. t['zacute'] = 389;
  19937. t['iogonek'] = 278;
  19938. t['Oacute'] = 722;
  19939. t['oacute'] = 500;
  19940. t['amacron'] = 500;
  19941. t['sacute'] = 389;
  19942. t['idieresis'] = 278;
  19943. t['Ocircumflex'] = 722;
  19944. t['Ugrave'] = 722;
  19945. t['Delta'] = 612;
  19946. t['thorn'] = 500;
  19947. t['twosuperior'] = 300;
  19948. t['Odieresis'] = 722;
  19949. t['mu'] = 500;
  19950. t['igrave'] = 278;
  19951. t['ohungarumlaut'] = 500;
  19952. t['Eogonek'] = 611;
  19953. t['dcroat'] = 500;
  19954. t['threequarters'] = 750;
  19955. t['Scedilla'] = 500;
  19956. t['lcaron'] = 300;
  19957. t['Kcommaaccent'] = 667;
  19958. t['Lacute'] = 556;
  19959. t['trademark'] = 980;
  19960. t['edotaccent'] = 444;
  19961. t['Igrave'] = 333;
  19962. t['Imacron'] = 333;
  19963. t['Lcaron'] = 611;
  19964. t['onehalf'] = 750;
  19965. t['lessequal'] = 549;
  19966. t['ocircumflex'] = 500;
  19967. t['ntilde'] = 500;
  19968. t['Uhungarumlaut'] = 722;
  19969. t['Eacute'] = 611;
  19970. t['emacron'] = 444;
  19971. t['gbreve'] = 500;
  19972. t['onequarter'] = 750;
  19973. t['Scaron'] = 500;
  19974. t['Scommaaccent'] = 500;
  19975. t['Ohungarumlaut'] = 722;
  19976. t['degree'] = 400;
  19977. t['ograve'] = 500;
  19978. t['Ccaron'] = 667;
  19979. t['ugrave'] = 500;
  19980. t['radical'] = 453;
  19981. t['Dcaron'] = 722;
  19982. t['rcommaaccent'] = 389;
  19983. t['Ntilde'] = 667;
  19984. t['otilde'] = 500;
  19985. t['Rcommaaccent'] = 611;
  19986. t['Lcommaaccent'] = 556;
  19987. t['Atilde'] = 611;
  19988. t['Aogonek'] = 611;
  19989. t['Aring'] = 611;
  19990. t['Otilde'] = 722;
  19991. t['zdotaccent'] = 389;
  19992. t['Ecaron'] = 611;
  19993. t['Iogonek'] = 333;
  19994. t['kcommaaccent'] = 444;
  19995. t['minus'] = 675;
  19996. t['Icircumflex'] = 333;
  19997. t['ncaron'] = 500;
  19998. t['tcommaaccent'] = 278;
  19999. t['logicalnot'] = 675;
  20000. t['odieresis'] = 500;
  20001. t['udieresis'] = 500;
  20002. t['notequal'] = 549;
  20003. t['gcommaaccent'] = 500;
  20004. t['eth'] = 500;
  20005. t['zcaron'] = 389;
  20006. t['ncommaaccent'] = 500;
  20007. t['onesuperior'] = 300;
  20008. t['imacron'] = 278;
  20009. t['Euro'] = 500;
  20010. });
  20011. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  20012. t['space'] = 278;
  20013. t['a1'] = 974;
  20014. t['a2'] = 961;
  20015. t['a202'] = 974;
  20016. t['a3'] = 980;
  20017. t['a4'] = 719;
  20018. t['a5'] = 789;
  20019. t['a119'] = 790;
  20020. t['a118'] = 791;
  20021. t['a117'] = 690;
  20022. t['a11'] = 960;
  20023. t['a12'] = 939;
  20024. t['a13'] = 549;
  20025. t['a14'] = 855;
  20026. t['a15'] = 911;
  20027. t['a16'] = 933;
  20028. t['a105'] = 911;
  20029. t['a17'] = 945;
  20030. t['a18'] = 974;
  20031. t['a19'] = 755;
  20032. t['a20'] = 846;
  20033. t['a21'] = 762;
  20034. t['a22'] = 761;
  20035. t['a23'] = 571;
  20036. t['a24'] = 677;
  20037. t['a25'] = 763;
  20038. t['a26'] = 760;
  20039. t['a27'] = 759;
  20040. t['a28'] = 754;
  20041. t['a6'] = 494;
  20042. t['a7'] = 552;
  20043. t['a8'] = 537;
  20044. t['a9'] = 577;
  20045. t['a10'] = 692;
  20046. t['a29'] = 786;
  20047. t['a30'] = 788;
  20048. t['a31'] = 788;
  20049. t['a32'] = 790;
  20050. t['a33'] = 793;
  20051. t['a34'] = 794;
  20052. t['a35'] = 816;
  20053. t['a36'] = 823;
  20054. t['a37'] = 789;
  20055. t['a38'] = 841;
  20056. t['a39'] = 823;
  20057. t['a40'] = 833;
  20058. t['a41'] = 816;
  20059. t['a42'] = 831;
  20060. t['a43'] = 923;
  20061. t['a44'] = 744;
  20062. t['a45'] = 723;
  20063. t['a46'] = 749;
  20064. t['a47'] = 790;
  20065. t['a48'] = 792;
  20066. t['a49'] = 695;
  20067. t['a50'] = 776;
  20068. t['a51'] = 768;
  20069. t['a52'] = 792;
  20070. t['a53'] = 759;
  20071. t['a54'] = 707;
  20072. t['a55'] = 708;
  20073. t['a56'] = 682;
  20074. t['a57'] = 701;
  20075. t['a58'] = 826;
  20076. t['a59'] = 815;
  20077. t['a60'] = 789;
  20078. t['a61'] = 789;
  20079. t['a62'] = 707;
  20080. t['a63'] = 687;
  20081. t['a64'] = 696;
  20082. t['a65'] = 689;
  20083. t['a66'] = 786;
  20084. t['a67'] = 787;
  20085. t['a68'] = 713;
  20086. t['a69'] = 791;
  20087. t['a70'] = 785;
  20088. t['a71'] = 791;
  20089. t['a72'] = 873;
  20090. t['a73'] = 761;
  20091. t['a74'] = 762;
  20092. t['a203'] = 762;
  20093. t['a75'] = 759;
  20094. t['a204'] = 759;
  20095. t['a76'] = 892;
  20096. t['a77'] = 892;
  20097. t['a78'] = 788;
  20098. t['a79'] = 784;
  20099. t['a81'] = 438;
  20100. t['a82'] = 138;
  20101. t['a83'] = 277;
  20102. t['a84'] = 415;
  20103. t['a97'] = 392;
  20104. t['a98'] = 392;
  20105. t['a99'] = 668;
  20106. t['a100'] = 668;
  20107. t['a89'] = 390;
  20108. t['a90'] = 390;
  20109. t['a93'] = 317;
  20110. t['a94'] = 317;
  20111. t['a91'] = 276;
  20112. t['a92'] = 276;
  20113. t['a205'] = 509;
  20114. t['a85'] = 509;
  20115. t['a206'] = 410;
  20116. t['a86'] = 410;
  20117. t['a87'] = 234;
  20118. t['a88'] = 234;
  20119. t['a95'] = 334;
  20120. t['a96'] = 334;
  20121. t['a101'] = 732;
  20122. t['a102'] = 544;
  20123. t['a103'] = 544;
  20124. t['a104'] = 910;
  20125. t['a106'] = 667;
  20126. t['a107'] = 760;
  20127. t['a108'] = 760;
  20128. t['a112'] = 776;
  20129. t['a111'] = 595;
  20130. t['a110'] = 694;
  20131. t['a109'] = 626;
  20132. t['a120'] = 788;
  20133. t['a121'] = 788;
  20134. t['a122'] = 788;
  20135. t['a123'] = 788;
  20136. t['a124'] = 788;
  20137. t['a125'] = 788;
  20138. t['a126'] = 788;
  20139. t['a127'] = 788;
  20140. t['a128'] = 788;
  20141. t['a129'] = 788;
  20142. t['a130'] = 788;
  20143. t['a131'] = 788;
  20144. t['a132'] = 788;
  20145. t['a133'] = 788;
  20146. t['a134'] = 788;
  20147. t['a135'] = 788;
  20148. t['a136'] = 788;
  20149. t['a137'] = 788;
  20150. t['a138'] = 788;
  20151. t['a139'] = 788;
  20152. t['a140'] = 788;
  20153. t['a141'] = 788;
  20154. t['a142'] = 788;
  20155. t['a143'] = 788;
  20156. t['a144'] = 788;
  20157. t['a145'] = 788;
  20158. t['a146'] = 788;
  20159. t['a147'] = 788;
  20160. t['a148'] = 788;
  20161. t['a149'] = 788;
  20162. t['a150'] = 788;
  20163. t['a151'] = 788;
  20164. t['a152'] = 788;
  20165. t['a153'] = 788;
  20166. t['a154'] = 788;
  20167. t['a155'] = 788;
  20168. t['a156'] = 788;
  20169. t['a157'] = 788;
  20170. t['a158'] = 788;
  20171. t['a159'] = 788;
  20172. t['a160'] = 894;
  20173. t['a161'] = 838;
  20174. t['a163'] = 1016;
  20175. t['a164'] = 458;
  20176. t['a196'] = 748;
  20177. t['a165'] = 924;
  20178. t['a192'] = 748;
  20179. t['a166'] = 918;
  20180. t['a167'] = 927;
  20181. t['a168'] = 928;
  20182. t['a169'] = 928;
  20183. t['a170'] = 834;
  20184. t['a171'] = 873;
  20185. t['a172'] = 828;
  20186. t['a173'] = 924;
  20187. t['a162'] = 924;
  20188. t['a174'] = 917;
  20189. t['a175'] = 930;
  20190. t['a176'] = 931;
  20191. t['a177'] = 463;
  20192. t['a178'] = 883;
  20193. t['a179'] = 836;
  20194. t['a193'] = 836;
  20195. t['a180'] = 867;
  20196. t['a199'] = 867;
  20197. t['a181'] = 696;
  20198. t['a200'] = 696;
  20199. t['a182'] = 874;
  20200. t['a201'] = 874;
  20201. t['a183'] = 760;
  20202. t['a184'] = 946;
  20203. t['a197'] = 771;
  20204. t['a185'] = 865;
  20205. t['a194'] = 771;
  20206. t['a198'] = 888;
  20207. t['a186'] = 967;
  20208. t['a195'] = 888;
  20209. t['a187'] = 831;
  20210. t['a188'] = 873;
  20211. t['a189'] = 927;
  20212. t['a190'] = 970;
  20213. t['a191'] = 918;
  20214. });
  20215. });
  20216. exports.getMetrics = getMetrics;
  20217. }));
  20218. (function (root, factory) {
  20219. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20220. }(this, function (exports, sharedUtil) {
  20221. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20222. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20223. var MASK_HIGH = 0xffff0000;
  20224. var MASK_LOW = 0xffff;
  20225. function MurmurHash3_64(seed) {
  20226. var SEED = 0xc3d2e1f0;
  20227. this.h1 = seed ? seed & 0xffffffff : SEED;
  20228. this.h2 = seed ? seed & 0xffffffff : SEED;
  20229. }
  20230. var alwaysUseUint32ArrayView = false;
  20231. try {
  20232. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20233. } catch (e) {
  20234. alwaysUseUint32ArrayView = true;
  20235. }
  20236. MurmurHash3_64.prototype = {
  20237. update: function MurmurHash3_64_update(input) {
  20238. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20239. var i;
  20240. if (typeof input === 'string') {
  20241. var data = new Uint8Array(input.length * 2);
  20242. var length = 0;
  20243. for (i = 0; i < input.length; i++) {
  20244. var code = input.charCodeAt(i);
  20245. if (code <= 0xff) {
  20246. data[length++] = code;
  20247. } else {
  20248. data[length++] = code >>> 8;
  20249. data[length++] = code & 0xff;
  20250. }
  20251. }
  20252. } else if (input instanceof Uint8Array) {
  20253. data = input;
  20254. length = data.length;
  20255. } else if (typeof input === 'object' && 'length' in input) {
  20256. data = input;
  20257. length = data.length;
  20258. useUint32ArrayView = true;
  20259. } else {
  20260. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20261. }
  20262. var blockCounts = length >> 2;
  20263. var tailLength = length - blockCounts * 4;
  20264. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20265. var k1 = 0;
  20266. var k2 = 0;
  20267. var h1 = this.h1;
  20268. var h2 = this.h2;
  20269. var C1 = 0xcc9e2d51;
  20270. var C2 = 0x1b873593;
  20271. var C1_LOW = C1 & MASK_LOW;
  20272. var C2_LOW = C2 & MASK_LOW;
  20273. for (i = 0; i < blockCounts; i++) {
  20274. if (i & 1) {
  20275. k1 = dataUint32[i];
  20276. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20277. k1 = k1 << 15 | k1 >>> 17;
  20278. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20279. h1 ^= k1;
  20280. h1 = h1 << 13 | h1 >>> 19;
  20281. h1 = h1 * 5 + 0xe6546b64;
  20282. } else {
  20283. k2 = dataUint32[i];
  20284. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20285. k2 = k2 << 15 | k2 >>> 17;
  20286. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20287. h2 ^= k2;
  20288. h2 = h2 << 13 | h2 >>> 19;
  20289. h2 = h2 * 5 + 0xe6546b64;
  20290. }
  20291. }
  20292. k1 = 0;
  20293. switch (tailLength) {
  20294. case 3:
  20295. k1 ^= data[blockCounts * 4 + 2] << 16;
  20296. case 2:
  20297. k1 ^= data[blockCounts * 4 + 1] << 8;
  20298. case 1:
  20299. k1 ^= data[blockCounts * 4];
  20300. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20301. k1 = k1 << 15 | k1 >>> 17;
  20302. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20303. if (blockCounts & 1) {
  20304. h1 ^= k1;
  20305. } else {
  20306. h2 ^= k1;
  20307. }
  20308. }
  20309. this.h1 = h1;
  20310. this.h2 = h2;
  20311. return this;
  20312. },
  20313. hexdigest: function MurmurHash3_64_hexdigest() {
  20314. var h1 = this.h1;
  20315. var h2 = this.h2;
  20316. h1 ^= h2 >>> 1;
  20317. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20318. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20319. h1 ^= h2 >>> 1;
  20320. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20321. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20322. h1 ^= h2 >>> 1;
  20323. for (var i = 0, arr = [
  20324. h1,
  20325. h2
  20326. ], str = ''; i < arr.length; i++) {
  20327. var hex = (arr[i] >>> 0).toString(16);
  20328. while (hex.length < 8) {
  20329. hex = '0' + hex;
  20330. }
  20331. str += hex;
  20332. }
  20333. return str;
  20334. }
  20335. };
  20336. return MurmurHash3_64;
  20337. }();
  20338. exports.MurmurHash3_64 = MurmurHash3_64;
  20339. }));
  20340. (function (root, factory) {
  20341. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20342. }(this, function (exports, sharedUtil) {
  20343. var isArray = sharedUtil.isArray;
  20344. var EOF = {};
  20345. var Name = function NameClosure() {
  20346. function Name(name) {
  20347. this.name = name;
  20348. }
  20349. Name.prototype = {};
  20350. var nameCache = Object.create(null);
  20351. Name.get = function Name_get(name) {
  20352. var nameValue = nameCache[name];
  20353. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20354. };
  20355. return Name;
  20356. }();
  20357. var Cmd = function CmdClosure() {
  20358. function Cmd(cmd) {
  20359. this.cmd = cmd;
  20360. }
  20361. Cmd.prototype = {};
  20362. var cmdCache = Object.create(null);
  20363. Cmd.get = function Cmd_get(cmd) {
  20364. var cmdValue = cmdCache[cmd];
  20365. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20366. };
  20367. return Cmd;
  20368. }();
  20369. var Dict = function DictClosure() {
  20370. var nonSerializable = function nonSerializableClosure() {
  20371. return nonSerializable;
  20372. };
  20373. function Dict(xref) {
  20374. this.map = Object.create(null);
  20375. this.xref = xref;
  20376. this.objId = null;
  20377. this.suppressEncryption = false;
  20378. this.__nonSerializable__ = nonSerializable;
  20379. }
  20380. Dict.prototype = {
  20381. assignXref: function Dict_assignXref(newXref) {
  20382. this.xref = newXref;
  20383. },
  20384. get: function Dict_get(key1, key2, key3) {
  20385. var value;
  20386. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20387. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20388. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20389. }
  20390. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20391. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20392. }
  20393. value = this.map[key3] || null;
  20394. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20395. },
  20396. getAsync: function Dict_getAsync(key1, key2, key3) {
  20397. var value;
  20398. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20399. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20400. if (xref) {
  20401. return xref.fetchIfRefAsync(value, suppressEncryption);
  20402. }
  20403. return Promise.resolve(value);
  20404. }
  20405. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20406. if (xref) {
  20407. return xref.fetchIfRefAsync(value, suppressEncryption);
  20408. }
  20409. return Promise.resolve(value);
  20410. }
  20411. value = this.map[key3] || null;
  20412. if (xref) {
  20413. return xref.fetchIfRefAsync(value, suppressEncryption);
  20414. }
  20415. return Promise.resolve(value);
  20416. },
  20417. getArray: function Dict_getArray(key1, key2, key3) {
  20418. var value = this.get(key1, key2, key3);
  20419. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20420. if (!isArray(value) || !xref) {
  20421. return value;
  20422. }
  20423. value = value.slice();
  20424. for (var i = 0, ii = value.length; i < ii; i++) {
  20425. if (!isRef(value[i])) {
  20426. continue;
  20427. }
  20428. value[i] = xref.fetch(value[i], suppressEncryption);
  20429. }
  20430. return value;
  20431. },
  20432. getRaw: function Dict_getRaw(key) {
  20433. return this.map[key];
  20434. },
  20435. getKeys: function Dict_getKeys() {
  20436. return Object.keys(this.map);
  20437. },
  20438. set: function Dict_set(key, value) {
  20439. this.map[key] = value;
  20440. },
  20441. has: function Dict_has(key) {
  20442. return key in this.map;
  20443. },
  20444. forEach: function Dict_forEach(callback) {
  20445. for (var key in this.map) {
  20446. callback(key, this.get(key));
  20447. }
  20448. }
  20449. };
  20450. Dict.empty = new Dict(null);
  20451. Dict.merge = function Dict_merge(xref, dictArray) {
  20452. var mergedDict = new Dict(xref);
  20453. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20454. var dict = dictArray[i];
  20455. if (!isDict(dict)) {
  20456. continue;
  20457. }
  20458. for (var keyName in dict.map) {
  20459. if (mergedDict.map[keyName]) {
  20460. continue;
  20461. }
  20462. mergedDict.map[keyName] = dict.map[keyName];
  20463. }
  20464. }
  20465. return mergedDict;
  20466. };
  20467. return Dict;
  20468. }();
  20469. var Ref = function RefClosure() {
  20470. function Ref(num, gen) {
  20471. this.num = num;
  20472. this.gen = gen;
  20473. }
  20474. Ref.prototype = {
  20475. toString: function Ref_toString() {
  20476. var str = this.num + 'R';
  20477. if (this.gen !== 0) {
  20478. str += this.gen;
  20479. }
  20480. return str;
  20481. }
  20482. };
  20483. return Ref;
  20484. }();
  20485. var RefSet = function RefSetClosure() {
  20486. function RefSet() {
  20487. this.dict = Object.create(null);
  20488. }
  20489. RefSet.prototype = {
  20490. has: function RefSet_has(ref) {
  20491. return ref.toString() in this.dict;
  20492. },
  20493. put: function RefSet_put(ref) {
  20494. this.dict[ref.toString()] = true;
  20495. },
  20496. remove: function RefSet_remove(ref) {
  20497. delete this.dict[ref.toString()];
  20498. }
  20499. };
  20500. return RefSet;
  20501. }();
  20502. var RefSetCache = function RefSetCacheClosure() {
  20503. function RefSetCache() {
  20504. this.dict = Object.create(null);
  20505. }
  20506. RefSetCache.prototype = {
  20507. get: function RefSetCache_get(ref) {
  20508. return this.dict[ref.toString()];
  20509. },
  20510. has: function RefSetCache_has(ref) {
  20511. return ref.toString() in this.dict;
  20512. },
  20513. put: function RefSetCache_put(ref, obj) {
  20514. this.dict[ref.toString()] = obj;
  20515. },
  20516. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20517. this.dict[ref.toString()] = this.get(aliasRef);
  20518. },
  20519. forEach: function RefSetCache_forEach(fn, thisArg) {
  20520. for (var i in this.dict) {
  20521. fn.call(thisArg, this.dict[i]);
  20522. }
  20523. },
  20524. clear: function RefSetCache_clear() {
  20525. this.dict = Object.create(null);
  20526. }
  20527. };
  20528. return RefSetCache;
  20529. }();
  20530. function isEOF(v) {
  20531. return v === EOF;
  20532. }
  20533. function isName(v, name) {
  20534. return v instanceof Name && (name === undefined || v.name === name);
  20535. }
  20536. function isCmd(v, cmd) {
  20537. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20538. }
  20539. function isDict(v, type) {
  20540. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20541. }
  20542. function isRef(v) {
  20543. return v instanceof Ref;
  20544. }
  20545. function isRefsEqual(v1, v2) {
  20546. return v1.num === v2.num && v1.gen === v2.gen;
  20547. }
  20548. function isStream(v) {
  20549. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20550. }
  20551. exports.EOF = EOF;
  20552. exports.Cmd = Cmd;
  20553. exports.Dict = Dict;
  20554. exports.Name = Name;
  20555. exports.Ref = Ref;
  20556. exports.RefSet = RefSet;
  20557. exports.RefSetCache = RefSetCache;
  20558. exports.isEOF = isEOF;
  20559. exports.isCmd = isCmd;
  20560. exports.isDict = isDict;
  20561. exports.isName = isName;
  20562. exports.isRef = isRef;
  20563. exports.isRefsEqual = isRefsEqual;
  20564. exports.isStream = isStream;
  20565. }));
  20566. (function (root, factory) {
  20567. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20568. }(this, function (exports, sharedUtil) {
  20569. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20570. var getStdFontMap = getLookupTableFactory(function (t) {
  20571. t['ArialNarrow'] = 'Helvetica';
  20572. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20573. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20574. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20575. t['ArialBlack'] = 'Helvetica';
  20576. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20577. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20578. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20579. t['Arial-Black'] = 'Helvetica';
  20580. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20581. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20582. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20583. t['Arial'] = 'Helvetica';
  20584. t['Arial-Bold'] = 'Helvetica-Bold';
  20585. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20586. t['Arial-Italic'] = 'Helvetica-Oblique';
  20587. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20588. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20589. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20590. t['ArialMT'] = 'Helvetica';
  20591. t['Courier-Bold'] = 'Courier-Bold';
  20592. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20593. t['Courier-Italic'] = 'Courier-Oblique';
  20594. t['CourierNew'] = 'Courier';
  20595. t['CourierNew-Bold'] = 'Courier-Bold';
  20596. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20597. t['CourierNew-Italic'] = 'Courier-Oblique';
  20598. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20599. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20600. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20601. t['CourierNewPSMT'] = 'Courier';
  20602. t['Helvetica'] = 'Helvetica';
  20603. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20604. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20605. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20606. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20607. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20608. t['Symbol-Bold'] = 'Symbol';
  20609. t['Symbol-BoldItalic'] = 'Symbol';
  20610. t['Symbol-Italic'] = 'Symbol';
  20611. t['TimesNewRoman'] = 'Times-Roman';
  20612. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20613. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20614. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20615. t['TimesNewRomanPS'] = 'Times-Roman';
  20616. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20617. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20618. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20619. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20620. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20621. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20622. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20623. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20624. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20625. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20626. });
  20627. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20628. t['CenturyGothic'] = 'Helvetica';
  20629. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20630. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20631. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20632. t['ComicSansMS'] = 'Comic Sans MS';
  20633. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20634. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20635. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20636. t['LucidaConsole'] = 'Courier';
  20637. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20638. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20639. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20640. t['MS-Gothic'] = 'MS Gothic';
  20641. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20642. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20643. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20644. t['MS-Mincho'] = 'MS Mincho';
  20645. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20646. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20647. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20648. t['MS-PGothic'] = 'MS PGothic';
  20649. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20650. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20651. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20652. t['MS-PMincho'] = 'MS PMincho';
  20653. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20654. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20655. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20656. t['NuptialScript'] = 'Times-Italic';
  20657. t['Wingdings'] = 'ZapfDingbats';
  20658. });
  20659. var getSerifFonts = getLookupTableFactory(function (t) {
  20660. t['Adobe Jenson'] = true;
  20661. t['Adobe Text'] = true;
  20662. t['Albertus'] = true;
  20663. t['Aldus'] = true;
  20664. t['Alexandria'] = true;
  20665. t['Algerian'] = true;
  20666. t['American Typewriter'] = true;
  20667. t['Antiqua'] = true;
  20668. t['Apex'] = true;
  20669. t['Arno'] = true;
  20670. t['Aster'] = true;
  20671. t['Aurora'] = true;
  20672. t['Baskerville'] = true;
  20673. t['Bell'] = true;
  20674. t['Bembo'] = true;
  20675. t['Bembo Schoolbook'] = true;
  20676. t['Benguiat'] = true;
  20677. t['Berkeley Old Style'] = true;
  20678. t['Bernhard Modern'] = true;
  20679. t['Berthold City'] = true;
  20680. t['Bodoni'] = true;
  20681. t['Bauer Bodoni'] = true;
  20682. t['Book Antiqua'] = true;
  20683. t['Bookman'] = true;
  20684. t['Bordeaux Roman'] = true;
  20685. t['Californian FB'] = true;
  20686. t['Calisto'] = true;
  20687. t['Calvert'] = true;
  20688. t['Capitals'] = true;
  20689. t['Cambria'] = true;
  20690. t['Cartier'] = true;
  20691. t['Caslon'] = true;
  20692. t['Catull'] = true;
  20693. t['Centaur'] = true;
  20694. t['Century Old Style'] = true;
  20695. t['Century Schoolbook'] = true;
  20696. t['Chaparral'] = true;
  20697. t['Charis SIL'] = true;
  20698. t['Cheltenham'] = true;
  20699. t['Cholla Slab'] = true;
  20700. t['Clarendon'] = true;
  20701. t['Clearface'] = true;
  20702. t['Cochin'] = true;
  20703. t['Colonna'] = true;
  20704. t['Computer Modern'] = true;
  20705. t['Concrete Roman'] = true;
  20706. t['Constantia'] = true;
  20707. t['Cooper Black'] = true;
  20708. t['Corona'] = true;
  20709. t['Ecotype'] = true;
  20710. t['Egyptienne'] = true;
  20711. t['Elephant'] = true;
  20712. t['Excelsior'] = true;
  20713. t['Fairfield'] = true;
  20714. t['FF Scala'] = true;
  20715. t['Folkard'] = true;
  20716. t['Footlight'] = true;
  20717. t['FreeSerif'] = true;
  20718. t['Friz Quadrata'] = true;
  20719. t['Garamond'] = true;
  20720. t['Gentium'] = true;
  20721. t['Georgia'] = true;
  20722. t['Gloucester'] = true;
  20723. t['Goudy Old Style'] = true;
  20724. t['Goudy Schoolbook'] = true;
  20725. t['Goudy Pro Font'] = true;
  20726. t['Granjon'] = true;
  20727. t['Guardian Egyptian'] = true;
  20728. t['Heather'] = true;
  20729. t['Hercules'] = true;
  20730. t['High Tower Text'] = true;
  20731. t['Hiroshige'] = true;
  20732. t['Hoefler Text'] = true;
  20733. t['Humana Serif'] = true;
  20734. t['Imprint'] = true;
  20735. t['Ionic No. 5'] = true;
  20736. t['Janson'] = true;
  20737. t['Joanna'] = true;
  20738. t['Korinna'] = true;
  20739. t['Lexicon'] = true;
  20740. t['Liberation Serif'] = true;
  20741. t['Linux Libertine'] = true;
  20742. t['Literaturnaya'] = true;
  20743. t['Lucida'] = true;
  20744. t['Lucida Bright'] = true;
  20745. t['Melior'] = true;
  20746. t['Memphis'] = true;
  20747. t['Miller'] = true;
  20748. t['Minion'] = true;
  20749. t['Modern'] = true;
  20750. t['Mona Lisa'] = true;
  20751. t['Mrs Eaves'] = true;
  20752. t['MS Serif'] = true;
  20753. t['Museo Slab'] = true;
  20754. t['New York'] = true;
  20755. t['Nimbus Roman'] = true;
  20756. t['NPS Rawlinson Roadway'] = true;
  20757. t['NuptialScript'] = true;
  20758. t['Palatino'] = true;
  20759. t['Perpetua'] = true;
  20760. t['Plantin'] = true;
  20761. t['Plantin Schoolbook'] = true;
  20762. t['Playbill'] = true;
  20763. t['Poor Richard'] = true;
  20764. t['Rawlinson Roadway'] = true;
  20765. t['Renault'] = true;
  20766. t['Requiem'] = true;
  20767. t['Rockwell'] = true;
  20768. t['Roman'] = true;
  20769. t['Rotis Serif'] = true;
  20770. t['Sabon'] = true;
  20771. t['Scala'] = true;
  20772. t['Seagull'] = true;
  20773. t['Sistina'] = true;
  20774. t['Souvenir'] = true;
  20775. t['STIX'] = true;
  20776. t['Stone Informal'] = true;
  20777. t['Stone Serif'] = true;
  20778. t['Sylfaen'] = true;
  20779. t['Times'] = true;
  20780. t['Trajan'] = true;
  20781. t['Trinité'] = true;
  20782. t['Trump Mediaeval'] = true;
  20783. t['Utopia'] = true;
  20784. t['Vale Type'] = true;
  20785. t['Bitstream Vera'] = true;
  20786. t['Vera Serif'] = true;
  20787. t['Versailles'] = true;
  20788. t['Wanted'] = true;
  20789. t['Weiss'] = true;
  20790. t['Wide Latin'] = true;
  20791. t['Windsor'] = true;
  20792. t['XITS'] = true;
  20793. });
  20794. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20795. t['Dingbats'] = true;
  20796. t['Symbol'] = true;
  20797. t['ZapfDingbats'] = true;
  20798. });
  20799. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20800. t[2] = 10;
  20801. t[3] = 32;
  20802. t[4] = 33;
  20803. t[5] = 34;
  20804. t[6] = 35;
  20805. t[7] = 36;
  20806. t[8] = 37;
  20807. t[9] = 38;
  20808. t[10] = 39;
  20809. t[11] = 40;
  20810. t[12] = 41;
  20811. t[13] = 42;
  20812. t[14] = 43;
  20813. t[15] = 44;
  20814. t[16] = 45;
  20815. t[17] = 46;
  20816. t[18] = 47;
  20817. t[19] = 48;
  20818. t[20] = 49;
  20819. t[21] = 50;
  20820. t[22] = 51;
  20821. t[23] = 52;
  20822. t[24] = 53;
  20823. t[25] = 54;
  20824. t[26] = 55;
  20825. t[27] = 56;
  20826. t[28] = 57;
  20827. t[29] = 58;
  20828. t[30] = 894;
  20829. t[31] = 60;
  20830. t[32] = 61;
  20831. t[33] = 62;
  20832. t[34] = 63;
  20833. t[35] = 64;
  20834. t[36] = 65;
  20835. t[37] = 66;
  20836. t[38] = 67;
  20837. t[39] = 68;
  20838. t[40] = 69;
  20839. t[41] = 70;
  20840. t[42] = 71;
  20841. t[43] = 72;
  20842. t[44] = 73;
  20843. t[45] = 74;
  20844. t[46] = 75;
  20845. t[47] = 76;
  20846. t[48] = 77;
  20847. t[49] = 78;
  20848. t[50] = 79;
  20849. t[51] = 80;
  20850. t[52] = 81;
  20851. t[53] = 82;
  20852. t[54] = 83;
  20853. t[55] = 84;
  20854. t[56] = 85;
  20855. t[57] = 86;
  20856. t[58] = 87;
  20857. t[59] = 88;
  20858. t[60] = 89;
  20859. t[61] = 90;
  20860. t[62] = 91;
  20861. t[63] = 92;
  20862. t[64] = 93;
  20863. t[65] = 94;
  20864. t[66] = 95;
  20865. t[67] = 96;
  20866. t[68] = 97;
  20867. t[69] = 98;
  20868. t[70] = 99;
  20869. t[71] = 100;
  20870. t[72] = 101;
  20871. t[73] = 102;
  20872. t[74] = 103;
  20873. t[75] = 104;
  20874. t[76] = 105;
  20875. t[77] = 106;
  20876. t[78] = 107;
  20877. t[79] = 108;
  20878. t[80] = 109;
  20879. t[81] = 110;
  20880. t[82] = 111;
  20881. t[83] = 112;
  20882. t[84] = 113;
  20883. t[85] = 114;
  20884. t[86] = 115;
  20885. t[87] = 116;
  20886. t[88] = 117;
  20887. t[89] = 118;
  20888. t[90] = 119;
  20889. t[91] = 120;
  20890. t[92] = 121;
  20891. t[93] = 122;
  20892. t[94] = 123;
  20893. t[95] = 124;
  20894. t[96] = 125;
  20895. t[97] = 126;
  20896. t[98] = 196;
  20897. t[99] = 197;
  20898. t[100] = 199;
  20899. t[101] = 201;
  20900. t[102] = 209;
  20901. t[103] = 214;
  20902. t[104] = 220;
  20903. t[105] = 225;
  20904. t[106] = 224;
  20905. t[107] = 226;
  20906. t[108] = 228;
  20907. t[109] = 227;
  20908. t[110] = 229;
  20909. t[111] = 231;
  20910. t[112] = 233;
  20911. t[113] = 232;
  20912. t[114] = 234;
  20913. t[115] = 235;
  20914. t[116] = 237;
  20915. t[117] = 236;
  20916. t[118] = 238;
  20917. t[119] = 239;
  20918. t[120] = 241;
  20919. t[121] = 243;
  20920. t[122] = 242;
  20921. t[123] = 244;
  20922. t[124] = 246;
  20923. t[125] = 245;
  20924. t[126] = 250;
  20925. t[127] = 249;
  20926. t[128] = 251;
  20927. t[129] = 252;
  20928. t[130] = 8224;
  20929. t[131] = 176;
  20930. t[132] = 162;
  20931. t[133] = 163;
  20932. t[134] = 167;
  20933. t[135] = 8226;
  20934. t[136] = 182;
  20935. t[137] = 223;
  20936. t[138] = 174;
  20937. t[139] = 169;
  20938. t[140] = 8482;
  20939. t[141] = 180;
  20940. t[142] = 168;
  20941. t[143] = 8800;
  20942. t[144] = 198;
  20943. t[145] = 216;
  20944. t[146] = 8734;
  20945. t[147] = 177;
  20946. t[148] = 8804;
  20947. t[149] = 8805;
  20948. t[150] = 165;
  20949. t[151] = 181;
  20950. t[152] = 8706;
  20951. t[153] = 8721;
  20952. t[154] = 8719;
  20953. t[156] = 8747;
  20954. t[157] = 170;
  20955. t[158] = 186;
  20956. t[159] = 8486;
  20957. t[160] = 230;
  20958. t[161] = 248;
  20959. t[162] = 191;
  20960. t[163] = 161;
  20961. t[164] = 172;
  20962. t[165] = 8730;
  20963. t[166] = 402;
  20964. t[167] = 8776;
  20965. t[168] = 8710;
  20966. t[169] = 171;
  20967. t[170] = 187;
  20968. t[171] = 8230;
  20969. t[210] = 218;
  20970. t[223] = 711;
  20971. t[224] = 321;
  20972. t[225] = 322;
  20973. t[227] = 353;
  20974. t[229] = 382;
  20975. t[234] = 253;
  20976. t[252] = 263;
  20977. t[253] = 268;
  20978. t[254] = 269;
  20979. t[258] = 258;
  20980. t[260] = 260;
  20981. t[261] = 261;
  20982. t[265] = 280;
  20983. t[266] = 281;
  20984. t[268] = 283;
  20985. t[269] = 313;
  20986. t[275] = 323;
  20987. t[276] = 324;
  20988. t[278] = 328;
  20989. t[284] = 345;
  20990. t[285] = 346;
  20991. t[286] = 347;
  20992. t[292] = 367;
  20993. t[295] = 377;
  20994. t[296] = 378;
  20995. t[298] = 380;
  20996. t[305] = 963;
  20997. t[306] = 964;
  20998. t[307] = 966;
  20999. t[308] = 8215;
  21000. t[309] = 8252;
  21001. t[310] = 8319;
  21002. t[311] = 8359;
  21003. t[312] = 8592;
  21004. t[313] = 8593;
  21005. t[337] = 9552;
  21006. t[493] = 1039;
  21007. t[494] = 1040;
  21008. t[705] = 1524;
  21009. t[706] = 8362;
  21010. t[710] = 64288;
  21011. t[711] = 64298;
  21012. t[759] = 1617;
  21013. t[761] = 1776;
  21014. t[763] = 1778;
  21015. t[775] = 1652;
  21016. t[777] = 1764;
  21017. t[778] = 1780;
  21018. t[779] = 1781;
  21019. t[780] = 1782;
  21020. t[782] = 771;
  21021. t[783] = 64726;
  21022. t[786] = 8363;
  21023. t[788] = 8532;
  21024. t[790] = 768;
  21025. t[791] = 769;
  21026. t[792] = 768;
  21027. t[795] = 803;
  21028. t[797] = 64336;
  21029. t[798] = 64337;
  21030. t[799] = 64342;
  21031. t[800] = 64343;
  21032. t[801] = 64344;
  21033. t[802] = 64345;
  21034. t[803] = 64362;
  21035. t[804] = 64363;
  21036. t[805] = 64364;
  21037. t[2424] = 7821;
  21038. t[2425] = 7822;
  21039. t[2426] = 7823;
  21040. t[2427] = 7824;
  21041. t[2428] = 7825;
  21042. t[2429] = 7826;
  21043. t[2430] = 7827;
  21044. t[2433] = 7682;
  21045. t[2678] = 8045;
  21046. t[2679] = 8046;
  21047. t[2830] = 1552;
  21048. t[2838] = 686;
  21049. t[2840] = 751;
  21050. t[2842] = 753;
  21051. t[2843] = 754;
  21052. t[2844] = 755;
  21053. t[2846] = 757;
  21054. t[2856] = 767;
  21055. t[2857] = 848;
  21056. t[2858] = 849;
  21057. t[2862] = 853;
  21058. t[2863] = 854;
  21059. t[2864] = 855;
  21060. t[2865] = 861;
  21061. t[2866] = 862;
  21062. t[2906] = 7460;
  21063. t[2908] = 7462;
  21064. t[2909] = 7463;
  21065. t[2910] = 7464;
  21066. t[2912] = 7466;
  21067. t[2913] = 7467;
  21068. t[2914] = 7468;
  21069. t[2916] = 7470;
  21070. t[2917] = 7471;
  21071. t[2918] = 7472;
  21072. t[2920] = 7474;
  21073. t[2921] = 7475;
  21074. t[2922] = 7476;
  21075. t[2924] = 7478;
  21076. t[2925] = 7479;
  21077. t[2926] = 7480;
  21078. t[2928] = 7482;
  21079. t[2929] = 7483;
  21080. t[2930] = 7484;
  21081. t[2932] = 7486;
  21082. t[2933] = 7487;
  21083. t[2934] = 7488;
  21084. t[2936] = 7490;
  21085. t[2937] = 7491;
  21086. t[2938] = 7492;
  21087. t[2940] = 7494;
  21088. t[2941] = 7495;
  21089. t[2942] = 7496;
  21090. t[2944] = 7498;
  21091. t[2946] = 7500;
  21092. t[2948] = 7502;
  21093. t[2950] = 7504;
  21094. t[2951] = 7505;
  21095. t[2952] = 7506;
  21096. t[2954] = 7508;
  21097. t[2955] = 7509;
  21098. t[2956] = 7510;
  21099. t[2958] = 7512;
  21100. t[2959] = 7513;
  21101. t[2960] = 7514;
  21102. t[2962] = 7516;
  21103. t[2963] = 7517;
  21104. t[2964] = 7518;
  21105. t[2966] = 7520;
  21106. t[2967] = 7521;
  21107. t[2968] = 7522;
  21108. t[2970] = 7524;
  21109. t[2971] = 7525;
  21110. t[2972] = 7526;
  21111. t[2974] = 7528;
  21112. t[2975] = 7529;
  21113. t[2976] = 7530;
  21114. t[2978] = 1537;
  21115. t[2979] = 1538;
  21116. t[2980] = 1539;
  21117. t[2982] = 1549;
  21118. t[2983] = 1551;
  21119. t[2984] = 1552;
  21120. t[2986] = 1554;
  21121. t[2987] = 1555;
  21122. t[2988] = 1556;
  21123. t[2990] = 1623;
  21124. t[2991] = 1624;
  21125. t[2995] = 1775;
  21126. t[2999] = 1791;
  21127. t[3002] = 64290;
  21128. t[3003] = 64291;
  21129. t[3004] = 64292;
  21130. t[3006] = 64294;
  21131. t[3007] = 64295;
  21132. t[3008] = 64296;
  21133. t[3011] = 1900;
  21134. t[3014] = 8223;
  21135. t[3015] = 8244;
  21136. t[3017] = 7532;
  21137. t[3018] = 7533;
  21138. t[3019] = 7534;
  21139. t[3075] = 7590;
  21140. t[3076] = 7591;
  21141. t[3079] = 7594;
  21142. t[3080] = 7595;
  21143. t[3083] = 7598;
  21144. t[3084] = 7599;
  21145. t[3087] = 7602;
  21146. t[3088] = 7603;
  21147. t[3091] = 7606;
  21148. t[3092] = 7607;
  21149. t[3095] = 7610;
  21150. t[3096] = 7611;
  21151. t[3099] = 7614;
  21152. t[3100] = 7615;
  21153. t[3103] = 7618;
  21154. t[3104] = 7619;
  21155. t[3107] = 8337;
  21156. t[3108] = 8338;
  21157. t[3116] = 1884;
  21158. t[3119] = 1885;
  21159. t[3120] = 1885;
  21160. t[3123] = 1886;
  21161. t[3124] = 1886;
  21162. t[3127] = 1887;
  21163. t[3128] = 1887;
  21164. t[3131] = 1888;
  21165. t[3132] = 1888;
  21166. t[3135] = 1889;
  21167. t[3136] = 1889;
  21168. t[3139] = 1890;
  21169. t[3140] = 1890;
  21170. t[3143] = 1891;
  21171. t[3144] = 1891;
  21172. t[3147] = 1892;
  21173. t[3148] = 1892;
  21174. t[3153] = 580;
  21175. t[3154] = 581;
  21176. t[3157] = 584;
  21177. t[3158] = 585;
  21178. t[3161] = 588;
  21179. t[3162] = 589;
  21180. t[3165] = 891;
  21181. t[3166] = 892;
  21182. t[3169] = 1274;
  21183. t[3170] = 1275;
  21184. t[3173] = 1278;
  21185. t[3174] = 1279;
  21186. t[3181] = 7622;
  21187. t[3182] = 7623;
  21188. t[3282] = 11799;
  21189. t[3316] = 578;
  21190. t[3379] = 42785;
  21191. t[3393] = 1159;
  21192. t[3416] = 8377;
  21193. });
  21194. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21195. t[227] = 322;
  21196. t[264] = 261;
  21197. t[291] = 346;
  21198. });
  21199. exports.getStdFontMap = getStdFontMap;
  21200. exports.getNonStdFontMap = getNonStdFontMap;
  21201. exports.getSerifFonts = getSerifFonts;
  21202. exports.getSymbolsFonts = getSymbolsFonts;
  21203. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21204. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21205. }));
  21206. (function (root, factory) {
  21207. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21208. }(this, function (exports, sharedUtil) {
  21209. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21210. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21211. t[63721] = 0x00A9;
  21212. t[63193] = 0x00A9;
  21213. t[63720] = 0x00AE;
  21214. t[63194] = 0x00AE;
  21215. t[63722] = 0x2122;
  21216. t[63195] = 0x2122;
  21217. t[63729] = 0x23A7;
  21218. t[63730] = 0x23A8;
  21219. t[63731] = 0x23A9;
  21220. t[63740] = 0x23AB;
  21221. t[63741] = 0x23AC;
  21222. t[63742] = 0x23AD;
  21223. t[63726] = 0x23A1;
  21224. t[63727] = 0x23A2;
  21225. t[63728] = 0x23A3;
  21226. t[63737] = 0x23A4;
  21227. t[63738] = 0x23A5;
  21228. t[63739] = 0x23A6;
  21229. t[63723] = 0x239B;
  21230. t[63724] = 0x239C;
  21231. t[63725] = 0x239D;
  21232. t[63734] = 0x239E;
  21233. t[63735] = 0x239F;
  21234. t[63736] = 0x23A0;
  21235. });
  21236. function mapSpecialUnicodeValues(code) {
  21237. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21238. return 0;
  21239. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21240. return getSpecialPUASymbols()[code] || code;
  21241. }
  21242. return code;
  21243. }
  21244. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21245. var unicode = glyphsUnicodeMap[name];
  21246. if (unicode !== undefined) {
  21247. return unicode;
  21248. }
  21249. if (!name) {
  21250. return -1;
  21251. }
  21252. if (name[0] === 'u') {
  21253. var nameLen = name.length, hexStr;
  21254. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21255. hexStr = name.substr(3);
  21256. } else if (nameLen >= 5 && nameLen <= 7) {
  21257. hexStr = name.substr(1);
  21258. } else {
  21259. return -1;
  21260. }
  21261. if (hexStr === hexStr.toUpperCase()) {
  21262. unicode = parseInt(hexStr, 16);
  21263. if (unicode >= 0) {
  21264. return unicode;
  21265. }
  21266. }
  21267. }
  21268. return -1;
  21269. }
  21270. var UnicodeRanges = [
  21271. {
  21272. 'begin': 0x0000,
  21273. 'end': 0x007F
  21274. },
  21275. {
  21276. 'begin': 0x0080,
  21277. 'end': 0x00FF
  21278. },
  21279. {
  21280. 'begin': 0x0100,
  21281. 'end': 0x017F
  21282. },
  21283. {
  21284. 'begin': 0x0180,
  21285. 'end': 0x024F
  21286. },
  21287. {
  21288. 'begin': 0x0250,
  21289. 'end': 0x02AF
  21290. },
  21291. {
  21292. 'begin': 0x02B0,
  21293. 'end': 0x02FF
  21294. },
  21295. {
  21296. 'begin': 0x0300,
  21297. 'end': 0x036F
  21298. },
  21299. {
  21300. 'begin': 0x0370,
  21301. 'end': 0x03FF
  21302. },
  21303. {
  21304. 'begin': 0x2C80,
  21305. 'end': 0x2CFF
  21306. },
  21307. {
  21308. 'begin': 0x0400,
  21309. 'end': 0x04FF
  21310. },
  21311. {
  21312. 'begin': 0x0530,
  21313. 'end': 0x058F
  21314. },
  21315. {
  21316. 'begin': 0x0590,
  21317. 'end': 0x05FF
  21318. },
  21319. {
  21320. 'begin': 0xA500,
  21321. 'end': 0xA63F
  21322. },
  21323. {
  21324. 'begin': 0x0600,
  21325. 'end': 0x06FF
  21326. },
  21327. {
  21328. 'begin': 0x07C0,
  21329. 'end': 0x07FF
  21330. },
  21331. {
  21332. 'begin': 0x0900,
  21333. 'end': 0x097F
  21334. },
  21335. {
  21336. 'begin': 0x0980,
  21337. 'end': 0x09FF
  21338. },
  21339. {
  21340. 'begin': 0x0A00,
  21341. 'end': 0x0A7F
  21342. },
  21343. {
  21344. 'begin': 0x0A80,
  21345. 'end': 0x0AFF
  21346. },
  21347. {
  21348. 'begin': 0x0B00,
  21349. 'end': 0x0B7F
  21350. },
  21351. {
  21352. 'begin': 0x0B80,
  21353. 'end': 0x0BFF
  21354. },
  21355. {
  21356. 'begin': 0x0C00,
  21357. 'end': 0x0C7F
  21358. },
  21359. {
  21360. 'begin': 0x0C80,
  21361. 'end': 0x0CFF
  21362. },
  21363. {
  21364. 'begin': 0x0D00,
  21365. 'end': 0x0D7F
  21366. },
  21367. {
  21368. 'begin': 0x0E00,
  21369. 'end': 0x0E7F
  21370. },
  21371. {
  21372. 'begin': 0x0E80,
  21373. 'end': 0x0EFF
  21374. },
  21375. {
  21376. 'begin': 0x10A0,
  21377. 'end': 0x10FF
  21378. },
  21379. {
  21380. 'begin': 0x1B00,
  21381. 'end': 0x1B7F
  21382. },
  21383. {
  21384. 'begin': 0x1100,
  21385. 'end': 0x11FF
  21386. },
  21387. {
  21388. 'begin': 0x1E00,
  21389. 'end': 0x1EFF
  21390. },
  21391. {
  21392. 'begin': 0x1F00,
  21393. 'end': 0x1FFF
  21394. },
  21395. {
  21396. 'begin': 0x2000,
  21397. 'end': 0x206F
  21398. },
  21399. {
  21400. 'begin': 0x2070,
  21401. 'end': 0x209F
  21402. },
  21403. {
  21404. 'begin': 0x20A0,
  21405. 'end': 0x20CF
  21406. },
  21407. {
  21408. 'begin': 0x20D0,
  21409. 'end': 0x20FF
  21410. },
  21411. {
  21412. 'begin': 0x2100,
  21413. 'end': 0x214F
  21414. },
  21415. {
  21416. 'begin': 0x2150,
  21417. 'end': 0x218F
  21418. },
  21419. {
  21420. 'begin': 0x2190,
  21421. 'end': 0x21FF
  21422. },
  21423. {
  21424. 'begin': 0x2200,
  21425. 'end': 0x22FF
  21426. },
  21427. {
  21428. 'begin': 0x2300,
  21429. 'end': 0x23FF
  21430. },
  21431. {
  21432. 'begin': 0x2400,
  21433. 'end': 0x243F
  21434. },
  21435. {
  21436. 'begin': 0x2440,
  21437. 'end': 0x245F
  21438. },
  21439. {
  21440. 'begin': 0x2460,
  21441. 'end': 0x24FF
  21442. },
  21443. {
  21444. 'begin': 0x2500,
  21445. 'end': 0x257F
  21446. },
  21447. {
  21448. 'begin': 0x2580,
  21449. 'end': 0x259F
  21450. },
  21451. {
  21452. 'begin': 0x25A0,
  21453. 'end': 0x25FF
  21454. },
  21455. {
  21456. 'begin': 0x2600,
  21457. 'end': 0x26FF
  21458. },
  21459. {
  21460. 'begin': 0x2700,
  21461. 'end': 0x27BF
  21462. },
  21463. {
  21464. 'begin': 0x3000,
  21465. 'end': 0x303F
  21466. },
  21467. {
  21468. 'begin': 0x3040,
  21469. 'end': 0x309F
  21470. },
  21471. {
  21472. 'begin': 0x30A0,
  21473. 'end': 0x30FF
  21474. },
  21475. {
  21476. 'begin': 0x3100,
  21477. 'end': 0x312F
  21478. },
  21479. {
  21480. 'begin': 0x3130,
  21481. 'end': 0x318F
  21482. },
  21483. {
  21484. 'begin': 0xA840,
  21485. 'end': 0xA87F
  21486. },
  21487. {
  21488. 'begin': 0x3200,
  21489. 'end': 0x32FF
  21490. },
  21491. {
  21492. 'begin': 0x3300,
  21493. 'end': 0x33FF
  21494. },
  21495. {
  21496. 'begin': 0xAC00,
  21497. 'end': 0xD7AF
  21498. },
  21499. {
  21500. 'begin': 0xD800,
  21501. 'end': 0xDFFF
  21502. },
  21503. {
  21504. 'begin': 0x10900,
  21505. 'end': 0x1091F
  21506. },
  21507. {
  21508. 'begin': 0x4E00,
  21509. 'end': 0x9FFF
  21510. },
  21511. {
  21512. 'begin': 0xE000,
  21513. 'end': 0xF8FF
  21514. },
  21515. {
  21516. 'begin': 0x31C0,
  21517. 'end': 0x31EF
  21518. },
  21519. {
  21520. 'begin': 0xFB00,
  21521. 'end': 0xFB4F
  21522. },
  21523. {
  21524. 'begin': 0xFB50,
  21525. 'end': 0xFDFF
  21526. },
  21527. {
  21528. 'begin': 0xFE20,
  21529. 'end': 0xFE2F
  21530. },
  21531. {
  21532. 'begin': 0xFE10,
  21533. 'end': 0xFE1F
  21534. },
  21535. {
  21536. 'begin': 0xFE50,
  21537. 'end': 0xFE6F
  21538. },
  21539. {
  21540. 'begin': 0xFE70,
  21541. 'end': 0xFEFF
  21542. },
  21543. {
  21544. 'begin': 0xFF00,
  21545. 'end': 0xFFEF
  21546. },
  21547. {
  21548. 'begin': 0xFFF0,
  21549. 'end': 0xFFFF
  21550. },
  21551. {
  21552. 'begin': 0x0F00,
  21553. 'end': 0x0FFF
  21554. },
  21555. {
  21556. 'begin': 0x0700,
  21557. 'end': 0x074F
  21558. },
  21559. {
  21560. 'begin': 0x0780,
  21561. 'end': 0x07BF
  21562. },
  21563. {
  21564. 'begin': 0x0D80,
  21565. 'end': 0x0DFF
  21566. },
  21567. {
  21568. 'begin': 0x1000,
  21569. 'end': 0x109F
  21570. },
  21571. {
  21572. 'begin': 0x1200,
  21573. 'end': 0x137F
  21574. },
  21575. {
  21576. 'begin': 0x13A0,
  21577. 'end': 0x13FF
  21578. },
  21579. {
  21580. 'begin': 0x1400,
  21581. 'end': 0x167F
  21582. },
  21583. {
  21584. 'begin': 0x1680,
  21585. 'end': 0x169F
  21586. },
  21587. {
  21588. 'begin': 0x16A0,
  21589. 'end': 0x16FF
  21590. },
  21591. {
  21592. 'begin': 0x1780,
  21593. 'end': 0x17FF
  21594. },
  21595. {
  21596. 'begin': 0x1800,
  21597. 'end': 0x18AF
  21598. },
  21599. {
  21600. 'begin': 0x2800,
  21601. 'end': 0x28FF
  21602. },
  21603. {
  21604. 'begin': 0xA000,
  21605. 'end': 0xA48F
  21606. },
  21607. {
  21608. 'begin': 0x1700,
  21609. 'end': 0x171F
  21610. },
  21611. {
  21612. 'begin': 0x10300,
  21613. 'end': 0x1032F
  21614. },
  21615. {
  21616. 'begin': 0x10330,
  21617. 'end': 0x1034F
  21618. },
  21619. {
  21620. 'begin': 0x10400,
  21621. 'end': 0x1044F
  21622. },
  21623. {
  21624. 'begin': 0x1D000,
  21625. 'end': 0x1D0FF
  21626. },
  21627. {
  21628. 'begin': 0x1D400,
  21629. 'end': 0x1D7FF
  21630. },
  21631. {
  21632. 'begin': 0xFF000,
  21633. 'end': 0xFFFFD
  21634. },
  21635. {
  21636. 'begin': 0xFE00,
  21637. 'end': 0xFE0F
  21638. },
  21639. {
  21640. 'begin': 0xE0000,
  21641. 'end': 0xE007F
  21642. },
  21643. {
  21644. 'begin': 0x1900,
  21645. 'end': 0x194F
  21646. },
  21647. {
  21648. 'begin': 0x1950,
  21649. 'end': 0x197F
  21650. },
  21651. {
  21652. 'begin': 0x1980,
  21653. 'end': 0x19DF
  21654. },
  21655. {
  21656. 'begin': 0x1A00,
  21657. 'end': 0x1A1F
  21658. },
  21659. {
  21660. 'begin': 0x2C00,
  21661. 'end': 0x2C5F
  21662. },
  21663. {
  21664. 'begin': 0x2D30,
  21665. 'end': 0x2D7F
  21666. },
  21667. {
  21668. 'begin': 0x4DC0,
  21669. 'end': 0x4DFF
  21670. },
  21671. {
  21672. 'begin': 0xA800,
  21673. 'end': 0xA82F
  21674. },
  21675. {
  21676. 'begin': 0x10000,
  21677. 'end': 0x1007F
  21678. },
  21679. {
  21680. 'begin': 0x10140,
  21681. 'end': 0x1018F
  21682. },
  21683. {
  21684. 'begin': 0x10380,
  21685. 'end': 0x1039F
  21686. },
  21687. {
  21688. 'begin': 0x103A0,
  21689. 'end': 0x103DF
  21690. },
  21691. {
  21692. 'begin': 0x10450,
  21693. 'end': 0x1047F
  21694. },
  21695. {
  21696. 'begin': 0x10480,
  21697. 'end': 0x104AF
  21698. },
  21699. {
  21700. 'begin': 0x10800,
  21701. 'end': 0x1083F
  21702. },
  21703. {
  21704. 'begin': 0x10A00,
  21705. 'end': 0x10A5F
  21706. },
  21707. {
  21708. 'begin': 0x1D300,
  21709. 'end': 0x1D35F
  21710. },
  21711. {
  21712. 'begin': 0x12000,
  21713. 'end': 0x123FF
  21714. },
  21715. {
  21716. 'begin': 0x1D360,
  21717. 'end': 0x1D37F
  21718. },
  21719. {
  21720. 'begin': 0x1B80,
  21721. 'end': 0x1BBF
  21722. },
  21723. {
  21724. 'begin': 0x1C00,
  21725. 'end': 0x1C4F
  21726. },
  21727. {
  21728. 'begin': 0x1C50,
  21729. 'end': 0x1C7F
  21730. },
  21731. {
  21732. 'begin': 0xA880,
  21733. 'end': 0xA8DF
  21734. },
  21735. {
  21736. 'begin': 0xA900,
  21737. 'end': 0xA92F
  21738. },
  21739. {
  21740. 'begin': 0xA930,
  21741. 'end': 0xA95F
  21742. },
  21743. {
  21744. 'begin': 0xAA00,
  21745. 'end': 0xAA5F
  21746. },
  21747. {
  21748. 'begin': 0x10190,
  21749. 'end': 0x101CF
  21750. },
  21751. {
  21752. 'begin': 0x101D0,
  21753. 'end': 0x101FF
  21754. },
  21755. {
  21756. 'begin': 0x102A0,
  21757. 'end': 0x102DF
  21758. },
  21759. {
  21760. 'begin': 0x1F030,
  21761. 'end': 0x1F09F
  21762. }
  21763. ];
  21764. function getUnicodeRangeFor(value) {
  21765. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21766. var range = UnicodeRanges[i];
  21767. if (value >= range.begin && value < range.end) {
  21768. return i;
  21769. }
  21770. }
  21771. return -1;
  21772. }
  21773. function isRTLRangeFor(value) {
  21774. var range = UnicodeRanges[13];
  21775. if (value >= range.begin && value < range.end) {
  21776. return true;
  21777. }
  21778. range = UnicodeRanges[11];
  21779. if (value >= range.begin && value < range.end) {
  21780. return true;
  21781. }
  21782. return false;
  21783. }
  21784. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21785. t['\u00A8'] = '\u0020\u0308';
  21786. t['\u00AF'] = '\u0020\u0304';
  21787. t['\u00B4'] = '\u0020\u0301';
  21788. t['\u00B5'] = '\u03BC';
  21789. t['\u00B8'] = '\u0020\u0327';
  21790. t['\u0132'] = '\u0049\u004A';
  21791. t['\u0133'] = '\u0069\u006A';
  21792. t['\u013F'] = '\u004C\u00B7';
  21793. t['\u0140'] = '\u006C\u00B7';
  21794. t['\u0149'] = '\u02BC\u006E';
  21795. t['\u017F'] = '\u0073';
  21796. t['\u01C4'] = '\u0044\u017D';
  21797. t['\u01C5'] = '\u0044\u017E';
  21798. t['\u01C6'] = '\u0064\u017E';
  21799. t['\u01C7'] = '\u004C\u004A';
  21800. t['\u01C8'] = '\u004C\u006A';
  21801. t['\u01C9'] = '\u006C\u006A';
  21802. t['\u01CA'] = '\u004E\u004A';
  21803. t['\u01CB'] = '\u004E\u006A';
  21804. t['\u01CC'] = '\u006E\u006A';
  21805. t['\u01F1'] = '\u0044\u005A';
  21806. t['\u01F2'] = '\u0044\u007A';
  21807. t['\u01F3'] = '\u0064\u007A';
  21808. t['\u02D8'] = '\u0020\u0306';
  21809. t['\u02D9'] = '\u0020\u0307';
  21810. t['\u02DA'] = '\u0020\u030A';
  21811. t['\u02DB'] = '\u0020\u0328';
  21812. t['\u02DC'] = '\u0020\u0303';
  21813. t['\u02DD'] = '\u0020\u030B';
  21814. t['\u037A'] = '\u0020\u0345';
  21815. t['\u0384'] = '\u0020\u0301';
  21816. t['\u03D0'] = '\u03B2';
  21817. t['\u03D1'] = '\u03B8';
  21818. t['\u03D2'] = '\u03A5';
  21819. t['\u03D5'] = '\u03C6';
  21820. t['\u03D6'] = '\u03C0';
  21821. t['\u03F0'] = '\u03BA';
  21822. t['\u03F1'] = '\u03C1';
  21823. t['\u03F2'] = '\u03C2';
  21824. t['\u03F4'] = '\u0398';
  21825. t['\u03F5'] = '\u03B5';
  21826. t['\u03F9'] = '\u03A3';
  21827. t['\u0587'] = '\u0565\u0582';
  21828. t['\u0675'] = '\u0627\u0674';
  21829. t['\u0676'] = '\u0648\u0674';
  21830. t['\u0677'] = '\u06C7\u0674';
  21831. t['\u0678'] = '\u064A\u0674';
  21832. t['\u0E33'] = '\u0E4D\u0E32';
  21833. t['\u0EB3'] = '\u0ECD\u0EB2';
  21834. t['\u0EDC'] = '\u0EAB\u0E99';
  21835. t['\u0EDD'] = '\u0EAB\u0EA1';
  21836. t['\u0F77'] = '\u0FB2\u0F81';
  21837. t['\u0F79'] = '\u0FB3\u0F81';
  21838. t['\u1E9A'] = '\u0061\u02BE';
  21839. t['\u1FBD'] = '\u0020\u0313';
  21840. t['\u1FBF'] = '\u0020\u0313';
  21841. t['\u1FC0'] = '\u0020\u0342';
  21842. t['\u1FFE'] = '\u0020\u0314';
  21843. t['\u2002'] = '\u0020';
  21844. t['\u2003'] = '\u0020';
  21845. t['\u2004'] = '\u0020';
  21846. t['\u2005'] = '\u0020';
  21847. t['\u2006'] = '\u0020';
  21848. t['\u2008'] = '\u0020';
  21849. t['\u2009'] = '\u0020';
  21850. t['\u200A'] = '\u0020';
  21851. t['\u2017'] = '\u0020\u0333';
  21852. t['\u2024'] = '\u002E';
  21853. t['\u2025'] = '\u002E\u002E';
  21854. t['\u2026'] = '\u002E\u002E\u002E';
  21855. t['\u2033'] = '\u2032\u2032';
  21856. t['\u2034'] = '\u2032\u2032\u2032';
  21857. t['\u2036'] = '\u2035\u2035';
  21858. t['\u2037'] = '\u2035\u2035\u2035';
  21859. t['\u203C'] = '\u0021\u0021';
  21860. t['\u203E'] = '\u0020\u0305';
  21861. t['\u2047'] = '\u003F\u003F';
  21862. t['\u2048'] = '\u003F\u0021';
  21863. t['\u2049'] = '\u0021\u003F';
  21864. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21865. t['\u205F'] = '\u0020';
  21866. t['\u20A8'] = '\u0052\u0073';
  21867. t['\u2100'] = '\u0061\u002F\u0063';
  21868. t['\u2101'] = '\u0061\u002F\u0073';
  21869. t['\u2103'] = '\u00B0\u0043';
  21870. t['\u2105'] = '\u0063\u002F\u006F';
  21871. t['\u2106'] = '\u0063\u002F\u0075';
  21872. t['\u2107'] = '\u0190';
  21873. t['\u2109'] = '\u00B0\u0046';
  21874. t['\u2116'] = '\u004E\u006F';
  21875. t['\u2121'] = '\u0054\u0045\u004C';
  21876. t['\u2135'] = '\u05D0';
  21877. t['\u2136'] = '\u05D1';
  21878. t['\u2137'] = '\u05D2';
  21879. t['\u2138'] = '\u05D3';
  21880. t['\u213B'] = '\u0046\u0041\u0058';
  21881. t['\u2160'] = '\u0049';
  21882. t['\u2161'] = '\u0049\u0049';
  21883. t['\u2162'] = '\u0049\u0049\u0049';
  21884. t['\u2163'] = '\u0049\u0056';
  21885. t['\u2164'] = '\u0056';
  21886. t['\u2165'] = '\u0056\u0049';
  21887. t['\u2166'] = '\u0056\u0049\u0049';
  21888. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21889. t['\u2168'] = '\u0049\u0058';
  21890. t['\u2169'] = '\u0058';
  21891. t['\u216A'] = '\u0058\u0049';
  21892. t['\u216B'] = '\u0058\u0049\u0049';
  21893. t['\u216C'] = '\u004C';
  21894. t['\u216D'] = '\u0043';
  21895. t['\u216E'] = '\u0044';
  21896. t['\u216F'] = '\u004D';
  21897. t['\u2170'] = '\u0069';
  21898. t['\u2171'] = '\u0069\u0069';
  21899. t['\u2172'] = '\u0069\u0069\u0069';
  21900. t['\u2173'] = '\u0069\u0076';
  21901. t['\u2174'] = '\u0076';
  21902. t['\u2175'] = '\u0076\u0069';
  21903. t['\u2176'] = '\u0076\u0069\u0069';
  21904. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21905. t['\u2178'] = '\u0069\u0078';
  21906. t['\u2179'] = '\u0078';
  21907. t['\u217A'] = '\u0078\u0069';
  21908. t['\u217B'] = '\u0078\u0069\u0069';
  21909. t['\u217C'] = '\u006C';
  21910. t['\u217D'] = '\u0063';
  21911. t['\u217E'] = '\u0064';
  21912. t['\u217F'] = '\u006D';
  21913. t['\u222C'] = '\u222B\u222B';
  21914. t['\u222D'] = '\u222B\u222B\u222B';
  21915. t['\u222F'] = '\u222E\u222E';
  21916. t['\u2230'] = '\u222E\u222E\u222E';
  21917. t['\u2474'] = '\u0028\u0031\u0029';
  21918. t['\u2475'] = '\u0028\u0032\u0029';
  21919. t['\u2476'] = '\u0028\u0033\u0029';
  21920. t['\u2477'] = '\u0028\u0034\u0029';
  21921. t['\u2478'] = '\u0028\u0035\u0029';
  21922. t['\u2479'] = '\u0028\u0036\u0029';
  21923. t['\u247A'] = '\u0028\u0037\u0029';
  21924. t['\u247B'] = '\u0028\u0038\u0029';
  21925. t['\u247C'] = '\u0028\u0039\u0029';
  21926. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21927. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21928. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21929. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21930. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21931. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21932. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21933. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21934. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21935. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21936. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21937. t['\u2488'] = '\u0031\u002E';
  21938. t['\u2489'] = '\u0032\u002E';
  21939. t['\u248A'] = '\u0033\u002E';
  21940. t['\u248B'] = '\u0034\u002E';
  21941. t['\u248C'] = '\u0035\u002E';
  21942. t['\u248D'] = '\u0036\u002E';
  21943. t['\u248E'] = '\u0037\u002E';
  21944. t['\u248F'] = '\u0038\u002E';
  21945. t['\u2490'] = '\u0039\u002E';
  21946. t['\u2491'] = '\u0031\u0030\u002E';
  21947. t['\u2492'] = '\u0031\u0031\u002E';
  21948. t['\u2493'] = '\u0031\u0032\u002E';
  21949. t['\u2494'] = '\u0031\u0033\u002E';
  21950. t['\u2495'] = '\u0031\u0034\u002E';
  21951. t['\u2496'] = '\u0031\u0035\u002E';
  21952. t['\u2497'] = '\u0031\u0036\u002E';
  21953. t['\u2498'] = '\u0031\u0037\u002E';
  21954. t['\u2499'] = '\u0031\u0038\u002E';
  21955. t['\u249A'] = '\u0031\u0039\u002E';
  21956. t['\u249B'] = '\u0032\u0030\u002E';
  21957. t['\u249C'] = '\u0028\u0061\u0029';
  21958. t['\u249D'] = '\u0028\u0062\u0029';
  21959. t['\u249E'] = '\u0028\u0063\u0029';
  21960. t['\u249F'] = '\u0028\u0064\u0029';
  21961. t['\u24A0'] = '\u0028\u0065\u0029';
  21962. t['\u24A1'] = '\u0028\u0066\u0029';
  21963. t['\u24A2'] = '\u0028\u0067\u0029';
  21964. t['\u24A3'] = '\u0028\u0068\u0029';
  21965. t['\u24A4'] = '\u0028\u0069\u0029';
  21966. t['\u24A5'] = '\u0028\u006A\u0029';
  21967. t['\u24A6'] = '\u0028\u006B\u0029';
  21968. t['\u24A7'] = '\u0028\u006C\u0029';
  21969. t['\u24A8'] = '\u0028\u006D\u0029';
  21970. t['\u24A9'] = '\u0028\u006E\u0029';
  21971. t['\u24AA'] = '\u0028\u006F\u0029';
  21972. t['\u24AB'] = '\u0028\u0070\u0029';
  21973. t['\u24AC'] = '\u0028\u0071\u0029';
  21974. t['\u24AD'] = '\u0028\u0072\u0029';
  21975. t['\u24AE'] = '\u0028\u0073\u0029';
  21976. t['\u24AF'] = '\u0028\u0074\u0029';
  21977. t['\u24B0'] = '\u0028\u0075\u0029';
  21978. t['\u24B1'] = '\u0028\u0076\u0029';
  21979. t['\u24B2'] = '\u0028\u0077\u0029';
  21980. t['\u24B3'] = '\u0028\u0078\u0029';
  21981. t['\u24B4'] = '\u0028\u0079\u0029';
  21982. t['\u24B5'] = '\u0028\u007A\u0029';
  21983. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21984. t['\u2A74'] = '\u003A\u003A\u003D';
  21985. t['\u2A75'] = '\u003D\u003D';
  21986. t['\u2A76'] = '\u003D\u003D\u003D';
  21987. t['\u2E9F'] = '\u6BCD';
  21988. t['\u2EF3'] = '\u9F9F';
  21989. t['\u2F00'] = '\u4E00';
  21990. t['\u2F01'] = '\u4E28';
  21991. t['\u2F02'] = '\u4E36';
  21992. t['\u2F03'] = '\u4E3F';
  21993. t['\u2F04'] = '\u4E59';
  21994. t['\u2F05'] = '\u4E85';
  21995. t['\u2F06'] = '\u4E8C';
  21996. t['\u2F07'] = '\u4EA0';
  21997. t['\u2F08'] = '\u4EBA';
  21998. t['\u2F09'] = '\u513F';
  21999. t['\u2F0A'] = '\u5165';
  22000. t['\u2F0B'] = '\u516B';
  22001. t['\u2F0C'] = '\u5182';
  22002. t['\u2F0D'] = '\u5196';
  22003. t['\u2F0E'] = '\u51AB';
  22004. t['\u2F0F'] = '\u51E0';
  22005. t['\u2F10'] = '\u51F5';
  22006. t['\u2F11'] = '\u5200';
  22007. t['\u2F12'] = '\u529B';
  22008. t['\u2F13'] = '\u52F9';
  22009. t['\u2F14'] = '\u5315';
  22010. t['\u2F15'] = '\u531A';
  22011. t['\u2F16'] = '\u5338';
  22012. t['\u2F17'] = '\u5341';
  22013. t['\u2F18'] = '\u535C';
  22014. t['\u2F19'] = '\u5369';
  22015. t['\u2F1A'] = '\u5382';
  22016. t['\u2F1B'] = '\u53B6';
  22017. t['\u2F1C'] = '\u53C8';
  22018. t['\u2F1D'] = '\u53E3';
  22019. t['\u2F1E'] = '\u56D7';
  22020. t['\u2F1F'] = '\u571F';
  22021. t['\u2F20'] = '\u58EB';
  22022. t['\u2F21'] = '\u5902';
  22023. t['\u2F22'] = '\u590A';
  22024. t['\u2F23'] = '\u5915';
  22025. t['\u2F24'] = '\u5927';
  22026. t['\u2F25'] = '\u5973';
  22027. t['\u2F26'] = '\u5B50';
  22028. t['\u2F27'] = '\u5B80';
  22029. t['\u2F28'] = '\u5BF8';
  22030. t['\u2F29'] = '\u5C0F';
  22031. t['\u2F2A'] = '\u5C22';
  22032. t['\u2F2B'] = '\u5C38';
  22033. t['\u2F2C'] = '\u5C6E';
  22034. t['\u2F2D'] = '\u5C71';
  22035. t['\u2F2E'] = '\u5DDB';
  22036. t['\u2F2F'] = '\u5DE5';
  22037. t['\u2F30'] = '\u5DF1';
  22038. t['\u2F31'] = '\u5DFE';
  22039. t['\u2F32'] = '\u5E72';
  22040. t['\u2F33'] = '\u5E7A';
  22041. t['\u2F34'] = '\u5E7F';
  22042. t['\u2F35'] = '\u5EF4';
  22043. t['\u2F36'] = '\u5EFE';
  22044. t['\u2F37'] = '\u5F0B';
  22045. t['\u2F38'] = '\u5F13';
  22046. t['\u2F39'] = '\u5F50';
  22047. t['\u2F3A'] = '\u5F61';
  22048. t['\u2F3B'] = '\u5F73';
  22049. t['\u2F3C'] = '\u5FC3';
  22050. t['\u2F3D'] = '\u6208';
  22051. t['\u2F3E'] = '\u6236';
  22052. t['\u2F3F'] = '\u624B';
  22053. t['\u2F40'] = '\u652F';
  22054. t['\u2F41'] = '\u6534';
  22055. t['\u2F42'] = '\u6587';
  22056. t['\u2F43'] = '\u6597';
  22057. t['\u2F44'] = '\u65A4';
  22058. t['\u2F45'] = '\u65B9';
  22059. t['\u2F46'] = '\u65E0';
  22060. t['\u2F47'] = '\u65E5';
  22061. t['\u2F48'] = '\u66F0';
  22062. t['\u2F49'] = '\u6708';
  22063. t['\u2F4A'] = '\u6728';
  22064. t['\u2F4B'] = '\u6B20';
  22065. t['\u2F4C'] = '\u6B62';
  22066. t['\u2F4D'] = '\u6B79';
  22067. t['\u2F4E'] = '\u6BB3';
  22068. t['\u2F4F'] = '\u6BCB';
  22069. t['\u2F50'] = '\u6BD4';
  22070. t['\u2F51'] = '\u6BDB';
  22071. t['\u2F52'] = '\u6C0F';
  22072. t['\u2F53'] = '\u6C14';
  22073. t['\u2F54'] = '\u6C34';
  22074. t['\u2F55'] = '\u706B';
  22075. t['\u2F56'] = '\u722A';
  22076. t['\u2F57'] = '\u7236';
  22077. t['\u2F58'] = '\u723B';
  22078. t['\u2F59'] = '\u723F';
  22079. t['\u2F5A'] = '\u7247';
  22080. t['\u2F5B'] = '\u7259';
  22081. t['\u2F5C'] = '\u725B';
  22082. t['\u2F5D'] = '\u72AC';
  22083. t['\u2F5E'] = '\u7384';
  22084. t['\u2F5F'] = '\u7389';
  22085. t['\u2F60'] = '\u74DC';
  22086. t['\u2F61'] = '\u74E6';
  22087. t['\u2F62'] = '\u7518';
  22088. t['\u2F63'] = '\u751F';
  22089. t['\u2F64'] = '\u7528';
  22090. t['\u2F65'] = '\u7530';
  22091. t['\u2F66'] = '\u758B';
  22092. t['\u2F67'] = '\u7592';
  22093. t['\u2F68'] = '\u7676';
  22094. t['\u2F69'] = '\u767D';
  22095. t['\u2F6A'] = '\u76AE';
  22096. t['\u2F6B'] = '\u76BF';
  22097. t['\u2F6C'] = '\u76EE';
  22098. t['\u2F6D'] = '\u77DB';
  22099. t['\u2F6E'] = '\u77E2';
  22100. t['\u2F6F'] = '\u77F3';
  22101. t['\u2F70'] = '\u793A';
  22102. t['\u2F71'] = '\u79B8';
  22103. t['\u2F72'] = '\u79BE';
  22104. t['\u2F73'] = '\u7A74';
  22105. t['\u2F74'] = '\u7ACB';
  22106. t['\u2F75'] = '\u7AF9';
  22107. t['\u2F76'] = '\u7C73';
  22108. t['\u2F77'] = '\u7CF8';
  22109. t['\u2F78'] = '\u7F36';
  22110. t['\u2F79'] = '\u7F51';
  22111. t['\u2F7A'] = '\u7F8A';
  22112. t['\u2F7B'] = '\u7FBD';
  22113. t['\u2F7C'] = '\u8001';
  22114. t['\u2F7D'] = '\u800C';
  22115. t['\u2F7E'] = '\u8012';
  22116. t['\u2F7F'] = '\u8033';
  22117. t['\u2F80'] = '\u807F';
  22118. t['\u2F81'] = '\u8089';
  22119. t['\u2F82'] = '\u81E3';
  22120. t['\u2F83'] = '\u81EA';
  22121. t['\u2F84'] = '\u81F3';
  22122. t['\u2F85'] = '\u81FC';
  22123. t['\u2F86'] = '\u820C';
  22124. t['\u2F87'] = '\u821B';
  22125. t['\u2F88'] = '\u821F';
  22126. t['\u2F89'] = '\u826E';
  22127. t['\u2F8A'] = '\u8272';
  22128. t['\u2F8B'] = '\u8278';
  22129. t['\u2F8C'] = '\u864D';
  22130. t['\u2F8D'] = '\u866B';
  22131. t['\u2F8E'] = '\u8840';
  22132. t['\u2F8F'] = '\u884C';
  22133. t['\u2F90'] = '\u8863';
  22134. t['\u2F91'] = '\u897E';
  22135. t['\u2F92'] = '\u898B';
  22136. t['\u2F93'] = '\u89D2';
  22137. t['\u2F94'] = '\u8A00';
  22138. t['\u2F95'] = '\u8C37';
  22139. t['\u2F96'] = '\u8C46';
  22140. t['\u2F97'] = '\u8C55';
  22141. t['\u2F98'] = '\u8C78';
  22142. t['\u2F99'] = '\u8C9D';
  22143. t['\u2F9A'] = '\u8D64';
  22144. t['\u2F9B'] = '\u8D70';
  22145. t['\u2F9C'] = '\u8DB3';
  22146. t['\u2F9D'] = '\u8EAB';
  22147. t['\u2F9E'] = '\u8ECA';
  22148. t['\u2F9F'] = '\u8F9B';
  22149. t['\u2FA0'] = '\u8FB0';
  22150. t['\u2FA1'] = '\u8FB5';
  22151. t['\u2FA2'] = '\u9091';
  22152. t['\u2FA3'] = '\u9149';
  22153. t['\u2FA4'] = '\u91C6';
  22154. t['\u2FA5'] = '\u91CC';
  22155. t['\u2FA6'] = '\u91D1';
  22156. t['\u2FA7'] = '\u9577';
  22157. t['\u2FA8'] = '\u9580';
  22158. t['\u2FA9'] = '\u961C';
  22159. t['\u2FAA'] = '\u96B6';
  22160. t['\u2FAB'] = '\u96B9';
  22161. t['\u2FAC'] = '\u96E8';
  22162. t['\u2FAD'] = '\u9751';
  22163. t['\u2FAE'] = '\u975E';
  22164. t['\u2FAF'] = '\u9762';
  22165. t['\u2FB0'] = '\u9769';
  22166. t['\u2FB1'] = '\u97CB';
  22167. t['\u2FB2'] = '\u97ED';
  22168. t['\u2FB3'] = '\u97F3';
  22169. t['\u2FB4'] = '\u9801';
  22170. t['\u2FB5'] = '\u98A8';
  22171. t['\u2FB6'] = '\u98DB';
  22172. t['\u2FB7'] = '\u98DF';
  22173. t['\u2FB8'] = '\u9996';
  22174. t['\u2FB9'] = '\u9999';
  22175. t['\u2FBA'] = '\u99AC';
  22176. t['\u2FBB'] = '\u9AA8';
  22177. t['\u2FBC'] = '\u9AD8';
  22178. t['\u2FBD'] = '\u9ADF';
  22179. t['\u2FBE'] = '\u9B25';
  22180. t['\u2FBF'] = '\u9B2F';
  22181. t['\u2FC0'] = '\u9B32';
  22182. t['\u2FC1'] = '\u9B3C';
  22183. t['\u2FC2'] = '\u9B5A';
  22184. t['\u2FC3'] = '\u9CE5';
  22185. t['\u2FC4'] = '\u9E75';
  22186. t['\u2FC5'] = '\u9E7F';
  22187. t['\u2FC6'] = '\u9EA5';
  22188. t['\u2FC7'] = '\u9EBB';
  22189. t['\u2FC8'] = '\u9EC3';
  22190. t['\u2FC9'] = '\u9ECD';
  22191. t['\u2FCA'] = '\u9ED1';
  22192. t['\u2FCB'] = '\u9EF9';
  22193. t['\u2FCC'] = '\u9EFD';
  22194. t['\u2FCD'] = '\u9F0E';
  22195. t['\u2FCE'] = '\u9F13';
  22196. t['\u2FCF'] = '\u9F20';
  22197. t['\u2FD0'] = '\u9F3B';
  22198. t['\u2FD1'] = '\u9F4A';
  22199. t['\u2FD2'] = '\u9F52';
  22200. t['\u2FD3'] = '\u9F8D';
  22201. t['\u2FD4'] = '\u9F9C';
  22202. t['\u2FD5'] = '\u9FA0';
  22203. t['\u3036'] = '\u3012';
  22204. t['\u3038'] = '\u5341';
  22205. t['\u3039'] = '\u5344';
  22206. t['\u303A'] = '\u5345';
  22207. t['\u309B'] = '\u0020\u3099';
  22208. t['\u309C'] = '\u0020\u309A';
  22209. t['\u3131'] = '\u1100';
  22210. t['\u3132'] = '\u1101';
  22211. t['\u3133'] = '\u11AA';
  22212. t['\u3134'] = '\u1102';
  22213. t['\u3135'] = '\u11AC';
  22214. t['\u3136'] = '\u11AD';
  22215. t['\u3137'] = '\u1103';
  22216. t['\u3138'] = '\u1104';
  22217. t['\u3139'] = '\u1105';
  22218. t['\u313A'] = '\u11B0';
  22219. t['\u313B'] = '\u11B1';
  22220. t['\u313C'] = '\u11B2';
  22221. t['\u313D'] = '\u11B3';
  22222. t['\u313E'] = '\u11B4';
  22223. t['\u313F'] = '\u11B5';
  22224. t['\u3140'] = '\u111A';
  22225. t['\u3141'] = '\u1106';
  22226. t['\u3142'] = '\u1107';
  22227. t['\u3143'] = '\u1108';
  22228. t['\u3144'] = '\u1121';
  22229. t['\u3145'] = '\u1109';
  22230. t['\u3146'] = '\u110A';
  22231. t['\u3147'] = '\u110B';
  22232. t['\u3148'] = '\u110C';
  22233. t['\u3149'] = '\u110D';
  22234. t['\u314A'] = '\u110E';
  22235. t['\u314B'] = '\u110F';
  22236. t['\u314C'] = '\u1110';
  22237. t['\u314D'] = '\u1111';
  22238. t['\u314E'] = '\u1112';
  22239. t['\u314F'] = '\u1161';
  22240. t['\u3150'] = '\u1162';
  22241. t['\u3151'] = '\u1163';
  22242. t['\u3152'] = '\u1164';
  22243. t['\u3153'] = '\u1165';
  22244. t['\u3154'] = '\u1166';
  22245. t['\u3155'] = '\u1167';
  22246. t['\u3156'] = '\u1168';
  22247. t['\u3157'] = '\u1169';
  22248. t['\u3158'] = '\u116A';
  22249. t['\u3159'] = '\u116B';
  22250. t['\u315A'] = '\u116C';
  22251. t['\u315B'] = '\u116D';
  22252. t['\u315C'] = '\u116E';
  22253. t['\u315D'] = '\u116F';
  22254. t['\u315E'] = '\u1170';
  22255. t['\u315F'] = '\u1171';
  22256. t['\u3160'] = '\u1172';
  22257. t['\u3161'] = '\u1173';
  22258. t['\u3162'] = '\u1174';
  22259. t['\u3163'] = '\u1175';
  22260. t['\u3164'] = '\u1160';
  22261. t['\u3165'] = '\u1114';
  22262. t['\u3166'] = '\u1115';
  22263. t['\u3167'] = '\u11C7';
  22264. t['\u3168'] = '\u11C8';
  22265. t['\u3169'] = '\u11CC';
  22266. t['\u316A'] = '\u11CE';
  22267. t['\u316B'] = '\u11D3';
  22268. t['\u316C'] = '\u11D7';
  22269. t['\u316D'] = '\u11D9';
  22270. t['\u316E'] = '\u111C';
  22271. t['\u316F'] = '\u11DD';
  22272. t['\u3170'] = '\u11DF';
  22273. t['\u3171'] = '\u111D';
  22274. t['\u3172'] = '\u111E';
  22275. t['\u3173'] = '\u1120';
  22276. t['\u3174'] = '\u1122';
  22277. t['\u3175'] = '\u1123';
  22278. t['\u3176'] = '\u1127';
  22279. t['\u3177'] = '\u1129';
  22280. t['\u3178'] = '\u112B';
  22281. t['\u3179'] = '\u112C';
  22282. t['\u317A'] = '\u112D';
  22283. t['\u317B'] = '\u112E';
  22284. t['\u317C'] = '\u112F';
  22285. t['\u317D'] = '\u1132';
  22286. t['\u317E'] = '\u1136';
  22287. t['\u317F'] = '\u1140';
  22288. t['\u3180'] = '\u1147';
  22289. t['\u3181'] = '\u114C';
  22290. t['\u3182'] = '\u11F1';
  22291. t['\u3183'] = '\u11F2';
  22292. t['\u3184'] = '\u1157';
  22293. t['\u3185'] = '\u1158';
  22294. t['\u3186'] = '\u1159';
  22295. t['\u3187'] = '\u1184';
  22296. t['\u3188'] = '\u1185';
  22297. t['\u3189'] = '\u1188';
  22298. t['\u318A'] = '\u1191';
  22299. t['\u318B'] = '\u1192';
  22300. t['\u318C'] = '\u1194';
  22301. t['\u318D'] = '\u119E';
  22302. t['\u318E'] = '\u11A1';
  22303. t['\u3200'] = '\u0028\u1100\u0029';
  22304. t['\u3201'] = '\u0028\u1102\u0029';
  22305. t['\u3202'] = '\u0028\u1103\u0029';
  22306. t['\u3203'] = '\u0028\u1105\u0029';
  22307. t['\u3204'] = '\u0028\u1106\u0029';
  22308. t['\u3205'] = '\u0028\u1107\u0029';
  22309. t['\u3206'] = '\u0028\u1109\u0029';
  22310. t['\u3207'] = '\u0028\u110B\u0029';
  22311. t['\u3208'] = '\u0028\u110C\u0029';
  22312. t['\u3209'] = '\u0028\u110E\u0029';
  22313. t['\u320A'] = '\u0028\u110F\u0029';
  22314. t['\u320B'] = '\u0028\u1110\u0029';
  22315. t['\u320C'] = '\u0028\u1111\u0029';
  22316. t['\u320D'] = '\u0028\u1112\u0029';
  22317. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22318. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22319. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22320. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22321. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22322. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22323. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22324. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22325. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22326. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22327. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22328. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22329. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22330. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22331. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22332. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22333. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22334. t['\u3220'] = '\u0028\u4E00\u0029';
  22335. t['\u3221'] = '\u0028\u4E8C\u0029';
  22336. t['\u3222'] = '\u0028\u4E09\u0029';
  22337. t['\u3223'] = '\u0028\u56DB\u0029';
  22338. t['\u3224'] = '\u0028\u4E94\u0029';
  22339. t['\u3225'] = '\u0028\u516D\u0029';
  22340. t['\u3226'] = '\u0028\u4E03\u0029';
  22341. t['\u3227'] = '\u0028\u516B\u0029';
  22342. t['\u3228'] = '\u0028\u4E5D\u0029';
  22343. t['\u3229'] = '\u0028\u5341\u0029';
  22344. t['\u322A'] = '\u0028\u6708\u0029';
  22345. t['\u322B'] = '\u0028\u706B\u0029';
  22346. t['\u322C'] = '\u0028\u6C34\u0029';
  22347. t['\u322D'] = '\u0028\u6728\u0029';
  22348. t['\u322E'] = '\u0028\u91D1\u0029';
  22349. t['\u322F'] = '\u0028\u571F\u0029';
  22350. t['\u3230'] = '\u0028\u65E5\u0029';
  22351. t['\u3231'] = '\u0028\u682A\u0029';
  22352. t['\u3232'] = '\u0028\u6709\u0029';
  22353. t['\u3233'] = '\u0028\u793E\u0029';
  22354. t['\u3234'] = '\u0028\u540D\u0029';
  22355. t['\u3235'] = '\u0028\u7279\u0029';
  22356. t['\u3236'] = '\u0028\u8CA1\u0029';
  22357. t['\u3237'] = '\u0028\u795D\u0029';
  22358. t['\u3238'] = '\u0028\u52B4\u0029';
  22359. t['\u3239'] = '\u0028\u4EE3\u0029';
  22360. t['\u323A'] = '\u0028\u547C\u0029';
  22361. t['\u323B'] = '\u0028\u5B66\u0029';
  22362. t['\u323C'] = '\u0028\u76E3\u0029';
  22363. t['\u323D'] = '\u0028\u4F01\u0029';
  22364. t['\u323E'] = '\u0028\u8CC7\u0029';
  22365. t['\u323F'] = '\u0028\u5354\u0029';
  22366. t['\u3240'] = '\u0028\u796D\u0029';
  22367. t['\u3241'] = '\u0028\u4F11\u0029';
  22368. t['\u3242'] = '\u0028\u81EA\u0029';
  22369. t['\u3243'] = '\u0028\u81F3\u0029';
  22370. t['\u32C0'] = '\u0031\u6708';
  22371. t['\u32C1'] = '\u0032\u6708';
  22372. t['\u32C2'] = '\u0033\u6708';
  22373. t['\u32C3'] = '\u0034\u6708';
  22374. t['\u32C4'] = '\u0035\u6708';
  22375. t['\u32C5'] = '\u0036\u6708';
  22376. t['\u32C6'] = '\u0037\u6708';
  22377. t['\u32C7'] = '\u0038\u6708';
  22378. t['\u32C8'] = '\u0039\u6708';
  22379. t['\u32C9'] = '\u0031\u0030\u6708';
  22380. t['\u32CA'] = '\u0031\u0031\u6708';
  22381. t['\u32CB'] = '\u0031\u0032\u6708';
  22382. t['\u3358'] = '\u0030\u70B9';
  22383. t['\u3359'] = '\u0031\u70B9';
  22384. t['\u335A'] = '\u0032\u70B9';
  22385. t['\u335B'] = '\u0033\u70B9';
  22386. t['\u335C'] = '\u0034\u70B9';
  22387. t['\u335D'] = '\u0035\u70B9';
  22388. t['\u335E'] = '\u0036\u70B9';
  22389. t['\u335F'] = '\u0037\u70B9';
  22390. t['\u3360'] = '\u0038\u70B9';
  22391. t['\u3361'] = '\u0039\u70B9';
  22392. t['\u3362'] = '\u0031\u0030\u70B9';
  22393. t['\u3363'] = '\u0031\u0031\u70B9';
  22394. t['\u3364'] = '\u0031\u0032\u70B9';
  22395. t['\u3365'] = '\u0031\u0033\u70B9';
  22396. t['\u3366'] = '\u0031\u0034\u70B9';
  22397. t['\u3367'] = '\u0031\u0035\u70B9';
  22398. t['\u3368'] = '\u0031\u0036\u70B9';
  22399. t['\u3369'] = '\u0031\u0037\u70B9';
  22400. t['\u336A'] = '\u0031\u0038\u70B9';
  22401. t['\u336B'] = '\u0031\u0039\u70B9';
  22402. t['\u336C'] = '\u0032\u0030\u70B9';
  22403. t['\u336D'] = '\u0032\u0031\u70B9';
  22404. t['\u336E'] = '\u0032\u0032\u70B9';
  22405. t['\u336F'] = '\u0032\u0033\u70B9';
  22406. t['\u3370'] = '\u0032\u0034\u70B9';
  22407. t['\u33E0'] = '\u0031\u65E5';
  22408. t['\u33E1'] = '\u0032\u65E5';
  22409. t['\u33E2'] = '\u0033\u65E5';
  22410. t['\u33E3'] = '\u0034\u65E5';
  22411. t['\u33E4'] = '\u0035\u65E5';
  22412. t['\u33E5'] = '\u0036\u65E5';
  22413. t['\u33E6'] = '\u0037\u65E5';
  22414. t['\u33E7'] = '\u0038\u65E5';
  22415. t['\u33E8'] = '\u0039\u65E5';
  22416. t['\u33E9'] = '\u0031\u0030\u65E5';
  22417. t['\u33EA'] = '\u0031\u0031\u65E5';
  22418. t['\u33EB'] = '\u0031\u0032\u65E5';
  22419. t['\u33EC'] = '\u0031\u0033\u65E5';
  22420. t['\u33ED'] = '\u0031\u0034\u65E5';
  22421. t['\u33EE'] = '\u0031\u0035\u65E5';
  22422. t['\u33EF'] = '\u0031\u0036\u65E5';
  22423. t['\u33F0'] = '\u0031\u0037\u65E5';
  22424. t['\u33F1'] = '\u0031\u0038\u65E5';
  22425. t['\u33F2'] = '\u0031\u0039\u65E5';
  22426. t['\u33F3'] = '\u0032\u0030\u65E5';
  22427. t['\u33F4'] = '\u0032\u0031\u65E5';
  22428. t['\u33F5'] = '\u0032\u0032\u65E5';
  22429. t['\u33F6'] = '\u0032\u0033\u65E5';
  22430. t['\u33F7'] = '\u0032\u0034\u65E5';
  22431. t['\u33F8'] = '\u0032\u0035\u65E5';
  22432. t['\u33F9'] = '\u0032\u0036\u65E5';
  22433. t['\u33FA'] = '\u0032\u0037\u65E5';
  22434. t['\u33FB'] = '\u0032\u0038\u65E5';
  22435. t['\u33FC'] = '\u0032\u0039\u65E5';
  22436. t['\u33FD'] = '\u0033\u0030\u65E5';
  22437. t['\u33FE'] = '\u0033\u0031\u65E5';
  22438. t['\uFB00'] = '\u0066\u0066';
  22439. t['\uFB01'] = '\u0066\u0069';
  22440. t['\uFB02'] = '\u0066\u006C';
  22441. t['\uFB03'] = '\u0066\u0066\u0069';
  22442. t['\uFB04'] = '\u0066\u0066\u006C';
  22443. t['\uFB05'] = '\u017F\u0074';
  22444. t['\uFB06'] = '\u0073\u0074';
  22445. t['\uFB13'] = '\u0574\u0576';
  22446. t['\uFB14'] = '\u0574\u0565';
  22447. t['\uFB15'] = '\u0574\u056B';
  22448. t['\uFB16'] = '\u057E\u0576';
  22449. t['\uFB17'] = '\u0574\u056D';
  22450. t['\uFB4F'] = '\u05D0\u05DC';
  22451. t['\uFB50'] = '\u0671';
  22452. t['\uFB51'] = '\u0671';
  22453. t['\uFB52'] = '\u067B';
  22454. t['\uFB53'] = '\u067B';
  22455. t['\uFB54'] = '\u067B';
  22456. t['\uFB55'] = '\u067B';
  22457. t['\uFB56'] = '\u067E';
  22458. t['\uFB57'] = '\u067E';
  22459. t['\uFB58'] = '\u067E';
  22460. t['\uFB59'] = '\u067E';
  22461. t['\uFB5A'] = '\u0680';
  22462. t['\uFB5B'] = '\u0680';
  22463. t['\uFB5C'] = '\u0680';
  22464. t['\uFB5D'] = '\u0680';
  22465. t['\uFB5E'] = '\u067A';
  22466. t['\uFB5F'] = '\u067A';
  22467. t['\uFB60'] = '\u067A';
  22468. t['\uFB61'] = '\u067A';
  22469. t['\uFB62'] = '\u067F';
  22470. t['\uFB63'] = '\u067F';
  22471. t['\uFB64'] = '\u067F';
  22472. t['\uFB65'] = '\u067F';
  22473. t['\uFB66'] = '\u0679';
  22474. t['\uFB67'] = '\u0679';
  22475. t['\uFB68'] = '\u0679';
  22476. t['\uFB69'] = '\u0679';
  22477. t['\uFB6A'] = '\u06A4';
  22478. t['\uFB6B'] = '\u06A4';
  22479. t['\uFB6C'] = '\u06A4';
  22480. t['\uFB6D'] = '\u06A4';
  22481. t['\uFB6E'] = '\u06A6';
  22482. t['\uFB6F'] = '\u06A6';
  22483. t['\uFB70'] = '\u06A6';
  22484. t['\uFB71'] = '\u06A6';
  22485. t['\uFB72'] = '\u0684';
  22486. t['\uFB73'] = '\u0684';
  22487. t['\uFB74'] = '\u0684';
  22488. t['\uFB75'] = '\u0684';
  22489. t['\uFB76'] = '\u0683';
  22490. t['\uFB77'] = '\u0683';
  22491. t['\uFB78'] = '\u0683';
  22492. t['\uFB79'] = '\u0683';
  22493. t['\uFB7A'] = '\u0686';
  22494. t['\uFB7B'] = '\u0686';
  22495. t['\uFB7C'] = '\u0686';
  22496. t['\uFB7D'] = '\u0686';
  22497. t['\uFB7E'] = '\u0687';
  22498. t['\uFB7F'] = '\u0687';
  22499. t['\uFB80'] = '\u0687';
  22500. t['\uFB81'] = '\u0687';
  22501. t['\uFB82'] = '\u068D';
  22502. t['\uFB83'] = '\u068D';
  22503. t['\uFB84'] = '\u068C';
  22504. t['\uFB85'] = '\u068C';
  22505. t['\uFB86'] = '\u068E';
  22506. t['\uFB87'] = '\u068E';
  22507. t['\uFB88'] = '\u0688';
  22508. t['\uFB89'] = '\u0688';
  22509. t['\uFB8A'] = '\u0698';
  22510. t['\uFB8B'] = '\u0698';
  22511. t['\uFB8C'] = '\u0691';
  22512. t['\uFB8D'] = '\u0691';
  22513. t['\uFB8E'] = '\u06A9';
  22514. t['\uFB8F'] = '\u06A9';
  22515. t['\uFB90'] = '\u06A9';
  22516. t['\uFB91'] = '\u06A9';
  22517. t['\uFB92'] = '\u06AF';
  22518. t['\uFB93'] = '\u06AF';
  22519. t['\uFB94'] = '\u06AF';
  22520. t['\uFB95'] = '\u06AF';
  22521. t['\uFB96'] = '\u06B3';
  22522. t['\uFB97'] = '\u06B3';
  22523. t['\uFB98'] = '\u06B3';
  22524. t['\uFB99'] = '\u06B3';
  22525. t['\uFB9A'] = '\u06B1';
  22526. t['\uFB9B'] = '\u06B1';
  22527. t['\uFB9C'] = '\u06B1';
  22528. t['\uFB9D'] = '\u06B1';
  22529. t['\uFB9E'] = '\u06BA';
  22530. t['\uFB9F'] = '\u06BA';
  22531. t['\uFBA0'] = '\u06BB';
  22532. t['\uFBA1'] = '\u06BB';
  22533. t['\uFBA2'] = '\u06BB';
  22534. t['\uFBA3'] = '\u06BB';
  22535. t['\uFBA4'] = '\u06C0';
  22536. t['\uFBA5'] = '\u06C0';
  22537. t['\uFBA6'] = '\u06C1';
  22538. t['\uFBA7'] = '\u06C1';
  22539. t['\uFBA8'] = '\u06C1';
  22540. t['\uFBA9'] = '\u06C1';
  22541. t['\uFBAA'] = '\u06BE';
  22542. t['\uFBAB'] = '\u06BE';
  22543. t['\uFBAC'] = '\u06BE';
  22544. t['\uFBAD'] = '\u06BE';
  22545. t['\uFBAE'] = '\u06D2';
  22546. t['\uFBAF'] = '\u06D2';
  22547. t['\uFBB0'] = '\u06D3';
  22548. t['\uFBB1'] = '\u06D3';
  22549. t['\uFBD3'] = '\u06AD';
  22550. t['\uFBD4'] = '\u06AD';
  22551. t['\uFBD5'] = '\u06AD';
  22552. t['\uFBD6'] = '\u06AD';
  22553. t['\uFBD7'] = '\u06C7';
  22554. t['\uFBD8'] = '\u06C7';
  22555. t['\uFBD9'] = '\u06C6';
  22556. t['\uFBDA'] = '\u06C6';
  22557. t['\uFBDB'] = '\u06C8';
  22558. t['\uFBDC'] = '\u06C8';
  22559. t['\uFBDD'] = '\u0677';
  22560. t['\uFBDE'] = '\u06CB';
  22561. t['\uFBDF'] = '\u06CB';
  22562. t['\uFBE0'] = '\u06C5';
  22563. t['\uFBE1'] = '\u06C5';
  22564. t['\uFBE2'] = '\u06C9';
  22565. t['\uFBE3'] = '\u06C9';
  22566. t['\uFBE4'] = '\u06D0';
  22567. t['\uFBE5'] = '\u06D0';
  22568. t['\uFBE6'] = '\u06D0';
  22569. t['\uFBE7'] = '\u06D0';
  22570. t['\uFBE8'] = '\u0649';
  22571. t['\uFBE9'] = '\u0649';
  22572. t['\uFBEA'] = '\u0626\u0627';
  22573. t['\uFBEB'] = '\u0626\u0627';
  22574. t['\uFBEC'] = '\u0626\u06D5';
  22575. t['\uFBED'] = '\u0626\u06D5';
  22576. t['\uFBEE'] = '\u0626\u0648';
  22577. t['\uFBEF'] = '\u0626\u0648';
  22578. t['\uFBF0'] = '\u0626\u06C7';
  22579. t['\uFBF1'] = '\u0626\u06C7';
  22580. t['\uFBF2'] = '\u0626\u06C6';
  22581. t['\uFBF3'] = '\u0626\u06C6';
  22582. t['\uFBF4'] = '\u0626\u06C8';
  22583. t['\uFBF5'] = '\u0626\u06C8';
  22584. t['\uFBF6'] = '\u0626\u06D0';
  22585. t['\uFBF7'] = '\u0626\u06D0';
  22586. t['\uFBF8'] = '\u0626\u06D0';
  22587. t['\uFBF9'] = '\u0626\u0649';
  22588. t['\uFBFA'] = '\u0626\u0649';
  22589. t['\uFBFB'] = '\u0626\u0649';
  22590. t['\uFBFC'] = '\u06CC';
  22591. t['\uFBFD'] = '\u06CC';
  22592. t['\uFBFE'] = '\u06CC';
  22593. t['\uFBFF'] = '\u06CC';
  22594. t['\uFC00'] = '\u0626\u062C';
  22595. t['\uFC01'] = '\u0626\u062D';
  22596. t['\uFC02'] = '\u0626\u0645';
  22597. t['\uFC03'] = '\u0626\u0649';
  22598. t['\uFC04'] = '\u0626\u064A';
  22599. t['\uFC05'] = '\u0628\u062C';
  22600. t['\uFC06'] = '\u0628\u062D';
  22601. t['\uFC07'] = '\u0628\u062E';
  22602. t['\uFC08'] = '\u0628\u0645';
  22603. t['\uFC09'] = '\u0628\u0649';
  22604. t['\uFC0A'] = '\u0628\u064A';
  22605. t['\uFC0B'] = '\u062A\u062C';
  22606. t['\uFC0C'] = '\u062A\u062D';
  22607. t['\uFC0D'] = '\u062A\u062E';
  22608. t['\uFC0E'] = '\u062A\u0645';
  22609. t['\uFC0F'] = '\u062A\u0649';
  22610. t['\uFC10'] = '\u062A\u064A';
  22611. t['\uFC11'] = '\u062B\u062C';
  22612. t['\uFC12'] = '\u062B\u0645';
  22613. t['\uFC13'] = '\u062B\u0649';
  22614. t['\uFC14'] = '\u062B\u064A';
  22615. t['\uFC15'] = '\u062C\u062D';
  22616. t['\uFC16'] = '\u062C\u0645';
  22617. t['\uFC17'] = '\u062D\u062C';
  22618. t['\uFC18'] = '\u062D\u0645';
  22619. t['\uFC19'] = '\u062E\u062C';
  22620. t['\uFC1A'] = '\u062E\u062D';
  22621. t['\uFC1B'] = '\u062E\u0645';
  22622. t['\uFC1C'] = '\u0633\u062C';
  22623. t['\uFC1D'] = '\u0633\u062D';
  22624. t['\uFC1E'] = '\u0633\u062E';
  22625. t['\uFC1F'] = '\u0633\u0645';
  22626. t['\uFC20'] = '\u0635\u062D';
  22627. t['\uFC21'] = '\u0635\u0645';
  22628. t['\uFC22'] = '\u0636\u062C';
  22629. t['\uFC23'] = '\u0636\u062D';
  22630. t['\uFC24'] = '\u0636\u062E';
  22631. t['\uFC25'] = '\u0636\u0645';
  22632. t['\uFC26'] = '\u0637\u062D';
  22633. t['\uFC27'] = '\u0637\u0645';
  22634. t['\uFC28'] = '\u0638\u0645';
  22635. t['\uFC29'] = '\u0639\u062C';
  22636. t['\uFC2A'] = '\u0639\u0645';
  22637. t['\uFC2B'] = '\u063A\u062C';
  22638. t['\uFC2C'] = '\u063A\u0645';
  22639. t['\uFC2D'] = '\u0641\u062C';
  22640. t['\uFC2E'] = '\u0641\u062D';
  22641. t['\uFC2F'] = '\u0641\u062E';
  22642. t['\uFC30'] = '\u0641\u0645';
  22643. t['\uFC31'] = '\u0641\u0649';
  22644. t['\uFC32'] = '\u0641\u064A';
  22645. t['\uFC33'] = '\u0642\u062D';
  22646. t['\uFC34'] = '\u0642\u0645';
  22647. t['\uFC35'] = '\u0642\u0649';
  22648. t['\uFC36'] = '\u0642\u064A';
  22649. t['\uFC37'] = '\u0643\u0627';
  22650. t['\uFC38'] = '\u0643\u062C';
  22651. t['\uFC39'] = '\u0643\u062D';
  22652. t['\uFC3A'] = '\u0643\u062E';
  22653. t['\uFC3B'] = '\u0643\u0644';
  22654. t['\uFC3C'] = '\u0643\u0645';
  22655. t['\uFC3D'] = '\u0643\u0649';
  22656. t['\uFC3E'] = '\u0643\u064A';
  22657. t['\uFC3F'] = '\u0644\u062C';
  22658. t['\uFC40'] = '\u0644\u062D';
  22659. t['\uFC41'] = '\u0644\u062E';
  22660. t['\uFC42'] = '\u0644\u0645';
  22661. t['\uFC43'] = '\u0644\u0649';
  22662. t['\uFC44'] = '\u0644\u064A';
  22663. t['\uFC45'] = '\u0645\u062C';
  22664. t['\uFC46'] = '\u0645\u062D';
  22665. t['\uFC47'] = '\u0645\u062E';
  22666. t['\uFC48'] = '\u0645\u0645';
  22667. t['\uFC49'] = '\u0645\u0649';
  22668. t['\uFC4A'] = '\u0645\u064A';
  22669. t['\uFC4B'] = '\u0646\u062C';
  22670. t['\uFC4C'] = '\u0646\u062D';
  22671. t['\uFC4D'] = '\u0646\u062E';
  22672. t['\uFC4E'] = '\u0646\u0645';
  22673. t['\uFC4F'] = '\u0646\u0649';
  22674. t['\uFC50'] = '\u0646\u064A';
  22675. t['\uFC51'] = '\u0647\u062C';
  22676. t['\uFC52'] = '\u0647\u0645';
  22677. t['\uFC53'] = '\u0647\u0649';
  22678. t['\uFC54'] = '\u0647\u064A';
  22679. t['\uFC55'] = '\u064A\u062C';
  22680. t['\uFC56'] = '\u064A\u062D';
  22681. t['\uFC57'] = '\u064A\u062E';
  22682. t['\uFC58'] = '\u064A\u0645';
  22683. t['\uFC59'] = '\u064A\u0649';
  22684. t['\uFC5A'] = '\u064A\u064A';
  22685. t['\uFC5B'] = '\u0630\u0670';
  22686. t['\uFC5C'] = '\u0631\u0670';
  22687. t['\uFC5D'] = '\u0649\u0670';
  22688. t['\uFC5E'] = '\u0020\u064C\u0651';
  22689. t['\uFC5F'] = '\u0020\u064D\u0651';
  22690. t['\uFC60'] = '\u0020\u064E\u0651';
  22691. t['\uFC61'] = '\u0020\u064F\u0651';
  22692. t['\uFC62'] = '\u0020\u0650\u0651';
  22693. t['\uFC63'] = '\u0020\u0651\u0670';
  22694. t['\uFC64'] = '\u0626\u0631';
  22695. t['\uFC65'] = '\u0626\u0632';
  22696. t['\uFC66'] = '\u0626\u0645';
  22697. t['\uFC67'] = '\u0626\u0646';
  22698. t['\uFC68'] = '\u0626\u0649';
  22699. t['\uFC69'] = '\u0626\u064A';
  22700. t['\uFC6A'] = '\u0628\u0631';
  22701. t['\uFC6B'] = '\u0628\u0632';
  22702. t['\uFC6C'] = '\u0628\u0645';
  22703. t['\uFC6D'] = '\u0628\u0646';
  22704. t['\uFC6E'] = '\u0628\u0649';
  22705. t['\uFC6F'] = '\u0628\u064A';
  22706. t['\uFC70'] = '\u062A\u0631';
  22707. t['\uFC71'] = '\u062A\u0632';
  22708. t['\uFC72'] = '\u062A\u0645';
  22709. t['\uFC73'] = '\u062A\u0646';
  22710. t['\uFC74'] = '\u062A\u0649';
  22711. t['\uFC75'] = '\u062A\u064A';
  22712. t['\uFC76'] = '\u062B\u0631';
  22713. t['\uFC77'] = '\u062B\u0632';
  22714. t['\uFC78'] = '\u062B\u0645';
  22715. t['\uFC79'] = '\u062B\u0646';
  22716. t['\uFC7A'] = '\u062B\u0649';
  22717. t['\uFC7B'] = '\u062B\u064A';
  22718. t['\uFC7C'] = '\u0641\u0649';
  22719. t['\uFC7D'] = '\u0641\u064A';
  22720. t['\uFC7E'] = '\u0642\u0649';
  22721. t['\uFC7F'] = '\u0642\u064A';
  22722. t['\uFC80'] = '\u0643\u0627';
  22723. t['\uFC81'] = '\u0643\u0644';
  22724. t['\uFC82'] = '\u0643\u0645';
  22725. t['\uFC83'] = '\u0643\u0649';
  22726. t['\uFC84'] = '\u0643\u064A';
  22727. t['\uFC85'] = '\u0644\u0645';
  22728. t['\uFC86'] = '\u0644\u0649';
  22729. t['\uFC87'] = '\u0644\u064A';
  22730. t['\uFC88'] = '\u0645\u0627';
  22731. t['\uFC89'] = '\u0645\u0645';
  22732. t['\uFC8A'] = '\u0646\u0631';
  22733. t['\uFC8B'] = '\u0646\u0632';
  22734. t['\uFC8C'] = '\u0646\u0645';
  22735. t['\uFC8D'] = '\u0646\u0646';
  22736. t['\uFC8E'] = '\u0646\u0649';
  22737. t['\uFC8F'] = '\u0646\u064A';
  22738. t['\uFC90'] = '\u0649\u0670';
  22739. t['\uFC91'] = '\u064A\u0631';
  22740. t['\uFC92'] = '\u064A\u0632';
  22741. t['\uFC93'] = '\u064A\u0645';
  22742. t['\uFC94'] = '\u064A\u0646';
  22743. t['\uFC95'] = '\u064A\u0649';
  22744. t['\uFC96'] = '\u064A\u064A';
  22745. t['\uFC97'] = '\u0626\u062C';
  22746. t['\uFC98'] = '\u0626\u062D';
  22747. t['\uFC99'] = '\u0626\u062E';
  22748. t['\uFC9A'] = '\u0626\u0645';
  22749. t['\uFC9B'] = '\u0626\u0647';
  22750. t['\uFC9C'] = '\u0628\u062C';
  22751. t['\uFC9D'] = '\u0628\u062D';
  22752. t['\uFC9E'] = '\u0628\u062E';
  22753. t['\uFC9F'] = '\u0628\u0645';
  22754. t['\uFCA0'] = '\u0628\u0647';
  22755. t['\uFCA1'] = '\u062A\u062C';
  22756. t['\uFCA2'] = '\u062A\u062D';
  22757. t['\uFCA3'] = '\u062A\u062E';
  22758. t['\uFCA4'] = '\u062A\u0645';
  22759. t['\uFCA5'] = '\u062A\u0647';
  22760. t['\uFCA6'] = '\u062B\u0645';
  22761. t['\uFCA7'] = '\u062C\u062D';
  22762. t['\uFCA8'] = '\u062C\u0645';
  22763. t['\uFCA9'] = '\u062D\u062C';
  22764. t['\uFCAA'] = '\u062D\u0645';
  22765. t['\uFCAB'] = '\u062E\u062C';
  22766. t['\uFCAC'] = '\u062E\u0645';
  22767. t['\uFCAD'] = '\u0633\u062C';
  22768. t['\uFCAE'] = '\u0633\u062D';
  22769. t['\uFCAF'] = '\u0633\u062E';
  22770. t['\uFCB0'] = '\u0633\u0645';
  22771. t['\uFCB1'] = '\u0635\u062D';
  22772. t['\uFCB2'] = '\u0635\u062E';
  22773. t['\uFCB3'] = '\u0635\u0645';
  22774. t['\uFCB4'] = '\u0636\u062C';
  22775. t['\uFCB5'] = '\u0636\u062D';
  22776. t['\uFCB6'] = '\u0636\u062E';
  22777. t['\uFCB7'] = '\u0636\u0645';
  22778. t['\uFCB8'] = '\u0637\u062D';
  22779. t['\uFCB9'] = '\u0638\u0645';
  22780. t['\uFCBA'] = '\u0639\u062C';
  22781. t['\uFCBB'] = '\u0639\u0645';
  22782. t['\uFCBC'] = '\u063A\u062C';
  22783. t['\uFCBD'] = '\u063A\u0645';
  22784. t['\uFCBE'] = '\u0641\u062C';
  22785. t['\uFCBF'] = '\u0641\u062D';
  22786. t['\uFCC0'] = '\u0641\u062E';
  22787. t['\uFCC1'] = '\u0641\u0645';
  22788. t['\uFCC2'] = '\u0642\u062D';
  22789. t['\uFCC3'] = '\u0642\u0645';
  22790. t['\uFCC4'] = '\u0643\u062C';
  22791. t['\uFCC5'] = '\u0643\u062D';
  22792. t['\uFCC6'] = '\u0643\u062E';
  22793. t['\uFCC7'] = '\u0643\u0644';
  22794. t['\uFCC8'] = '\u0643\u0645';
  22795. t['\uFCC9'] = '\u0644\u062C';
  22796. t['\uFCCA'] = '\u0644\u062D';
  22797. t['\uFCCB'] = '\u0644\u062E';
  22798. t['\uFCCC'] = '\u0644\u0645';
  22799. t['\uFCCD'] = '\u0644\u0647';
  22800. t['\uFCCE'] = '\u0645\u062C';
  22801. t['\uFCCF'] = '\u0645\u062D';
  22802. t['\uFCD0'] = '\u0645\u062E';
  22803. t['\uFCD1'] = '\u0645\u0645';
  22804. t['\uFCD2'] = '\u0646\u062C';
  22805. t['\uFCD3'] = '\u0646\u062D';
  22806. t['\uFCD4'] = '\u0646\u062E';
  22807. t['\uFCD5'] = '\u0646\u0645';
  22808. t['\uFCD6'] = '\u0646\u0647';
  22809. t['\uFCD7'] = '\u0647\u062C';
  22810. t['\uFCD8'] = '\u0647\u0645';
  22811. t['\uFCD9'] = '\u0647\u0670';
  22812. t['\uFCDA'] = '\u064A\u062C';
  22813. t['\uFCDB'] = '\u064A\u062D';
  22814. t['\uFCDC'] = '\u064A\u062E';
  22815. t['\uFCDD'] = '\u064A\u0645';
  22816. t['\uFCDE'] = '\u064A\u0647';
  22817. t['\uFCDF'] = '\u0626\u0645';
  22818. t['\uFCE0'] = '\u0626\u0647';
  22819. t['\uFCE1'] = '\u0628\u0645';
  22820. t['\uFCE2'] = '\u0628\u0647';
  22821. t['\uFCE3'] = '\u062A\u0645';
  22822. t['\uFCE4'] = '\u062A\u0647';
  22823. t['\uFCE5'] = '\u062B\u0645';
  22824. t['\uFCE6'] = '\u062B\u0647';
  22825. t['\uFCE7'] = '\u0633\u0645';
  22826. t['\uFCE8'] = '\u0633\u0647';
  22827. t['\uFCE9'] = '\u0634\u0645';
  22828. t['\uFCEA'] = '\u0634\u0647';
  22829. t['\uFCEB'] = '\u0643\u0644';
  22830. t['\uFCEC'] = '\u0643\u0645';
  22831. t['\uFCED'] = '\u0644\u0645';
  22832. t['\uFCEE'] = '\u0646\u0645';
  22833. t['\uFCEF'] = '\u0646\u0647';
  22834. t['\uFCF0'] = '\u064A\u0645';
  22835. t['\uFCF1'] = '\u064A\u0647';
  22836. t['\uFCF2'] = '\u0640\u064E\u0651';
  22837. t['\uFCF3'] = '\u0640\u064F\u0651';
  22838. t['\uFCF4'] = '\u0640\u0650\u0651';
  22839. t['\uFCF5'] = '\u0637\u0649';
  22840. t['\uFCF6'] = '\u0637\u064A';
  22841. t['\uFCF7'] = '\u0639\u0649';
  22842. t['\uFCF8'] = '\u0639\u064A';
  22843. t['\uFCF9'] = '\u063A\u0649';
  22844. t['\uFCFA'] = '\u063A\u064A';
  22845. t['\uFCFB'] = '\u0633\u0649';
  22846. t['\uFCFC'] = '\u0633\u064A';
  22847. t['\uFCFD'] = '\u0634\u0649';
  22848. t['\uFCFE'] = '\u0634\u064A';
  22849. t['\uFCFF'] = '\u062D\u0649';
  22850. t['\uFD00'] = '\u062D\u064A';
  22851. t['\uFD01'] = '\u062C\u0649';
  22852. t['\uFD02'] = '\u062C\u064A';
  22853. t['\uFD03'] = '\u062E\u0649';
  22854. t['\uFD04'] = '\u062E\u064A';
  22855. t['\uFD05'] = '\u0635\u0649';
  22856. t['\uFD06'] = '\u0635\u064A';
  22857. t['\uFD07'] = '\u0636\u0649';
  22858. t['\uFD08'] = '\u0636\u064A';
  22859. t['\uFD09'] = '\u0634\u062C';
  22860. t['\uFD0A'] = '\u0634\u062D';
  22861. t['\uFD0B'] = '\u0634\u062E';
  22862. t['\uFD0C'] = '\u0634\u0645';
  22863. t['\uFD0D'] = '\u0634\u0631';
  22864. t['\uFD0E'] = '\u0633\u0631';
  22865. t['\uFD0F'] = '\u0635\u0631';
  22866. t['\uFD10'] = '\u0636\u0631';
  22867. t['\uFD11'] = '\u0637\u0649';
  22868. t['\uFD12'] = '\u0637\u064A';
  22869. t['\uFD13'] = '\u0639\u0649';
  22870. t['\uFD14'] = '\u0639\u064A';
  22871. t['\uFD15'] = '\u063A\u0649';
  22872. t['\uFD16'] = '\u063A\u064A';
  22873. t['\uFD17'] = '\u0633\u0649';
  22874. t['\uFD18'] = '\u0633\u064A';
  22875. t['\uFD19'] = '\u0634\u0649';
  22876. t['\uFD1A'] = '\u0634\u064A';
  22877. t['\uFD1B'] = '\u062D\u0649';
  22878. t['\uFD1C'] = '\u062D\u064A';
  22879. t['\uFD1D'] = '\u062C\u0649';
  22880. t['\uFD1E'] = '\u062C\u064A';
  22881. t['\uFD1F'] = '\u062E\u0649';
  22882. t['\uFD20'] = '\u062E\u064A';
  22883. t['\uFD21'] = '\u0635\u0649';
  22884. t['\uFD22'] = '\u0635\u064A';
  22885. t['\uFD23'] = '\u0636\u0649';
  22886. t['\uFD24'] = '\u0636\u064A';
  22887. t['\uFD25'] = '\u0634\u062C';
  22888. t['\uFD26'] = '\u0634\u062D';
  22889. t['\uFD27'] = '\u0634\u062E';
  22890. t['\uFD28'] = '\u0634\u0645';
  22891. t['\uFD29'] = '\u0634\u0631';
  22892. t['\uFD2A'] = '\u0633\u0631';
  22893. t['\uFD2B'] = '\u0635\u0631';
  22894. t['\uFD2C'] = '\u0636\u0631';
  22895. t['\uFD2D'] = '\u0634\u062C';
  22896. t['\uFD2E'] = '\u0634\u062D';
  22897. t['\uFD2F'] = '\u0634\u062E';
  22898. t['\uFD30'] = '\u0634\u0645';
  22899. t['\uFD31'] = '\u0633\u0647';
  22900. t['\uFD32'] = '\u0634\u0647';
  22901. t['\uFD33'] = '\u0637\u0645';
  22902. t['\uFD34'] = '\u0633\u062C';
  22903. t['\uFD35'] = '\u0633\u062D';
  22904. t['\uFD36'] = '\u0633\u062E';
  22905. t['\uFD37'] = '\u0634\u062C';
  22906. t['\uFD38'] = '\u0634\u062D';
  22907. t['\uFD39'] = '\u0634\u062E';
  22908. t['\uFD3A'] = '\u0637\u0645';
  22909. t['\uFD3B'] = '\u0638\u0645';
  22910. t['\uFD3C'] = '\u0627\u064B';
  22911. t['\uFD3D'] = '\u0627\u064B';
  22912. t['\uFD50'] = '\u062A\u062C\u0645';
  22913. t['\uFD51'] = '\u062A\u062D\u062C';
  22914. t['\uFD52'] = '\u062A\u062D\u062C';
  22915. t['\uFD53'] = '\u062A\u062D\u0645';
  22916. t['\uFD54'] = '\u062A\u062E\u0645';
  22917. t['\uFD55'] = '\u062A\u0645\u062C';
  22918. t['\uFD56'] = '\u062A\u0645\u062D';
  22919. t['\uFD57'] = '\u062A\u0645\u062E';
  22920. t['\uFD58'] = '\u062C\u0645\u062D';
  22921. t['\uFD59'] = '\u062C\u0645\u062D';
  22922. t['\uFD5A'] = '\u062D\u0645\u064A';
  22923. t['\uFD5B'] = '\u062D\u0645\u0649';
  22924. t['\uFD5C'] = '\u0633\u062D\u062C';
  22925. t['\uFD5D'] = '\u0633\u062C\u062D';
  22926. t['\uFD5E'] = '\u0633\u062C\u0649';
  22927. t['\uFD5F'] = '\u0633\u0645\u062D';
  22928. t['\uFD60'] = '\u0633\u0645\u062D';
  22929. t['\uFD61'] = '\u0633\u0645\u062C';
  22930. t['\uFD62'] = '\u0633\u0645\u0645';
  22931. t['\uFD63'] = '\u0633\u0645\u0645';
  22932. t['\uFD64'] = '\u0635\u062D\u062D';
  22933. t['\uFD65'] = '\u0635\u062D\u062D';
  22934. t['\uFD66'] = '\u0635\u0645\u0645';
  22935. t['\uFD67'] = '\u0634\u062D\u0645';
  22936. t['\uFD68'] = '\u0634\u062D\u0645';
  22937. t['\uFD69'] = '\u0634\u062C\u064A';
  22938. t['\uFD6A'] = '\u0634\u0645\u062E';
  22939. t['\uFD6B'] = '\u0634\u0645\u062E';
  22940. t['\uFD6C'] = '\u0634\u0645\u0645';
  22941. t['\uFD6D'] = '\u0634\u0645\u0645';
  22942. t['\uFD6E'] = '\u0636\u062D\u0649';
  22943. t['\uFD6F'] = '\u0636\u062E\u0645';
  22944. t['\uFD70'] = '\u0636\u062E\u0645';
  22945. t['\uFD71'] = '\u0637\u0645\u062D';
  22946. t['\uFD72'] = '\u0637\u0645\u062D';
  22947. t['\uFD73'] = '\u0637\u0645\u0645';
  22948. t['\uFD74'] = '\u0637\u0645\u064A';
  22949. t['\uFD75'] = '\u0639\u062C\u0645';
  22950. t['\uFD76'] = '\u0639\u0645\u0645';
  22951. t['\uFD77'] = '\u0639\u0645\u0645';
  22952. t['\uFD78'] = '\u0639\u0645\u0649';
  22953. t['\uFD79'] = '\u063A\u0645\u0645';
  22954. t['\uFD7A'] = '\u063A\u0645\u064A';
  22955. t['\uFD7B'] = '\u063A\u0645\u0649';
  22956. t['\uFD7C'] = '\u0641\u062E\u0645';
  22957. t['\uFD7D'] = '\u0641\u062E\u0645';
  22958. t['\uFD7E'] = '\u0642\u0645\u062D';
  22959. t['\uFD7F'] = '\u0642\u0645\u0645';
  22960. t['\uFD80'] = '\u0644\u062D\u0645';
  22961. t['\uFD81'] = '\u0644\u062D\u064A';
  22962. t['\uFD82'] = '\u0644\u062D\u0649';
  22963. t['\uFD83'] = '\u0644\u062C\u062C';
  22964. t['\uFD84'] = '\u0644\u062C\u062C';
  22965. t['\uFD85'] = '\u0644\u062E\u0645';
  22966. t['\uFD86'] = '\u0644\u062E\u0645';
  22967. t['\uFD87'] = '\u0644\u0645\u062D';
  22968. t['\uFD88'] = '\u0644\u0645\u062D';
  22969. t['\uFD89'] = '\u0645\u062D\u062C';
  22970. t['\uFD8A'] = '\u0645\u062D\u0645';
  22971. t['\uFD8B'] = '\u0645\u062D\u064A';
  22972. t['\uFD8C'] = '\u0645\u062C\u062D';
  22973. t['\uFD8D'] = '\u0645\u062C\u0645';
  22974. t['\uFD8E'] = '\u0645\u062E\u062C';
  22975. t['\uFD8F'] = '\u0645\u062E\u0645';
  22976. t['\uFD92'] = '\u0645\u062C\u062E';
  22977. t['\uFD93'] = '\u0647\u0645\u062C';
  22978. t['\uFD94'] = '\u0647\u0645\u0645';
  22979. t['\uFD95'] = '\u0646\u062D\u0645';
  22980. t['\uFD96'] = '\u0646\u062D\u0649';
  22981. t['\uFD97'] = '\u0646\u062C\u0645';
  22982. t['\uFD98'] = '\u0646\u062C\u0645';
  22983. t['\uFD99'] = '\u0646\u062C\u0649';
  22984. t['\uFD9A'] = '\u0646\u0645\u064A';
  22985. t['\uFD9B'] = '\u0646\u0645\u0649';
  22986. t['\uFD9C'] = '\u064A\u0645\u0645';
  22987. t['\uFD9D'] = '\u064A\u0645\u0645';
  22988. t['\uFD9E'] = '\u0628\u062E\u064A';
  22989. t['\uFD9F'] = '\u062A\u062C\u064A';
  22990. t['\uFDA0'] = '\u062A\u062C\u0649';
  22991. t['\uFDA1'] = '\u062A\u062E\u064A';
  22992. t['\uFDA2'] = '\u062A\u062E\u0649';
  22993. t['\uFDA3'] = '\u062A\u0645\u064A';
  22994. t['\uFDA4'] = '\u062A\u0645\u0649';
  22995. t['\uFDA5'] = '\u062C\u0645\u064A';
  22996. t['\uFDA6'] = '\u062C\u062D\u0649';
  22997. t['\uFDA7'] = '\u062C\u0645\u0649';
  22998. t['\uFDA8'] = '\u0633\u062E\u0649';
  22999. t['\uFDA9'] = '\u0635\u062D\u064A';
  23000. t['\uFDAA'] = '\u0634\u062D\u064A';
  23001. t['\uFDAB'] = '\u0636\u062D\u064A';
  23002. t['\uFDAC'] = '\u0644\u062C\u064A';
  23003. t['\uFDAD'] = '\u0644\u0645\u064A';
  23004. t['\uFDAE'] = '\u064A\u062D\u064A';
  23005. t['\uFDAF'] = '\u064A\u062C\u064A';
  23006. t['\uFDB0'] = '\u064A\u0645\u064A';
  23007. t['\uFDB1'] = '\u0645\u0645\u064A';
  23008. t['\uFDB2'] = '\u0642\u0645\u064A';
  23009. t['\uFDB3'] = '\u0646\u062D\u064A';
  23010. t['\uFDB4'] = '\u0642\u0645\u062D';
  23011. t['\uFDB5'] = '\u0644\u062D\u0645';
  23012. t['\uFDB6'] = '\u0639\u0645\u064A';
  23013. t['\uFDB7'] = '\u0643\u0645\u064A';
  23014. t['\uFDB8'] = '\u0646\u062C\u062D';
  23015. t['\uFDB9'] = '\u0645\u062E\u064A';
  23016. t['\uFDBA'] = '\u0644\u062C\u0645';
  23017. t['\uFDBB'] = '\u0643\u0645\u0645';
  23018. t['\uFDBC'] = '\u0644\u062C\u0645';
  23019. t['\uFDBD'] = '\u0646\u062C\u062D';
  23020. t['\uFDBE'] = '\u062C\u062D\u064A';
  23021. t['\uFDBF'] = '\u062D\u062C\u064A';
  23022. t['\uFDC0'] = '\u0645\u062C\u064A';
  23023. t['\uFDC1'] = '\u0641\u0645\u064A';
  23024. t['\uFDC2'] = '\u0628\u062D\u064A';
  23025. t['\uFDC3'] = '\u0643\u0645\u0645';
  23026. t['\uFDC4'] = '\u0639\u062C\u0645';
  23027. t['\uFDC5'] = '\u0635\u0645\u0645';
  23028. t['\uFDC6'] = '\u0633\u062E\u064A';
  23029. t['\uFDC7'] = '\u0646\u062C\u064A';
  23030. t['\uFE49'] = '\u203E';
  23031. t['\uFE4A'] = '\u203E';
  23032. t['\uFE4B'] = '\u203E';
  23033. t['\uFE4C'] = '\u203E';
  23034. t['\uFE4D'] = '\u005F';
  23035. t['\uFE4E'] = '\u005F';
  23036. t['\uFE4F'] = '\u005F';
  23037. t['\uFE80'] = '\u0621';
  23038. t['\uFE81'] = '\u0622';
  23039. t['\uFE82'] = '\u0622';
  23040. t['\uFE83'] = '\u0623';
  23041. t['\uFE84'] = '\u0623';
  23042. t['\uFE85'] = '\u0624';
  23043. t['\uFE86'] = '\u0624';
  23044. t['\uFE87'] = '\u0625';
  23045. t['\uFE88'] = '\u0625';
  23046. t['\uFE89'] = '\u0626';
  23047. t['\uFE8A'] = '\u0626';
  23048. t['\uFE8B'] = '\u0626';
  23049. t['\uFE8C'] = '\u0626';
  23050. t['\uFE8D'] = '\u0627';
  23051. t['\uFE8E'] = '\u0627';
  23052. t['\uFE8F'] = '\u0628';
  23053. t['\uFE90'] = '\u0628';
  23054. t['\uFE91'] = '\u0628';
  23055. t['\uFE92'] = '\u0628';
  23056. t['\uFE93'] = '\u0629';
  23057. t['\uFE94'] = '\u0629';
  23058. t['\uFE95'] = '\u062A';
  23059. t['\uFE96'] = '\u062A';
  23060. t['\uFE97'] = '\u062A';
  23061. t['\uFE98'] = '\u062A';
  23062. t['\uFE99'] = '\u062B';
  23063. t['\uFE9A'] = '\u062B';
  23064. t['\uFE9B'] = '\u062B';
  23065. t['\uFE9C'] = '\u062B';
  23066. t['\uFE9D'] = '\u062C';
  23067. t['\uFE9E'] = '\u062C';
  23068. t['\uFE9F'] = '\u062C';
  23069. t['\uFEA0'] = '\u062C';
  23070. t['\uFEA1'] = '\u062D';
  23071. t['\uFEA2'] = '\u062D';
  23072. t['\uFEA3'] = '\u062D';
  23073. t['\uFEA4'] = '\u062D';
  23074. t['\uFEA5'] = '\u062E';
  23075. t['\uFEA6'] = '\u062E';
  23076. t['\uFEA7'] = '\u062E';
  23077. t['\uFEA8'] = '\u062E';
  23078. t['\uFEA9'] = '\u062F';
  23079. t['\uFEAA'] = '\u062F';
  23080. t['\uFEAB'] = '\u0630';
  23081. t['\uFEAC'] = '\u0630';
  23082. t['\uFEAD'] = '\u0631';
  23083. t['\uFEAE'] = '\u0631';
  23084. t['\uFEAF'] = '\u0632';
  23085. t['\uFEB0'] = '\u0632';
  23086. t['\uFEB1'] = '\u0633';
  23087. t['\uFEB2'] = '\u0633';
  23088. t['\uFEB3'] = '\u0633';
  23089. t['\uFEB4'] = '\u0633';
  23090. t['\uFEB5'] = '\u0634';
  23091. t['\uFEB6'] = '\u0634';
  23092. t['\uFEB7'] = '\u0634';
  23093. t['\uFEB8'] = '\u0634';
  23094. t['\uFEB9'] = '\u0635';
  23095. t['\uFEBA'] = '\u0635';
  23096. t['\uFEBB'] = '\u0635';
  23097. t['\uFEBC'] = '\u0635';
  23098. t['\uFEBD'] = '\u0636';
  23099. t['\uFEBE'] = '\u0636';
  23100. t['\uFEBF'] = '\u0636';
  23101. t['\uFEC0'] = '\u0636';
  23102. t['\uFEC1'] = '\u0637';
  23103. t['\uFEC2'] = '\u0637';
  23104. t['\uFEC3'] = '\u0637';
  23105. t['\uFEC4'] = '\u0637';
  23106. t['\uFEC5'] = '\u0638';
  23107. t['\uFEC6'] = '\u0638';
  23108. t['\uFEC7'] = '\u0638';
  23109. t['\uFEC8'] = '\u0638';
  23110. t['\uFEC9'] = '\u0639';
  23111. t['\uFECA'] = '\u0639';
  23112. t['\uFECB'] = '\u0639';
  23113. t['\uFECC'] = '\u0639';
  23114. t['\uFECD'] = '\u063A';
  23115. t['\uFECE'] = '\u063A';
  23116. t['\uFECF'] = '\u063A';
  23117. t['\uFED0'] = '\u063A';
  23118. t['\uFED1'] = '\u0641';
  23119. t['\uFED2'] = '\u0641';
  23120. t['\uFED3'] = '\u0641';
  23121. t['\uFED4'] = '\u0641';
  23122. t['\uFED5'] = '\u0642';
  23123. t['\uFED6'] = '\u0642';
  23124. t['\uFED7'] = '\u0642';
  23125. t['\uFED8'] = '\u0642';
  23126. t['\uFED9'] = '\u0643';
  23127. t['\uFEDA'] = '\u0643';
  23128. t['\uFEDB'] = '\u0643';
  23129. t['\uFEDC'] = '\u0643';
  23130. t['\uFEDD'] = '\u0644';
  23131. t['\uFEDE'] = '\u0644';
  23132. t['\uFEDF'] = '\u0644';
  23133. t['\uFEE0'] = '\u0644';
  23134. t['\uFEE1'] = '\u0645';
  23135. t['\uFEE2'] = '\u0645';
  23136. t['\uFEE3'] = '\u0645';
  23137. t['\uFEE4'] = '\u0645';
  23138. t['\uFEE5'] = '\u0646';
  23139. t['\uFEE6'] = '\u0646';
  23140. t['\uFEE7'] = '\u0646';
  23141. t['\uFEE8'] = '\u0646';
  23142. t['\uFEE9'] = '\u0647';
  23143. t['\uFEEA'] = '\u0647';
  23144. t['\uFEEB'] = '\u0647';
  23145. t['\uFEEC'] = '\u0647';
  23146. t['\uFEED'] = '\u0648';
  23147. t['\uFEEE'] = '\u0648';
  23148. t['\uFEEF'] = '\u0649';
  23149. t['\uFEF0'] = '\u0649';
  23150. t['\uFEF1'] = '\u064A';
  23151. t['\uFEF2'] = '\u064A';
  23152. t['\uFEF3'] = '\u064A';
  23153. t['\uFEF4'] = '\u064A';
  23154. t['\uFEF5'] = '\u0644\u0622';
  23155. t['\uFEF6'] = '\u0644\u0622';
  23156. t['\uFEF7'] = '\u0644\u0623';
  23157. t['\uFEF8'] = '\u0644\u0623';
  23158. t['\uFEF9'] = '\u0644\u0625';
  23159. t['\uFEFA'] = '\u0644\u0625';
  23160. t['\uFEFB'] = '\u0644\u0627';
  23161. t['\uFEFC'] = '\u0644\u0627';
  23162. });
  23163. function reverseIfRtl(chars) {
  23164. var charsLength = chars.length;
  23165. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23166. return chars;
  23167. }
  23168. var s = '';
  23169. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23170. s += chars[ii];
  23171. }
  23172. return s;
  23173. }
  23174. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23175. exports.reverseIfRtl = reverseIfRtl;
  23176. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23177. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23178. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23179. }));
  23180. (function (root, factory) {
  23181. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23182. }(this, function (exports, sharedUtil) {
  23183. var assert = sharedUtil.assert;
  23184. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23185. var warn = sharedUtil.warn;
  23186. var deprecated = sharedUtil.deprecated;
  23187. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23188. var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
  23189. function DOMCanvasFactory() {
  23190. }
  23191. DOMCanvasFactory.prototype = {
  23192. create: function DOMCanvasFactory_create(width, height) {
  23193. assert(width > 0 && height > 0, 'invalid canvas size');
  23194. var canvas = document.createElement('canvas');
  23195. canvas.width = width;
  23196. canvas.height = height;
  23197. return canvas;
  23198. },
  23199. reset: function DOMCanvasFactory_reset(canvas, width, height) {
  23200. assert(canvas, 'canvas is not specified');
  23201. assert(width > 0 && height > 0, 'invalid canvas size');
  23202. canvas.width = width;
  23203. canvas.height = height;
  23204. },
  23205. destroy: function DOMCanvasFactory_destroy(canvas) {
  23206. assert(canvas, 'canvas is not specified');
  23207. canvas.width = 0;
  23208. canvas.height = 0;
  23209. }
  23210. };
  23211. var CustomStyle = function CustomStyleClosure() {
  23212. var prefixes = [
  23213. 'ms',
  23214. 'Moz',
  23215. 'Webkit',
  23216. 'O'
  23217. ];
  23218. var _cache = Object.create(null);
  23219. function CustomStyle() {
  23220. }
  23221. CustomStyle.getProp = function get(propName, element) {
  23222. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23223. return _cache[propName];
  23224. }
  23225. element = element || document.documentElement;
  23226. var style = element.style, prefixed, uPropName;
  23227. if (typeof style[propName] === 'string') {
  23228. return _cache[propName] = propName;
  23229. }
  23230. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23231. for (var i = 0, l = prefixes.length; i < l; i++) {
  23232. prefixed = prefixes[i] + uPropName;
  23233. if (typeof style[prefixed] === 'string') {
  23234. return _cache[propName] = prefixed;
  23235. }
  23236. }
  23237. return _cache[propName] = 'undefined';
  23238. };
  23239. CustomStyle.setProp = function set(propName, element, str) {
  23240. var prop = this.getProp(propName);
  23241. if (prop !== 'undefined') {
  23242. element.style[prop] = str;
  23243. }
  23244. };
  23245. return CustomStyle;
  23246. }();
  23247. var hasCanvasTypedArrays;
  23248. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23249. var canvas = document.createElement('canvas');
  23250. canvas.width = canvas.height = 1;
  23251. var ctx = canvas.getContext('2d');
  23252. var imageData = ctx.createImageData(1, 1);
  23253. return typeof imageData.data.buffer !== 'undefined';
  23254. };
  23255. var LinkTarget = {
  23256. NONE: 0,
  23257. SELF: 1,
  23258. BLANK: 2,
  23259. PARENT: 3,
  23260. TOP: 4
  23261. };
  23262. var LinkTargetStringMap = [
  23263. '',
  23264. '_self',
  23265. '_blank',
  23266. '_parent',
  23267. '_top'
  23268. ];
  23269. function addLinkAttributes(link, params) {
  23270. var url = params && params.url;
  23271. link.href = link.title = url ? removeNullCharacters(url) : '';
  23272. if (url) {
  23273. var target = params.target;
  23274. if (typeof target === 'undefined') {
  23275. target = getDefaultSetting('externalLinkTarget');
  23276. }
  23277. link.target = LinkTargetStringMap[target];
  23278. var rel = params.rel;
  23279. if (typeof rel === 'undefined') {
  23280. rel = getDefaultSetting('externalLinkRel');
  23281. }
  23282. link.rel = rel;
  23283. }
  23284. }
  23285. function getFilenameFromUrl(url) {
  23286. var anchor = url.indexOf('#');
  23287. var query = url.indexOf('?');
  23288. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23289. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23290. }
  23291. function getDefaultSetting(id) {
  23292. var globalSettings = sharedUtil.globalScope.PDFJS;
  23293. switch (id) {
  23294. case 'pdfBug':
  23295. return globalSettings ? globalSettings.pdfBug : false;
  23296. case 'disableAutoFetch':
  23297. return globalSettings ? globalSettings.disableAutoFetch : false;
  23298. case 'disableStream':
  23299. return globalSettings ? globalSettings.disableStream : false;
  23300. case 'disableRange':
  23301. return globalSettings ? globalSettings.disableRange : false;
  23302. case 'disableFontFace':
  23303. return globalSettings ? globalSettings.disableFontFace : false;
  23304. case 'disableCreateObjectURL':
  23305. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23306. case 'disableWebGL':
  23307. return globalSettings ? globalSettings.disableWebGL : true;
  23308. case 'cMapUrl':
  23309. return globalSettings ? globalSettings.cMapUrl : null;
  23310. case 'cMapPacked':
  23311. return globalSettings ? globalSettings.cMapPacked : false;
  23312. case 'postMessageTransfers':
  23313. return globalSettings ? globalSettings.postMessageTransfers : true;
  23314. case 'workerSrc':
  23315. return globalSettings ? globalSettings.workerSrc : null;
  23316. case 'disableWorker':
  23317. return globalSettings ? globalSettings.disableWorker : false;
  23318. case 'maxImageSize':
  23319. return globalSettings ? globalSettings.maxImageSize : -1;
  23320. case 'imageResourcesPath':
  23321. return globalSettings ? globalSettings.imageResourcesPath : '';
  23322. case 'isEvalSupported':
  23323. return globalSettings ? globalSettings.isEvalSupported : true;
  23324. case 'externalLinkTarget':
  23325. if (!globalSettings) {
  23326. return LinkTarget.NONE;
  23327. }
  23328. switch (globalSettings.externalLinkTarget) {
  23329. case LinkTarget.NONE:
  23330. case LinkTarget.SELF:
  23331. case LinkTarget.BLANK:
  23332. case LinkTarget.PARENT:
  23333. case LinkTarget.TOP:
  23334. return globalSettings.externalLinkTarget;
  23335. }
  23336. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23337. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23338. return LinkTarget.NONE;
  23339. case 'externalLinkRel':
  23340. return globalSettings ? globalSettings.externalLinkRel : DEFAULT_LINK_REL;
  23341. case 'enableStats':
  23342. return !!(globalSettings && globalSettings.enableStats);
  23343. default:
  23344. throw new Error('Unknown default setting: ' + id);
  23345. }
  23346. }
  23347. function isExternalLinkTargetSet() {
  23348. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23349. switch (externalLinkTarget) {
  23350. case LinkTarget.NONE:
  23351. return false;
  23352. case LinkTarget.SELF:
  23353. case LinkTarget.BLANK:
  23354. case LinkTarget.PARENT:
  23355. case LinkTarget.TOP:
  23356. return true;
  23357. }
  23358. }
  23359. function isValidUrl(url, allowRelative) {
  23360. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23361. var baseUrl = allowRelative ? 'http://example.com' : null;
  23362. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23363. }
  23364. exports.CustomStyle = CustomStyle;
  23365. exports.addLinkAttributes = addLinkAttributes;
  23366. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23367. exports.isValidUrl = isValidUrl;
  23368. exports.getFilenameFromUrl = getFilenameFromUrl;
  23369. exports.LinkTarget = LinkTarget;
  23370. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23371. exports.getDefaultSetting = getDefaultSetting;
  23372. exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
  23373. exports.DOMCanvasFactory = DOMCanvasFactory;
  23374. }));
  23375. (function (root, factory) {
  23376. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23377. }(this, function (exports, sharedUtil) {
  23378. var assert = sharedUtil.assert;
  23379. var bytesToString = sharedUtil.bytesToString;
  23380. var string32 = sharedUtil.string32;
  23381. var shadow = sharedUtil.shadow;
  23382. var warn = sharedUtil.warn;
  23383. function FontLoader(docId) {
  23384. this.docId = docId;
  23385. this.styleElement = null;
  23386. this.nativeFontFaces = [];
  23387. this.loadTestFontId = 0;
  23388. this.loadingContext = {
  23389. requests: [],
  23390. nextRequestId: 0
  23391. };
  23392. }
  23393. FontLoader.prototype = {
  23394. insertRule: function fontLoaderInsertRule(rule) {
  23395. var styleElement = this.styleElement;
  23396. if (!styleElement) {
  23397. styleElement = this.styleElement = document.createElement('style');
  23398. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23399. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23400. }
  23401. var styleSheet = styleElement.sheet;
  23402. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23403. },
  23404. clear: function fontLoaderClear() {
  23405. var styleElement = this.styleElement;
  23406. if (styleElement) {
  23407. if (styleElement.parentNode) {
  23408. styleElement.parentNode.removeChild(styleElement);
  23409. }
  23410. styleElement = this.styleElement = null;
  23411. }
  23412. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23413. document.fonts.delete(nativeFontFace);
  23414. });
  23415. this.nativeFontFaces.length = 0;
  23416. }
  23417. };
  23418. var getLoadTestFont = function () {
  23419. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
  23420. };
  23421. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23422. get: function () {
  23423. return shadow(this, 'loadTestFont', getLoadTestFont());
  23424. },
  23425. configurable: true
  23426. });
  23427. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23428. this.nativeFontFaces.push(nativeFontFace);
  23429. document.fonts.add(nativeFontFace);
  23430. };
  23431. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23432. var rules = [];
  23433. var fontsToLoad = [];
  23434. var fontLoadPromises = [];
  23435. var getNativeFontPromise = function (nativeFontFace) {
  23436. return nativeFontFace.loaded.catch(function (e) {
  23437. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23438. });
  23439. };
  23440. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23441. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23442. var font = fonts[i];
  23443. if (font.attached || font.loading === false) {
  23444. continue;
  23445. }
  23446. font.attached = true;
  23447. if (isFontLoadingAPISupported) {
  23448. var nativeFontFace = font.createNativeFontFace();
  23449. if (nativeFontFace) {
  23450. this.addNativeFontFace(nativeFontFace);
  23451. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23452. }
  23453. } else {
  23454. var rule = font.createFontFaceRule();
  23455. if (rule) {
  23456. this.insertRule(rule);
  23457. rules.push(rule);
  23458. fontsToLoad.push(font);
  23459. }
  23460. }
  23461. }
  23462. var request = this.queueLoadingCallback(callback);
  23463. if (isFontLoadingAPISupported) {
  23464. Promise.all(fontLoadPromises).then(function () {
  23465. request.complete();
  23466. });
  23467. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23468. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23469. } else {
  23470. request.complete();
  23471. }
  23472. };
  23473. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23474. function LoadLoader_completeRequest() {
  23475. assert(!request.end, 'completeRequest() cannot be called twice');
  23476. request.end = Date.now();
  23477. while (context.requests.length > 0 && context.requests[0].end) {
  23478. var otherRequest = context.requests.shift();
  23479. setTimeout(otherRequest.callback, 0);
  23480. }
  23481. }
  23482. var context = this.loadingContext;
  23483. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23484. var request = {
  23485. id: requestId,
  23486. complete: LoadLoader_completeRequest,
  23487. callback: callback,
  23488. started: Date.now()
  23489. };
  23490. context.requests.push(request);
  23491. return request;
  23492. };
  23493. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23494. function int32(data, offset) {
  23495. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23496. }
  23497. function spliceString(s, offset, remove, insert) {
  23498. var chunk1 = s.substr(0, offset);
  23499. var chunk2 = s.substr(offset + remove);
  23500. return chunk1 + insert + chunk2;
  23501. }
  23502. var i, ii;
  23503. var canvas = document.createElement('canvas');
  23504. canvas.width = 1;
  23505. canvas.height = 1;
  23506. var ctx = canvas.getContext('2d');
  23507. var called = 0;
  23508. function isFontReady(name, callback) {
  23509. called++;
  23510. if (called > 30) {
  23511. warn('Load test font never loaded.');
  23512. callback();
  23513. return;
  23514. }
  23515. ctx.font = '30px ' + name;
  23516. ctx.fillText('.', 0, 20);
  23517. var imageData = ctx.getImageData(0, 0, 1, 1);
  23518. if (imageData.data[3] > 0) {
  23519. callback();
  23520. return;
  23521. }
  23522. setTimeout(isFontReady.bind(null, name, callback));
  23523. }
  23524. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23525. var data = this.loadTestFont;
  23526. var COMMENT_OFFSET = 976;
  23527. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23528. var CFF_CHECKSUM_OFFSET = 16;
  23529. var XXXX_VALUE = 0x58585858;
  23530. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23531. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23532. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23533. }
  23534. if (i < loadTestFontId.length) {
  23535. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23536. }
  23537. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23538. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23539. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23540. this.insertRule(rule);
  23541. var names = [];
  23542. for (i = 0, ii = fonts.length; i < ii; i++) {
  23543. names.push(fonts[i].loadedName);
  23544. }
  23545. names.push(loadTestFontId);
  23546. var div = document.createElement('div');
  23547. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23548. for (i = 0, ii = names.length; i < ii; ++i) {
  23549. var span = document.createElement('span');
  23550. span.textContent = 'Hi';
  23551. span.style.fontFamily = names[i];
  23552. div.appendChild(span);
  23553. }
  23554. document.body.appendChild(div);
  23555. isFontReady(loadTestFontId, function () {
  23556. document.body.removeChild(div);
  23557. request.complete();
  23558. });
  23559. };
  23560. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23561. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23562. if (typeof navigator === 'undefined') {
  23563. return true;
  23564. }
  23565. var supported = false;
  23566. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23567. if (m && m[1] >= 14) {
  23568. supported = true;
  23569. }
  23570. return supported;
  23571. };
  23572. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23573. get: function () {
  23574. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23575. },
  23576. enumerable: true,
  23577. configurable: true
  23578. });
  23579. var IsEvalSupportedCached = {
  23580. get value() {
  23581. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23582. }
  23583. };
  23584. var FontFaceObject = function FontFaceObjectClosure() {
  23585. function FontFaceObject(translatedData, options) {
  23586. this.compiledGlyphs = Object.create(null);
  23587. for (var i in translatedData) {
  23588. this[i] = translatedData[i];
  23589. }
  23590. this.options = options;
  23591. }
  23592. FontFaceObject.prototype = {
  23593. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23594. if (!this.data) {
  23595. return null;
  23596. }
  23597. if (this.options.disableFontFace) {
  23598. this.disableFontFace = true;
  23599. return null;
  23600. }
  23601. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23602. if (this.options.fontRegistry) {
  23603. this.options.fontRegistry.registerFont(this);
  23604. }
  23605. return nativeFontFace;
  23606. },
  23607. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23608. if (!this.data) {
  23609. return null;
  23610. }
  23611. if (this.options.disableFontFace) {
  23612. this.disableFontFace = true;
  23613. return null;
  23614. }
  23615. var data = bytesToString(new Uint8Array(this.data));
  23616. var fontName = this.loadedName;
  23617. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23618. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23619. if (this.options.fontRegistry) {
  23620. this.options.fontRegistry.registerFont(this, url);
  23621. }
  23622. return rule;
  23623. },
  23624. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23625. if (!(character in this.compiledGlyphs)) {
  23626. var cmds = objs.get(this.loadedName + '_path_' + character);
  23627. var current, i, len;
  23628. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23629. var args, js = '';
  23630. for (i = 0, len = cmds.length; i < len; i++) {
  23631. current = cmds[i];
  23632. if (current.args !== undefined) {
  23633. args = current.args.join(',');
  23634. } else {
  23635. args = '';
  23636. }
  23637. js += 'c.' + current.cmd + '(' + args + ');\n';
  23638. }
  23639. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23640. } else {
  23641. this.compiledGlyphs[character] = function (c, size) {
  23642. for (i = 0, len = cmds.length; i < len; i++) {
  23643. current = cmds[i];
  23644. if (current.cmd === 'scale') {
  23645. current.args = [
  23646. size,
  23647. -size
  23648. ];
  23649. }
  23650. c[current.cmd].apply(c, current.args);
  23651. }
  23652. };
  23653. }
  23654. }
  23655. return this.compiledGlyphs[character];
  23656. }
  23657. };
  23658. return FontFaceObject;
  23659. }();
  23660. exports.FontFaceObject = FontFaceObject;
  23661. exports.FontLoader = FontLoader;
  23662. }));
  23663. (function (root, factory) {
  23664. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23665. }(this, function (exports, sharedUtil) {
  23666. var error = sharedUtil.error;
  23667. function fixMetadata(meta) {
  23668. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23669. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23670. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23671. });
  23672. var chars = '';
  23673. for (var i = 0; i < bytes.length; i += 2) {
  23674. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23675. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23676. }
  23677. return '>' + chars;
  23678. });
  23679. }
  23680. function Metadata(meta) {
  23681. if (typeof meta === 'string') {
  23682. meta = fixMetadata(meta);
  23683. var parser = new DOMParser();
  23684. meta = parser.parseFromString(meta, 'application/xml');
  23685. } else if (!(meta instanceof Document)) {
  23686. error('Metadata: Invalid metadata object');
  23687. }
  23688. this.metaDocument = meta;
  23689. this.metadata = Object.create(null);
  23690. this.parse();
  23691. }
  23692. Metadata.prototype = {
  23693. parse: function Metadata_parse() {
  23694. var doc = this.metaDocument;
  23695. var rdf = doc.documentElement;
  23696. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23697. rdf = rdf.firstChild;
  23698. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23699. rdf = rdf.nextSibling;
  23700. }
  23701. }
  23702. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23703. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23704. return;
  23705. }
  23706. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23707. for (i = 0, length = children.length; i < length; i++) {
  23708. desc = children[i];
  23709. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23710. continue;
  23711. }
  23712. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23713. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23714. entry = desc.childNodes[ii];
  23715. name = entry.nodeName.toLowerCase();
  23716. this.metadata[name] = entry.textContent.trim();
  23717. }
  23718. }
  23719. }
  23720. },
  23721. get: function Metadata_get(name) {
  23722. return this.metadata[name] || null;
  23723. },
  23724. has: function Metadata_has(name) {
  23725. return typeof this.metadata[name] !== 'undefined';
  23726. }
  23727. };
  23728. exports.Metadata = Metadata;
  23729. }));
  23730. (function (root, factory) {
  23731. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23732. }(this, function (exports, sharedUtil) {
  23733. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23734. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23735. var ImageKind = sharedUtil.ImageKind;
  23736. var OPS = sharedUtil.OPS;
  23737. var Util = sharedUtil.Util;
  23738. var isNum = sharedUtil.isNum;
  23739. var isArray = sharedUtil.isArray;
  23740. var warn = sharedUtil.warn;
  23741. var createObjectURL = sharedUtil.createObjectURL;
  23742. var SVG_DEFAULTS = {
  23743. fontStyle: 'normal',
  23744. fontWeight: 'normal',
  23745. fillColor: '#000000'
  23746. };
  23747. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23748. var PNG_HEADER = new Uint8Array([
  23749. 0x89,
  23750. 0x50,
  23751. 0x4e,
  23752. 0x47,
  23753. 0x0d,
  23754. 0x0a,
  23755. 0x1a,
  23756. 0x0a
  23757. ]);
  23758. var CHUNK_WRAPPER_SIZE = 12;
  23759. var crcTable = new Int32Array(256);
  23760. for (var i = 0; i < 256; i++) {
  23761. var c = i;
  23762. for (var h = 0; h < 8; h++) {
  23763. if (c & 1) {
  23764. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23765. } else {
  23766. c = c >> 1 & 0x7fffffff;
  23767. }
  23768. }
  23769. crcTable[i] = c;
  23770. }
  23771. function crc32(data, start, end) {
  23772. var crc = -1;
  23773. for (var i = start; i < end; i++) {
  23774. var a = (crc ^ data[i]) & 0xff;
  23775. var b = crcTable[a];
  23776. crc = crc >>> 8 ^ b;
  23777. }
  23778. return crc ^ -1;
  23779. }
  23780. function writePngChunk(type, body, data, offset) {
  23781. var p = offset;
  23782. var len = body.length;
  23783. data[p] = len >> 24 & 0xff;
  23784. data[p + 1] = len >> 16 & 0xff;
  23785. data[p + 2] = len >> 8 & 0xff;
  23786. data[p + 3] = len & 0xff;
  23787. p += 4;
  23788. data[p] = type.charCodeAt(0) & 0xff;
  23789. data[p + 1] = type.charCodeAt(1) & 0xff;
  23790. data[p + 2] = type.charCodeAt(2) & 0xff;
  23791. data[p + 3] = type.charCodeAt(3) & 0xff;
  23792. p += 4;
  23793. data.set(body, p);
  23794. p += body.length;
  23795. var crc = crc32(data, offset + 4, p);
  23796. data[p] = crc >> 24 & 0xff;
  23797. data[p + 1] = crc >> 16 & 0xff;
  23798. data[p + 2] = crc >> 8 & 0xff;
  23799. data[p + 3] = crc & 0xff;
  23800. }
  23801. function adler32(data, start, end) {
  23802. var a = 1;
  23803. var b = 0;
  23804. for (var i = start; i < end; ++i) {
  23805. a = (a + (data[i] & 0xff)) % 65521;
  23806. b = (b + a) % 65521;
  23807. }
  23808. return b << 16 | a;
  23809. }
  23810. function encode(imgData, kind, forceDataSchema) {
  23811. var width = imgData.width;
  23812. var height = imgData.height;
  23813. var bitDepth, colorType, lineSize;
  23814. var bytes = imgData.data;
  23815. switch (kind) {
  23816. case ImageKind.GRAYSCALE_1BPP:
  23817. colorType = 0;
  23818. bitDepth = 1;
  23819. lineSize = width + 7 >> 3;
  23820. break;
  23821. case ImageKind.RGB_24BPP:
  23822. colorType = 2;
  23823. bitDepth = 8;
  23824. lineSize = width * 3;
  23825. break;
  23826. case ImageKind.RGBA_32BPP:
  23827. colorType = 6;
  23828. bitDepth = 8;
  23829. lineSize = width * 4;
  23830. break;
  23831. default:
  23832. throw new Error('invalid format');
  23833. }
  23834. var literals = new Uint8Array((1 + lineSize) * height);
  23835. var offsetLiterals = 0, offsetBytes = 0;
  23836. var y, i;
  23837. for (y = 0; y < height; ++y) {
  23838. literals[offsetLiterals++] = 0;
  23839. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23840. offsetBytes += lineSize;
  23841. offsetLiterals += lineSize;
  23842. }
  23843. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23844. offsetLiterals = 0;
  23845. for (y = 0; y < height; y++) {
  23846. offsetLiterals++;
  23847. for (i = 0; i < lineSize; i++) {
  23848. literals[offsetLiterals++] ^= 0xFF;
  23849. }
  23850. }
  23851. }
  23852. var ihdr = new Uint8Array([
  23853. width >> 24 & 0xff,
  23854. width >> 16 & 0xff,
  23855. width >> 8 & 0xff,
  23856. width & 0xff,
  23857. height >> 24 & 0xff,
  23858. height >> 16 & 0xff,
  23859. height >> 8 & 0xff,
  23860. height & 0xff,
  23861. bitDepth,
  23862. colorType,
  23863. 0x00,
  23864. 0x00,
  23865. 0x00
  23866. ]);
  23867. var len = literals.length;
  23868. var maxBlockLength = 0xFFFF;
  23869. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23870. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23871. var pi = 0;
  23872. idat[pi++] = 0x78;
  23873. idat[pi++] = 0x9c;
  23874. var pos = 0;
  23875. while (len > maxBlockLength) {
  23876. idat[pi++] = 0x00;
  23877. idat[pi++] = 0xff;
  23878. idat[pi++] = 0xff;
  23879. idat[pi++] = 0x00;
  23880. idat[pi++] = 0x00;
  23881. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23882. pi += maxBlockLength;
  23883. pos += maxBlockLength;
  23884. len -= maxBlockLength;
  23885. }
  23886. idat[pi++] = 0x01;
  23887. idat[pi++] = len & 0xff;
  23888. idat[pi++] = len >> 8 & 0xff;
  23889. idat[pi++] = ~len & 0xffff & 0xff;
  23890. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23891. idat.set(literals.subarray(pos), pi);
  23892. pi += literals.length - pos;
  23893. var adler = adler32(literals, 0, literals.length);
  23894. idat[pi++] = adler >> 24 & 0xff;
  23895. idat[pi++] = adler >> 16 & 0xff;
  23896. idat[pi++] = adler >> 8 & 0xff;
  23897. idat[pi++] = adler & 0xff;
  23898. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23899. var data = new Uint8Array(pngLength);
  23900. var offset = 0;
  23901. data.set(PNG_HEADER, offset);
  23902. offset += PNG_HEADER.length;
  23903. writePngChunk('IHDR', ihdr, data, offset);
  23904. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23905. writePngChunk('IDATA', idat, data, offset);
  23906. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23907. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23908. return createObjectURL(data, 'image/png', forceDataSchema);
  23909. }
  23910. return function convertImgDataToPng(imgData, forceDataSchema) {
  23911. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23912. return encode(imgData, kind, forceDataSchema);
  23913. };
  23914. }();
  23915. var SVGExtraState = function SVGExtraStateClosure() {
  23916. function SVGExtraState() {
  23917. this.fontSizeScale = 1;
  23918. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23919. this.fontSize = 0;
  23920. this.textMatrix = IDENTITY_MATRIX;
  23921. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23922. this.leading = 0;
  23923. this.x = 0;
  23924. this.y = 0;
  23925. this.lineX = 0;
  23926. this.lineY = 0;
  23927. this.charSpacing = 0;
  23928. this.wordSpacing = 0;
  23929. this.textHScale = 1;
  23930. this.textRise = 0;
  23931. this.fillColor = SVG_DEFAULTS.fillColor;
  23932. this.strokeColor = '#000000';
  23933. this.fillAlpha = 1;
  23934. this.strokeAlpha = 1;
  23935. this.lineWidth = 1;
  23936. this.lineJoin = '';
  23937. this.lineCap = '';
  23938. this.miterLimit = 0;
  23939. this.dashArray = [];
  23940. this.dashPhase = 0;
  23941. this.dependencies = [];
  23942. this.activeClipUrl = null;
  23943. this.clipGroup = null;
  23944. this.maskId = '';
  23945. }
  23946. SVGExtraState.prototype = {
  23947. clone: function SVGExtraState_clone() {
  23948. return Object.create(this);
  23949. },
  23950. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23951. this.x = x;
  23952. this.y = y;
  23953. }
  23954. };
  23955. return SVGExtraState;
  23956. }();
  23957. var SVGGraphics = function SVGGraphicsClosure() {
  23958. function opListToTree(opList) {
  23959. var opTree = [];
  23960. var tmp = [];
  23961. var opListLen = opList.length;
  23962. for (var x = 0; x < opListLen; x++) {
  23963. if (opList[x].fn === 'save') {
  23964. opTree.push({
  23965. 'fnId': 92,
  23966. 'fn': 'group',
  23967. 'items': []
  23968. });
  23969. tmp.push(opTree);
  23970. opTree = opTree[opTree.length - 1].items;
  23971. continue;
  23972. }
  23973. if (opList[x].fn === 'restore') {
  23974. opTree = tmp.pop();
  23975. } else {
  23976. opTree.push(opList[x]);
  23977. }
  23978. }
  23979. return opTree;
  23980. }
  23981. function pf(value) {
  23982. if (value === (value | 0)) {
  23983. return value.toString();
  23984. }
  23985. var s = value.toFixed(10);
  23986. var i = s.length - 1;
  23987. if (s[i] !== '0') {
  23988. return s;
  23989. }
  23990. do {
  23991. i--;
  23992. } while (s[i] === '0');
  23993. return s.substr(0, s[i] === '.' ? i : i + 1);
  23994. }
  23995. function pm(m) {
  23996. if (m[4] === 0 && m[5] === 0) {
  23997. if (m[1] === 0 && m[2] === 0) {
  23998. if (m[0] === 1 && m[3] === 1) {
  23999. return '';
  24000. }
  24001. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  24002. }
  24003. if (m[0] === m[3] && m[1] === -m[2]) {
  24004. var a = Math.acos(m[0]) * 180 / Math.PI;
  24005. return 'rotate(' + pf(a) + ')';
  24006. }
  24007. } else {
  24008. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  24009. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  24010. }
  24011. }
  24012. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  24013. }
  24014. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  24015. this.current = new SVGExtraState();
  24016. this.transformMatrix = IDENTITY_MATRIX;
  24017. this.transformStack = [];
  24018. this.extraStack = [];
  24019. this.commonObjs = commonObjs;
  24020. this.objs = objs;
  24021. this.pendingEOFill = false;
  24022. this.embedFonts = false;
  24023. this.embeddedFonts = Object.create(null);
  24024. this.cssStyle = null;
  24025. this.forceDataSchema = !!forceDataSchema;
  24026. }
  24027. var NS = 'http://www.w3.org/2000/svg';
  24028. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  24029. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  24030. var LINE_CAP_STYLES = [
  24031. 'butt',
  24032. 'round',
  24033. 'square'
  24034. ];
  24035. var LINE_JOIN_STYLES = [
  24036. 'miter',
  24037. 'round',
  24038. 'bevel'
  24039. ];
  24040. var clipCount = 0;
  24041. var maskCount = 0;
  24042. SVGGraphics.prototype = {
  24043. save: function SVGGraphics_save() {
  24044. this.transformStack.push(this.transformMatrix);
  24045. var old = this.current;
  24046. this.extraStack.push(old);
  24047. this.current = old.clone();
  24048. },
  24049. restore: function SVGGraphics_restore() {
  24050. this.transformMatrix = this.transformStack.pop();
  24051. this.current = this.extraStack.pop();
  24052. this.tgrp = null;
  24053. },
  24054. group: function SVGGraphics_group(items) {
  24055. this.save();
  24056. this.executeOpTree(items);
  24057. this.restore();
  24058. },
  24059. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  24060. var fnArray = operatorList.fnArray;
  24061. var fnArrayLen = fnArray.length;
  24062. var argsArray = operatorList.argsArray;
  24063. var self = this;
  24064. for (var i = 0; i < fnArrayLen; i++) {
  24065. if (OPS.dependency === fnArray[i]) {
  24066. var deps = argsArray[i];
  24067. for (var n = 0, nn = deps.length; n < nn; n++) {
  24068. var obj = deps[n];
  24069. var common = obj.substring(0, 2) === 'g_';
  24070. var promise;
  24071. if (common) {
  24072. promise = new Promise(function (resolve) {
  24073. self.commonObjs.get(obj, resolve);
  24074. });
  24075. } else {
  24076. promise = new Promise(function (resolve) {
  24077. self.objs.get(obj, resolve);
  24078. });
  24079. }
  24080. this.current.dependencies.push(promise);
  24081. }
  24082. }
  24083. }
  24084. return Promise.all(this.current.dependencies);
  24085. },
  24086. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  24087. var transformMatrix = [
  24088. a,
  24089. b,
  24090. c,
  24091. d,
  24092. e,
  24093. f
  24094. ];
  24095. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  24096. this.tgrp = null;
  24097. },
  24098. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  24099. this.viewport = viewport;
  24100. var svgElement = this._initialize(viewport);
  24101. return this.loadDependencies(operatorList).then(function () {
  24102. this.transformMatrix = IDENTITY_MATRIX;
  24103. var opTree = this.convertOpList(operatorList);
  24104. this.executeOpTree(opTree);
  24105. return svgElement;
  24106. }.bind(this));
  24107. },
  24108. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  24109. var argsArray = operatorList.argsArray;
  24110. var fnArray = operatorList.fnArray;
  24111. var fnArrayLen = fnArray.length;
  24112. var REVOPS = [];
  24113. var opList = [];
  24114. for (var op in OPS) {
  24115. REVOPS[OPS[op]] = op;
  24116. }
  24117. for (var x = 0; x < fnArrayLen; x++) {
  24118. var fnId = fnArray[x];
  24119. opList.push({
  24120. 'fnId': fnId,
  24121. 'fn': REVOPS[fnId],
  24122. 'args': argsArray[x]
  24123. });
  24124. }
  24125. return opListToTree(opList);
  24126. },
  24127. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  24128. var opTreeLen = opTree.length;
  24129. for (var x = 0; x < opTreeLen; x++) {
  24130. var fn = opTree[x].fn;
  24131. var fnId = opTree[x].fnId;
  24132. var args = opTree[x].args;
  24133. switch (fnId | 0) {
  24134. case OPS.beginText:
  24135. this.beginText();
  24136. break;
  24137. case OPS.setLeading:
  24138. this.setLeading(args);
  24139. break;
  24140. case OPS.setLeadingMoveText:
  24141. this.setLeadingMoveText(args[0], args[1]);
  24142. break;
  24143. case OPS.setFont:
  24144. this.setFont(args);
  24145. break;
  24146. case OPS.showText:
  24147. this.showText(args[0]);
  24148. break;
  24149. case OPS.showSpacedText:
  24150. this.showText(args[0]);
  24151. break;
  24152. case OPS.endText:
  24153. this.endText();
  24154. break;
  24155. case OPS.moveText:
  24156. this.moveText(args[0], args[1]);
  24157. break;
  24158. case OPS.setCharSpacing:
  24159. this.setCharSpacing(args[0]);
  24160. break;
  24161. case OPS.setWordSpacing:
  24162. this.setWordSpacing(args[0]);
  24163. break;
  24164. case OPS.setHScale:
  24165. this.setHScale(args[0]);
  24166. break;
  24167. case OPS.setTextMatrix:
  24168. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24169. break;
  24170. case OPS.setLineWidth:
  24171. this.setLineWidth(args[0]);
  24172. break;
  24173. case OPS.setLineJoin:
  24174. this.setLineJoin(args[0]);
  24175. break;
  24176. case OPS.setLineCap:
  24177. this.setLineCap(args[0]);
  24178. break;
  24179. case OPS.setMiterLimit:
  24180. this.setMiterLimit(args[0]);
  24181. break;
  24182. case OPS.setFillRGBColor:
  24183. this.setFillRGBColor(args[0], args[1], args[2]);
  24184. break;
  24185. case OPS.setStrokeRGBColor:
  24186. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24187. break;
  24188. case OPS.setDash:
  24189. this.setDash(args[0], args[1]);
  24190. break;
  24191. case OPS.setGState:
  24192. this.setGState(args[0]);
  24193. break;
  24194. case OPS.fill:
  24195. this.fill();
  24196. break;
  24197. case OPS.eoFill:
  24198. this.eoFill();
  24199. break;
  24200. case OPS.stroke:
  24201. this.stroke();
  24202. break;
  24203. case OPS.fillStroke:
  24204. this.fillStroke();
  24205. break;
  24206. case OPS.eoFillStroke:
  24207. this.eoFillStroke();
  24208. break;
  24209. case OPS.clip:
  24210. this.clip('nonzero');
  24211. break;
  24212. case OPS.eoClip:
  24213. this.clip('evenodd');
  24214. break;
  24215. case OPS.paintSolidColorImageMask:
  24216. this.paintSolidColorImageMask();
  24217. break;
  24218. case OPS.paintJpegXObject:
  24219. this.paintJpegXObject(args[0], args[1], args[2]);
  24220. break;
  24221. case OPS.paintImageXObject:
  24222. this.paintImageXObject(args[0]);
  24223. break;
  24224. case OPS.paintInlineImageXObject:
  24225. this.paintInlineImageXObject(args[0]);
  24226. break;
  24227. case OPS.paintImageMaskXObject:
  24228. this.paintImageMaskXObject(args[0]);
  24229. break;
  24230. case OPS.paintFormXObjectBegin:
  24231. this.paintFormXObjectBegin(args[0], args[1]);
  24232. break;
  24233. case OPS.paintFormXObjectEnd:
  24234. this.paintFormXObjectEnd();
  24235. break;
  24236. case OPS.closePath:
  24237. this.closePath();
  24238. break;
  24239. case OPS.closeStroke:
  24240. this.closeStroke();
  24241. break;
  24242. case OPS.closeFillStroke:
  24243. this.closeFillStroke();
  24244. break;
  24245. case OPS.nextLine:
  24246. this.nextLine();
  24247. break;
  24248. case OPS.transform:
  24249. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24250. break;
  24251. case OPS.constructPath:
  24252. this.constructPath(args[0], args[1]);
  24253. break;
  24254. case OPS.endPath:
  24255. this.endPath();
  24256. break;
  24257. case 92:
  24258. this.group(opTree[x].items);
  24259. break;
  24260. default:
  24261. warn('Unimplemented operator ' + fn);
  24262. break;
  24263. }
  24264. }
  24265. },
  24266. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24267. this.current.wordSpacing = wordSpacing;
  24268. },
  24269. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24270. this.current.charSpacing = charSpacing;
  24271. },
  24272. nextLine: function SVGGraphics_nextLine() {
  24273. this.moveText(0, this.current.leading);
  24274. },
  24275. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24276. var current = this.current;
  24277. this.current.textMatrix = this.current.lineMatrix = [
  24278. a,
  24279. b,
  24280. c,
  24281. d,
  24282. e,
  24283. f
  24284. ];
  24285. this.current.x = this.current.lineX = 0;
  24286. this.current.y = this.current.lineY = 0;
  24287. current.xcoords = [];
  24288. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24289. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24290. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24291. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24292. current.txtElement = document.createElementNS(NS, 'svg:text');
  24293. current.txtElement.appendChild(current.tspan);
  24294. },
  24295. beginText: function SVGGraphics_beginText() {
  24296. this.current.x = this.current.lineX = 0;
  24297. this.current.y = this.current.lineY = 0;
  24298. this.current.textMatrix = IDENTITY_MATRIX;
  24299. this.current.lineMatrix = IDENTITY_MATRIX;
  24300. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24301. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24302. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24303. this.current.xcoords = [];
  24304. },
  24305. moveText: function SVGGraphics_moveText(x, y) {
  24306. var current = this.current;
  24307. this.current.x = this.current.lineX += x;
  24308. this.current.y = this.current.lineY += y;
  24309. current.xcoords = [];
  24310. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24311. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24312. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24313. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24314. },
  24315. showText: function SVGGraphics_showText(glyphs) {
  24316. var current = this.current;
  24317. var font = current.font;
  24318. var fontSize = current.fontSize;
  24319. if (fontSize === 0) {
  24320. return;
  24321. }
  24322. var charSpacing = current.charSpacing;
  24323. var wordSpacing = current.wordSpacing;
  24324. var fontDirection = current.fontDirection;
  24325. var textHScale = current.textHScale * fontDirection;
  24326. var glyphsLength = glyphs.length;
  24327. var vertical = font.vertical;
  24328. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24329. var x = 0, i;
  24330. for (i = 0; i < glyphsLength; ++i) {
  24331. var glyph = glyphs[i];
  24332. if (glyph === null) {
  24333. x += fontDirection * wordSpacing;
  24334. continue;
  24335. } else if (isNum(glyph)) {
  24336. x += -glyph * fontSize * 0.001;
  24337. continue;
  24338. }
  24339. current.xcoords.push(current.x + x * textHScale);
  24340. var width = glyph.width;
  24341. var character = glyph.fontChar;
  24342. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24343. x += charWidth;
  24344. current.tspan.textContent += character;
  24345. }
  24346. if (vertical) {
  24347. current.y -= x * textHScale;
  24348. } else {
  24349. current.x += x * textHScale;
  24350. }
  24351. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24352. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24353. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24354. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24355. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24356. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24357. }
  24358. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24359. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24360. }
  24361. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24362. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24363. }
  24364. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24365. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24366. current.txtElement.appendChild(current.tspan);
  24367. current.txtgrp.appendChild(current.txtElement);
  24368. this._ensureTransformGroup().appendChild(current.txtElement);
  24369. },
  24370. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24371. this.setLeading(-y);
  24372. this.moveText(x, y);
  24373. },
  24374. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24375. if (!this.cssStyle) {
  24376. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24377. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24378. this.defs.appendChild(this.cssStyle);
  24379. }
  24380. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24381. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24382. },
  24383. setFont: function SVGGraphics_setFont(details) {
  24384. var current = this.current;
  24385. var fontObj = this.commonObjs.get(details[0]);
  24386. var size = details[1];
  24387. this.current.font = fontObj;
  24388. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24389. this.addFontStyle(fontObj);
  24390. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24391. }
  24392. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24393. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24394. var italic = fontObj.italic ? 'italic' : 'normal';
  24395. if (size < 0) {
  24396. size = -size;
  24397. current.fontDirection = -1;
  24398. } else {
  24399. current.fontDirection = 1;
  24400. }
  24401. current.fontSize = size;
  24402. current.fontFamily = fontObj.loadedName;
  24403. current.fontWeight = bold;
  24404. current.fontStyle = italic;
  24405. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24406. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24407. current.xcoords = [];
  24408. },
  24409. endText: function SVGGraphics_endText() {
  24410. },
  24411. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24412. this.current.lineWidth = width;
  24413. },
  24414. setLineCap: function SVGGraphics_setLineCap(style) {
  24415. this.current.lineCap = LINE_CAP_STYLES[style];
  24416. },
  24417. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24418. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24419. },
  24420. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24421. this.current.miterLimit = limit;
  24422. },
  24423. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24424. var color = Util.makeCssRgb(r, g, b);
  24425. this.current.strokeColor = color;
  24426. },
  24427. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24428. var color = Util.makeCssRgb(r, g, b);
  24429. this.current.fillColor = color;
  24430. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24431. this.current.xcoords = [];
  24432. },
  24433. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24434. this.current.dashArray = dashArray;
  24435. this.current.dashPhase = dashPhase;
  24436. },
  24437. constructPath: function SVGGraphics_constructPath(ops, args) {
  24438. var current = this.current;
  24439. var x = current.x, y = current.y;
  24440. current.path = document.createElementNS(NS, 'svg:path');
  24441. var d = [];
  24442. var opLength = ops.length;
  24443. for (var i = 0, j = 0; i < opLength; i++) {
  24444. switch (ops[i] | 0) {
  24445. case OPS.rectangle:
  24446. x = args[j++];
  24447. y = args[j++];
  24448. var width = args[j++];
  24449. var height = args[j++];
  24450. var xw = x + width;
  24451. var yh = y + height;
  24452. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24453. break;
  24454. case OPS.moveTo:
  24455. x = args[j++];
  24456. y = args[j++];
  24457. d.push('M', pf(x), pf(y));
  24458. break;
  24459. case OPS.lineTo:
  24460. x = args[j++];
  24461. y = args[j++];
  24462. d.push('L', pf(x), pf(y));
  24463. break;
  24464. case OPS.curveTo:
  24465. x = args[j + 4];
  24466. y = args[j + 5];
  24467. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24468. j += 6;
  24469. break;
  24470. case OPS.curveTo2:
  24471. x = args[j + 2];
  24472. y = args[j + 3];
  24473. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24474. j += 4;
  24475. break;
  24476. case OPS.curveTo3:
  24477. x = args[j + 2];
  24478. y = args[j + 3];
  24479. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24480. j += 4;
  24481. break;
  24482. case OPS.closePath:
  24483. d.push('Z');
  24484. break;
  24485. }
  24486. }
  24487. current.path.setAttributeNS(null, 'd', d.join(' '));
  24488. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24489. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24490. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24491. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24492. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24493. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24494. current.path.setAttributeNS(null, 'fill', 'none');
  24495. this._ensureTransformGroup().appendChild(current.path);
  24496. current.element = current.path;
  24497. current.setCurrentPoint(x, y);
  24498. },
  24499. endPath: function SVGGraphics_endPath() {
  24500. },
  24501. clip: function SVGGraphics_clip(type) {
  24502. var current = this.current;
  24503. var clipId = 'clippath' + clipCount;
  24504. clipCount++;
  24505. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24506. clipPath.setAttributeNS(null, 'id', clipId);
  24507. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24508. var clipElement = current.element.cloneNode();
  24509. if (type === 'evenodd') {
  24510. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24511. } else {
  24512. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24513. }
  24514. clipPath.appendChild(clipElement);
  24515. this.defs.appendChild(clipPath);
  24516. if (current.activeClipUrl) {
  24517. current.clipGroup = null;
  24518. this.extraStack.forEach(function (prev) {
  24519. prev.clipGroup = null;
  24520. });
  24521. }
  24522. current.activeClipUrl = 'url(#' + clipId + ')';
  24523. this.tgrp = null;
  24524. },
  24525. closePath: function SVGGraphics_closePath() {
  24526. var current = this.current;
  24527. var d = current.path.getAttributeNS(null, 'd');
  24528. d += 'Z';
  24529. current.path.setAttributeNS(null, 'd', d);
  24530. },
  24531. setLeading: function SVGGraphics_setLeading(leading) {
  24532. this.current.leading = -leading;
  24533. },
  24534. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24535. this.current.textRise = textRise;
  24536. },
  24537. setHScale: function SVGGraphics_setHScale(scale) {
  24538. this.current.textHScale = scale / 100;
  24539. },
  24540. setGState: function SVGGraphics_setGState(states) {
  24541. for (var i = 0, ii = states.length; i < ii; i++) {
  24542. var state = states[i];
  24543. var key = state[0];
  24544. var value = state[1];
  24545. switch (key) {
  24546. case 'LW':
  24547. this.setLineWidth(value);
  24548. break;
  24549. case 'LC':
  24550. this.setLineCap(value);
  24551. break;
  24552. case 'LJ':
  24553. this.setLineJoin(value);
  24554. break;
  24555. case 'ML':
  24556. this.setMiterLimit(value);
  24557. break;
  24558. case 'D':
  24559. this.setDash(value[0], value[1]);
  24560. break;
  24561. case 'Font':
  24562. this.setFont(value);
  24563. break;
  24564. default:
  24565. warn('Unimplemented graphic state ' + key);
  24566. break;
  24567. }
  24568. }
  24569. },
  24570. fill: function SVGGraphics_fill() {
  24571. var current = this.current;
  24572. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24573. },
  24574. stroke: function SVGGraphics_stroke() {
  24575. var current = this.current;
  24576. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24577. current.element.setAttributeNS(null, 'fill', 'none');
  24578. },
  24579. eoFill: function SVGGraphics_eoFill() {
  24580. var current = this.current;
  24581. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24582. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24583. },
  24584. fillStroke: function SVGGraphics_fillStroke() {
  24585. this.stroke();
  24586. this.fill();
  24587. },
  24588. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24589. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24590. this.fillStroke();
  24591. },
  24592. closeStroke: function SVGGraphics_closeStroke() {
  24593. this.closePath();
  24594. this.stroke();
  24595. },
  24596. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24597. this.closePath();
  24598. this.fillStroke();
  24599. },
  24600. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24601. var current = this.current;
  24602. var rect = document.createElementNS(NS, 'svg:rect');
  24603. rect.setAttributeNS(null, 'x', '0');
  24604. rect.setAttributeNS(null, 'y', '0');
  24605. rect.setAttributeNS(null, 'width', '1px');
  24606. rect.setAttributeNS(null, 'height', '1px');
  24607. rect.setAttributeNS(null, 'fill', current.fillColor);
  24608. this._ensureTransformGroup().appendChild(rect);
  24609. },
  24610. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24611. var imgObj = this.objs.get(objId);
  24612. var imgEl = document.createElementNS(NS, 'svg:image');
  24613. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24614. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24615. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24616. imgEl.setAttributeNS(null, 'x', '0');
  24617. imgEl.setAttributeNS(null, 'y', pf(-h));
  24618. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24619. this._ensureTransformGroup().appendChild(imgEl);
  24620. },
  24621. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24622. var imgData = this.objs.get(objId);
  24623. if (!imgData) {
  24624. warn('Dependent image isn\'t ready yet');
  24625. return;
  24626. }
  24627. this.paintInlineImageXObject(imgData);
  24628. },
  24629. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24630. var width = imgData.width;
  24631. var height = imgData.height;
  24632. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24633. var cliprect = document.createElementNS(NS, 'svg:rect');
  24634. cliprect.setAttributeNS(null, 'x', '0');
  24635. cliprect.setAttributeNS(null, 'y', '0');
  24636. cliprect.setAttributeNS(null, 'width', pf(width));
  24637. cliprect.setAttributeNS(null, 'height', pf(height));
  24638. this.current.element = cliprect;
  24639. this.clip('nonzero');
  24640. var imgEl = document.createElementNS(NS, 'svg:image');
  24641. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24642. imgEl.setAttributeNS(null, 'x', '0');
  24643. imgEl.setAttributeNS(null, 'y', pf(-height));
  24644. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24645. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24646. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24647. if (mask) {
  24648. mask.appendChild(imgEl);
  24649. } else {
  24650. this._ensureTransformGroup().appendChild(imgEl);
  24651. }
  24652. },
  24653. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24654. var current = this.current;
  24655. var width = imgData.width;
  24656. var height = imgData.height;
  24657. var fillColor = current.fillColor;
  24658. current.maskId = 'mask' + maskCount++;
  24659. var mask = document.createElementNS(NS, 'svg:mask');
  24660. mask.setAttributeNS(null, 'id', current.maskId);
  24661. var rect = document.createElementNS(NS, 'svg:rect');
  24662. rect.setAttributeNS(null, 'x', '0');
  24663. rect.setAttributeNS(null, 'y', '0');
  24664. rect.setAttributeNS(null, 'width', pf(width));
  24665. rect.setAttributeNS(null, 'height', pf(height));
  24666. rect.setAttributeNS(null, 'fill', fillColor);
  24667. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24668. this.defs.appendChild(mask);
  24669. this._ensureTransformGroup().appendChild(rect);
  24670. this.paintInlineImageXObject(imgData, mask);
  24671. },
  24672. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24673. if (isArray(matrix) && matrix.length === 6) {
  24674. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24675. }
  24676. if (isArray(bbox) && bbox.length === 4) {
  24677. var width = bbox[2] - bbox[0];
  24678. var height = bbox[3] - bbox[1];
  24679. var cliprect = document.createElementNS(NS, 'svg:rect');
  24680. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24681. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24682. cliprect.setAttributeNS(null, 'width', pf(width));
  24683. cliprect.setAttributeNS(null, 'height', pf(height));
  24684. this.current.element = cliprect;
  24685. this.clip('nonzero');
  24686. this.endPath();
  24687. }
  24688. },
  24689. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24690. },
  24691. _initialize: function SVGGraphics_initialize(viewport) {
  24692. var svg = document.createElementNS(NS, 'svg:svg');
  24693. svg.setAttributeNS(null, 'version', '1.1');
  24694. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24695. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24696. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24697. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24698. var definitions = document.createElementNS(NS, 'svg:defs');
  24699. svg.appendChild(definitions);
  24700. this.defs = definitions;
  24701. var rootGroup = document.createElementNS(NS, 'svg:g');
  24702. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24703. svg.appendChild(rootGroup);
  24704. this.svg = rootGroup;
  24705. return svg;
  24706. },
  24707. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24708. if (!this.current.clipGroup) {
  24709. var clipGroup = document.createElementNS(NS, 'svg:g');
  24710. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24711. this.svg.appendChild(clipGroup);
  24712. this.current.clipGroup = clipGroup;
  24713. }
  24714. return this.current.clipGroup;
  24715. },
  24716. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24717. if (!this.tgrp) {
  24718. this.tgrp = document.createElementNS(NS, 'svg:g');
  24719. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24720. if (this.current.activeClipUrl) {
  24721. this._ensureClipGroup().appendChild(this.tgrp);
  24722. } else {
  24723. this.svg.appendChild(this.tgrp);
  24724. }
  24725. }
  24726. return this.tgrp;
  24727. }
  24728. };
  24729. return SVGGraphics;
  24730. }();
  24731. exports.SVGGraphics = SVGGraphics;
  24732. }));
  24733. (function (root, factory) {
  24734. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives);
  24735. }(this, function (exports, sharedUtil, corePrimitives) {
  24736. var error = sharedUtil.error;
  24737. var isSpace = sharedUtil.isSpace;
  24738. var EOF = corePrimitives.EOF;
  24739. var PostScriptParser = function PostScriptParserClosure() {
  24740. function PostScriptParser(lexer) {
  24741. this.lexer = lexer;
  24742. this.operators = [];
  24743. this.token = null;
  24744. this.prev = null;
  24745. }
  24746. PostScriptParser.prototype = {
  24747. nextToken: function PostScriptParser_nextToken() {
  24748. this.prev = this.token;
  24749. this.token = this.lexer.getToken();
  24750. },
  24751. accept: function PostScriptParser_accept(type) {
  24752. if (this.token.type === type) {
  24753. this.nextToken();
  24754. return true;
  24755. }
  24756. return false;
  24757. },
  24758. expect: function PostScriptParser_expect(type) {
  24759. if (this.accept(type)) {
  24760. return true;
  24761. }
  24762. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  24763. },
  24764. parse: function PostScriptParser_parse() {
  24765. this.nextToken();
  24766. this.expect(PostScriptTokenTypes.LBRACE);
  24767. this.parseBlock();
  24768. this.expect(PostScriptTokenTypes.RBRACE);
  24769. return this.operators;
  24770. },
  24771. parseBlock: function PostScriptParser_parseBlock() {
  24772. while (true) {
  24773. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  24774. this.operators.push(this.prev.value);
  24775. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  24776. this.operators.push(this.prev.value);
  24777. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  24778. this.parseCondition();
  24779. } else {
  24780. return;
  24781. }
  24782. }
  24783. },
  24784. parseCondition: function PostScriptParser_parseCondition() {
  24785. var conditionLocation = this.operators.length;
  24786. this.operators.push(null, null);
  24787. this.parseBlock();
  24788. this.expect(PostScriptTokenTypes.RBRACE);
  24789. if (this.accept(PostScriptTokenTypes.IF)) {
  24790. this.operators[conditionLocation] = this.operators.length;
  24791. this.operators[conditionLocation + 1] = 'jz';
  24792. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  24793. var jumpLocation = this.operators.length;
  24794. this.operators.push(null, null);
  24795. var endOfTrue = this.operators.length;
  24796. this.parseBlock();
  24797. this.expect(PostScriptTokenTypes.RBRACE);
  24798. this.expect(PostScriptTokenTypes.IFELSE);
  24799. this.operators[jumpLocation] = this.operators.length;
  24800. this.operators[jumpLocation + 1] = 'j';
  24801. this.operators[conditionLocation] = endOfTrue;
  24802. this.operators[conditionLocation + 1] = 'jz';
  24803. } else {
  24804. error('PS Function: error parsing conditional.');
  24805. }
  24806. }
  24807. };
  24808. return PostScriptParser;
  24809. }();
  24810. var PostScriptTokenTypes = {
  24811. LBRACE: 0,
  24812. RBRACE: 1,
  24813. NUMBER: 2,
  24814. OPERATOR: 3,
  24815. IF: 4,
  24816. IFELSE: 5
  24817. };
  24818. var PostScriptToken = function PostScriptTokenClosure() {
  24819. function PostScriptToken(type, value) {
  24820. this.type = type;
  24821. this.value = value;
  24822. }
  24823. var opCache = Object.create(null);
  24824. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  24825. var opValue = opCache[op];
  24826. if (opValue) {
  24827. return opValue;
  24828. }
  24829. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  24830. };
  24831. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  24832. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  24833. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  24834. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  24835. return PostScriptToken;
  24836. }();
  24837. var PostScriptLexer = function PostScriptLexerClosure() {
  24838. function PostScriptLexer(stream) {
  24839. this.stream = stream;
  24840. this.nextChar();
  24841. this.strBuf = [];
  24842. }
  24843. PostScriptLexer.prototype = {
  24844. nextChar: function PostScriptLexer_nextChar() {
  24845. return this.currentChar = this.stream.getByte();
  24846. },
  24847. getToken: function PostScriptLexer_getToken() {
  24848. var comment = false;
  24849. var ch = this.currentChar;
  24850. while (true) {
  24851. if (ch < 0) {
  24852. return EOF;
  24853. }
  24854. if (comment) {
  24855. if (ch === 0x0A || ch === 0x0D) {
  24856. comment = false;
  24857. }
  24858. } else if (ch === 0x25) {
  24859. comment = true;
  24860. } else if (!isSpace(ch)) {
  24861. break;
  24862. }
  24863. ch = this.nextChar();
  24864. }
  24865. switch (ch | 0) {
  24866. case 0x30:
  24867. case 0x31:
  24868. case 0x32:
  24869. case 0x33:
  24870. case 0x34:
  24871. case 0x35:
  24872. case 0x36:
  24873. case 0x37:
  24874. case 0x38:
  24875. case 0x39:
  24876. case 0x2B:
  24877. case 0x2D:
  24878. case 0x2E:
  24879. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  24880. case 0x7B:
  24881. this.nextChar();
  24882. return PostScriptToken.LBRACE;
  24883. case 0x7D:
  24884. this.nextChar();
  24885. return PostScriptToken.RBRACE;
  24886. }
  24887. var strBuf = this.strBuf;
  24888. strBuf.length = 0;
  24889. strBuf[0] = String.fromCharCode(ch);
  24890. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  24891. strBuf.push(String.fromCharCode(ch));
  24892. }
  24893. var str = strBuf.join('');
  24894. switch (str.toLowerCase()) {
  24895. case 'if':
  24896. return PostScriptToken.IF;
  24897. case 'ifelse':
  24898. return PostScriptToken.IFELSE;
  24899. default:
  24900. return PostScriptToken.getOperator(str);
  24901. }
  24902. },
  24903. getNumber: function PostScriptLexer_getNumber() {
  24904. var ch = this.currentChar;
  24905. var strBuf = this.strBuf;
  24906. strBuf.length = 0;
  24907. strBuf[0] = String.fromCharCode(ch);
  24908. while ((ch = this.nextChar()) >= 0) {
  24909. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  24910. strBuf.push(String.fromCharCode(ch));
  24911. } else {
  24912. break;
  24913. }
  24914. }
  24915. var value = parseFloat(strBuf.join(''));
  24916. if (isNaN(value)) {
  24917. error('Invalid floating point number: ' + value);
  24918. }
  24919. return value;
  24920. }
  24921. };
  24922. return PostScriptLexer;
  24923. }();
  24924. exports.PostScriptLexer = PostScriptLexer;
  24925. exports.PostScriptParser = PostScriptParser;
  24926. }));
  24927. (function (root, factory) {
  24928. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24929. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24930. var Util = sharedUtil.Util;
  24931. var error = sharedUtil.error;
  24932. var info = sharedUtil.info;
  24933. var isInt = sharedUtil.isInt;
  24934. var isArray = sharedUtil.isArray;
  24935. var createObjectURL = sharedUtil.createObjectURL;
  24936. var shadow = sharedUtil.shadow;
  24937. var isSpace = sharedUtil.isSpace;
  24938. var Dict = corePrimitives.Dict;
  24939. var isDict = corePrimitives.isDict;
  24940. var isStream = corePrimitives.isStream;
  24941. var Jbig2Image = coreJbig2.Jbig2Image;
  24942. var JpegImage = coreJpg.JpegImage;
  24943. var JpxImage = coreJpx.JpxImage;
  24944. var Stream = function StreamClosure() {
  24945. function Stream(arrayBuffer, start, length, dict) {
  24946. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24947. this.start = start || 0;
  24948. this.pos = this.start;
  24949. this.end = start + length || this.bytes.length;
  24950. this.dict = dict;
  24951. }
  24952. Stream.prototype = {
  24953. get length() {
  24954. return this.end - this.start;
  24955. },
  24956. get isEmpty() {
  24957. return this.length === 0;
  24958. },
  24959. getByte: function Stream_getByte() {
  24960. if (this.pos >= this.end) {
  24961. return -1;
  24962. }
  24963. return this.bytes[this.pos++];
  24964. },
  24965. getUint16: function Stream_getUint16() {
  24966. var b0 = this.getByte();
  24967. var b1 = this.getByte();
  24968. if (b0 === -1 || b1 === -1) {
  24969. return -1;
  24970. }
  24971. return (b0 << 8) + b1;
  24972. },
  24973. getInt32: function Stream_getInt32() {
  24974. var b0 = this.getByte();
  24975. var b1 = this.getByte();
  24976. var b2 = this.getByte();
  24977. var b3 = this.getByte();
  24978. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24979. },
  24980. getBytes: function Stream_getBytes(length) {
  24981. var bytes = this.bytes;
  24982. var pos = this.pos;
  24983. var strEnd = this.end;
  24984. if (!length) {
  24985. return bytes.subarray(pos, strEnd);
  24986. }
  24987. var end = pos + length;
  24988. if (end > strEnd) {
  24989. end = strEnd;
  24990. }
  24991. this.pos = end;
  24992. return bytes.subarray(pos, end);
  24993. },
  24994. peekByte: function Stream_peekByte() {
  24995. var peekedByte = this.getByte();
  24996. this.pos--;
  24997. return peekedByte;
  24998. },
  24999. peekBytes: function Stream_peekBytes(length) {
  25000. var bytes = this.getBytes(length);
  25001. this.pos -= bytes.length;
  25002. return bytes;
  25003. },
  25004. skip: function Stream_skip(n) {
  25005. if (!n) {
  25006. n = 1;
  25007. }
  25008. this.pos += n;
  25009. },
  25010. reset: function Stream_reset() {
  25011. this.pos = this.start;
  25012. },
  25013. moveStart: function Stream_moveStart() {
  25014. this.start = this.pos;
  25015. },
  25016. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  25017. return new Stream(this.bytes.buffer, start, length, dict);
  25018. }
  25019. };
  25020. return Stream;
  25021. }();
  25022. var StringStream = function StringStreamClosure() {
  25023. function StringStream(str) {
  25024. var length = str.length;
  25025. var bytes = new Uint8Array(length);
  25026. for (var n = 0; n < length; ++n) {
  25027. bytes[n] = str.charCodeAt(n);
  25028. }
  25029. Stream.call(this, bytes);
  25030. }
  25031. StringStream.prototype = Stream.prototype;
  25032. return StringStream;
  25033. }();
  25034. var DecodeStream = function DecodeStreamClosure() {
  25035. var emptyBuffer = new Uint8Array(0);
  25036. function DecodeStream(maybeMinBufferLength) {
  25037. this.pos = 0;
  25038. this.bufferLength = 0;
  25039. this.eof = false;
  25040. this.buffer = emptyBuffer;
  25041. this.minBufferLength = 512;
  25042. if (maybeMinBufferLength) {
  25043. while (this.minBufferLength < maybeMinBufferLength) {
  25044. this.minBufferLength *= 2;
  25045. }
  25046. }
  25047. }
  25048. DecodeStream.prototype = {
  25049. get isEmpty() {
  25050. while (!this.eof && this.bufferLength === 0) {
  25051. this.readBlock();
  25052. }
  25053. return this.bufferLength === 0;
  25054. },
  25055. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  25056. var buffer = this.buffer;
  25057. if (requested <= buffer.byteLength) {
  25058. return buffer;
  25059. }
  25060. var size = this.minBufferLength;
  25061. while (size < requested) {
  25062. size *= 2;
  25063. }
  25064. var buffer2 = new Uint8Array(size);
  25065. buffer2.set(buffer);
  25066. return this.buffer = buffer2;
  25067. },
  25068. getByte: function DecodeStream_getByte() {
  25069. var pos = this.pos;
  25070. while (this.bufferLength <= pos) {
  25071. if (this.eof) {
  25072. return -1;
  25073. }
  25074. this.readBlock();
  25075. }
  25076. return this.buffer[this.pos++];
  25077. },
  25078. getUint16: function DecodeStream_getUint16() {
  25079. var b0 = this.getByte();
  25080. var b1 = this.getByte();
  25081. if (b0 === -1 || b1 === -1) {
  25082. return -1;
  25083. }
  25084. return (b0 << 8) + b1;
  25085. },
  25086. getInt32: function DecodeStream_getInt32() {
  25087. var b0 = this.getByte();
  25088. var b1 = this.getByte();
  25089. var b2 = this.getByte();
  25090. var b3 = this.getByte();
  25091. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  25092. },
  25093. getBytes: function DecodeStream_getBytes(length) {
  25094. var end, pos = this.pos;
  25095. if (length) {
  25096. this.ensureBuffer(pos + length);
  25097. end = pos + length;
  25098. while (!this.eof && this.bufferLength < end) {
  25099. this.readBlock();
  25100. }
  25101. var bufEnd = this.bufferLength;
  25102. if (end > bufEnd) {
  25103. end = bufEnd;
  25104. }
  25105. } else {
  25106. while (!this.eof) {
  25107. this.readBlock();
  25108. }
  25109. end = this.bufferLength;
  25110. }
  25111. this.pos = end;
  25112. return this.buffer.subarray(pos, end);
  25113. },
  25114. peekByte: function DecodeStream_peekByte() {
  25115. var peekedByte = this.getByte();
  25116. this.pos--;
  25117. return peekedByte;
  25118. },
  25119. peekBytes: function DecodeStream_peekBytes(length) {
  25120. var bytes = this.getBytes(length);
  25121. this.pos -= bytes.length;
  25122. return bytes;
  25123. },
  25124. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  25125. var end = start + length;
  25126. while (this.bufferLength <= end && !this.eof) {
  25127. this.readBlock();
  25128. }
  25129. return new Stream(this.buffer, start, length, dict);
  25130. },
  25131. skip: function DecodeStream_skip(n) {
  25132. if (!n) {
  25133. n = 1;
  25134. }
  25135. this.pos += n;
  25136. },
  25137. reset: function DecodeStream_reset() {
  25138. this.pos = 0;
  25139. },
  25140. getBaseStreams: function DecodeStream_getBaseStreams() {
  25141. if (this.str && this.str.getBaseStreams) {
  25142. return this.str.getBaseStreams();
  25143. }
  25144. return [];
  25145. }
  25146. };
  25147. return DecodeStream;
  25148. }();
  25149. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  25150. function StreamsSequenceStream(streams) {
  25151. this.streams = streams;
  25152. DecodeStream.call(this, null);
  25153. }
  25154. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  25155. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  25156. var streams = this.streams;
  25157. if (streams.length === 0) {
  25158. this.eof = true;
  25159. return;
  25160. }
  25161. var stream = streams.shift();
  25162. var chunk = stream.getBytes();
  25163. var bufferLength = this.bufferLength;
  25164. var newLength = bufferLength + chunk.length;
  25165. var buffer = this.ensureBuffer(newLength);
  25166. buffer.set(chunk, bufferLength);
  25167. this.bufferLength = newLength;
  25168. };
  25169. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  25170. var baseStreams = [];
  25171. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  25172. var stream = this.streams[i];
  25173. if (stream.getBaseStreams) {
  25174. Util.appendToArray(baseStreams, stream.getBaseStreams());
  25175. }
  25176. }
  25177. return baseStreams;
  25178. };
  25179. return StreamsSequenceStream;
  25180. }();
  25181. var FlateStream = function FlateStreamClosure() {
  25182. var codeLenCodeMap = new Int32Array([
  25183. 16,
  25184. 17,
  25185. 18,
  25186. 0,
  25187. 8,
  25188. 7,
  25189. 9,
  25190. 6,
  25191. 10,
  25192. 5,
  25193. 11,
  25194. 4,
  25195. 12,
  25196. 3,
  25197. 13,
  25198. 2,
  25199. 14,
  25200. 1,
  25201. 15
  25202. ]);
  25203. var lengthDecode = new Int32Array([
  25204. 0x00003,
  25205. 0x00004,
  25206. 0x00005,
  25207. 0x00006,
  25208. 0x00007,
  25209. 0x00008,
  25210. 0x00009,
  25211. 0x0000a,
  25212. 0x1000b,
  25213. 0x1000d,
  25214. 0x1000f,
  25215. 0x10011,
  25216. 0x20013,
  25217. 0x20017,
  25218. 0x2001b,
  25219. 0x2001f,
  25220. 0x30023,
  25221. 0x3002b,
  25222. 0x30033,
  25223. 0x3003b,
  25224. 0x40043,
  25225. 0x40053,
  25226. 0x40063,
  25227. 0x40073,
  25228. 0x50083,
  25229. 0x500a3,
  25230. 0x500c3,
  25231. 0x500e3,
  25232. 0x00102,
  25233. 0x00102,
  25234. 0x00102
  25235. ]);
  25236. var distDecode = new Int32Array([
  25237. 0x00001,
  25238. 0x00002,
  25239. 0x00003,
  25240. 0x00004,
  25241. 0x10005,
  25242. 0x10007,
  25243. 0x20009,
  25244. 0x2000d,
  25245. 0x30011,
  25246. 0x30019,
  25247. 0x40021,
  25248. 0x40031,
  25249. 0x50041,
  25250. 0x50061,
  25251. 0x60081,
  25252. 0x600c1,
  25253. 0x70101,
  25254. 0x70181,
  25255. 0x80201,
  25256. 0x80301,
  25257. 0x90401,
  25258. 0x90601,
  25259. 0xa0801,
  25260. 0xa0c01,
  25261. 0xb1001,
  25262. 0xb1801,
  25263. 0xc2001,
  25264. 0xc3001,
  25265. 0xd4001,
  25266. 0xd6001
  25267. ]);
  25268. var fixedLitCodeTab = [
  25269. new Int32Array([
  25270. 0x70100,
  25271. 0x80050,
  25272. 0x80010,
  25273. 0x80118,
  25274. 0x70110,
  25275. 0x80070,
  25276. 0x80030,
  25277. 0x900c0,
  25278. 0x70108,
  25279. 0x80060,
  25280. 0x80020,
  25281. 0x900a0,
  25282. 0x80000,
  25283. 0x80080,
  25284. 0x80040,
  25285. 0x900e0,
  25286. 0x70104,
  25287. 0x80058,
  25288. 0x80018,
  25289. 0x90090,
  25290. 0x70114,
  25291. 0x80078,
  25292. 0x80038,
  25293. 0x900d0,
  25294. 0x7010c,
  25295. 0x80068,
  25296. 0x80028,
  25297. 0x900b0,
  25298. 0x80008,
  25299. 0x80088,
  25300. 0x80048,
  25301. 0x900f0,
  25302. 0x70102,
  25303. 0x80054,
  25304. 0x80014,
  25305. 0x8011c,
  25306. 0x70112,
  25307. 0x80074,
  25308. 0x80034,
  25309. 0x900c8,
  25310. 0x7010a,
  25311. 0x80064,
  25312. 0x80024,
  25313. 0x900a8,
  25314. 0x80004,
  25315. 0x80084,
  25316. 0x80044,
  25317. 0x900e8,
  25318. 0x70106,
  25319. 0x8005c,
  25320. 0x8001c,
  25321. 0x90098,
  25322. 0x70116,
  25323. 0x8007c,
  25324. 0x8003c,
  25325. 0x900d8,
  25326. 0x7010e,
  25327. 0x8006c,
  25328. 0x8002c,
  25329. 0x900b8,
  25330. 0x8000c,
  25331. 0x8008c,
  25332. 0x8004c,
  25333. 0x900f8,
  25334. 0x70101,
  25335. 0x80052,
  25336. 0x80012,
  25337. 0x8011a,
  25338. 0x70111,
  25339. 0x80072,
  25340. 0x80032,
  25341. 0x900c4,
  25342. 0x70109,
  25343. 0x80062,
  25344. 0x80022,
  25345. 0x900a4,
  25346. 0x80002,
  25347. 0x80082,
  25348. 0x80042,
  25349. 0x900e4,
  25350. 0x70105,
  25351. 0x8005a,
  25352. 0x8001a,
  25353. 0x90094,
  25354. 0x70115,
  25355. 0x8007a,
  25356. 0x8003a,
  25357. 0x900d4,
  25358. 0x7010d,
  25359. 0x8006a,
  25360. 0x8002a,
  25361. 0x900b4,
  25362. 0x8000a,
  25363. 0x8008a,
  25364. 0x8004a,
  25365. 0x900f4,
  25366. 0x70103,
  25367. 0x80056,
  25368. 0x80016,
  25369. 0x8011e,
  25370. 0x70113,
  25371. 0x80076,
  25372. 0x80036,
  25373. 0x900cc,
  25374. 0x7010b,
  25375. 0x80066,
  25376. 0x80026,
  25377. 0x900ac,
  25378. 0x80006,
  25379. 0x80086,
  25380. 0x80046,
  25381. 0x900ec,
  25382. 0x70107,
  25383. 0x8005e,
  25384. 0x8001e,
  25385. 0x9009c,
  25386. 0x70117,
  25387. 0x8007e,
  25388. 0x8003e,
  25389. 0x900dc,
  25390. 0x7010f,
  25391. 0x8006e,
  25392. 0x8002e,
  25393. 0x900bc,
  25394. 0x8000e,
  25395. 0x8008e,
  25396. 0x8004e,
  25397. 0x900fc,
  25398. 0x70100,
  25399. 0x80051,
  25400. 0x80011,
  25401. 0x80119,
  25402. 0x70110,
  25403. 0x80071,
  25404. 0x80031,
  25405. 0x900c2,
  25406. 0x70108,
  25407. 0x80061,
  25408. 0x80021,
  25409. 0x900a2,
  25410. 0x80001,
  25411. 0x80081,
  25412. 0x80041,
  25413. 0x900e2,
  25414. 0x70104,
  25415. 0x80059,
  25416. 0x80019,
  25417. 0x90092,
  25418. 0x70114,
  25419. 0x80079,
  25420. 0x80039,
  25421. 0x900d2,
  25422. 0x7010c,
  25423. 0x80069,
  25424. 0x80029,
  25425. 0x900b2,
  25426. 0x80009,
  25427. 0x80089,
  25428. 0x80049,
  25429. 0x900f2,
  25430. 0x70102,
  25431. 0x80055,
  25432. 0x80015,
  25433. 0x8011d,
  25434. 0x70112,
  25435. 0x80075,
  25436. 0x80035,
  25437. 0x900ca,
  25438. 0x7010a,
  25439. 0x80065,
  25440. 0x80025,
  25441. 0x900aa,
  25442. 0x80005,
  25443. 0x80085,
  25444. 0x80045,
  25445. 0x900ea,
  25446. 0x70106,
  25447. 0x8005d,
  25448. 0x8001d,
  25449. 0x9009a,
  25450. 0x70116,
  25451. 0x8007d,
  25452. 0x8003d,
  25453. 0x900da,
  25454. 0x7010e,
  25455. 0x8006d,
  25456. 0x8002d,
  25457. 0x900ba,
  25458. 0x8000d,
  25459. 0x8008d,
  25460. 0x8004d,
  25461. 0x900fa,
  25462. 0x70101,
  25463. 0x80053,
  25464. 0x80013,
  25465. 0x8011b,
  25466. 0x70111,
  25467. 0x80073,
  25468. 0x80033,
  25469. 0x900c6,
  25470. 0x70109,
  25471. 0x80063,
  25472. 0x80023,
  25473. 0x900a6,
  25474. 0x80003,
  25475. 0x80083,
  25476. 0x80043,
  25477. 0x900e6,
  25478. 0x70105,
  25479. 0x8005b,
  25480. 0x8001b,
  25481. 0x90096,
  25482. 0x70115,
  25483. 0x8007b,
  25484. 0x8003b,
  25485. 0x900d6,
  25486. 0x7010d,
  25487. 0x8006b,
  25488. 0x8002b,
  25489. 0x900b6,
  25490. 0x8000b,
  25491. 0x8008b,
  25492. 0x8004b,
  25493. 0x900f6,
  25494. 0x70103,
  25495. 0x80057,
  25496. 0x80017,
  25497. 0x8011f,
  25498. 0x70113,
  25499. 0x80077,
  25500. 0x80037,
  25501. 0x900ce,
  25502. 0x7010b,
  25503. 0x80067,
  25504. 0x80027,
  25505. 0x900ae,
  25506. 0x80007,
  25507. 0x80087,
  25508. 0x80047,
  25509. 0x900ee,
  25510. 0x70107,
  25511. 0x8005f,
  25512. 0x8001f,
  25513. 0x9009e,
  25514. 0x70117,
  25515. 0x8007f,
  25516. 0x8003f,
  25517. 0x900de,
  25518. 0x7010f,
  25519. 0x8006f,
  25520. 0x8002f,
  25521. 0x900be,
  25522. 0x8000f,
  25523. 0x8008f,
  25524. 0x8004f,
  25525. 0x900fe,
  25526. 0x70100,
  25527. 0x80050,
  25528. 0x80010,
  25529. 0x80118,
  25530. 0x70110,
  25531. 0x80070,
  25532. 0x80030,
  25533. 0x900c1,
  25534. 0x70108,
  25535. 0x80060,
  25536. 0x80020,
  25537. 0x900a1,
  25538. 0x80000,
  25539. 0x80080,
  25540. 0x80040,
  25541. 0x900e1,
  25542. 0x70104,
  25543. 0x80058,
  25544. 0x80018,
  25545. 0x90091,
  25546. 0x70114,
  25547. 0x80078,
  25548. 0x80038,
  25549. 0x900d1,
  25550. 0x7010c,
  25551. 0x80068,
  25552. 0x80028,
  25553. 0x900b1,
  25554. 0x80008,
  25555. 0x80088,
  25556. 0x80048,
  25557. 0x900f1,
  25558. 0x70102,
  25559. 0x80054,
  25560. 0x80014,
  25561. 0x8011c,
  25562. 0x70112,
  25563. 0x80074,
  25564. 0x80034,
  25565. 0x900c9,
  25566. 0x7010a,
  25567. 0x80064,
  25568. 0x80024,
  25569. 0x900a9,
  25570. 0x80004,
  25571. 0x80084,
  25572. 0x80044,
  25573. 0x900e9,
  25574. 0x70106,
  25575. 0x8005c,
  25576. 0x8001c,
  25577. 0x90099,
  25578. 0x70116,
  25579. 0x8007c,
  25580. 0x8003c,
  25581. 0x900d9,
  25582. 0x7010e,
  25583. 0x8006c,
  25584. 0x8002c,
  25585. 0x900b9,
  25586. 0x8000c,
  25587. 0x8008c,
  25588. 0x8004c,
  25589. 0x900f9,
  25590. 0x70101,
  25591. 0x80052,
  25592. 0x80012,
  25593. 0x8011a,
  25594. 0x70111,
  25595. 0x80072,
  25596. 0x80032,
  25597. 0x900c5,
  25598. 0x70109,
  25599. 0x80062,
  25600. 0x80022,
  25601. 0x900a5,
  25602. 0x80002,
  25603. 0x80082,
  25604. 0x80042,
  25605. 0x900e5,
  25606. 0x70105,
  25607. 0x8005a,
  25608. 0x8001a,
  25609. 0x90095,
  25610. 0x70115,
  25611. 0x8007a,
  25612. 0x8003a,
  25613. 0x900d5,
  25614. 0x7010d,
  25615. 0x8006a,
  25616. 0x8002a,
  25617. 0x900b5,
  25618. 0x8000a,
  25619. 0x8008a,
  25620. 0x8004a,
  25621. 0x900f5,
  25622. 0x70103,
  25623. 0x80056,
  25624. 0x80016,
  25625. 0x8011e,
  25626. 0x70113,
  25627. 0x80076,
  25628. 0x80036,
  25629. 0x900cd,
  25630. 0x7010b,
  25631. 0x80066,
  25632. 0x80026,
  25633. 0x900ad,
  25634. 0x80006,
  25635. 0x80086,
  25636. 0x80046,
  25637. 0x900ed,
  25638. 0x70107,
  25639. 0x8005e,
  25640. 0x8001e,
  25641. 0x9009d,
  25642. 0x70117,
  25643. 0x8007e,
  25644. 0x8003e,
  25645. 0x900dd,
  25646. 0x7010f,
  25647. 0x8006e,
  25648. 0x8002e,
  25649. 0x900bd,
  25650. 0x8000e,
  25651. 0x8008e,
  25652. 0x8004e,
  25653. 0x900fd,
  25654. 0x70100,
  25655. 0x80051,
  25656. 0x80011,
  25657. 0x80119,
  25658. 0x70110,
  25659. 0x80071,
  25660. 0x80031,
  25661. 0x900c3,
  25662. 0x70108,
  25663. 0x80061,
  25664. 0x80021,
  25665. 0x900a3,
  25666. 0x80001,
  25667. 0x80081,
  25668. 0x80041,
  25669. 0x900e3,
  25670. 0x70104,
  25671. 0x80059,
  25672. 0x80019,
  25673. 0x90093,
  25674. 0x70114,
  25675. 0x80079,
  25676. 0x80039,
  25677. 0x900d3,
  25678. 0x7010c,
  25679. 0x80069,
  25680. 0x80029,
  25681. 0x900b3,
  25682. 0x80009,
  25683. 0x80089,
  25684. 0x80049,
  25685. 0x900f3,
  25686. 0x70102,
  25687. 0x80055,
  25688. 0x80015,
  25689. 0x8011d,
  25690. 0x70112,
  25691. 0x80075,
  25692. 0x80035,
  25693. 0x900cb,
  25694. 0x7010a,
  25695. 0x80065,
  25696. 0x80025,
  25697. 0x900ab,
  25698. 0x80005,
  25699. 0x80085,
  25700. 0x80045,
  25701. 0x900eb,
  25702. 0x70106,
  25703. 0x8005d,
  25704. 0x8001d,
  25705. 0x9009b,
  25706. 0x70116,
  25707. 0x8007d,
  25708. 0x8003d,
  25709. 0x900db,
  25710. 0x7010e,
  25711. 0x8006d,
  25712. 0x8002d,
  25713. 0x900bb,
  25714. 0x8000d,
  25715. 0x8008d,
  25716. 0x8004d,
  25717. 0x900fb,
  25718. 0x70101,
  25719. 0x80053,
  25720. 0x80013,
  25721. 0x8011b,
  25722. 0x70111,
  25723. 0x80073,
  25724. 0x80033,
  25725. 0x900c7,
  25726. 0x70109,
  25727. 0x80063,
  25728. 0x80023,
  25729. 0x900a7,
  25730. 0x80003,
  25731. 0x80083,
  25732. 0x80043,
  25733. 0x900e7,
  25734. 0x70105,
  25735. 0x8005b,
  25736. 0x8001b,
  25737. 0x90097,
  25738. 0x70115,
  25739. 0x8007b,
  25740. 0x8003b,
  25741. 0x900d7,
  25742. 0x7010d,
  25743. 0x8006b,
  25744. 0x8002b,
  25745. 0x900b7,
  25746. 0x8000b,
  25747. 0x8008b,
  25748. 0x8004b,
  25749. 0x900f7,
  25750. 0x70103,
  25751. 0x80057,
  25752. 0x80017,
  25753. 0x8011f,
  25754. 0x70113,
  25755. 0x80077,
  25756. 0x80037,
  25757. 0x900cf,
  25758. 0x7010b,
  25759. 0x80067,
  25760. 0x80027,
  25761. 0x900af,
  25762. 0x80007,
  25763. 0x80087,
  25764. 0x80047,
  25765. 0x900ef,
  25766. 0x70107,
  25767. 0x8005f,
  25768. 0x8001f,
  25769. 0x9009f,
  25770. 0x70117,
  25771. 0x8007f,
  25772. 0x8003f,
  25773. 0x900df,
  25774. 0x7010f,
  25775. 0x8006f,
  25776. 0x8002f,
  25777. 0x900bf,
  25778. 0x8000f,
  25779. 0x8008f,
  25780. 0x8004f,
  25781. 0x900ff
  25782. ]),
  25783. 9
  25784. ];
  25785. var fixedDistCodeTab = [
  25786. new Int32Array([
  25787. 0x50000,
  25788. 0x50010,
  25789. 0x50008,
  25790. 0x50018,
  25791. 0x50004,
  25792. 0x50014,
  25793. 0x5000c,
  25794. 0x5001c,
  25795. 0x50002,
  25796. 0x50012,
  25797. 0x5000a,
  25798. 0x5001a,
  25799. 0x50006,
  25800. 0x50016,
  25801. 0x5000e,
  25802. 0x00000,
  25803. 0x50001,
  25804. 0x50011,
  25805. 0x50009,
  25806. 0x50019,
  25807. 0x50005,
  25808. 0x50015,
  25809. 0x5000d,
  25810. 0x5001d,
  25811. 0x50003,
  25812. 0x50013,
  25813. 0x5000b,
  25814. 0x5001b,
  25815. 0x50007,
  25816. 0x50017,
  25817. 0x5000f,
  25818. 0x00000
  25819. ]),
  25820. 5
  25821. ];
  25822. function FlateStream(str, maybeLength) {
  25823. this.str = str;
  25824. this.dict = str.dict;
  25825. var cmf = str.getByte();
  25826. var flg = str.getByte();
  25827. if (cmf === -1 || flg === -1) {
  25828. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25829. }
  25830. if ((cmf & 0x0f) !== 0x08) {
  25831. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25832. }
  25833. if (((cmf << 8) + flg) % 31 !== 0) {
  25834. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25835. }
  25836. if (flg & 0x20) {
  25837. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25838. }
  25839. this.codeSize = 0;
  25840. this.codeBuf = 0;
  25841. DecodeStream.call(this, maybeLength);
  25842. }
  25843. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25844. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25845. var str = this.str;
  25846. var codeSize = this.codeSize;
  25847. var codeBuf = this.codeBuf;
  25848. var b;
  25849. while (codeSize < bits) {
  25850. if ((b = str.getByte()) === -1) {
  25851. error('Bad encoding in flate stream');
  25852. }
  25853. codeBuf |= b << codeSize;
  25854. codeSize += 8;
  25855. }
  25856. b = codeBuf & (1 << bits) - 1;
  25857. this.codeBuf = codeBuf >> bits;
  25858. this.codeSize = codeSize -= bits;
  25859. return b;
  25860. };
  25861. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25862. var str = this.str;
  25863. var codes = table[0];
  25864. var maxLen = table[1];
  25865. var codeSize = this.codeSize;
  25866. var codeBuf = this.codeBuf;
  25867. var b;
  25868. while (codeSize < maxLen) {
  25869. if ((b = str.getByte()) === -1) {
  25870. break;
  25871. }
  25872. codeBuf |= b << codeSize;
  25873. codeSize += 8;
  25874. }
  25875. var code = codes[codeBuf & (1 << maxLen) - 1];
  25876. var codeLen = code >> 16;
  25877. var codeVal = code & 0xffff;
  25878. if (codeLen < 1 || codeSize < codeLen) {
  25879. error('Bad encoding in flate stream');
  25880. }
  25881. this.codeBuf = codeBuf >> codeLen;
  25882. this.codeSize = codeSize - codeLen;
  25883. return codeVal;
  25884. };
  25885. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25886. var n = lengths.length;
  25887. var maxLen = 0;
  25888. var i;
  25889. for (i = 0; i < n; ++i) {
  25890. if (lengths[i] > maxLen) {
  25891. maxLen = lengths[i];
  25892. }
  25893. }
  25894. var size = 1 << maxLen;
  25895. var codes = new Int32Array(size);
  25896. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25897. for (var val = 0; val < n; ++val) {
  25898. if (lengths[val] === len) {
  25899. var code2 = 0;
  25900. var t = code;
  25901. for (i = 0; i < len; ++i) {
  25902. code2 = code2 << 1 | t & 1;
  25903. t >>= 1;
  25904. }
  25905. for (i = code2; i < size; i += skip) {
  25906. codes[i] = len << 16 | val;
  25907. }
  25908. ++code;
  25909. }
  25910. }
  25911. }
  25912. return [
  25913. codes,
  25914. maxLen
  25915. ];
  25916. };
  25917. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25918. var buffer, len;
  25919. var str = this.str;
  25920. var hdr = this.getBits(3);
  25921. if (hdr & 1) {
  25922. this.eof = true;
  25923. }
  25924. hdr >>= 1;
  25925. if (hdr === 0) {
  25926. var b;
  25927. if ((b = str.getByte()) === -1) {
  25928. error('Bad block header in flate stream');
  25929. }
  25930. var blockLen = b;
  25931. if ((b = str.getByte()) === -1) {
  25932. error('Bad block header in flate stream');
  25933. }
  25934. blockLen |= b << 8;
  25935. if ((b = str.getByte()) === -1) {
  25936. error('Bad block header in flate stream');
  25937. }
  25938. var check = b;
  25939. if ((b = str.getByte()) === -1) {
  25940. error('Bad block header in flate stream');
  25941. }
  25942. check |= b << 8;
  25943. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25944. error('Bad uncompressed block length in flate stream');
  25945. }
  25946. this.codeBuf = 0;
  25947. this.codeSize = 0;
  25948. var bufferLength = this.bufferLength;
  25949. buffer = this.ensureBuffer(bufferLength + blockLen);
  25950. var end = bufferLength + blockLen;
  25951. this.bufferLength = end;
  25952. if (blockLen === 0) {
  25953. if (str.peekByte() === -1) {
  25954. this.eof = true;
  25955. }
  25956. } else {
  25957. for (var n = bufferLength; n < end; ++n) {
  25958. if ((b = str.getByte()) === -1) {
  25959. this.eof = true;
  25960. break;
  25961. }
  25962. buffer[n] = b;
  25963. }
  25964. }
  25965. return;
  25966. }
  25967. var litCodeTable;
  25968. var distCodeTable;
  25969. if (hdr === 1) {
  25970. litCodeTable = fixedLitCodeTab;
  25971. distCodeTable = fixedDistCodeTab;
  25972. } else if (hdr === 2) {
  25973. var numLitCodes = this.getBits(5) + 257;
  25974. var numDistCodes = this.getBits(5) + 1;
  25975. var numCodeLenCodes = this.getBits(4) + 4;
  25976. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25977. var i;
  25978. for (i = 0; i < numCodeLenCodes; ++i) {
  25979. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25980. }
  25981. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25982. len = 0;
  25983. i = 0;
  25984. var codes = numLitCodes + numDistCodes;
  25985. var codeLengths = new Uint8Array(codes);
  25986. var bitsLength, bitsOffset, what;
  25987. while (i < codes) {
  25988. var code = this.getCode(codeLenCodeTab);
  25989. if (code === 16) {
  25990. bitsLength = 2;
  25991. bitsOffset = 3;
  25992. what = len;
  25993. } else if (code === 17) {
  25994. bitsLength = 3;
  25995. bitsOffset = 3;
  25996. what = len = 0;
  25997. } else if (code === 18) {
  25998. bitsLength = 7;
  25999. bitsOffset = 11;
  26000. what = len = 0;
  26001. } else {
  26002. codeLengths[i++] = len = code;
  26003. continue;
  26004. }
  26005. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  26006. while (repeatLength-- > 0) {
  26007. codeLengths[i++] = what;
  26008. }
  26009. }
  26010. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  26011. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  26012. } else {
  26013. error('Unknown block type in flate stream');
  26014. }
  26015. buffer = this.buffer;
  26016. var limit = buffer ? buffer.length : 0;
  26017. var pos = this.bufferLength;
  26018. while (true) {
  26019. var code1 = this.getCode(litCodeTable);
  26020. if (code1 < 256) {
  26021. if (pos + 1 >= limit) {
  26022. buffer = this.ensureBuffer(pos + 1);
  26023. limit = buffer.length;
  26024. }
  26025. buffer[pos++] = code1;
  26026. continue;
  26027. }
  26028. if (code1 === 256) {
  26029. this.bufferLength = pos;
  26030. return;
  26031. }
  26032. code1 -= 257;
  26033. code1 = lengthDecode[code1];
  26034. var code2 = code1 >> 16;
  26035. if (code2 > 0) {
  26036. code2 = this.getBits(code2);
  26037. }
  26038. len = (code1 & 0xffff) + code2;
  26039. code1 = this.getCode(distCodeTable);
  26040. code1 = distDecode[code1];
  26041. code2 = code1 >> 16;
  26042. if (code2 > 0) {
  26043. code2 = this.getBits(code2);
  26044. }
  26045. var dist = (code1 & 0xffff) + code2;
  26046. if (pos + len >= limit) {
  26047. buffer = this.ensureBuffer(pos + len);
  26048. limit = buffer.length;
  26049. }
  26050. for (var k = 0; k < len; ++k, ++pos) {
  26051. buffer[pos] = buffer[pos - dist];
  26052. }
  26053. }
  26054. };
  26055. return FlateStream;
  26056. }();
  26057. var PredictorStream = function PredictorStreamClosure() {
  26058. function PredictorStream(str, maybeLength, params) {
  26059. if (!isDict(params)) {
  26060. return str;
  26061. }
  26062. var predictor = this.predictor = params.get('Predictor') || 1;
  26063. if (predictor <= 1) {
  26064. return str;
  26065. }
  26066. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  26067. error('Unsupported predictor: ' + predictor);
  26068. }
  26069. if (predictor === 2) {
  26070. this.readBlock = this.readBlockTiff;
  26071. } else {
  26072. this.readBlock = this.readBlockPng;
  26073. }
  26074. this.str = str;
  26075. this.dict = str.dict;
  26076. var colors = this.colors = params.get('Colors') || 1;
  26077. var bits = this.bits = params.get('BitsPerComponent') || 8;
  26078. var columns = this.columns = params.get('Columns') || 1;
  26079. this.pixBytes = colors * bits + 7 >> 3;
  26080. this.rowBytes = columns * colors * bits + 7 >> 3;
  26081. DecodeStream.call(this, maybeLength);
  26082. return this;
  26083. }
  26084. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  26085. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  26086. var rowBytes = this.rowBytes;
  26087. var bufferLength = this.bufferLength;
  26088. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  26089. var bits = this.bits;
  26090. var colors = this.colors;
  26091. var rawBytes = this.str.getBytes(rowBytes);
  26092. this.eof = !rawBytes.length;
  26093. if (this.eof) {
  26094. return;
  26095. }
  26096. var inbuf = 0, outbuf = 0;
  26097. var inbits = 0, outbits = 0;
  26098. var pos = bufferLength;
  26099. var i;
  26100. if (bits === 1 && colors === 1) {
  26101. for (i = 0; i < rowBytes; ++i) {
  26102. var c = rawBytes[i] ^ inbuf;
  26103. c ^= c >> 1;
  26104. c ^= c >> 2;
  26105. c ^= c >> 4;
  26106. inbuf = (c & 1) << 7;
  26107. buffer[pos++] = c;
  26108. }
  26109. } else if (bits === 8) {
  26110. for (i = 0; i < colors; ++i) {
  26111. buffer[pos++] = rawBytes[i];
  26112. }
  26113. for (; i < rowBytes; ++i) {
  26114. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  26115. pos++;
  26116. }
  26117. } else {
  26118. var compArray = new Uint8Array(colors + 1);
  26119. var bitMask = (1 << bits) - 1;
  26120. var j = 0, k = bufferLength;
  26121. var columns = this.columns;
  26122. for (i = 0; i < columns; ++i) {
  26123. for (var kk = 0; kk < colors; ++kk) {
  26124. if (inbits < bits) {
  26125. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  26126. inbits += 8;
  26127. }
  26128. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  26129. inbits -= bits;
  26130. outbuf = outbuf << bits | compArray[kk];
  26131. outbits += bits;
  26132. if (outbits >= 8) {
  26133. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  26134. outbits -= 8;
  26135. }
  26136. }
  26137. }
  26138. if (outbits > 0) {
  26139. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  26140. }
  26141. }
  26142. this.bufferLength += rowBytes;
  26143. };
  26144. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  26145. var rowBytes = this.rowBytes;
  26146. var pixBytes = this.pixBytes;
  26147. var predictor = this.str.getByte();
  26148. var rawBytes = this.str.getBytes(rowBytes);
  26149. this.eof = !rawBytes.length;
  26150. if (this.eof) {
  26151. return;
  26152. }
  26153. var bufferLength = this.bufferLength;
  26154. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  26155. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  26156. if (prevRow.length === 0) {
  26157. prevRow = new Uint8Array(rowBytes);
  26158. }
  26159. var i, j = bufferLength, up, c;
  26160. switch (predictor) {
  26161. case 0:
  26162. for (i = 0; i < rowBytes; ++i) {
  26163. buffer[j++] = rawBytes[i];
  26164. }
  26165. break;
  26166. case 1:
  26167. for (i = 0; i < pixBytes; ++i) {
  26168. buffer[j++] = rawBytes[i];
  26169. }
  26170. for (; i < rowBytes; ++i) {
  26171. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  26172. j++;
  26173. }
  26174. break;
  26175. case 2:
  26176. for (i = 0; i < rowBytes; ++i) {
  26177. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  26178. }
  26179. break;
  26180. case 3:
  26181. for (i = 0; i < pixBytes; ++i) {
  26182. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  26183. }
  26184. for (; i < rowBytes; ++i) {
  26185. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  26186. j++;
  26187. }
  26188. break;
  26189. case 4:
  26190. for (i = 0; i < pixBytes; ++i) {
  26191. up = prevRow[i];
  26192. c = rawBytes[i];
  26193. buffer[j++] = up + c;
  26194. }
  26195. for (; i < rowBytes; ++i) {
  26196. up = prevRow[i];
  26197. var upLeft = prevRow[i - pixBytes];
  26198. var left = buffer[j - pixBytes];
  26199. var p = left + up - upLeft;
  26200. var pa = p - left;
  26201. if (pa < 0) {
  26202. pa = -pa;
  26203. }
  26204. var pb = p - up;
  26205. if (pb < 0) {
  26206. pb = -pb;
  26207. }
  26208. var pc = p - upLeft;
  26209. if (pc < 0) {
  26210. pc = -pc;
  26211. }
  26212. c = rawBytes[i];
  26213. if (pa <= pb && pa <= pc) {
  26214. buffer[j++] = left + c;
  26215. } else if (pb <= pc) {
  26216. buffer[j++] = up + c;
  26217. } else {
  26218. buffer[j++] = upLeft + c;
  26219. }
  26220. }
  26221. break;
  26222. default:
  26223. error('Unsupported predictor: ' + predictor);
  26224. }
  26225. this.bufferLength += rowBytes;
  26226. };
  26227. return PredictorStream;
  26228. }();
  26229. var JpegStream = function JpegStreamClosure() {
  26230. function JpegStream(stream, maybeLength, dict, params) {
  26231. var ch;
  26232. while ((ch = stream.getByte()) !== -1) {
  26233. if (ch === 0xFF) {
  26234. stream.skip(-1);
  26235. break;
  26236. }
  26237. }
  26238. this.stream = stream;
  26239. this.maybeLength = maybeLength;
  26240. this.dict = dict;
  26241. this.params = params;
  26242. DecodeStream.call(this, maybeLength);
  26243. }
  26244. JpegStream.prototype = Object.create(DecodeStream.prototype);
  26245. Object.defineProperty(JpegStream.prototype, 'bytes', {
  26246. get: function JpegStream_bytes() {
  26247. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26248. },
  26249. configurable: true
  26250. });
  26251. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  26252. if (this.bufferLength) {
  26253. return;
  26254. }
  26255. var jpegImage = new JpegImage();
  26256. var decodeArr = this.dict.getArray('Decode', 'D');
  26257. if (this.forceRGB && isArray(decodeArr)) {
  26258. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  26259. var decodeArrLength = decodeArr.length;
  26260. var transform = new Int32Array(decodeArrLength);
  26261. var transformNeeded = false;
  26262. var maxValue = (1 << bitsPerComponent) - 1;
  26263. for (var i = 0; i < decodeArrLength; i += 2) {
  26264. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  26265. transform[i + 1] = decodeArr[i] * maxValue | 0;
  26266. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  26267. transformNeeded = true;
  26268. }
  26269. }
  26270. if (transformNeeded) {
  26271. jpegImage.decodeTransform = transform;
  26272. }
  26273. }
  26274. if (isDict(this.params)) {
  26275. var colorTransform = this.params.get('ColorTransform');
  26276. if (isInt(colorTransform)) {
  26277. jpegImage.colorTransform = colorTransform;
  26278. }
  26279. }
  26280. jpegImage.parse(this.bytes);
  26281. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  26282. this.buffer = data;
  26283. this.bufferLength = data.length;
  26284. this.eof = true;
  26285. };
  26286. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  26287. this.ensureBuffer();
  26288. return this.buffer;
  26289. };
  26290. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  26291. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  26292. };
  26293. return JpegStream;
  26294. }();
  26295. var JpxStream = function JpxStreamClosure() {
  26296. function JpxStream(stream, maybeLength, dict, params) {
  26297. this.stream = stream;
  26298. this.maybeLength = maybeLength;
  26299. this.dict = dict;
  26300. this.params = params;
  26301. DecodeStream.call(this, maybeLength);
  26302. }
  26303. JpxStream.prototype = Object.create(DecodeStream.prototype);
  26304. Object.defineProperty(JpxStream.prototype, 'bytes', {
  26305. get: function JpxStream_bytes() {
  26306. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26307. },
  26308. configurable: true
  26309. });
  26310. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  26311. if (this.bufferLength) {
  26312. return;
  26313. }
  26314. var jpxImage = new JpxImage();
  26315. jpxImage.parse(this.bytes);
  26316. var width = jpxImage.width;
  26317. var height = jpxImage.height;
  26318. var componentsCount = jpxImage.componentsCount;
  26319. var tileCount = jpxImage.tiles.length;
  26320. if (tileCount === 1) {
  26321. this.buffer = jpxImage.tiles[0].items;
  26322. } else {
  26323. var data = new Uint8Array(width * height * componentsCount);
  26324. for (var k = 0; k < tileCount; k++) {
  26325. var tileComponents = jpxImage.tiles[k];
  26326. var tileWidth = tileComponents.width;
  26327. var tileHeight = tileComponents.height;
  26328. var tileLeft = tileComponents.left;
  26329. var tileTop = tileComponents.top;
  26330. var src = tileComponents.items;
  26331. var srcPosition = 0;
  26332. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  26333. var imgRowSize = width * componentsCount;
  26334. var tileRowSize = tileWidth * componentsCount;
  26335. for (var j = 0; j < tileHeight; j++) {
  26336. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  26337. data.set(rowBytes, dataPosition);
  26338. srcPosition += tileRowSize;
  26339. dataPosition += imgRowSize;
  26340. }
  26341. }
  26342. this.buffer = data;
  26343. }
  26344. this.bufferLength = this.buffer.length;
  26345. this.eof = true;
  26346. };
  26347. return JpxStream;
  26348. }();
  26349. var Jbig2Stream = function Jbig2StreamClosure() {
  26350. function Jbig2Stream(stream, maybeLength, dict, params) {
  26351. this.stream = stream;
  26352. this.maybeLength = maybeLength;
  26353. this.dict = dict;
  26354. this.params = params;
  26355. DecodeStream.call(this, maybeLength);
  26356. }
  26357. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26358. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26359. get: function Jbig2Stream_bytes() {
  26360. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26361. },
  26362. configurable: true
  26363. });
  26364. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26365. if (this.bufferLength) {
  26366. return;
  26367. }
  26368. var jbig2Image = new Jbig2Image();
  26369. var chunks = [];
  26370. if (isDict(this.params)) {
  26371. var globalsStream = this.params.get('JBIG2Globals');
  26372. if (isStream(globalsStream)) {
  26373. var globals = globalsStream.getBytes();
  26374. chunks.push({
  26375. data: globals,
  26376. start: 0,
  26377. end: globals.length
  26378. });
  26379. }
  26380. }
  26381. chunks.push({
  26382. data: this.bytes,
  26383. start: 0,
  26384. end: this.bytes.length
  26385. });
  26386. var data = jbig2Image.parseChunks(chunks);
  26387. var dataLength = data.length;
  26388. for (var i = 0; i < dataLength; i++) {
  26389. data[i] ^= 0xFF;
  26390. }
  26391. this.buffer = data;
  26392. this.bufferLength = dataLength;
  26393. this.eof = true;
  26394. };
  26395. return Jbig2Stream;
  26396. }();
  26397. var DecryptStream = function DecryptStreamClosure() {
  26398. function DecryptStream(str, maybeLength, decrypt) {
  26399. this.str = str;
  26400. this.dict = str.dict;
  26401. this.decrypt = decrypt;
  26402. this.nextChunk = null;
  26403. this.initialized = false;
  26404. DecodeStream.call(this, maybeLength);
  26405. }
  26406. var chunkSize = 512;
  26407. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26408. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26409. var chunk;
  26410. if (this.initialized) {
  26411. chunk = this.nextChunk;
  26412. } else {
  26413. chunk = this.str.getBytes(chunkSize);
  26414. this.initialized = true;
  26415. }
  26416. if (!chunk || chunk.length === 0) {
  26417. this.eof = true;
  26418. return;
  26419. }
  26420. this.nextChunk = this.str.getBytes(chunkSize);
  26421. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26422. var decrypt = this.decrypt;
  26423. chunk = decrypt(chunk, !hasMoreData);
  26424. var bufferLength = this.bufferLength;
  26425. var i, n = chunk.length;
  26426. var buffer = this.ensureBuffer(bufferLength + n);
  26427. for (i = 0; i < n; i++) {
  26428. buffer[bufferLength++] = chunk[i];
  26429. }
  26430. this.bufferLength = bufferLength;
  26431. };
  26432. return DecryptStream;
  26433. }();
  26434. var Ascii85Stream = function Ascii85StreamClosure() {
  26435. function Ascii85Stream(str, maybeLength) {
  26436. this.str = str;
  26437. this.dict = str.dict;
  26438. this.input = new Uint8Array(5);
  26439. if (maybeLength) {
  26440. maybeLength = 0.8 * maybeLength;
  26441. }
  26442. DecodeStream.call(this, maybeLength);
  26443. }
  26444. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26445. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26446. var TILDA_CHAR = 0x7E;
  26447. var Z_LOWER_CHAR = 0x7A;
  26448. var EOF = -1;
  26449. var str = this.str;
  26450. var c = str.getByte();
  26451. while (isSpace(c)) {
  26452. c = str.getByte();
  26453. }
  26454. if (c === EOF || c === TILDA_CHAR) {
  26455. this.eof = true;
  26456. return;
  26457. }
  26458. var bufferLength = this.bufferLength, buffer;
  26459. var i;
  26460. if (c === Z_LOWER_CHAR) {
  26461. buffer = this.ensureBuffer(bufferLength + 4);
  26462. for (i = 0; i < 4; ++i) {
  26463. buffer[bufferLength + i] = 0;
  26464. }
  26465. this.bufferLength += 4;
  26466. } else {
  26467. var input = this.input;
  26468. input[0] = c;
  26469. for (i = 1; i < 5; ++i) {
  26470. c = str.getByte();
  26471. while (isSpace(c)) {
  26472. c = str.getByte();
  26473. }
  26474. input[i] = c;
  26475. if (c === EOF || c === TILDA_CHAR) {
  26476. break;
  26477. }
  26478. }
  26479. buffer = this.ensureBuffer(bufferLength + i - 1);
  26480. this.bufferLength += i - 1;
  26481. if (i < 5) {
  26482. for (; i < 5; ++i) {
  26483. input[i] = 0x21 + 84;
  26484. }
  26485. this.eof = true;
  26486. }
  26487. var t = 0;
  26488. for (i = 0; i < 5; ++i) {
  26489. t = t * 85 + (input[i] - 0x21);
  26490. }
  26491. for (i = 3; i >= 0; --i) {
  26492. buffer[bufferLength + i] = t & 0xFF;
  26493. t >>= 8;
  26494. }
  26495. }
  26496. };
  26497. return Ascii85Stream;
  26498. }();
  26499. var AsciiHexStream = function AsciiHexStreamClosure() {
  26500. function AsciiHexStream(str, maybeLength) {
  26501. this.str = str;
  26502. this.dict = str.dict;
  26503. this.firstDigit = -1;
  26504. if (maybeLength) {
  26505. maybeLength = 0.5 * maybeLength;
  26506. }
  26507. DecodeStream.call(this, maybeLength);
  26508. }
  26509. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26510. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26511. var UPSTREAM_BLOCK_SIZE = 8000;
  26512. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26513. if (!bytes.length) {
  26514. this.eof = true;
  26515. return;
  26516. }
  26517. var maxDecodeLength = bytes.length + 1 >> 1;
  26518. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26519. var bufferLength = this.bufferLength;
  26520. var firstDigit = this.firstDigit;
  26521. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26522. var ch = bytes[i], digit;
  26523. if (ch >= 0x30 && ch <= 0x39) {
  26524. digit = ch & 0x0F;
  26525. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26526. digit = (ch & 0x0F) + 9;
  26527. } else if (ch === 0x3E) {
  26528. this.eof = true;
  26529. break;
  26530. } else {
  26531. continue;
  26532. }
  26533. if (firstDigit < 0) {
  26534. firstDigit = digit;
  26535. } else {
  26536. buffer[bufferLength++] = firstDigit << 4 | digit;
  26537. firstDigit = -1;
  26538. }
  26539. }
  26540. if (firstDigit >= 0 && this.eof) {
  26541. buffer[bufferLength++] = firstDigit << 4;
  26542. firstDigit = -1;
  26543. }
  26544. this.firstDigit = firstDigit;
  26545. this.bufferLength = bufferLength;
  26546. };
  26547. return AsciiHexStream;
  26548. }();
  26549. var RunLengthStream = function RunLengthStreamClosure() {
  26550. function RunLengthStream(str, maybeLength) {
  26551. this.str = str;
  26552. this.dict = str.dict;
  26553. DecodeStream.call(this, maybeLength);
  26554. }
  26555. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26556. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26557. var repeatHeader = this.str.getBytes(2);
  26558. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26559. this.eof = true;
  26560. return;
  26561. }
  26562. var buffer;
  26563. var bufferLength = this.bufferLength;
  26564. var n = repeatHeader[0];
  26565. if (n < 128) {
  26566. buffer = this.ensureBuffer(bufferLength + n + 1);
  26567. buffer[bufferLength++] = repeatHeader[1];
  26568. if (n > 0) {
  26569. var source = this.str.getBytes(n);
  26570. buffer.set(source, bufferLength);
  26571. bufferLength += n;
  26572. }
  26573. } else {
  26574. n = 257 - n;
  26575. var b = repeatHeader[1];
  26576. buffer = this.ensureBuffer(bufferLength + n + 1);
  26577. for (var i = 0; i < n; i++) {
  26578. buffer[bufferLength++] = b;
  26579. }
  26580. }
  26581. this.bufferLength = bufferLength;
  26582. };
  26583. return RunLengthStream;
  26584. }();
  26585. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26586. var ccittEOL = -2;
  26587. var ccittEOF = -1;
  26588. var twoDimPass = 0;
  26589. var twoDimHoriz = 1;
  26590. var twoDimVert0 = 2;
  26591. var twoDimVertR1 = 3;
  26592. var twoDimVertL1 = 4;
  26593. var twoDimVertR2 = 5;
  26594. var twoDimVertL2 = 6;
  26595. var twoDimVertR3 = 7;
  26596. var twoDimVertL3 = 8;
  26597. var twoDimTable = [
  26598. [
  26599. -1,
  26600. -1
  26601. ],
  26602. [
  26603. -1,
  26604. -1
  26605. ],
  26606. [
  26607. 7,
  26608. twoDimVertL3
  26609. ],
  26610. [
  26611. 7,
  26612. twoDimVertR3
  26613. ],
  26614. [
  26615. 6,
  26616. twoDimVertL2
  26617. ],
  26618. [
  26619. 6,
  26620. twoDimVertL2
  26621. ],
  26622. [
  26623. 6,
  26624. twoDimVertR2
  26625. ],
  26626. [
  26627. 6,
  26628. twoDimVertR2
  26629. ],
  26630. [
  26631. 4,
  26632. twoDimPass
  26633. ],
  26634. [
  26635. 4,
  26636. twoDimPass
  26637. ],
  26638. [
  26639. 4,
  26640. twoDimPass
  26641. ],
  26642. [
  26643. 4,
  26644. twoDimPass
  26645. ],
  26646. [
  26647. 4,
  26648. twoDimPass
  26649. ],
  26650. [
  26651. 4,
  26652. twoDimPass
  26653. ],
  26654. [
  26655. 4,
  26656. twoDimPass
  26657. ],
  26658. [
  26659. 4,
  26660. twoDimPass
  26661. ],
  26662. [
  26663. 3,
  26664. twoDimHoriz
  26665. ],
  26666. [
  26667. 3,
  26668. twoDimHoriz
  26669. ],
  26670. [
  26671. 3,
  26672. twoDimHoriz
  26673. ],
  26674. [
  26675. 3,
  26676. twoDimHoriz
  26677. ],
  26678. [
  26679. 3,
  26680. twoDimHoriz
  26681. ],
  26682. [
  26683. 3,
  26684. twoDimHoriz
  26685. ],
  26686. [
  26687. 3,
  26688. twoDimHoriz
  26689. ],
  26690. [
  26691. 3,
  26692. twoDimHoriz
  26693. ],
  26694. [
  26695. 3,
  26696. twoDimHoriz
  26697. ],
  26698. [
  26699. 3,
  26700. twoDimHoriz
  26701. ],
  26702. [
  26703. 3,
  26704. twoDimHoriz
  26705. ],
  26706. [
  26707. 3,
  26708. twoDimHoriz
  26709. ],
  26710. [
  26711. 3,
  26712. twoDimHoriz
  26713. ],
  26714. [
  26715. 3,
  26716. twoDimHoriz
  26717. ],
  26718. [
  26719. 3,
  26720. twoDimHoriz
  26721. ],
  26722. [
  26723. 3,
  26724. twoDimHoriz
  26725. ],
  26726. [
  26727. 3,
  26728. twoDimVertL1
  26729. ],
  26730. [
  26731. 3,
  26732. twoDimVertL1
  26733. ],
  26734. [
  26735. 3,
  26736. twoDimVertL1
  26737. ],
  26738. [
  26739. 3,
  26740. twoDimVertL1
  26741. ],
  26742. [
  26743. 3,
  26744. twoDimVertL1
  26745. ],
  26746. [
  26747. 3,
  26748. twoDimVertL1
  26749. ],
  26750. [
  26751. 3,
  26752. twoDimVertL1
  26753. ],
  26754. [
  26755. 3,
  26756. twoDimVertL1
  26757. ],
  26758. [
  26759. 3,
  26760. twoDimVertL1
  26761. ],
  26762. [
  26763. 3,
  26764. twoDimVertL1
  26765. ],
  26766. [
  26767. 3,
  26768. twoDimVertL1
  26769. ],
  26770. [
  26771. 3,
  26772. twoDimVertL1
  26773. ],
  26774. [
  26775. 3,
  26776. twoDimVertL1
  26777. ],
  26778. [
  26779. 3,
  26780. twoDimVertL1
  26781. ],
  26782. [
  26783. 3,
  26784. twoDimVertL1
  26785. ],
  26786. [
  26787. 3,
  26788. twoDimVertL1
  26789. ],
  26790. [
  26791. 3,
  26792. twoDimVertR1
  26793. ],
  26794. [
  26795. 3,
  26796. twoDimVertR1
  26797. ],
  26798. [
  26799. 3,
  26800. twoDimVertR1
  26801. ],
  26802. [
  26803. 3,
  26804. twoDimVertR1
  26805. ],
  26806. [
  26807. 3,
  26808. twoDimVertR1
  26809. ],
  26810. [
  26811. 3,
  26812. twoDimVertR1
  26813. ],
  26814. [
  26815. 3,
  26816. twoDimVertR1
  26817. ],
  26818. [
  26819. 3,
  26820. twoDimVertR1
  26821. ],
  26822. [
  26823. 3,
  26824. twoDimVertR1
  26825. ],
  26826. [
  26827. 3,
  26828. twoDimVertR1
  26829. ],
  26830. [
  26831. 3,
  26832. twoDimVertR1
  26833. ],
  26834. [
  26835. 3,
  26836. twoDimVertR1
  26837. ],
  26838. [
  26839. 3,
  26840. twoDimVertR1
  26841. ],
  26842. [
  26843. 3,
  26844. twoDimVertR1
  26845. ],
  26846. [
  26847. 3,
  26848. twoDimVertR1
  26849. ],
  26850. [
  26851. 3,
  26852. twoDimVertR1
  26853. ],
  26854. [
  26855. 1,
  26856. twoDimVert0
  26857. ],
  26858. [
  26859. 1,
  26860. twoDimVert0
  26861. ],
  26862. [
  26863. 1,
  26864. twoDimVert0
  26865. ],
  26866. [
  26867. 1,
  26868. twoDimVert0
  26869. ],
  26870. [
  26871. 1,
  26872. twoDimVert0
  26873. ],
  26874. [
  26875. 1,
  26876. twoDimVert0
  26877. ],
  26878. [
  26879. 1,
  26880. twoDimVert0
  26881. ],
  26882. [
  26883. 1,
  26884. twoDimVert0
  26885. ],
  26886. [
  26887. 1,
  26888. twoDimVert0
  26889. ],
  26890. [
  26891. 1,
  26892. twoDimVert0
  26893. ],
  26894. [
  26895. 1,
  26896. twoDimVert0
  26897. ],
  26898. [
  26899. 1,
  26900. twoDimVert0
  26901. ],
  26902. [
  26903. 1,
  26904. twoDimVert0
  26905. ],
  26906. [
  26907. 1,
  26908. twoDimVert0
  26909. ],
  26910. [
  26911. 1,
  26912. twoDimVert0
  26913. ],
  26914. [
  26915. 1,
  26916. twoDimVert0
  26917. ],
  26918. [
  26919. 1,
  26920. twoDimVert0
  26921. ],
  26922. [
  26923. 1,
  26924. twoDimVert0
  26925. ],
  26926. [
  26927. 1,
  26928. twoDimVert0
  26929. ],
  26930. [
  26931. 1,
  26932. twoDimVert0
  26933. ],
  26934. [
  26935. 1,
  26936. twoDimVert0
  26937. ],
  26938. [
  26939. 1,
  26940. twoDimVert0
  26941. ],
  26942. [
  26943. 1,
  26944. twoDimVert0
  26945. ],
  26946. [
  26947. 1,
  26948. twoDimVert0
  26949. ],
  26950. [
  26951. 1,
  26952. twoDimVert0
  26953. ],
  26954. [
  26955. 1,
  26956. twoDimVert0
  26957. ],
  26958. [
  26959. 1,
  26960. twoDimVert0
  26961. ],
  26962. [
  26963. 1,
  26964. twoDimVert0
  26965. ],
  26966. [
  26967. 1,
  26968. twoDimVert0
  26969. ],
  26970. [
  26971. 1,
  26972. twoDimVert0
  26973. ],
  26974. [
  26975. 1,
  26976. twoDimVert0
  26977. ],
  26978. [
  26979. 1,
  26980. twoDimVert0
  26981. ],
  26982. [
  26983. 1,
  26984. twoDimVert0
  26985. ],
  26986. [
  26987. 1,
  26988. twoDimVert0
  26989. ],
  26990. [
  26991. 1,
  26992. twoDimVert0
  26993. ],
  26994. [
  26995. 1,
  26996. twoDimVert0
  26997. ],
  26998. [
  26999. 1,
  27000. twoDimVert0
  27001. ],
  27002. [
  27003. 1,
  27004. twoDimVert0
  27005. ],
  27006. [
  27007. 1,
  27008. twoDimVert0
  27009. ],
  27010. [
  27011. 1,
  27012. twoDimVert0
  27013. ],
  27014. [
  27015. 1,
  27016. twoDimVert0
  27017. ],
  27018. [
  27019. 1,
  27020. twoDimVert0
  27021. ],
  27022. [
  27023. 1,
  27024. twoDimVert0
  27025. ],
  27026. [
  27027. 1,
  27028. twoDimVert0
  27029. ],
  27030. [
  27031. 1,
  27032. twoDimVert0
  27033. ],
  27034. [
  27035. 1,
  27036. twoDimVert0
  27037. ],
  27038. [
  27039. 1,
  27040. twoDimVert0
  27041. ],
  27042. [
  27043. 1,
  27044. twoDimVert0
  27045. ],
  27046. [
  27047. 1,
  27048. twoDimVert0
  27049. ],
  27050. [
  27051. 1,
  27052. twoDimVert0
  27053. ],
  27054. [
  27055. 1,
  27056. twoDimVert0
  27057. ],
  27058. [
  27059. 1,
  27060. twoDimVert0
  27061. ],
  27062. [
  27063. 1,
  27064. twoDimVert0
  27065. ],
  27066. [
  27067. 1,
  27068. twoDimVert0
  27069. ],
  27070. [
  27071. 1,
  27072. twoDimVert0
  27073. ],
  27074. [
  27075. 1,
  27076. twoDimVert0
  27077. ],
  27078. [
  27079. 1,
  27080. twoDimVert0
  27081. ],
  27082. [
  27083. 1,
  27084. twoDimVert0
  27085. ],
  27086. [
  27087. 1,
  27088. twoDimVert0
  27089. ],
  27090. [
  27091. 1,
  27092. twoDimVert0
  27093. ],
  27094. [
  27095. 1,
  27096. twoDimVert0
  27097. ],
  27098. [
  27099. 1,
  27100. twoDimVert0
  27101. ],
  27102. [
  27103. 1,
  27104. twoDimVert0
  27105. ],
  27106. [
  27107. 1,
  27108. twoDimVert0
  27109. ]
  27110. ];
  27111. var whiteTable1 = [
  27112. [
  27113. -1,
  27114. -1
  27115. ],
  27116. [
  27117. 12,
  27118. ccittEOL
  27119. ],
  27120. [
  27121. -1,
  27122. -1
  27123. ],
  27124. [
  27125. -1,
  27126. -1
  27127. ],
  27128. [
  27129. -1,
  27130. -1
  27131. ],
  27132. [
  27133. -1,
  27134. -1
  27135. ],
  27136. [
  27137. -1,
  27138. -1
  27139. ],
  27140. [
  27141. -1,
  27142. -1
  27143. ],
  27144. [
  27145. -1,
  27146. -1
  27147. ],
  27148. [
  27149. -1,
  27150. -1
  27151. ],
  27152. [
  27153. -1,
  27154. -1
  27155. ],
  27156. [
  27157. -1,
  27158. -1
  27159. ],
  27160. [
  27161. -1,
  27162. -1
  27163. ],
  27164. [
  27165. -1,
  27166. -1
  27167. ],
  27168. [
  27169. -1,
  27170. -1
  27171. ],
  27172. [
  27173. -1,
  27174. -1
  27175. ],
  27176. [
  27177. 11,
  27178. 1792
  27179. ],
  27180. [
  27181. 11,
  27182. 1792
  27183. ],
  27184. [
  27185. 12,
  27186. 1984
  27187. ],
  27188. [
  27189. 12,
  27190. 2048
  27191. ],
  27192. [
  27193. 12,
  27194. 2112
  27195. ],
  27196. [
  27197. 12,
  27198. 2176
  27199. ],
  27200. [
  27201. 12,
  27202. 2240
  27203. ],
  27204. [
  27205. 12,
  27206. 2304
  27207. ],
  27208. [
  27209. 11,
  27210. 1856
  27211. ],
  27212. [
  27213. 11,
  27214. 1856
  27215. ],
  27216. [
  27217. 11,
  27218. 1920
  27219. ],
  27220. [
  27221. 11,
  27222. 1920
  27223. ],
  27224. [
  27225. 12,
  27226. 2368
  27227. ],
  27228. [
  27229. 12,
  27230. 2432
  27231. ],
  27232. [
  27233. 12,
  27234. 2496
  27235. ],
  27236. [
  27237. 12,
  27238. 2560
  27239. ]
  27240. ];
  27241. var whiteTable2 = [
  27242. [
  27243. -1,
  27244. -1
  27245. ],
  27246. [
  27247. -1,
  27248. -1
  27249. ],
  27250. [
  27251. -1,
  27252. -1
  27253. ],
  27254. [
  27255. -1,
  27256. -1
  27257. ],
  27258. [
  27259. 8,
  27260. 29
  27261. ],
  27262. [
  27263. 8,
  27264. 29
  27265. ],
  27266. [
  27267. 8,
  27268. 30
  27269. ],
  27270. [
  27271. 8,
  27272. 30
  27273. ],
  27274. [
  27275. 8,
  27276. 45
  27277. ],
  27278. [
  27279. 8,
  27280. 45
  27281. ],
  27282. [
  27283. 8,
  27284. 46
  27285. ],
  27286. [
  27287. 8,
  27288. 46
  27289. ],
  27290. [
  27291. 7,
  27292. 22
  27293. ],
  27294. [
  27295. 7,
  27296. 22
  27297. ],
  27298. [
  27299. 7,
  27300. 22
  27301. ],
  27302. [
  27303. 7,
  27304. 22
  27305. ],
  27306. [
  27307. 7,
  27308. 23
  27309. ],
  27310. [
  27311. 7,
  27312. 23
  27313. ],
  27314. [
  27315. 7,
  27316. 23
  27317. ],
  27318. [
  27319. 7,
  27320. 23
  27321. ],
  27322. [
  27323. 8,
  27324. 47
  27325. ],
  27326. [
  27327. 8,
  27328. 47
  27329. ],
  27330. [
  27331. 8,
  27332. 48
  27333. ],
  27334. [
  27335. 8,
  27336. 48
  27337. ],
  27338. [
  27339. 6,
  27340. 13
  27341. ],
  27342. [
  27343. 6,
  27344. 13
  27345. ],
  27346. [
  27347. 6,
  27348. 13
  27349. ],
  27350. [
  27351. 6,
  27352. 13
  27353. ],
  27354. [
  27355. 6,
  27356. 13
  27357. ],
  27358. [
  27359. 6,
  27360. 13
  27361. ],
  27362. [
  27363. 6,
  27364. 13
  27365. ],
  27366. [
  27367. 6,
  27368. 13
  27369. ],
  27370. [
  27371. 7,
  27372. 20
  27373. ],
  27374. [
  27375. 7,
  27376. 20
  27377. ],
  27378. [
  27379. 7,
  27380. 20
  27381. ],
  27382. [
  27383. 7,
  27384. 20
  27385. ],
  27386. [
  27387. 8,
  27388. 33
  27389. ],
  27390. [
  27391. 8,
  27392. 33
  27393. ],
  27394. [
  27395. 8,
  27396. 34
  27397. ],
  27398. [
  27399. 8,
  27400. 34
  27401. ],
  27402. [
  27403. 8,
  27404. 35
  27405. ],
  27406. [
  27407. 8,
  27408. 35
  27409. ],
  27410. [
  27411. 8,
  27412. 36
  27413. ],
  27414. [
  27415. 8,
  27416. 36
  27417. ],
  27418. [
  27419. 8,
  27420. 37
  27421. ],
  27422. [
  27423. 8,
  27424. 37
  27425. ],
  27426. [
  27427. 8,
  27428. 38
  27429. ],
  27430. [
  27431. 8,
  27432. 38
  27433. ],
  27434. [
  27435. 7,
  27436. 19
  27437. ],
  27438. [
  27439. 7,
  27440. 19
  27441. ],
  27442. [
  27443. 7,
  27444. 19
  27445. ],
  27446. [
  27447. 7,
  27448. 19
  27449. ],
  27450. [
  27451. 8,
  27452. 31
  27453. ],
  27454. [
  27455. 8,
  27456. 31
  27457. ],
  27458. [
  27459. 8,
  27460. 32
  27461. ],
  27462. [
  27463. 8,
  27464. 32
  27465. ],
  27466. [
  27467. 6,
  27468. 1
  27469. ],
  27470. [
  27471. 6,
  27472. 1
  27473. ],
  27474. [
  27475. 6,
  27476. 1
  27477. ],
  27478. [
  27479. 6,
  27480. 1
  27481. ],
  27482. [
  27483. 6,
  27484. 1
  27485. ],
  27486. [
  27487. 6,
  27488. 1
  27489. ],
  27490. [
  27491. 6,
  27492. 1
  27493. ],
  27494. [
  27495. 6,
  27496. 1
  27497. ],
  27498. [
  27499. 6,
  27500. 12
  27501. ],
  27502. [
  27503. 6,
  27504. 12
  27505. ],
  27506. [
  27507. 6,
  27508. 12
  27509. ],
  27510. [
  27511. 6,
  27512. 12
  27513. ],
  27514. [
  27515. 6,
  27516. 12
  27517. ],
  27518. [
  27519. 6,
  27520. 12
  27521. ],
  27522. [
  27523. 6,
  27524. 12
  27525. ],
  27526. [
  27527. 6,
  27528. 12
  27529. ],
  27530. [
  27531. 8,
  27532. 53
  27533. ],
  27534. [
  27535. 8,
  27536. 53
  27537. ],
  27538. [
  27539. 8,
  27540. 54
  27541. ],
  27542. [
  27543. 8,
  27544. 54
  27545. ],
  27546. [
  27547. 7,
  27548. 26
  27549. ],
  27550. [
  27551. 7,
  27552. 26
  27553. ],
  27554. [
  27555. 7,
  27556. 26
  27557. ],
  27558. [
  27559. 7,
  27560. 26
  27561. ],
  27562. [
  27563. 8,
  27564. 39
  27565. ],
  27566. [
  27567. 8,
  27568. 39
  27569. ],
  27570. [
  27571. 8,
  27572. 40
  27573. ],
  27574. [
  27575. 8,
  27576. 40
  27577. ],
  27578. [
  27579. 8,
  27580. 41
  27581. ],
  27582. [
  27583. 8,
  27584. 41
  27585. ],
  27586. [
  27587. 8,
  27588. 42
  27589. ],
  27590. [
  27591. 8,
  27592. 42
  27593. ],
  27594. [
  27595. 8,
  27596. 43
  27597. ],
  27598. [
  27599. 8,
  27600. 43
  27601. ],
  27602. [
  27603. 8,
  27604. 44
  27605. ],
  27606. [
  27607. 8,
  27608. 44
  27609. ],
  27610. [
  27611. 7,
  27612. 21
  27613. ],
  27614. [
  27615. 7,
  27616. 21
  27617. ],
  27618. [
  27619. 7,
  27620. 21
  27621. ],
  27622. [
  27623. 7,
  27624. 21
  27625. ],
  27626. [
  27627. 7,
  27628. 28
  27629. ],
  27630. [
  27631. 7,
  27632. 28
  27633. ],
  27634. [
  27635. 7,
  27636. 28
  27637. ],
  27638. [
  27639. 7,
  27640. 28
  27641. ],
  27642. [
  27643. 8,
  27644. 61
  27645. ],
  27646. [
  27647. 8,
  27648. 61
  27649. ],
  27650. [
  27651. 8,
  27652. 62
  27653. ],
  27654. [
  27655. 8,
  27656. 62
  27657. ],
  27658. [
  27659. 8,
  27660. 63
  27661. ],
  27662. [
  27663. 8,
  27664. 63
  27665. ],
  27666. [
  27667. 8,
  27668. 0
  27669. ],
  27670. [
  27671. 8,
  27672. 0
  27673. ],
  27674. [
  27675. 8,
  27676. 320
  27677. ],
  27678. [
  27679. 8,
  27680. 320
  27681. ],
  27682. [
  27683. 8,
  27684. 384
  27685. ],
  27686. [
  27687. 8,
  27688. 384
  27689. ],
  27690. [
  27691. 5,
  27692. 10
  27693. ],
  27694. [
  27695. 5,
  27696. 10
  27697. ],
  27698. [
  27699. 5,
  27700. 10
  27701. ],
  27702. [
  27703. 5,
  27704. 10
  27705. ],
  27706. [
  27707. 5,
  27708. 10
  27709. ],
  27710. [
  27711. 5,
  27712. 10
  27713. ],
  27714. [
  27715. 5,
  27716. 10
  27717. ],
  27718. [
  27719. 5,
  27720. 10
  27721. ],
  27722. [
  27723. 5,
  27724. 10
  27725. ],
  27726. [
  27727. 5,
  27728. 10
  27729. ],
  27730. [
  27731. 5,
  27732. 10
  27733. ],
  27734. [
  27735. 5,
  27736. 10
  27737. ],
  27738. [
  27739. 5,
  27740. 10
  27741. ],
  27742. [
  27743. 5,
  27744. 10
  27745. ],
  27746. [
  27747. 5,
  27748. 10
  27749. ],
  27750. [
  27751. 5,
  27752. 10
  27753. ],
  27754. [
  27755. 5,
  27756. 11
  27757. ],
  27758. [
  27759. 5,
  27760. 11
  27761. ],
  27762. [
  27763. 5,
  27764. 11
  27765. ],
  27766. [
  27767. 5,
  27768. 11
  27769. ],
  27770. [
  27771. 5,
  27772. 11
  27773. ],
  27774. [
  27775. 5,
  27776. 11
  27777. ],
  27778. [
  27779. 5,
  27780. 11
  27781. ],
  27782. [
  27783. 5,
  27784. 11
  27785. ],
  27786. [
  27787. 5,
  27788. 11
  27789. ],
  27790. [
  27791. 5,
  27792. 11
  27793. ],
  27794. [
  27795. 5,
  27796. 11
  27797. ],
  27798. [
  27799. 5,
  27800. 11
  27801. ],
  27802. [
  27803. 5,
  27804. 11
  27805. ],
  27806. [
  27807. 5,
  27808. 11
  27809. ],
  27810. [
  27811. 5,
  27812. 11
  27813. ],
  27814. [
  27815. 5,
  27816. 11
  27817. ],
  27818. [
  27819. 7,
  27820. 27
  27821. ],
  27822. [
  27823. 7,
  27824. 27
  27825. ],
  27826. [
  27827. 7,
  27828. 27
  27829. ],
  27830. [
  27831. 7,
  27832. 27
  27833. ],
  27834. [
  27835. 8,
  27836. 59
  27837. ],
  27838. [
  27839. 8,
  27840. 59
  27841. ],
  27842. [
  27843. 8,
  27844. 60
  27845. ],
  27846. [
  27847. 8,
  27848. 60
  27849. ],
  27850. [
  27851. 9,
  27852. 1472
  27853. ],
  27854. [
  27855. 9,
  27856. 1536
  27857. ],
  27858. [
  27859. 9,
  27860. 1600
  27861. ],
  27862. [
  27863. 9,
  27864. 1728
  27865. ],
  27866. [
  27867. 7,
  27868. 18
  27869. ],
  27870. [
  27871. 7,
  27872. 18
  27873. ],
  27874. [
  27875. 7,
  27876. 18
  27877. ],
  27878. [
  27879. 7,
  27880. 18
  27881. ],
  27882. [
  27883. 7,
  27884. 24
  27885. ],
  27886. [
  27887. 7,
  27888. 24
  27889. ],
  27890. [
  27891. 7,
  27892. 24
  27893. ],
  27894. [
  27895. 7,
  27896. 24
  27897. ],
  27898. [
  27899. 8,
  27900. 49
  27901. ],
  27902. [
  27903. 8,
  27904. 49
  27905. ],
  27906. [
  27907. 8,
  27908. 50
  27909. ],
  27910. [
  27911. 8,
  27912. 50
  27913. ],
  27914. [
  27915. 8,
  27916. 51
  27917. ],
  27918. [
  27919. 8,
  27920. 51
  27921. ],
  27922. [
  27923. 8,
  27924. 52
  27925. ],
  27926. [
  27927. 8,
  27928. 52
  27929. ],
  27930. [
  27931. 7,
  27932. 25
  27933. ],
  27934. [
  27935. 7,
  27936. 25
  27937. ],
  27938. [
  27939. 7,
  27940. 25
  27941. ],
  27942. [
  27943. 7,
  27944. 25
  27945. ],
  27946. [
  27947. 8,
  27948. 55
  27949. ],
  27950. [
  27951. 8,
  27952. 55
  27953. ],
  27954. [
  27955. 8,
  27956. 56
  27957. ],
  27958. [
  27959. 8,
  27960. 56
  27961. ],
  27962. [
  27963. 8,
  27964. 57
  27965. ],
  27966. [
  27967. 8,
  27968. 57
  27969. ],
  27970. [
  27971. 8,
  27972. 58
  27973. ],
  27974. [
  27975. 8,
  27976. 58
  27977. ],
  27978. [
  27979. 6,
  27980. 192
  27981. ],
  27982. [
  27983. 6,
  27984. 192
  27985. ],
  27986. [
  27987. 6,
  27988. 192
  27989. ],
  27990. [
  27991. 6,
  27992. 192
  27993. ],
  27994. [
  27995. 6,
  27996. 192
  27997. ],
  27998. [
  27999. 6,
  28000. 192
  28001. ],
  28002. [
  28003. 6,
  28004. 192
  28005. ],
  28006. [
  28007. 6,
  28008. 192
  28009. ],
  28010. [
  28011. 6,
  28012. 1664
  28013. ],
  28014. [
  28015. 6,
  28016. 1664
  28017. ],
  28018. [
  28019. 6,
  28020. 1664
  28021. ],
  28022. [
  28023. 6,
  28024. 1664
  28025. ],
  28026. [
  28027. 6,
  28028. 1664
  28029. ],
  28030. [
  28031. 6,
  28032. 1664
  28033. ],
  28034. [
  28035. 6,
  28036. 1664
  28037. ],
  28038. [
  28039. 6,
  28040. 1664
  28041. ],
  28042. [
  28043. 8,
  28044. 448
  28045. ],
  28046. [
  28047. 8,
  28048. 448
  28049. ],
  28050. [
  28051. 8,
  28052. 512
  28053. ],
  28054. [
  28055. 8,
  28056. 512
  28057. ],
  28058. [
  28059. 9,
  28060. 704
  28061. ],
  28062. [
  28063. 9,
  28064. 768
  28065. ],
  28066. [
  28067. 8,
  28068. 640
  28069. ],
  28070. [
  28071. 8,
  28072. 640
  28073. ],
  28074. [
  28075. 8,
  28076. 576
  28077. ],
  28078. [
  28079. 8,
  28080. 576
  28081. ],
  28082. [
  28083. 9,
  28084. 832
  28085. ],
  28086. [
  28087. 9,
  28088. 896
  28089. ],
  28090. [
  28091. 9,
  28092. 960
  28093. ],
  28094. [
  28095. 9,
  28096. 1024
  28097. ],
  28098. [
  28099. 9,
  28100. 1088
  28101. ],
  28102. [
  28103. 9,
  28104. 1152
  28105. ],
  28106. [
  28107. 9,
  28108. 1216
  28109. ],
  28110. [
  28111. 9,
  28112. 1280
  28113. ],
  28114. [
  28115. 9,
  28116. 1344
  28117. ],
  28118. [
  28119. 9,
  28120. 1408
  28121. ],
  28122. [
  28123. 7,
  28124. 256
  28125. ],
  28126. [
  28127. 7,
  28128. 256
  28129. ],
  28130. [
  28131. 7,
  28132. 256
  28133. ],
  28134. [
  28135. 7,
  28136. 256
  28137. ],
  28138. [
  28139. 4,
  28140. 2
  28141. ],
  28142. [
  28143. 4,
  28144. 2
  28145. ],
  28146. [
  28147. 4,
  28148. 2
  28149. ],
  28150. [
  28151. 4,
  28152. 2
  28153. ],
  28154. [
  28155. 4,
  28156. 2
  28157. ],
  28158. [
  28159. 4,
  28160. 2
  28161. ],
  28162. [
  28163. 4,
  28164. 2
  28165. ],
  28166. [
  28167. 4,
  28168. 2
  28169. ],
  28170. [
  28171. 4,
  28172. 2
  28173. ],
  28174. [
  28175. 4,
  28176. 2
  28177. ],
  28178. [
  28179. 4,
  28180. 2
  28181. ],
  28182. [
  28183. 4,
  28184. 2
  28185. ],
  28186. [
  28187. 4,
  28188. 2
  28189. ],
  28190. [
  28191. 4,
  28192. 2
  28193. ],
  28194. [
  28195. 4,
  28196. 2
  28197. ],
  28198. [
  28199. 4,
  28200. 2
  28201. ],
  28202. [
  28203. 4,
  28204. 2
  28205. ],
  28206. [
  28207. 4,
  28208. 2
  28209. ],
  28210. [
  28211. 4,
  28212. 2
  28213. ],
  28214. [
  28215. 4,
  28216. 2
  28217. ],
  28218. [
  28219. 4,
  28220. 2
  28221. ],
  28222. [
  28223. 4,
  28224. 2
  28225. ],
  28226. [
  28227. 4,
  28228. 2
  28229. ],
  28230. [
  28231. 4,
  28232. 2
  28233. ],
  28234. [
  28235. 4,
  28236. 2
  28237. ],
  28238. [
  28239. 4,
  28240. 2
  28241. ],
  28242. [
  28243. 4,
  28244. 2
  28245. ],
  28246. [
  28247. 4,
  28248. 2
  28249. ],
  28250. [
  28251. 4,
  28252. 2
  28253. ],
  28254. [
  28255. 4,
  28256. 2
  28257. ],
  28258. [
  28259. 4,
  28260. 2
  28261. ],
  28262. [
  28263. 4,
  28264. 2
  28265. ],
  28266. [
  28267. 4,
  28268. 3
  28269. ],
  28270. [
  28271. 4,
  28272. 3
  28273. ],
  28274. [
  28275. 4,
  28276. 3
  28277. ],
  28278. [
  28279. 4,
  28280. 3
  28281. ],
  28282. [
  28283. 4,
  28284. 3
  28285. ],
  28286. [
  28287. 4,
  28288. 3
  28289. ],
  28290. [
  28291. 4,
  28292. 3
  28293. ],
  28294. [
  28295. 4,
  28296. 3
  28297. ],
  28298. [
  28299. 4,
  28300. 3
  28301. ],
  28302. [
  28303. 4,
  28304. 3
  28305. ],
  28306. [
  28307. 4,
  28308. 3
  28309. ],
  28310. [
  28311. 4,
  28312. 3
  28313. ],
  28314. [
  28315. 4,
  28316. 3
  28317. ],
  28318. [
  28319. 4,
  28320. 3
  28321. ],
  28322. [
  28323. 4,
  28324. 3
  28325. ],
  28326. [
  28327. 4,
  28328. 3
  28329. ],
  28330. [
  28331. 4,
  28332. 3
  28333. ],
  28334. [
  28335. 4,
  28336. 3
  28337. ],
  28338. [
  28339. 4,
  28340. 3
  28341. ],
  28342. [
  28343. 4,
  28344. 3
  28345. ],
  28346. [
  28347. 4,
  28348. 3
  28349. ],
  28350. [
  28351. 4,
  28352. 3
  28353. ],
  28354. [
  28355. 4,
  28356. 3
  28357. ],
  28358. [
  28359. 4,
  28360. 3
  28361. ],
  28362. [
  28363. 4,
  28364. 3
  28365. ],
  28366. [
  28367. 4,
  28368. 3
  28369. ],
  28370. [
  28371. 4,
  28372. 3
  28373. ],
  28374. [
  28375. 4,
  28376. 3
  28377. ],
  28378. [
  28379. 4,
  28380. 3
  28381. ],
  28382. [
  28383. 4,
  28384. 3
  28385. ],
  28386. [
  28387. 4,
  28388. 3
  28389. ],
  28390. [
  28391. 4,
  28392. 3
  28393. ],
  28394. [
  28395. 5,
  28396. 128
  28397. ],
  28398. [
  28399. 5,
  28400. 128
  28401. ],
  28402. [
  28403. 5,
  28404. 128
  28405. ],
  28406. [
  28407. 5,
  28408. 128
  28409. ],
  28410. [
  28411. 5,
  28412. 128
  28413. ],
  28414. [
  28415. 5,
  28416. 128
  28417. ],
  28418. [
  28419. 5,
  28420. 128
  28421. ],
  28422. [
  28423. 5,
  28424. 128
  28425. ],
  28426. [
  28427. 5,
  28428. 128
  28429. ],
  28430. [
  28431. 5,
  28432. 128
  28433. ],
  28434. [
  28435. 5,
  28436. 128
  28437. ],
  28438. [
  28439. 5,
  28440. 128
  28441. ],
  28442. [
  28443. 5,
  28444. 128
  28445. ],
  28446. [
  28447. 5,
  28448. 128
  28449. ],
  28450. [
  28451. 5,
  28452. 128
  28453. ],
  28454. [
  28455. 5,
  28456. 128
  28457. ],
  28458. [
  28459. 5,
  28460. 8
  28461. ],
  28462. [
  28463. 5,
  28464. 8
  28465. ],
  28466. [
  28467. 5,
  28468. 8
  28469. ],
  28470. [
  28471. 5,
  28472. 8
  28473. ],
  28474. [
  28475. 5,
  28476. 8
  28477. ],
  28478. [
  28479. 5,
  28480. 8
  28481. ],
  28482. [
  28483. 5,
  28484. 8
  28485. ],
  28486. [
  28487. 5,
  28488. 8
  28489. ],
  28490. [
  28491. 5,
  28492. 8
  28493. ],
  28494. [
  28495. 5,
  28496. 8
  28497. ],
  28498. [
  28499. 5,
  28500. 8
  28501. ],
  28502. [
  28503. 5,
  28504. 8
  28505. ],
  28506. [
  28507. 5,
  28508. 8
  28509. ],
  28510. [
  28511. 5,
  28512. 8
  28513. ],
  28514. [
  28515. 5,
  28516. 8
  28517. ],
  28518. [
  28519. 5,
  28520. 8
  28521. ],
  28522. [
  28523. 5,
  28524. 9
  28525. ],
  28526. [
  28527. 5,
  28528. 9
  28529. ],
  28530. [
  28531. 5,
  28532. 9
  28533. ],
  28534. [
  28535. 5,
  28536. 9
  28537. ],
  28538. [
  28539. 5,
  28540. 9
  28541. ],
  28542. [
  28543. 5,
  28544. 9
  28545. ],
  28546. [
  28547. 5,
  28548. 9
  28549. ],
  28550. [
  28551. 5,
  28552. 9
  28553. ],
  28554. [
  28555. 5,
  28556. 9
  28557. ],
  28558. [
  28559. 5,
  28560. 9
  28561. ],
  28562. [
  28563. 5,
  28564. 9
  28565. ],
  28566. [
  28567. 5,
  28568. 9
  28569. ],
  28570. [
  28571. 5,
  28572. 9
  28573. ],
  28574. [
  28575. 5,
  28576. 9
  28577. ],
  28578. [
  28579. 5,
  28580. 9
  28581. ],
  28582. [
  28583. 5,
  28584. 9
  28585. ],
  28586. [
  28587. 6,
  28588. 16
  28589. ],
  28590. [
  28591. 6,
  28592. 16
  28593. ],
  28594. [
  28595. 6,
  28596. 16
  28597. ],
  28598. [
  28599. 6,
  28600. 16
  28601. ],
  28602. [
  28603. 6,
  28604. 16
  28605. ],
  28606. [
  28607. 6,
  28608. 16
  28609. ],
  28610. [
  28611. 6,
  28612. 16
  28613. ],
  28614. [
  28615. 6,
  28616. 16
  28617. ],
  28618. [
  28619. 6,
  28620. 17
  28621. ],
  28622. [
  28623. 6,
  28624. 17
  28625. ],
  28626. [
  28627. 6,
  28628. 17
  28629. ],
  28630. [
  28631. 6,
  28632. 17
  28633. ],
  28634. [
  28635. 6,
  28636. 17
  28637. ],
  28638. [
  28639. 6,
  28640. 17
  28641. ],
  28642. [
  28643. 6,
  28644. 17
  28645. ],
  28646. [
  28647. 6,
  28648. 17
  28649. ],
  28650. [
  28651. 4,
  28652. 4
  28653. ],
  28654. [
  28655. 4,
  28656. 4
  28657. ],
  28658. [
  28659. 4,
  28660. 4
  28661. ],
  28662. [
  28663. 4,
  28664. 4
  28665. ],
  28666. [
  28667. 4,
  28668. 4
  28669. ],
  28670. [
  28671. 4,
  28672. 4
  28673. ],
  28674. [
  28675. 4,
  28676. 4
  28677. ],
  28678. [
  28679. 4,
  28680. 4
  28681. ],
  28682. [
  28683. 4,
  28684. 4
  28685. ],
  28686. [
  28687. 4,
  28688. 4
  28689. ],
  28690. [
  28691. 4,
  28692. 4
  28693. ],
  28694. [
  28695. 4,
  28696. 4
  28697. ],
  28698. [
  28699. 4,
  28700. 4
  28701. ],
  28702. [
  28703. 4,
  28704. 4
  28705. ],
  28706. [
  28707. 4,
  28708. 4
  28709. ],
  28710. [
  28711. 4,
  28712. 4
  28713. ],
  28714. [
  28715. 4,
  28716. 4
  28717. ],
  28718. [
  28719. 4,
  28720. 4
  28721. ],
  28722. [
  28723. 4,
  28724. 4
  28725. ],
  28726. [
  28727. 4,
  28728. 4
  28729. ],
  28730. [
  28731. 4,
  28732. 4
  28733. ],
  28734. [
  28735. 4,
  28736. 4
  28737. ],
  28738. [
  28739. 4,
  28740. 4
  28741. ],
  28742. [
  28743. 4,
  28744. 4
  28745. ],
  28746. [
  28747. 4,
  28748. 4
  28749. ],
  28750. [
  28751. 4,
  28752. 4
  28753. ],
  28754. [
  28755. 4,
  28756. 4
  28757. ],
  28758. [
  28759. 4,
  28760. 4
  28761. ],
  28762. [
  28763. 4,
  28764. 4
  28765. ],
  28766. [
  28767. 4,
  28768. 4
  28769. ],
  28770. [
  28771. 4,
  28772. 4
  28773. ],
  28774. [
  28775. 4,
  28776. 4
  28777. ],
  28778. [
  28779. 4,
  28780. 5
  28781. ],
  28782. [
  28783. 4,
  28784. 5
  28785. ],
  28786. [
  28787. 4,
  28788. 5
  28789. ],
  28790. [
  28791. 4,
  28792. 5
  28793. ],
  28794. [
  28795. 4,
  28796. 5
  28797. ],
  28798. [
  28799. 4,
  28800. 5
  28801. ],
  28802. [
  28803. 4,
  28804. 5
  28805. ],
  28806. [
  28807. 4,
  28808. 5
  28809. ],
  28810. [
  28811. 4,
  28812. 5
  28813. ],
  28814. [
  28815. 4,
  28816. 5
  28817. ],
  28818. [
  28819. 4,
  28820. 5
  28821. ],
  28822. [
  28823. 4,
  28824. 5
  28825. ],
  28826. [
  28827. 4,
  28828. 5
  28829. ],
  28830. [
  28831. 4,
  28832. 5
  28833. ],
  28834. [
  28835. 4,
  28836. 5
  28837. ],
  28838. [
  28839. 4,
  28840. 5
  28841. ],
  28842. [
  28843. 4,
  28844. 5
  28845. ],
  28846. [
  28847. 4,
  28848. 5
  28849. ],
  28850. [
  28851. 4,
  28852. 5
  28853. ],
  28854. [
  28855. 4,
  28856. 5
  28857. ],
  28858. [
  28859. 4,
  28860. 5
  28861. ],
  28862. [
  28863. 4,
  28864. 5
  28865. ],
  28866. [
  28867. 4,
  28868. 5
  28869. ],
  28870. [
  28871. 4,
  28872. 5
  28873. ],
  28874. [
  28875. 4,
  28876. 5
  28877. ],
  28878. [
  28879. 4,
  28880. 5
  28881. ],
  28882. [
  28883. 4,
  28884. 5
  28885. ],
  28886. [
  28887. 4,
  28888. 5
  28889. ],
  28890. [
  28891. 4,
  28892. 5
  28893. ],
  28894. [
  28895. 4,
  28896. 5
  28897. ],
  28898. [
  28899. 4,
  28900. 5
  28901. ],
  28902. [
  28903. 4,
  28904. 5
  28905. ],
  28906. [
  28907. 6,
  28908. 14
  28909. ],
  28910. [
  28911. 6,
  28912. 14
  28913. ],
  28914. [
  28915. 6,
  28916. 14
  28917. ],
  28918. [
  28919. 6,
  28920. 14
  28921. ],
  28922. [
  28923. 6,
  28924. 14
  28925. ],
  28926. [
  28927. 6,
  28928. 14
  28929. ],
  28930. [
  28931. 6,
  28932. 14
  28933. ],
  28934. [
  28935. 6,
  28936. 14
  28937. ],
  28938. [
  28939. 6,
  28940. 15
  28941. ],
  28942. [
  28943. 6,
  28944. 15
  28945. ],
  28946. [
  28947. 6,
  28948. 15
  28949. ],
  28950. [
  28951. 6,
  28952. 15
  28953. ],
  28954. [
  28955. 6,
  28956. 15
  28957. ],
  28958. [
  28959. 6,
  28960. 15
  28961. ],
  28962. [
  28963. 6,
  28964. 15
  28965. ],
  28966. [
  28967. 6,
  28968. 15
  28969. ],
  28970. [
  28971. 5,
  28972. 64
  28973. ],
  28974. [
  28975. 5,
  28976. 64
  28977. ],
  28978. [
  28979. 5,
  28980. 64
  28981. ],
  28982. [
  28983. 5,
  28984. 64
  28985. ],
  28986. [
  28987. 5,
  28988. 64
  28989. ],
  28990. [
  28991. 5,
  28992. 64
  28993. ],
  28994. [
  28995. 5,
  28996. 64
  28997. ],
  28998. [
  28999. 5,
  29000. 64
  29001. ],
  29002. [
  29003. 5,
  29004. 64
  29005. ],
  29006. [
  29007. 5,
  29008. 64
  29009. ],
  29010. [
  29011. 5,
  29012. 64
  29013. ],
  29014. [
  29015. 5,
  29016. 64
  29017. ],
  29018. [
  29019. 5,
  29020. 64
  29021. ],
  29022. [
  29023. 5,
  29024. 64
  29025. ],
  29026. [
  29027. 5,
  29028. 64
  29029. ],
  29030. [
  29031. 5,
  29032. 64
  29033. ],
  29034. [
  29035. 4,
  29036. 6
  29037. ],
  29038. [
  29039. 4,
  29040. 6
  29041. ],
  29042. [
  29043. 4,
  29044. 6
  29045. ],
  29046. [
  29047. 4,
  29048. 6
  29049. ],
  29050. [
  29051. 4,
  29052. 6
  29053. ],
  29054. [
  29055. 4,
  29056. 6
  29057. ],
  29058. [
  29059. 4,
  29060. 6
  29061. ],
  29062. [
  29063. 4,
  29064. 6
  29065. ],
  29066. [
  29067. 4,
  29068. 6
  29069. ],
  29070. [
  29071. 4,
  29072. 6
  29073. ],
  29074. [
  29075. 4,
  29076. 6
  29077. ],
  29078. [
  29079. 4,
  29080. 6
  29081. ],
  29082. [
  29083. 4,
  29084. 6
  29085. ],
  29086. [
  29087. 4,
  29088. 6
  29089. ],
  29090. [
  29091. 4,
  29092. 6
  29093. ],
  29094. [
  29095. 4,
  29096. 6
  29097. ],
  29098. [
  29099. 4,
  29100. 6
  29101. ],
  29102. [
  29103. 4,
  29104. 6
  29105. ],
  29106. [
  29107. 4,
  29108. 6
  29109. ],
  29110. [
  29111. 4,
  29112. 6
  29113. ],
  29114. [
  29115. 4,
  29116. 6
  29117. ],
  29118. [
  29119. 4,
  29120. 6
  29121. ],
  29122. [
  29123. 4,
  29124. 6
  29125. ],
  29126. [
  29127. 4,
  29128. 6
  29129. ],
  29130. [
  29131. 4,
  29132. 6
  29133. ],
  29134. [
  29135. 4,
  29136. 6
  29137. ],
  29138. [
  29139. 4,
  29140. 6
  29141. ],
  29142. [
  29143. 4,
  29144. 6
  29145. ],
  29146. [
  29147. 4,
  29148. 6
  29149. ],
  29150. [
  29151. 4,
  29152. 6
  29153. ],
  29154. [
  29155. 4,
  29156. 6
  29157. ],
  29158. [
  29159. 4,
  29160. 6
  29161. ],
  29162. [
  29163. 4,
  29164. 7
  29165. ],
  29166. [
  29167. 4,
  29168. 7
  29169. ],
  29170. [
  29171. 4,
  29172. 7
  29173. ],
  29174. [
  29175. 4,
  29176. 7
  29177. ],
  29178. [
  29179. 4,
  29180. 7
  29181. ],
  29182. [
  29183. 4,
  29184. 7
  29185. ],
  29186. [
  29187. 4,
  29188. 7
  29189. ],
  29190. [
  29191. 4,
  29192. 7
  29193. ],
  29194. [
  29195. 4,
  29196. 7
  29197. ],
  29198. [
  29199. 4,
  29200. 7
  29201. ],
  29202. [
  29203. 4,
  29204. 7
  29205. ],
  29206. [
  29207. 4,
  29208. 7
  29209. ],
  29210. [
  29211. 4,
  29212. 7
  29213. ],
  29214. [
  29215. 4,
  29216. 7
  29217. ],
  29218. [
  29219. 4,
  29220. 7
  29221. ],
  29222. [
  29223. 4,
  29224. 7
  29225. ],
  29226. [
  29227. 4,
  29228. 7
  29229. ],
  29230. [
  29231. 4,
  29232. 7
  29233. ],
  29234. [
  29235. 4,
  29236. 7
  29237. ],
  29238. [
  29239. 4,
  29240. 7
  29241. ],
  29242. [
  29243. 4,
  29244. 7
  29245. ],
  29246. [
  29247. 4,
  29248. 7
  29249. ],
  29250. [
  29251. 4,
  29252. 7
  29253. ],
  29254. [
  29255. 4,
  29256. 7
  29257. ],
  29258. [
  29259. 4,
  29260. 7
  29261. ],
  29262. [
  29263. 4,
  29264. 7
  29265. ],
  29266. [
  29267. 4,
  29268. 7
  29269. ],
  29270. [
  29271. 4,
  29272. 7
  29273. ],
  29274. [
  29275. 4,
  29276. 7
  29277. ],
  29278. [
  29279. 4,
  29280. 7
  29281. ],
  29282. [
  29283. 4,
  29284. 7
  29285. ],
  29286. [
  29287. 4,
  29288. 7
  29289. ]
  29290. ];
  29291. var blackTable1 = [
  29292. [
  29293. -1,
  29294. -1
  29295. ],
  29296. [
  29297. -1,
  29298. -1
  29299. ],
  29300. [
  29301. 12,
  29302. ccittEOL
  29303. ],
  29304. [
  29305. 12,
  29306. ccittEOL
  29307. ],
  29308. [
  29309. -1,
  29310. -1
  29311. ],
  29312. [
  29313. -1,
  29314. -1
  29315. ],
  29316. [
  29317. -1,
  29318. -1
  29319. ],
  29320. [
  29321. -1,
  29322. -1
  29323. ],
  29324. [
  29325. -1,
  29326. -1
  29327. ],
  29328. [
  29329. -1,
  29330. -1
  29331. ],
  29332. [
  29333. -1,
  29334. -1
  29335. ],
  29336. [
  29337. -1,
  29338. -1
  29339. ],
  29340. [
  29341. -1,
  29342. -1
  29343. ],
  29344. [
  29345. -1,
  29346. -1
  29347. ],
  29348. [
  29349. -1,
  29350. -1
  29351. ],
  29352. [
  29353. -1,
  29354. -1
  29355. ],
  29356. [
  29357. -1,
  29358. -1
  29359. ],
  29360. [
  29361. -1,
  29362. -1
  29363. ],
  29364. [
  29365. -1,
  29366. -1
  29367. ],
  29368. [
  29369. -1,
  29370. -1
  29371. ],
  29372. [
  29373. -1,
  29374. -1
  29375. ],
  29376. [
  29377. -1,
  29378. -1
  29379. ],
  29380. [
  29381. -1,
  29382. -1
  29383. ],
  29384. [
  29385. -1,
  29386. -1
  29387. ],
  29388. [
  29389. -1,
  29390. -1
  29391. ],
  29392. [
  29393. -1,
  29394. -1
  29395. ],
  29396. [
  29397. -1,
  29398. -1
  29399. ],
  29400. [
  29401. -1,
  29402. -1
  29403. ],
  29404. [
  29405. -1,
  29406. -1
  29407. ],
  29408. [
  29409. -1,
  29410. -1
  29411. ],
  29412. [
  29413. -1,
  29414. -1
  29415. ],
  29416. [
  29417. -1,
  29418. -1
  29419. ],
  29420. [
  29421. 11,
  29422. 1792
  29423. ],
  29424. [
  29425. 11,
  29426. 1792
  29427. ],
  29428. [
  29429. 11,
  29430. 1792
  29431. ],
  29432. [
  29433. 11,
  29434. 1792
  29435. ],
  29436. [
  29437. 12,
  29438. 1984
  29439. ],
  29440. [
  29441. 12,
  29442. 1984
  29443. ],
  29444. [
  29445. 12,
  29446. 2048
  29447. ],
  29448. [
  29449. 12,
  29450. 2048
  29451. ],
  29452. [
  29453. 12,
  29454. 2112
  29455. ],
  29456. [
  29457. 12,
  29458. 2112
  29459. ],
  29460. [
  29461. 12,
  29462. 2176
  29463. ],
  29464. [
  29465. 12,
  29466. 2176
  29467. ],
  29468. [
  29469. 12,
  29470. 2240
  29471. ],
  29472. [
  29473. 12,
  29474. 2240
  29475. ],
  29476. [
  29477. 12,
  29478. 2304
  29479. ],
  29480. [
  29481. 12,
  29482. 2304
  29483. ],
  29484. [
  29485. 11,
  29486. 1856
  29487. ],
  29488. [
  29489. 11,
  29490. 1856
  29491. ],
  29492. [
  29493. 11,
  29494. 1856
  29495. ],
  29496. [
  29497. 11,
  29498. 1856
  29499. ],
  29500. [
  29501. 11,
  29502. 1920
  29503. ],
  29504. [
  29505. 11,
  29506. 1920
  29507. ],
  29508. [
  29509. 11,
  29510. 1920
  29511. ],
  29512. [
  29513. 11,
  29514. 1920
  29515. ],
  29516. [
  29517. 12,
  29518. 2368
  29519. ],
  29520. [
  29521. 12,
  29522. 2368
  29523. ],
  29524. [
  29525. 12,
  29526. 2432
  29527. ],
  29528. [
  29529. 12,
  29530. 2432
  29531. ],
  29532. [
  29533. 12,
  29534. 2496
  29535. ],
  29536. [
  29537. 12,
  29538. 2496
  29539. ],
  29540. [
  29541. 12,
  29542. 2560
  29543. ],
  29544. [
  29545. 12,
  29546. 2560
  29547. ],
  29548. [
  29549. 10,
  29550. 18
  29551. ],
  29552. [
  29553. 10,
  29554. 18
  29555. ],
  29556. [
  29557. 10,
  29558. 18
  29559. ],
  29560. [
  29561. 10,
  29562. 18
  29563. ],
  29564. [
  29565. 10,
  29566. 18
  29567. ],
  29568. [
  29569. 10,
  29570. 18
  29571. ],
  29572. [
  29573. 10,
  29574. 18
  29575. ],
  29576. [
  29577. 10,
  29578. 18
  29579. ],
  29580. [
  29581. 12,
  29582. 52
  29583. ],
  29584. [
  29585. 12,
  29586. 52
  29587. ],
  29588. [
  29589. 13,
  29590. 640
  29591. ],
  29592. [
  29593. 13,
  29594. 704
  29595. ],
  29596. [
  29597. 13,
  29598. 768
  29599. ],
  29600. [
  29601. 13,
  29602. 832
  29603. ],
  29604. [
  29605. 12,
  29606. 55
  29607. ],
  29608. [
  29609. 12,
  29610. 55
  29611. ],
  29612. [
  29613. 12,
  29614. 56
  29615. ],
  29616. [
  29617. 12,
  29618. 56
  29619. ],
  29620. [
  29621. 13,
  29622. 1280
  29623. ],
  29624. [
  29625. 13,
  29626. 1344
  29627. ],
  29628. [
  29629. 13,
  29630. 1408
  29631. ],
  29632. [
  29633. 13,
  29634. 1472
  29635. ],
  29636. [
  29637. 12,
  29638. 59
  29639. ],
  29640. [
  29641. 12,
  29642. 59
  29643. ],
  29644. [
  29645. 12,
  29646. 60
  29647. ],
  29648. [
  29649. 12,
  29650. 60
  29651. ],
  29652. [
  29653. 13,
  29654. 1536
  29655. ],
  29656. [
  29657. 13,
  29658. 1600
  29659. ],
  29660. [
  29661. 11,
  29662. 24
  29663. ],
  29664. [
  29665. 11,
  29666. 24
  29667. ],
  29668. [
  29669. 11,
  29670. 24
  29671. ],
  29672. [
  29673. 11,
  29674. 24
  29675. ],
  29676. [
  29677. 11,
  29678. 25
  29679. ],
  29680. [
  29681. 11,
  29682. 25
  29683. ],
  29684. [
  29685. 11,
  29686. 25
  29687. ],
  29688. [
  29689. 11,
  29690. 25
  29691. ],
  29692. [
  29693. 13,
  29694. 1664
  29695. ],
  29696. [
  29697. 13,
  29698. 1728
  29699. ],
  29700. [
  29701. 12,
  29702. 320
  29703. ],
  29704. [
  29705. 12,
  29706. 320
  29707. ],
  29708. [
  29709. 12,
  29710. 384
  29711. ],
  29712. [
  29713. 12,
  29714. 384
  29715. ],
  29716. [
  29717. 12,
  29718. 448
  29719. ],
  29720. [
  29721. 12,
  29722. 448
  29723. ],
  29724. [
  29725. 13,
  29726. 512
  29727. ],
  29728. [
  29729. 13,
  29730. 576
  29731. ],
  29732. [
  29733. 12,
  29734. 53
  29735. ],
  29736. [
  29737. 12,
  29738. 53
  29739. ],
  29740. [
  29741. 12,
  29742. 54
  29743. ],
  29744. [
  29745. 12,
  29746. 54
  29747. ],
  29748. [
  29749. 13,
  29750. 896
  29751. ],
  29752. [
  29753. 13,
  29754. 960
  29755. ],
  29756. [
  29757. 13,
  29758. 1024
  29759. ],
  29760. [
  29761. 13,
  29762. 1088
  29763. ],
  29764. [
  29765. 13,
  29766. 1152
  29767. ],
  29768. [
  29769. 13,
  29770. 1216
  29771. ],
  29772. [
  29773. 10,
  29774. 64
  29775. ],
  29776. [
  29777. 10,
  29778. 64
  29779. ],
  29780. [
  29781. 10,
  29782. 64
  29783. ],
  29784. [
  29785. 10,
  29786. 64
  29787. ],
  29788. [
  29789. 10,
  29790. 64
  29791. ],
  29792. [
  29793. 10,
  29794. 64
  29795. ],
  29796. [
  29797. 10,
  29798. 64
  29799. ],
  29800. [
  29801. 10,
  29802. 64
  29803. ]
  29804. ];
  29805. var blackTable2 = [
  29806. [
  29807. 8,
  29808. 13
  29809. ],
  29810. [
  29811. 8,
  29812. 13
  29813. ],
  29814. [
  29815. 8,
  29816. 13
  29817. ],
  29818. [
  29819. 8,
  29820. 13
  29821. ],
  29822. [
  29823. 8,
  29824. 13
  29825. ],
  29826. [
  29827. 8,
  29828. 13
  29829. ],
  29830. [
  29831. 8,
  29832. 13
  29833. ],
  29834. [
  29835. 8,
  29836. 13
  29837. ],
  29838. [
  29839. 8,
  29840. 13
  29841. ],
  29842. [
  29843. 8,
  29844. 13
  29845. ],
  29846. [
  29847. 8,
  29848. 13
  29849. ],
  29850. [
  29851. 8,
  29852. 13
  29853. ],
  29854. [
  29855. 8,
  29856. 13
  29857. ],
  29858. [
  29859. 8,
  29860. 13
  29861. ],
  29862. [
  29863. 8,
  29864. 13
  29865. ],
  29866. [
  29867. 8,
  29868. 13
  29869. ],
  29870. [
  29871. 11,
  29872. 23
  29873. ],
  29874. [
  29875. 11,
  29876. 23
  29877. ],
  29878. [
  29879. 12,
  29880. 50
  29881. ],
  29882. [
  29883. 12,
  29884. 51
  29885. ],
  29886. [
  29887. 12,
  29888. 44
  29889. ],
  29890. [
  29891. 12,
  29892. 45
  29893. ],
  29894. [
  29895. 12,
  29896. 46
  29897. ],
  29898. [
  29899. 12,
  29900. 47
  29901. ],
  29902. [
  29903. 12,
  29904. 57
  29905. ],
  29906. [
  29907. 12,
  29908. 58
  29909. ],
  29910. [
  29911. 12,
  29912. 61
  29913. ],
  29914. [
  29915. 12,
  29916. 256
  29917. ],
  29918. [
  29919. 10,
  29920. 16
  29921. ],
  29922. [
  29923. 10,
  29924. 16
  29925. ],
  29926. [
  29927. 10,
  29928. 16
  29929. ],
  29930. [
  29931. 10,
  29932. 16
  29933. ],
  29934. [
  29935. 10,
  29936. 17
  29937. ],
  29938. [
  29939. 10,
  29940. 17
  29941. ],
  29942. [
  29943. 10,
  29944. 17
  29945. ],
  29946. [
  29947. 10,
  29948. 17
  29949. ],
  29950. [
  29951. 12,
  29952. 48
  29953. ],
  29954. [
  29955. 12,
  29956. 49
  29957. ],
  29958. [
  29959. 12,
  29960. 62
  29961. ],
  29962. [
  29963. 12,
  29964. 63
  29965. ],
  29966. [
  29967. 12,
  29968. 30
  29969. ],
  29970. [
  29971. 12,
  29972. 31
  29973. ],
  29974. [
  29975. 12,
  29976. 32
  29977. ],
  29978. [
  29979. 12,
  29980. 33
  29981. ],
  29982. [
  29983. 12,
  29984. 40
  29985. ],
  29986. [
  29987. 12,
  29988. 41
  29989. ],
  29990. [
  29991. 11,
  29992. 22
  29993. ],
  29994. [
  29995. 11,
  29996. 22
  29997. ],
  29998. [
  29999. 8,
  30000. 14
  30001. ],
  30002. [
  30003. 8,
  30004. 14
  30005. ],
  30006. [
  30007. 8,
  30008. 14
  30009. ],
  30010. [
  30011. 8,
  30012. 14
  30013. ],
  30014. [
  30015. 8,
  30016. 14
  30017. ],
  30018. [
  30019. 8,
  30020. 14
  30021. ],
  30022. [
  30023. 8,
  30024. 14
  30025. ],
  30026. [
  30027. 8,
  30028. 14
  30029. ],
  30030. [
  30031. 8,
  30032. 14
  30033. ],
  30034. [
  30035. 8,
  30036. 14
  30037. ],
  30038. [
  30039. 8,
  30040. 14
  30041. ],
  30042. [
  30043. 8,
  30044. 14
  30045. ],
  30046. [
  30047. 8,
  30048. 14
  30049. ],
  30050. [
  30051. 8,
  30052. 14
  30053. ],
  30054. [
  30055. 8,
  30056. 14
  30057. ],
  30058. [
  30059. 8,
  30060. 14
  30061. ],
  30062. [
  30063. 7,
  30064. 10
  30065. ],
  30066. [
  30067. 7,
  30068. 10
  30069. ],
  30070. [
  30071. 7,
  30072. 10
  30073. ],
  30074. [
  30075. 7,
  30076. 10
  30077. ],
  30078. [
  30079. 7,
  30080. 10
  30081. ],
  30082. [
  30083. 7,
  30084. 10
  30085. ],
  30086. [
  30087. 7,
  30088. 10
  30089. ],
  30090. [
  30091. 7,
  30092. 10
  30093. ],
  30094. [
  30095. 7,
  30096. 10
  30097. ],
  30098. [
  30099. 7,
  30100. 10
  30101. ],
  30102. [
  30103. 7,
  30104. 10
  30105. ],
  30106. [
  30107. 7,
  30108. 10
  30109. ],
  30110. [
  30111. 7,
  30112. 10
  30113. ],
  30114. [
  30115. 7,
  30116. 10
  30117. ],
  30118. [
  30119. 7,
  30120. 10
  30121. ],
  30122. [
  30123. 7,
  30124. 10
  30125. ],
  30126. [
  30127. 7,
  30128. 10
  30129. ],
  30130. [
  30131. 7,
  30132. 10
  30133. ],
  30134. [
  30135. 7,
  30136. 10
  30137. ],
  30138. [
  30139. 7,
  30140. 10
  30141. ],
  30142. [
  30143. 7,
  30144. 10
  30145. ],
  30146. [
  30147. 7,
  30148. 10
  30149. ],
  30150. [
  30151. 7,
  30152. 10
  30153. ],
  30154. [
  30155. 7,
  30156. 10
  30157. ],
  30158. [
  30159. 7,
  30160. 10
  30161. ],
  30162. [
  30163. 7,
  30164. 10
  30165. ],
  30166. [
  30167. 7,
  30168. 10
  30169. ],
  30170. [
  30171. 7,
  30172. 10
  30173. ],
  30174. [
  30175. 7,
  30176. 10
  30177. ],
  30178. [
  30179. 7,
  30180. 10
  30181. ],
  30182. [
  30183. 7,
  30184. 10
  30185. ],
  30186. [
  30187. 7,
  30188. 10
  30189. ],
  30190. [
  30191. 7,
  30192. 11
  30193. ],
  30194. [
  30195. 7,
  30196. 11
  30197. ],
  30198. [
  30199. 7,
  30200. 11
  30201. ],
  30202. [
  30203. 7,
  30204. 11
  30205. ],
  30206. [
  30207. 7,
  30208. 11
  30209. ],
  30210. [
  30211. 7,
  30212. 11
  30213. ],
  30214. [
  30215. 7,
  30216. 11
  30217. ],
  30218. [
  30219. 7,
  30220. 11
  30221. ],
  30222. [
  30223. 7,
  30224. 11
  30225. ],
  30226. [
  30227. 7,
  30228. 11
  30229. ],
  30230. [
  30231. 7,
  30232. 11
  30233. ],
  30234. [
  30235. 7,
  30236. 11
  30237. ],
  30238. [
  30239. 7,
  30240. 11
  30241. ],
  30242. [
  30243. 7,
  30244. 11
  30245. ],
  30246. [
  30247. 7,
  30248. 11
  30249. ],
  30250. [
  30251. 7,
  30252. 11
  30253. ],
  30254. [
  30255. 7,
  30256. 11
  30257. ],
  30258. [
  30259. 7,
  30260. 11
  30261. ],
  30262. [
  30263. 7,
  30264. 11
  30265. ],
  30266. [
  30267. 7,
  30268. 11
  30269. ],
  30270. [
  30271. 7,
  30272. 11
  30273. ],
  30274. [
  30275. 7,
  30276. 11
  30277. ],
  30278. [
  30279. 7,
  30280. 11
  30281. ],
  30282. [
  30283. 7,
  30284. 11
  30285. ],
  30286. [
  30287. 7,
  30288. 11
  30289. ],
  30290. [
  30291. 7,
  30292. 11
  30293. ],
  30294. [
  30295. 7,
  30296. 11
  30297. ],
  30298. [
  30299. 7,
  30300. 11
  30301. ],
  30302. [
  30303. 7,
  30304. 11
  30305. ],
  30306. [
  30307. 7,
  30308. 11
  30309. ],
  30310. [
  30311. 7,
  30312. 11
  30313. ],
  30314. [
  30315. 7,
  30316. 11
  30317. ],
  30318. [
  30319. 9,
  30320. 15
  30321. ],
  30322. [
  30323. 9,
  30324. 15
  30325. ],
  30326. [
  30327. 9,
  30328. 15
  30329. ],
  30330. [
  30331. 9,
  30332. 15
  30333. ],
  30334. [
  30335. 9,
  30336. 15
  30337. ],
  30338. [
  30339. 9,
  30340. 15
  30341. ],
  30342. [
  30343. 9,
  30344. 15
  30345. ],
  30346. [
  30347. 9,
  30348. 15
  30349. ],
  30350. [
  30351. 12,
  30352. 128
  30353. ],
  30354. [
  30355. 12,
  30356. 192
  30357. ],
  30358. [
  30359. 12,
  30360. 26
  30361. ],
  30362. [
  30363. 12,
  30364. 27
  30365. ],
  30366. [
  30367. 12,
  30368. 28
  30369. ],
  30370. [
  30371. 12,
  30372. 29
  30373. ],
  30374. [
  30375. 11,
  30376. 19
  30377. ],
  30378. [
  30379. 11,
  30380. 19
  30381. ],
  30382. [
  30383. 11,
  30384. 20
  30385. ],
  30386. [
  30387. 11,
  30388. 20
  30389. ],
  30390. [
  30391. 12,
  30392. 34
  30393. ],
  30394. [
  30395. 12,
  30396. 35
  30397. ],
  30398. [
  30399. 12,
  30400. 36
  30401. ],
  30402. [
  30403. 12,
  30404. 37
  30405. ],
  30406. [
  30407. 12,
  30408. 38
  30409. ],
  30410. [
  30411. 12,
  30412. 39
  30413. ],
  30414. [
  30415. 11,
  30416. 21
  30417. ],
  30418. [
  30419. 11,
  30420. 21
  30421. ],
  30422. [
  30423. 12,
  30424. 42
  30425. ],
  30426. [
  30427. 12,
  30428. 43
  30429. ],
  30430. [
  30431. 10,
  30432. 0
  30433. ],
  30434. [
  30435. 10,
  30436. 0
  30437. ],
  30438. [
  30439. 10,
  30440. 0
  30441. ],
  30442. [
  30443. 10,
  30444. 0
  30445. ],
  30446. [
  30447. 7,
  30448. 12
  30449. ],
  30450. [
  30451. 7,
  30452. 12
  30453. ],
  30454. [
  30455. 7,
  30456. 12
  30457. ],
  30458. [
  30459. 7,
  30460. 12
  30461. ],
  30462. [
  30463. 7,
  30464. 12
  30465. ],
  30466. [
  30467. 7,
  30468. 12
  30469. ],
  30470. [
  30471. 7,
  30472. 12
  30473. ],
  30474. [
  30475. 7,
  30476. 12
  30477. ],
  30478. [
  30479. 7,
  30480. 12
  30481. ],
  30482. [
  30483. 7,
  30484. 12
  30485. ],
  30486. [
  30487. 7,
  30488. 12
  30489. ],
  30490. [
  30491. 7,
  30492. 12
  30493. ],
  30494. [
  30495. 7,
  30496. 12
  30497. ],
  30498. [
  30499. 7,
  30500. 12
  30501. ],
  30502. [
  30503. 7,
  30504. 12
  30505. ],
  30506. [
  30507. 7,
  30508. 12
  30509. ],
  30510. [
  30511. 7,
  30512. 12
  30513. ],
  30514. [
  30515. 7,
  30516. 12
  30517. ],
  30518. [
  30519. 7,
  30520. 12
  30521. ],
  30522. [
  30523. 7,
  30524. 12
  30525. ],
  30526. [
  30527. 7,
  30528. 12
  30529. ],
  30530. [
  30531. 7,
  30532. 12
  30533. ],
  30534. [
  30535. 7,
  30536. 12
  30537. ],
  30538. [
  30539. 7,
  30540. 12
  30541. ],
  30542. [
  30543. 7,
  30544. 12
  30545. ],
  30546. [
  30547. 7,
  30548. 12
  30549. ],
  30550. [
  30551. 7,
  30552. 12
  30553. ],
  30554. [
  30555. 7,
  30556. 12
  30557. ],
  30558. [
  30559. 7,
  30560. 12
  30561. ],
  30562. [
  30563. 7,
  30564. 12
  30565. ],
  30566. [
  30567. 7,
  30568. 12
  30569. ],
  30570. [
  30571. 7,
  30572. 12
  30573. ]
  30574. ];
  30575. var blackTable3 = [
  30576. [
  30577. -1,
  30578. -1
  30579. ],
  30580. [
  30581. -1,
  30582. -1
  30583. ],
  30584. [
  30585. -1,
  30586. -1
  30587. ],
  30588. [
  30589. -1,
  30590. -1
  30591. ],
  30592. [
  30593. 6,
  30594. 9
  30595. ],
  30596. [
  30597. 6,
  30598. 8
  30599. ],
  30600. [
  30601. 5,
  30602. 7
  30603. ],
  30604. [
  30605. 5,
  30606. 7
  30607. ],
  30608. [
  30609. 4,
  30610. 6
  30611. ],
  30612. [
  30613. 4,
  30614. 6
  30615. ],
  30616. [
  30617. 4,
  30618. 6
  30619. ],
  30620. [
  30621. 4,
  30622. 6
  30623. ],
  30624. [
  30625. 4,
  30626. 5
  30627. ],
  30628. [
  30629. 4,
  30630. 5
  30631. ],
  30632. [
  30633. 4,
  30634. 5
  30635. ],
  30636. [
  30637. 4,
  30638. 5
  30639. ],
  30640. [
  30641. 3,
  30642. 1
  30643. ],
  30644. [
  30645. 3,
  30646. 1
  30647. ],
  30648. [
  30649. 3,
  30650. 1
  30651. ],
  30652. [
  30653. 3,
  30654. 1
  30655. ],
  30656. [
  30657. 3,
  30658. 1
  30659. ],
  30660. [
  30661. 3,
  30662. 1
  30663. ],
  30664. [
  30665. 3,
  30666. 1
  30667. ],
  30668. [
  30669. 3,
  30670. 1
  30671. ],
  30672. [
  30673. 3,
  30674. 4
  30675. ],
  30676. [
  30677. 3,
  30678. 4
  30679. ],
  30680. [
  30681. 3,
  30682. 4
  30683. ],
  30684. [
  30685. 3,
  30686. 4
  30687. ],
  30688. [
  30689. 3,
  30690. 4
  30691. ],
  30692. [
  30693. 3,
  30694. 4
  30695. ],
  30696. [
  30697. 3,
  30698. 4
  30699. ],
  30700. [
  30701. 3,
  30702. 4
  30703. ],
  30704. [
  30705. 2,
  30706. 3
  30707. ],
  30708. [
  30709. 2,
  30710. 3
  30711. ],
  30712. [
  30713. 2,
  30714. 3
  30715. ],
  30716. [
  30717. 2,
  30718. 3
  30719. ],
  30720. [
  30721. 2,
  30722. 3
  30723. ],
  30724. [
  30725. 2,
  30726. 3
  30727. ],
  30728. [
  30729. 2,
  30730. 3
  30731. ],
  30732. [
  30733. 2,
  30734. 3
  30735. ],
  30736. [
  30737. 2,
  30738. 3
  30739. ],
  30740. [
  30741. 2,
  30742. 3
  30743. ],
  30744. [
  30745. 2,
  30746. 3
  30747. ],
  30748. [
  30749. 2,
  30750. 3
  30751. ],
  30752. [
  30753. 2,
  30754. 3
  30755. ],
  30756. [
  30757. 2,
  30758. 3
  30759. ],
  30760. [
  30761. 2,
  30762. 3
  30763. ],
  30764. [
  30765. 2,
  30766. 3
  30767. ],
  30768. [
  30769. 2,
  30770. 2
  30771. ],
  30772. [
  30773. 2,
  30774. 2
  30775. ],
  30776. [
  30777. 2,
  30778. 2
  30779. ],
  30780. [
  30781. 2,
  30782. 2
  30783. ],
  30784. [
  30785. 2,
  30786. 2
  30787. ],
  30788. [
  30789. 2,
  30790. 2
  30791. ],
  30792. [
  30793. 2,
  30794. 2
  30795. ],
  30796. [
  30797. 2,
  30798. 2
  30799. ],
  30800. [
  30801. 2,
  30802. 2
  30803. ],
  30804. [
  30805. 2,
  30806. 2
  30807. ],
  30808. [
  30809. 2,
  30810. 2
  30811. ],
  30812. [
  30813. 2,
  30814. 2
  30815. ],
  30816. [
  30817. 2,
  30818. 2
  30819. ],
  30820. [
  30821. 2,
  30822. 2
  30823. ],
  30824. [
  30825. 2,
  30826. 2
  30827. ],
  30828. [
  30829. 2,
  30830. 2
  30831. ]
  30832. ];
  30833. function CCITTFaxStream(str, maybeLength, params) {
  30834. this.str = str;
  30835. this.dict = str.dict;
  30836. params = params || Dict.empty;
  30837. this.encoding = params.get('K') || 0;
  30838. this.eoline = params.get('EndOfLine') || false;
  30839. this.byteAlign = params.get('EncodedByteAlign') || false;
  30840. this.columns = params.get('Columns') || 1728;
  30841. this.rows = params.get('Rows') || 0;
  30842. var eoblock = params.get('EndOfBlock');
  30843. if (eoblock === null || eoblock === undefined) {
  30844. eoblock = true;
  30845. }
  30846. this.eoblock = eoblock;
  30847. this.black = params.get('BlackIs1') || false;
  30848. this.codingLine = new Uint32Array(this.columns + 1);
  30849. this.refLine = new Uint32Array(this.columns + 2);
  30850. this.codingLine[0] = this.columns;
  30851. this.codingPos = 0;
  30852. this.row = 0;
  30853. this.nextLine2D = this.encoding < 0;
  30854. this.inputBits = 0;
  30855. this.inputBuf = 0;
  30856. this.outputBits = 0;
  30857. var code1;
  30858. while ((code1 = this.lookBits(12)) === 0) {
  30859. this.eatBits(1);
  30860. }
  30861. if (code1 === 1) {
  30862. this.eatBits(12);
  30863. }
  30864. if (this.encoding > 0) {
  30865. this.nextLine2D = !this.lookBits(1);
  30866. this.eatBits(1);
  30867. }
  30868. DecodeStream.call(this, maybeLength);
  30869. }
  30870. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30871. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30872. while (!this.eof) {
  30873. var c = this.lookChar();
  30874. this.ensureBuffer(this.bufferLength + 1);
  30875. this.buffer[this.bufferLength++] = c;
  30876. }
  30877. };
  30878. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30879. var codingLine = this.codingLine;
  30880. var codingPos = this.codingPos;
  30881. if (a1 > codingLine[codingPos]) {
  30882. if (a1 > this.columns) {
  30883. info('row is wrong length');
  30884. this.err = true;
  30885. a1 = this.columns;
  30886. }
  30887. if (codingPos & 1 ^ blackPixels) {
  30888. ++codingPos;
  30889. }
  30890. codingLine[codingPos] = a1;
  30891. }
  30892. this.codingPos = codingPos;
  30893. };
  30894. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30895. var codingLine = this.codingLine;
  30896. var codingPos = this.codingPos;
  30897. if (a1 > codingLine[codingPos]) {
  30898. if (a1 > this.columns) {
  30899. info('row is wrong length');
  30900. this.err = true;
  30901. a1 = this.columns;
  30902. }
  30903. if (codingPos & 1 ^ blackPixels) {
  30904. ++codingPos;
  30905. }
  30906. codingLine[codingPos] = a1;
  30907. } else if (a1 < codingLine[codingPos]) {
  30908. if (a1 < 0) {
  30909. info('invalid code');
  30910. this.err = true;
  30911. a1 = 0;
  30912. }
  30913. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30914. --codingPos;
  30915. }
  30916. codingLine[codingPos] = a1;
  30917. }
  30918. this.codingPos = codingPos;
  30919. };
  30920. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30921. var refLine = this.refLine;
  30922. var codingLine = this.codingLine;
  30923. var columns = this.columns;
  30924. var refPos, blackPixels, bits, i;
  30925. if (this.outputBits === 0) {
  30926. if (this.eof) {
  30927. return null;
  30928. }
  30929. this.err = false;
  30930. var code1, code2, code3;
  30931. if (this.nextLine2D) {
  30932. for (i = 0; codingLine[i] < columns; ++i) {
  30933. refLine[i] = codingLine[i];
  30934. }
  30935. refLine[i++] = columns;
  30936. refLine[i] = columns;
  30937. codingLine[0] = 0;
  30938. this.codingPos = 0;
  30939. refPos = 0;
  30940. blackPixels = 0;
  30941. while (codingLine[this.codingPos] < columns) {
  30942. code1 = this.getTwoDimCode();
  30943. switch (code1) {
  30944. case twoDimPass:
  30945. this.addPixels(refLine[refPos + 1], blackPixels);
  30946. if (refLine[refPos + 1] < columns) {
  30947. refPos += 2;
  30948. }
  30949. break;
  30950. case twoDimHoriz:
  30951. code1 = code2 = 0;
  30952. if (blackPixels) {
  30953. do {
  30954. code1 += code3 = this.getBlackCode();
  30955. } while (code3 >= 64);
  30956. do {
  30957. code2 += code3 = this.getWhiteCode();
  30958. } while (code3 >= 64);
  30959. } else {
  30960. do {
  30961. code1 += code3 = this.getWhiteCode();
  30962. } while (code3 >= 64);
  30963. do {
  30964. code2 += code3 = this.getBlackCode();
  30965. } while (code3 >= 64);
  30966. }
  30967. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30968. if (codingLine[this.codingPos] < columns) {
  30969. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30970. }
  30971. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30972. refPos += 2;
  30973. }
  30974. break;
  30975. case twoDimVertR3:
  30976. this.addPixels(refLine[refPos] + 3, blackPixels);
  30977. blackPixels ^= 1;
  30978. if (codingLine[this.codingPos] < columns) {
  30979. ++refPos;
  30980. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30981. refPos += 2;
  30982. }
  30983. }
  30984. break;
  30985. case twoDimVertR2:
  30986. this.addPixels(refLine[refPos] + 2, blackPixels);
  30987. blackPixels ^= 1;
  30988. if (codingLine[this.codingPos] < columns) {
  30989. ++refPos;
  30990. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30991. refPos += 2;
  30992. }
  30993. }
  30994. break;
  30995. case twoDimVertR1:
  30996. this.addPixels(refLine[refPos] + 1, blackPixels);
  30997. blackPixels ^= 1;
  30998. if (codingLine[this.codingPos] < columns) {
  30999. ++refPos;
  31000. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  31001. refPos += 2;
  31002. }
  31003. }
  31004. break;
  31005. case twoDimVert0:
  31006. this.addPixels(refLine[refPos], blackPixels);
  31007. blackPixels ^= 1;
  31008. if (codingLine[this.codingPos] < columns) {
  31009. ++refPos;
  31010. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  31011. refPos += 2;
  31012. }
  31013. }
  31014. break;
  31015. case twoDimVertL3:
  31016. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  31017. blackPixels ^= 1;
  31018. if (codingLine[this.codingPos] < columns) {
  31019. if (refPos > 0) {
  31020. --refPos;
  31021. } else {
  31022. ++refPos;
  31023. }
  31024. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  31025. refPos += 2;
  31026. }
  31027. }
  31028. break;
  31029. case twoDimVertL2:
  31030. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  31031. blackPixels ^= 1;
  31032. if (codingLine[this.codingPos] < columns) {
  31033. if (refPos > 0) {
  31034. --refPos;
  31035. } else {
  31036. ++refPos;
  31037. }
  31038. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  31039. refPos += 2;
  31040. }
  31041. }
  31042. break;
  31043. case twoDimVertL1:
  31044. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  31045. blackPixels ^= 1;
  31046. if (codingLine[this.codingPos] < columns) {
  31047. if (refPos > 0) {
  31048. --refPos;
  31049. } else {
  31050. ++refPos;
  31051. }
  31052. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  31053. refPos += 2;
  31054. }
  31055. }
  31056. break;
  31057. case ccittEOF:
  31058. this.addPixels(columns, 0);
  31059. this.eof = true;
  31060. break;
  31061. default:
  31062. info('bad 2d code');
  31063. this.addPixels(columns, 0);
  31064. this.err = true;
  31065. }
  31066. }
  31067. } else {
  31068. codingLine[0] = 0;
  31069. this.codingPos = 0;
  31070. blackPixels = 0;
  31071. while (codingLine[this.codingPos] < columns) {
  31072. code1 = 0;
  31073. if (blackPixels) {
  31074. do {
  31075. code1 += code3 = this.getBlackCode();
  31076. } while (code3 >= 64);
  31077. } else {
  31078. do {
  31079. code1 += code3 = this.getWhiteCode();
  31080. } while (code3 >= 64);
  31081. }
  31082. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  31083. blackPixels ^= 1;
  31084. }
  31085. }
  31086. var gotEOL = false;
  31087. if (this.byteAlign) {
  31088. this.inputBits &= ~7;
  31089. }
  31090. if (!this.eoblock && this.row === this.rows - 1) {
  31091. this.eof = true;
  31092. } else {
  31093. code1 = this.lookBits(12);
  31094. if (this.eoline) {
  31095. while (code1 !== ccittEOF && code1 !== 1) {
  31096. this.eatBits(1);
  31097. code1 = this.lookBits(12);
  31098. }
  31099. } else {
  31100. while (code1 === 0) {
  31101. this.eatBits(1);
  31102. code1 = this.lookBits(12);
  31103. }
  31104. }
  31105. if (code1 === 1) {
  31106. this.eatBits(12);
  31107. gotEOL = true;
  31108. } else if (code1 === ccittEOF) {
  31109. this.eof = true;
  31110. }
  31111. }
  31112. if (!this.eof && this.encoding > 0) {
  31113. this.nextLine2D = !this.lookBits(1);
  31114. this.eatBits(1);
  31115. }
  31116. if (this.eoblock && gotEOL && this.byteAlign) {
  31117. code1 = this.lookBits(12);
  31118. if (code1 === 1) {
  31119. this.eatBits(12);
  31120. if (this.encoding > 0) {
  31121. this.lookBits(1);
  31122. this.eatBits(1);
  31123. }
  31124. if (this.encoding >= 0) {
  31125. for (i = 0; i < 4; ++i) {
  31126. code1 = this.lookBits(12);
  31127. if (code1 !== 1) {
  31128. info('bad rtc code: ' + code1);
  31129. }
  31130. this.eatBits(12);
  31131. if (this.encoding > 0) {
  31132. this.lookBits(1);
  31133. this.eatBits(1);
  31134. }
  31135. }
  31136. }
  31137. this.eof = true;
  31138. }
  31139. } else if (this.err && this.eoline) {
  31140. while (true) {
  31141. code1 = this.lookBits(13);
  31142. if (code1 === ccittEOF) {
  31143. this.eof = true;
  31144. return null;
  31145. }
  31146. if (code1 >> 1 === 1) {
  31147. break;
  31148. }
  31149. this.eatBits(1);
  31150. }
  31151. this.eatBits(12);
  31152. if (this.encoding > 0) {
  31153. this.eatBits(1);
  31154. this.nextLine2D = !(code1 & 1);
  31155. }
  31156. }
  31157. if (codingLine[0] > 0) {
  31158. this.outputBits = codingLine[this.codingPos = 0];
  31159. } else {
  31160. this.outputBits = codingLine[this.codingPos = 1];
  31161. }
  31162. this.row++;
  31163. }
  31164. var c;
  31165. if (this.outputBits >= 8) {
  31166. c = this.codingPos & 1 ? 0 : 0xFF;
  31167. this.outputBits -= 8;
  31168. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  31169. this.codingPos++;
  31170. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  31171. }
  31172. } else {
  31173. bits = 8;
  31174. c = 0;
  31175. do {
  31176. if (this.outputBits > bits) {
  31177. c <<= bits;
  31178. if (!(this.codingPos & 1)) {
  31179. c |= 0xFF >> 8 - bits;
  31180. }
  31181. this.outputBits -= bits;
  31182. bits = 0;
  31183. } else {
  31184. c <<= this.outputBits;
  31185. if (!(this.codingPos & 1)) {
  31186. c |= 0xFF >> 8 - this.outputBits;
  31187. }
  31188. bits -= this.outputBits;
  31189. this.outputBits = 0;
  31190. if (codingLine[this.codingPos] < columns) {
  31191. this.codingPos++;
  31192. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  31193. } else if (bits > 0) {
  31194. c <<= bits;
  31195. bits = 0;
  31196. }
  31197. }
  31198. } while (bits);
  31199. }
  31200. if (this.black) {
  31201. c ^= 0xFF;
  31202. }
  31203. return c;
  31204. };
  31205. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  31206. var limitValue = limit || 0;
  31207. for (var i = start; i <= end; ++i) {
  31208. var code = this.lookBits(i);
  31209. if (code === ccittEOF) {
  31210. return [
  31211. true,
  31212. 1,
  31213. false
  31214. ];
  31215. }
  31216. if (i < end) {
  31217. code <<= end - i;
  31218. }
  31219. if (!limitValue || code >= limitValue) {
  31220. var p = table[code - limitValue];
  31221. if (p[0] === i) {
  31222. this.eatBits(i);
  31223. return [
  31224. true,
  31225. p[1],
  31226. true
  31227. ];
  31228. }
  31229. }
  31230. }
  31231. return [
  31232. false,
  31233. 0,
  31234. false
  31235. ];
  31236. };
  31237. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  31238. var code = 0;
  31239. var p;
  31240. if (this.eoblock) {
  31241. code = this.lookBits(7);
  31242. p = twoDimTable[code];
  31243. if (p && p[0] > 0) {
  31244. this.eatBits(p[0]);
  31245. return p[1];
  31246. }
  31247. } else {
  31248. var result = this.findTableCode(1, 7, twoDimTable);
  31249. if (result[0] && result[2]) {
  31250. return result[1];
  31251. }
  31252. }
  31253. info('Bad two dim code');
  31254. return ccittEOF;
  31255. };
  31256. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  31257. var code = 0;
  31258. var p;
  31259. if (this.eoblock) {
  31260. code = this.lookBits(12);
  31261. if (code === ccittEOF) {
  31262. return 1;
  31263. }
  31264. if (code >> 5 === 0) {
  31265. p = whiteTable1[code];
  31266. } else {
  31267. p = whiteTable2[code >> 3];
  31268. }
  31269. if (p[0] > 0) {
  31270. this.eatBits(p[0]);
  31271. return p[1];
  31272. }
  31273. } else {
  31274. var result = this.findTableCode(1, 9, whiteTable2);
  31275. if (result[0]) {
  31276. return result[1];
  31277. }
  31278. result = this.findTableCode(11, 12, whiteTable1);
  31279. if (result[0]) {
  31280. return result[1];
  31281. }
  31282. }
  31283. info('bad white code');
  31284. this.eatBits(1);
  31285. return 1;
  31286. };
  31287. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  31288. var code, p;
  31289. if (this.eoblock) {
  31290. code = this.lookBits(13);
  31291. if (code === ccittEOF) {
  31292. return 1;
  31293. }
  31294. if (code >> 7 === 0) {
  31295. p = blackTable1[code];
  31296. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  31297. p = blackTable2[(code >> 1) - 64];
  31298. } else {
  31299. p = blackTable3[code >> 7];
  31300. }
  31301. if (p[0] > 0) {
  31302. this.eatBits(p[0]);
  31303. return p[1];
  31304. }
  31305. } else {
  31306. var result = this.findTableCode(2, 6, blackTable3);
  31307. if (result[0]) {
  31308. return result[1];
  31309. }
  31310. result = this.findTableCode(7, 12, blackTable2, 64);
  31311. if (result[0]) {
  31312. return result[1];
  31313. }
  31314. result = this.findTableCode(10, 13, blackTable1);
  31315. if (result[0]) {
  31316. return result[1];
  31317. }
  31318. }
  31319. info('bad black code');
  31320. this.eatBits(1);
  31321. return 1;
  31322. };
  31323. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  31324. var c;
  31325. while (this.inputBits < n) {
  31326. if ((c = this.str.getByte()) === -1) {
  31327. if (this.inputBits === 0) {
  31328. return ccittEOF;
  31329. }
  31330. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  31331. }
  31332. this.inputBuf = this.inputBuf << 8 | c;
  31333. this.inputBits += 8;
  31334. }
  31335. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  31336. };
  31337. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  31338. if ((this.inputBits -= n) < 0) {
  31339. this.inputBits = 0;
  31340. }
  31341. };
  31342. return CCITTFaxStream;
  31343. }();
  31344. var LZWStream = function LZWStreamClosure() {
  31345. function LZWStream(str, maybeLength, earlyChange) {
  31346. this.str = str;
  31347. this.dict = str.dict;
  31348. this.cachedData = 0;
  31349. this.bitsCached = 0;
  31350. var maxLzwDictionarySize = 4096;
  31351. var lzwState = {
  31352. earlyChange: earlyChange,
  31353. codeLength: 9,
  31354. nextCode: 258,
  31355. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31356. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31357. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31358. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31359. currentSequenceLength: 0
  31360. };
  31361. for (var i = 0; i < 256; ++i) {
  31362. lzwState.dictionaryValues[i] = i;
  31363. lzwState.dictionaryLengths[i] = 1;
  31364. }
  31365. this.lzwState = lzwState;
  31366. DecodeStream.call(this, maybeLength);
  31367. }
  31368. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31369. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31370. var bitsCached = this.bitsCached;
  31371. var cachedData = this.cachedData;
  31372. while (bitsCached < n) {
  31373. var c = this.str.getByte();
  31374. if (c === -1) {
  31375. this.eof = true;
  31376. return null;
  31377. }
  31378. cachedData = cachedData << 8 | c;
  31379. bitsCached += 8;
  31380. }
  31381. this.bitsCached = bitsCached -= n;
  31382. this.cachedData = cachedData;
  31383. this.lastCode = null;
  31384. return cachedData >>> bitsCached & (1 << n) - 1;
  31385. };
  31386. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31387. var blockSize = 512;
  31388. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31389. var i, j, q;
  31390. var lzwState = this.lzwState;
  31391. if (!lzwState) {
  31392. return;
  31393. }
  31394. var earlyChange = lzwState.earlyChange;
  31395. var nextCode = lzwState.nextCode;
  31396. var dictionaryValues = lzwState.dictionaryValues;
  31397. var dictionaryLengths = lzwState.dictionaryLengths;
  31398. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31399. var codeLength = lzwState.codeLength;
  31400. var prevCode = lzwState.prevCode;
  31401. var currentSequence = lzwState.currentSequence;
  31402. var currentSequenceLength = lzwState.currentSequenceLength;
  31403. var decodedLength = 0;
  31404. var currentBufferLength = this.bufferLength;
  31405. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31406. for (i = 0; i < blockSize; i++) {
  31407. var code = this.readBits(codeLength);
  31408. var hasPrev = currentSequenceLength > 0;
  31409. if (code < 256) {
  31410. currentSequence[0] = code;
  31411. currentSequenceLength = 1;
  31412. } else if (code >= 258) {
  31413. if (code < nextCode) {
  31414. currentSequenceLength = dictionaryLengths[code];
  31415. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31416. currentSequence[j] = dictionaryValues[q];
  31417. q = dictionaryPrevCodes[q];
  31418. }
  31419. } else {
  31420. currentSequence[currentSequenceLength++] = currentSequence[0];
  31421. }
  31422. } else if (code === 256) {
  31423. codeLength = 9;
  31424. nextCode = 258;
  31425. currentSequenceLength = 0;
  31426. continue;
  31427. } else {
  31428. this.eof = true;
  31429. delete this.lzwState;
  31430. break;
  31431. }
  31432. if (hasPrev) {
  31433. dictionaryPrevCodes[nextCode] = prevCode;
  31434. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31435. dictionaryValues[nextCode] = currentSequence[0];
  31436. nextCode++;
  31437. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31438. }
  31439. prevCode = code;
  31440. decodedLength += currentSequenceLength;
  31441. if (estimatedDecodedSize < decodedLength) {
  31442. do {
  31443. estimatedDecodedSize += decodedSizeDelta;
  31444. } while (estimatedDecodedSize < decodedLength);
  31445. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31446. }
  31447. for (j = 0; j < currentSequenceLength; j++) {
  31448. buffer[currentBufferLength++] = currentSequence[j];
  31449. }
  31450. }
  31451. lzwState.nextCode = nextCode;
  31452. lzwState.codeLength = codeLength;
  31453. lzwState.prevCode = prevCode;
  31454. lzwState.currentSequenceLength = currentSequenceLength;
  31455. this.bufferLength = currentBufferLength;
  31456. };
  31457. return LZWStream;
  31458. }();
  31459. var NullStream = function NullStreamClosure() {
  31460. function NullStream() {
  31461. Stream.call(this, new Uint8Array(0));
  31462. }
  31463. NullStream.prototype = Stream.prototype;
  31464. return NullStream;
  31465. }();
  31466. exports.Ascii85Stream = Ascii85Stream;
  31467. exports.AsciiHexStream = AsciiHexStream;
  31468. exports.CCITTFaxStream = CCITTFaxStream;
  31469. exports.DecryptStream = DecryptStream;
  31470. exports.DecodeStream = DecodeStream;
  31471. exports.FlateStream = FlateStream;
  31472. exports.Jbig2Stream = Jbig2Stream;
  31473. exports.JpegStream = JpegStream;
  31474. exports.JpxStream = JpxStream;
  31475. exports.NullStream = NullStream;
  31476. exports.PredictorStream = PredictorStream;
  31477. exports.RunLengthStream = RunLengthStream;
  31478. exports.Stream = Stream;
  31479. exports.StreamsSequenceStream = StreamsSequenceStream;
  31480. exports.StringStream = StringStream;
  31481. exports.LZWStream = LZWStream;
  31482. }));
  31483. (function (root, factory) {
  31484. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31485. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31486. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31487. var AnnotationType = sharedUtil.AnnotationType;
  31488. var stringToPDFString = sharedUtil.stringToPDFString;
  31489. var Util = sharedUtil.Util;
  31490. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31491. var LinkTarget = displayDOMUtils.LinkTarget;
  31492. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31493. var warn = sharedUtil.warn;
  31494. var CustomStyle = displayDOMUtils.CustomStyle;
  31495. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31496. function AnnotationElementFactory() {
  31497. }
  31498. AnnotationElementFactory.prototype = {
  31499. create: function AnnotationElementFactory_create(parameters) {
  31500. var subtype = parameters.data.annotationType;
  31501. switch (subtype) {
  31502. case AnnotationType.LINK:
  31503. return new LinkAnnotationElement(parameters);
  31504. case AnnotationType.TEXT:
  31505. return new TextAnnotationElement(parameters);
  31506. case AnnotationType.WIDGET:
  31507. var fieldType = parameters.data.fieldType;
  31508. switch (fieldType) {
  31509. case 'Tx':
  31510. return new TextWidgetAnnotationElement(parameters);
  31511. case 'Btn':
  31512. if (parameters.data.radioButton) {
  31513. return new RadioButtonWidgetAnnotationElement(parameters);
  31514. } else if (parameters.data.checkBox) {
  31515. return new CheckboxWidgetAnnotationElement(parameters);
  31516. }
  31517. warn('Unimplemented button widget annotation: pushbutton');
  31518. break;
  31519. case 'Ch':
  31520. return new ChoiceWidgetAnnotationElement(parameters);
  31521. }
  31522. return new WidgetAnnotationElement(parameters);
  31523. case AnnotationType.POPUP:
  31524. return new PopupAnnotationElement(parameters);
  31525. case AnnotationType.HIGHLIGHT:
  31526. return new HighlightAnnotationElement(parameters);
  31527. case AnnotationType.UNDERLINE:
  31528. return new UnderlineAnnotationElement(parameters);
  31529. case AnnotationType.SQUIGGLY:
  31530. return new SquigglyAnnotationElement(parameters);
  31531. case AnnotationType.STRIKEOUT:
  31532. return new StrikeOutAnnotationElement(parameters);
  31533. case AnnotationType.FILEATTACHMENT:
  31534. return new FileAttachmentAnnotationElement(parameters);
  31535. default:
  31536. return new AnnotationElement(parameters);
  31537. }
  31538. }
  31539. };
  31540. var AnnotationElement = function AnnotationElementClosure() {
  31541. function AnnotationElement(parameters, isRenderable) {
  31542. this.isRenderable = isRenderable || false;
  31543. this.data = parameters.data;
  31544. this.layer = parameters.layer;
  31545. this.page = parameters.page;
  31546. this.viewport = parameters.viewport;
  31547. this.linkService = parameters.linkService;
  31548. this.downloadManager = parameters.downloadManager;
  31549. this.imageResourcesPath = parameters.imageResourcesPath;
  31550. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31551. if (isRenderable) {
  31552. this.container = this._createContainer();
  31553. }
  31554. }
  31555. AnnotationElement.prototype = {
  31556. _createContainer: function AnnotationElement_createContainer() {
  31557. var data = this.data, page = this.page, viewport = this.viewport;
  31558. var container = document.createElement('section');
  31559. var width = data.rect[2] - data.rect[0];
  31560. var height = data.rect[3] - data.rect[1];
  31561. container.setAttribute('data-annotation-id', data.id);
  31562. var rect = Util.normalizeRect([
  31563. data.rect[0],
  31564. page.view[3] - data.rect[1] + page.view[1],
  31565. data.rect[2],
  31566. page.view[3] - data.rect[3] + page.view[1]
  31567. ]);
  31568. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31569. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31570. if (data.borderStyle.width > 0) {
  31571. container.style.borderWidth = data.borderStyle.width + 'px';
  31572. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31573. width = width - 2 * data.borderStyle.width;
  31574. height = height - 2 * data.borderStyle.width;
  31575. }
  31576. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31577. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31578. if (horizontalRadius > 0 || verticalRadius > 0) {
  31579. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31580. CustomStyle.setProp('borderRadius', container, radius);
  31581. }
  31582. switch (data.borderStyle.style) {
  31583. case AnnotationBorderStyleType.SOLID:
  31584. container.style.borderStyle = 'solid';
  31585. break;
  31586. case AnnotationBorderStyleType.DASHED:
  31587. container.style.borderStyle = 'dashed';
  31588. break;
  31589. case AnnotationBorderStyleType.BEVELED:
  31590. warn('Unimplemented border style: beveled');
  31591. break;
  31592. case AnnotationBorderStyleType.INSET:
  31593. warn('Unimplemented border style: inset');
  31594. break;
  31595. case AnnotationBorderStyleType.UNDERLINE:
  31596. container.style.borderBottomStyle = 'solid';
  31597. break;
  31598. default:
  31599. break;
  31600. }
  31601. if (data.color) {
  31602. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31603. } else {
  31604. container.style.borderWidth = 0;
  31605. }
  31606. }
  31607. container.style.left = rect[0] + 'px';
  31608. container.style.top = rect[1] + 'px';
  31609. container.style.width = width + 'px';
  31610. container.style.height = height + 'px';
  31611. return container;
  31612. },
  31613. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31614. if (!trigger) {
  31615. trigger = document.createElement('div');
  31616. trigger.style.height = container.style.height;
  31617. trigger.style.width = container.style.width;
  31618. container.appendChild(trigger);
  31619. }
  31620. var popupElement = new PopupElement({
  31621. container: container,
  31622. trigger: trigger,
  31623. color: data.color,
  31624. title: data.title,
  31625. contents: data.contents,
  31626. hideWrapper: true
  31627. });
  31628. var popup = popupElement.render();
  31629. popup.style.left = container.style.width;
  31630. container.appendChild(popup);
  31631. },
  31632. render: function AnnotationElement_render() {
  31633. throw new Error('Abstract method AnnotationElement.render called');
  31634. }
  31635. };
  31636. return AnnotationElement;
  31637. }();
  31638. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31639. function LinkAnnotationElement(parameters) {
  31640. AnnotationElement.call(this, parameters, true);
  31641. }
  31642. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31643. render: function LinkAnnotationElement_render() {
  31644. this.container.className = 'linkAnnotation';
  31645. var link = document.createElement('a');
  31646. addLinkAttributes(link, {
  31647. url: this.data.url,
  31648. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31649. });
  31650. if (!this.data.url) {
  31651. if (this.data.action) {
  31652. this._bindNamedAction(link, this.data.action);
  31653. } else {
  31654. this._bindLink(link, this.data.dest);
  31655. }
  31656. }
  31657. this.container.appendChild(link);
  31658. return this.container;
  31659. },
  31660. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31661. var self = this;
  31662. link.href = this.linkService.getDestinationHash(destination);
  31663. link.onclick = function () {
  31664. if (destination) {
  31665. self.linkService.navigateTo(destination);
  31666. }
  31667. return false;
  31668. };
  31669. if (destination) {
  31670. link.className = 'internalLink';
  31671. }
  31672. },
  31673. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31674. var self = this;
  31675. link.href = this.linkService.getAnchorUrl('');
  31676. link.onclick = function () {
  31677. self.linkService.executeNamedAction(action);
  31678. return false;
  31679. };
  31680. link.className = 'internalLink';
  31681. }
  31682. });
  31683. return LinkAnnotationElement;
  31684. }();
  31685. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31686. function TextAnnotationElement(parameters) {
  31687. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31688. AnnotationElement.call(this, parameters, isRenderable);
  31689. }
  31690. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31691. render: function TextAnnotationElement_render() {
  31692. this.container.className = 'textAnnotation';
  31693. var image = document.createElement('img');
  31694. image.style.height = this.container.style.height;
  31695. image.style.width = this.container.style.width;
  31696. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31697. image.alt = '[{{type}} Annotation]';
  31698. image.dataset.l10nId = 'text_annotation_type';
  31699. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31700. if (!this.data.hasPopup) {
  31701. this._createPopup(this.container, image, this.data);
  31702. }
  31703. this.container.appendChild(image);
  31704. return this.container;
  31705. }
  31706. });
  31707. return TextAnnotationElement;
  31708. }();
  31709. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31710. function WidgetAnnotationElement(parameters, isRenderable) {
  31711. AnnotationElement.call(this, parameters, isRenderable);
  31712. }
  31713. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31714. render: function WidgetAnnotationElement_render() {
  31715. return this.container;
  31716. }
  31717. });
  31718. return WidgetAnnotationElement;
  31719. }();
  31720. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31721. var TEXT_ALIGNMENT = [
  31722. 'left',
  31723. 'center',
  31724. 'right'
  31725. ];
  31726. function TextWidgetAnnotationElement(parameters) {
  31727. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31728. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31729. }
  31730. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31731. render: function TextWidgetAnnotationElement_render() {
  31732. this.container.className = 'textWidgetAnnotation';
  31733. var element = null;
  31734. if (this.renderInteractiveForms) {
  31735. if (this.data.multiLine) {
  31736. element = document.createElement('textarea');
  31737. element.textContent = this.data.fieldValue;
  31738. } else {
  31739. element = document.createElement('input');
  31740. element.type = 'text';
  31741. element.setAttribute('value', this.data.fieldValue);
  31742. }
  31743. element.disabled = this.data.readOnly;
  31744. if (this.data.maxLen !== null) {
  31745. element.maxLength = this.data.maxLen;
  31746. }
  31747. if (this.data.comb) {
  31748. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31749. var combWidth = fieldWidth / this.data.maxLen;
  31750. element.classList.add('comb');
  31751. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31752. }
  31753. } else {
  31754. element = document.createElement('div');
  31755. element.textContent = this.data.fieldValue;
  31756. element.style.verticalAlign = 'middle';
  31757. element.style.display = 'table-cell';
  31758. var font = null;
  31759. if (this.data.fontRefName) {
  31760. font = this.page.commonObjs.getData(this.data.fontRefName);
  31761. }
  31762. this._setTextStyle(element, font);
  31763. }
  31764. if (this.data.textAlignment !== null) {
  31765. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31766. }
  31767. this.container.appendChild(element);
  31768. return this.container;
  31769. },
  31770. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31771. var style = element.style;
  31772. style.fontSize = this.data.fontSize + 'px';
  31773. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31774. if (!font) {
  31775. return;
  31776. }
  31777. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31778. style.fontStyle = font.italic ? 'italic' : 'normal';
  31779. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31780. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31781. style.fontFamily = fontFamily + fallbackName;
  31782. }
  31783. });
  31784. return TextWidgetAnnotationElement;
  31785. }();
  31786. var CheckboxWidgetAnnotationElement = function CheckboxWidgetAnnotationElementClosure() {
  31787. function CheckboxWidgetAnnotationElement(parameters) {
  31788. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31789. }
  31790. Util.inherit(CheckboxWidgetAnnotationElement, WidgetAnnotationElement, {
  31791. render: function CheckboxWidgetAnnotationElement_render() {
  31792. this.container.className = 'buttonWidgetAnnotation checkBox';
  31793. var element = document.createElement('input');
  31794. element.disabled = this.data.readOnly;
  31795. element.type = 'checkbox';
  31796. if (this.data.fieldValue && this.data.fieldValue !== 'Off') {
  31797. element.setAttribute('checked', true);
  31798. }
  31799. this.container.appendChild(element);
  31800. return this.container;
  31801. }
  31802. });
  31803. return CheckboxWidgetAnnotationElement;
  31804. }();
  31805. var RadioButtonWidgetAnnotationElement = function RadioButtonWidgetAnnotationElementClosure() {
  31806. function RadioButtonWidgetAnnotationElement(parameters) {
  31807. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31808. }
  31809. Util.inherit(RadioButtonWidgetAnnotationElement, WidgetAnnotationElement, {
  31810. render: function RadioButtonWidgetAnnotationElement_render() {
  31811. this.container.className = 'buttonWidgetAnnotation radioButton';
  31812. var element = document.createElement('input');
  31813. element.disabled = this.data.readOnly;
  31814. element.type = 'radio';
  31815. element.name = this.data.fieldName;
  31816. if (this.data.fieldValue === this.data.buttonValue) {
  31817. element.setAttribute('checked', true);
  31818. }
  31819. this.container.appendChild(element);
  31820. return this.container;
  31821. }
  31822. });
  31823. return RadioButtonWidgetAnnotationElement;
  31824. }();
  31825. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31826. function ChoiceWidgetAnnotationElement(parameters) {
  31827. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31828. }
  31829. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31830. render: function ChoiceWidgetAnnotationElement_render() {
  31831. this.container.className = 'choiceWidgetAnnotation';
  31832. var selectElement = document.createElement('select');
  31833. selectElement.disabled = this.data.readOnly;
  31834. if (!this.data.combo) {
  31835. selectElement.size = this.data.options.length;
  31836. if (this.data.multiSelect) {
  31837. selectElement.multiple = true;
  31838. }
  31839. }
  31840. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31841. var option = this.data.options[i];
  31842. var optionElement = document.createElement('option');
  31843. optionElement.textContent = option.displayValue;
  31844. optionElement.value = option.exportValue;
  31845. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31846. optionElement.setAttribute('selected', true);
  31847. }
  31848. selectElement.appendChild(optionElement);
  31849. }
  31850. this.container.appendChild(selectElement);
  31851. return this.container;
  31852. }
  31853. });
  31854. return ChoiceWidgetAnnotationElement;
  31855. }();
  31856. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31857. function PopupAnnotationElement(parameters) {
  31858. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31859. AnnotationElement.call(this, parameters, isRenderable);
  31860. }
  31861. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31862. render: function PopupAnnotationElement_render() {
  31863. this.container.className = 'popupAnnotation';
  31864. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31865. var parentElement = this.layer.querySelector(selector);
  31866. if (!parentElement) {
  31867. return this.container;
  31868. }
  31869. var popup = new PopupElement({
  31870. container: this.container,
  31871. trigger: parentElement,
  31872. color: this.data.color,
  31873. title: this.data.title,
  31874. contents: this.data.contents
  31875. });
  31876. var parentLeft = parseFloat(parentElement.style.left);
  31877. var parentWidth = parseFloat(parentElement.style.width);
  31878. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31879. this.container.style.left = parentLeft + parentWidth + 'px';
  31880. this.container.appendChild(popup.render());
  31881. return this.container;
  31882. }
  31883. });
  31884. return PopupAnnotationElement;
  31885. }();
  31886. var PopupElement = function PopupElementClosure() {
  31887. var BACKGROUND_ENLIGHT = 0.7;
  31888. function PopupElement(parameters) {
  31889. this.container = parameters.container;
  31890. this.trigger = parameters.trigger;
  31891. this.color = parameters.color;
  31892. this.title = parameters.title;
  31893. this.contents = parameters.contents;
  31894. this.hideWrapper = parameters.hideWrapper || false;
  31895. this.pinned = false;
  31896. }
  31897. PopupElement.prototype = {
  31898. render: function PopupElement_render() {
  31899. var wrapper = document.createElement('div');
  31900. wrapper.className = 'popupWrapper';
  31901. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31902. this.hideElement.setAttribute('hidden', true);
  31903. var popup = document.createElement('div');
  31904. popup.className = 'popup';
  31905. var color = this.color;
  31906. if (color) {
  31907. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31908. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31909. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31910. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31911. }
  31912. var contents = this._formatContents(this.contents);
  31913. var title = document.createElement('h1');
  31914. title.textContent = this.title;
  31915. this.trigger.addEventListener('click', this._toggle.bind(this));
  31916. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31917. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31918. popup.addEventListener('click', this._hide.bind(this, true));
  31919. popup.appendChild(title);
  31920. popup.appendChild(contents);
  31921. wrapper.appendChild(popup);
  31922. return wrapper;
  31923. },
  31924. _formatContents: function PopupElement_formatContents(contents) {
  31925. var p = document.createElement('p');
  31926. var lines = contents.split(/(?:\r\n?|\n)/);
  31927. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31928. var line = lines[i];
  31929. p.appendChild(document.createTextNode(line));
  31930. if (i < ii - 1) {
  31931. p.appendChild(document.createElement('br'));
  31932. }
  31933. }
  31934. return p;
  31935. },
  31936. _toggle: function PopupElement_toggle() {
  31937. if (this.pinned) {
  31938. this._hide(true);
  31939. } else {
  31940. this._show(true);
  31941. }
  31942. },
  31943. _show: function PopupElement_show(pin) {
  31944. if (pin) {
  31945. this.pinned = true;
  31946. }
  31947. if (this.hideElement.hasAttribute('hidden')) {
  31948. this.hideElement.removeAttribute('hidden');
  31949. this.container.style.zIndex += 1;
  31950. }
  31951. },
  31952. _hide: function PopupElement_hide(unpin) {
  31953. if (unpin) {
  31954. this.pinned = false;
  31955. }
  31956. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31957. this.hideElement.setAttribute('hidden', true);
  31958. this.container.style.zIndex -= 1;
  31959. }
  31960. }
  31961. };
  31962. return PopupElement;
  31963. }();
  31964. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31965. function HighlightAnnotationElement(parameters) {
  31966. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31967. AnnotationElement.call(this, parameters, isRenderable);
  31968. }
  31969. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31970. render: function HighlightAnnotationElement_render() {
  31971. this.container.className = 'highlightAnnotation';
  31972. if (!this.data.hasPopup) {
  31973. this._createPopup(this.container, null, this.data);
  31974. }
  31975. return this.container;
  31976. }
  31977. });
  31978. return HighlightAnnotationElement;
  31979. }();
  31980. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31981. function UnderlineAnnotationElement(parameters) {
  31982. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31983. AnnotationElement.call(this, parameters, isRenderable);
  31984. }
  31985. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31986. render: function UnderlineAnnotationElement_render() {
  31987. this.container.className = 'underlineAnnotation';
  31988. if (!this.data.hasPopup) {
  31989. this._createPopup(this.container, null, this.data);
  31990. }
  31991. return this.container;
  31992. }
  31993. });
  31994. return UnderlineAnnotationElement;
  31995. }();
  31996. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31997. function SquigglyAnnotationElement(parameters) {
  31998. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31999. AnnotationElement.call(this, parameters, isRenderable);
  32000. }
  32001. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  32002. render: function SquigglyAnnotationElement_render() {
  32003. this.container.className = 'squigglyAnnotation';
  32004. if (!this.data.hasPopup) {
  32005. this._createPopup(this.container, null, this.data);
  32006. }
  32007. return this.container;
  32008. }
  32009. });
  32010. return SquigglyAnnotationElement;
  32011. }();
  32012. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  32013. function StrikeOutAnnotationElement(parameters) {
  32014. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  32015. AnnotationElement.call(this, parameters, isRenderable);
  32016. }
  32017. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  32018. render: function StrikeOutAnnotationElement_render() {
  32019. this.container.className = 'strikeoutAnnotation';
  32020. if (!this.data.hasPopup) {
  32021. this._createPopup(this.container, null, this.data);
  32022. }
  32023. return this.container;
  32024. }
  32025. });
  32026. return StrikeOutAnnotationElement;
  32027. }();
  32028. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  32029. function FileAttachmentAnnotationElement(parameters) {
  32030. AnnotationElement.call(this, parameters, true);
  32031. var file = this.data.file;
  32032. this.filename = getFilenameFromUrl(file.filename);
  32033. this.content = file.content;
  32034. this.linkService.onFileAttachmentAnnotation({
  32035. id: stringToPDFString(file.filename),
  32036. filename: file.filename,
  32037. content: file.content
  32038. });
  32039. }
  32040. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  32041. render: function FileAttachmentAnnotationElement_render() {
  32042. this.container.className = 'fileAttachmentAnnotation';
  32043. var trigger = document.createElement('div');
  32044. trigger.style.height = this.container.style.height;
  32045. trigger.style.width = this.container.style.width;
  32046. trigger.addEventListener('dblclick', this._download.bind(this));
  32047. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  32048. this._createPopup(this.container, trigger, this.data);
  32049. }
  32050. this.container.appendChild(trigger);
  32051. return this.container;
  32052. },
  32053. _download: function FileAttachmentAnnotationElement_download() {
  32054. if (!this.downloadManager) {
  32055. warn('Download cannot be started due to unavailable download manager');
  32056. return;
  32057. }
  32058. this.downloadManager.downloadData(this.content, this.filename, '');
  32059. }
  32060. });
  32061. return FileAttachmentAnnotationElement;
  32062. }();
  32063. var AnnotationLayer = function AnnotationLayerClosure() {
  32064. return {
  32065. render: function AnnotationLayer_render(parameters) {
  32066. var annotationElementFactory = new AnnotationElementFactory();
  32067. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  32068. var data = parameters.annotations[i];
  32069. if (!data) {
  32070. continue;
  32071. }
  32072. var element = annotationElementFactory.create({
  32073. data: data,
  32074. layer: parameters.div,
  32075. page: parameters.page,
  32076. viewport: parameters.viewport,
  32077. linkService: parameters.linkService,
  32078. downloadManager: parameters.downloadManager,
  32079. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  32080. renderInteractiveForms: parameters.renderInteractiveForms || false
  32081. });
  32082. if (element.isRenderable) {
  32083. parameters.div.appendChild(element.render());
  32084. }
  32085. }
  32086. },
  32087. update: function AnnotationLayer_update(parameters) {
  32088. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  32089. var data = parameters.annotations[i];
  32090. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  32091. if (element) {
  32092. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  32093. }
  32094. }
  32095. parameters.div.removeAttribute('hidden');
  32096. }
  32097. };
  32098. }();
  32099. exports.AnnotationLayer = AnnotationLayer;
  32100. }));
  32101. (function (root, factory) {
  32102. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32103. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32104. var Util = sharedUtil.Util;
  32105. var createPromiseCapability = sharedUtil.createPromiseCapability;
  32106. var CustomStyle = displayDOMUtils.CustomStyle;
  32107. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32108. var renderTextLayer = function renderTextLayerClosure() {
  32109. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  32110. var NonWhitespaceRegexp = /\S/;
  32111. function isAllWhitespace(str) {
  32112. return !NonWhitespaceRegexp.test(str);
  32113. }
  32114. var styleBuf = [
  32115. 'left: ',
  32116. 0,
  32117. 'px; top: ',
  32118. 0,
  32119. 'px; font-size: ',
  32120. 0,
  32121. 'px; font-family: ',
  32122. '',
  32123. ';'
  32124. ];
  32125. function appendText(task, geom, styles) {
  32126. var textDiv = document.createElement('div');
  32127. var textDivProperties = {
  32128. style: null,
  32129. angle: 0,
  32130. canvasWidth: 0,
  32131. isWhitespace: false,
  32132. originalTransform: null,
  32133. paddingBottom: 0,
  32134. paddingLeft: 0,
  32135. paddingRight: 0,
  32136. paddingTop: 0,
  32137. scale: 1
  32138. };
  32139. task._textDivs.push(textDiv);
  32140. if (isAllWhitespace(geom.str)) {
  32141. textDivProperties.isWhitespace = true;
  32142. task._textDivProperties.set(textDiv, textDivProperties);
  32143. return;
  32144. }
  32145. var tx = Util.transform(task._viewport.transform, geom.transform);
  32146. var angle = Math.atan2(tx[1], tx[0]);
  32147. var style = styles[geom.fontName];
  32148. if (style.vertical) {
  32149. angle += Math.PI / 2;
  32150. }
  32151. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  32152. var fontAscent = fontHeight;
  32153. if (style.ascent) {
  32154. fontAscent = style.ascent * fontAscent;
  32155. } else if (style.descent) {
  32156. fontAscent = (1 + style.descent) * fontAscent;
  32157. }
  32158. var left;
  32159. var top;
  32160. if (angle === 0) {
  32161. left = tx[4];
  32162. top = tx[5] - fontAscent;
  32163. } else {
  32164. left = tx[4] + fontAscent * Math.sin(angle);
  32165. top = tx[5] - fontAscent * Math.cos(angle);
  32166. }
  32167. styleBuf[1] = left;
  32168. styleBuf[3] = top;
  32169. styleBuf[5] = fontHeight;
  32170. styleBuf[7] = style.fontFamily;
  32171. textDivProperties.style = styleBuf.join('');
  32172. textDiv.setAttribute('style', textDivProperties.style);
  32173. textDiv.textContent = geom.str;
  32174. if (getDefaultSetting('pdfBug')) {
  32175. textDiv.dataset.fontName = geom.fontName;
  32176. }
  32177. if (angle !== 0) {
  32178. textDivProperties.angle = angle * (180 / Math.PI);
  32179. }
  32180. if (geom.str.length > 1) {
  32181. if (style.vertical) {
  32182. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  32183. } else {
  32184. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  32185. }
  32186. }
  32187. task._textDivProperties.set(textDiv, textDivProperties);
  32188. if (task._enhanceTextSelection) {
  32189. var angleCos = 1, angleSin = 0;
  32190. if (angle !== 0) {
  32191. angleCos = Math.cos(angle);
  32192. angleSin = Math.sin(angle);
  32193. }
  32194. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  32195. var divHeight = fontHeight;
  32196. var m, b;
  32197. if (angle !== 0) {
  32198. m = [
  32199. angleCos,
  32200. angleSin,
  32201. -angleSin,
  32202. angleCos,
  32203. left,
  32204. top
  32205. ];
  32206. b = Util.getAxialAlignedBoundingBox([
  32207. 0,
  32208. 0,
  32209. divWidth,
  32210. divHeight
  32211. ], m);
  32212. } else {
  32213. b = [
  32214. left,
  32215. top,
  32216. left + divWidth,
  32217. top + divHeight
  32218. ];
  32219. }
  32220. task._bounds.push({
  32221. left: b[0],
  32222. top: b[1],
  32223. right: b[2],
  32224. bottom: b[3],
  32225. div: textDiv,
  32226. size: [
  32227. divWidth,
  32228. divHeight
  32229. ],
  32230. m: m
  32231. });
  32232. }
  32233. }
  32234. function render(task) {
  32235. if (task._canceled) {
  32236. return;
  32237. }
  32238. var textLayerFrag = task._container;
  32239. var textDivs = task._textDivs;
  32240. var capability = task._capability;
  32241. var textDivsLength = textDivs.length;
  32242. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  32243. task._renderingDone = true;
  32244. capability.resolve();
  32245. return;
  32246. }
  32247. var canvas = document.createElement('canvas');
  32248. var ctx = canvas.getContext('2d', { alpha: false });
  32249. var lastFontSize;
  32250. var lastFontFamily;
  32251. for (var i = 0; i < textDivsLength; i++) {
  32252. var textDiv = textDivs[i];
  32253. var textDivProperties = task._textDivProperties.get(textDiv);
  32254. if (textDivProperties.isWhitespace) {
  32255. continue;
  32256. }
  32257. var fontSize = textDiv.style.fontSize;
  32258. var fontFamily = textDiv.style.fontFamily;
  32259. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  32260. ctx.font = fontSize + ' ' + fontFamily;
  32261. lastFontSize = fontSize;
  32262. lastFontFamily = fontFamily;
  32263. }
  32264. var width = ctx.measureText(textDiv.textContent).width;
  32265. textLayerFrag.appendChild(textDiv);
  32266. var transform = '';
  32267. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  32268. textDivProperties.scale = textDivProperties.canvasWidth / width;
  32269. transform = 'scaleX(' + textDivProperties.scale + ')';
  32270. }
  32271. if (textDivProperties.angle !== 0) {
  32272. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  32273. }
  32274. if (transform !== '') {
  32275. textDivProperties.originalTransform = transform;
  32276. CustomStyle.setProp('transform', textDiv, transform);
  32277. }
  32278. task._textDivProperties.set(textDiv, textDivProperties);
  32279. }
  32280. task._renderingDone = true;
  32281. capability.resolve();
  32282. }
  32283. function expand(task) {
  32284. var bounds = task._bounds;
  32285. var viewport = task._viewport;
  32286. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  32287. for (var i = 0; i < expanded.length; i++) {
  32288. var div = bounds[i].div;
  32289. var divProperties = task._textDivProperties.get(div);
  32290. if (divProperties.angle === 0) {
  32291. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  32292. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  32293. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  32294. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  32295. task._textDivProperties.set(div, divProperties);
  32296. continue;
  32297. }
  32298. var e = expanded[i], b = bounds[i];
  32299. var m = b.m, c = m[0], s = m[1];
  32300. var points = [
  32301. [
  32302. 0,
  32303. 0
  32304. ],
  32305. [
  32306. 0,
  32307. b.size[1]
  32308. ],
  32309. [
  32310. b.size[0],
  32311. 0
  32312. ],
  32313. b.size
  32314. ];
  32315. var ts = new Float64Array(64);
  32316. points.forEach(function (p, i) {
  32317. var t = Util.applyTransform(p, m);
  32318. ts[i + 0] = c && (e.left - t[0]) / c;
  32319. ts[i + 4] = s && (e.top - t[1]) / s;
  32320. ts[i + 8] = c && (e.right - t[0]) / c;
  32321. ts[i + 12] = s && (e.bottom - t[1]) / s;
  32322. ts[i + 16] = s && (e.left - t[0]) / -s;
  32323. ts[i + 20] = c && (e.top - t[1]) / c;
  32324. ts[i + 24] = s && (e.right - t[0]) / -s;
  32325. ts[i + 28] = c && (e.bottom - t[1]) / c;
  32326. ts[i + 32] = c && (e.left - t[0]) / -c;
  32327. ts[i + 36] = s && (e.top - t[1]) / -s;
  32328. ts[i + 40] = c && (e.right - t[0]) / -c;
  32329. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  32330. ts[i + 48] = s && (e.left - t[0]) / s;
  32331. ts[i + 52] = c && (e.top - t[1]) / -c;
  32332. ts[i + 56] = s && (e.right - t[0]) / s;
  32333. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  32334. });
  32335. var findPositiveMin = function (ts, offset, count) {
  32336. var result = 0;
  32337. for (var i = 0; i < count; i++) {
  32338. var t = ts[offset++];
  32339. if (t > 0) {
  32340. result = result ? Math.min(t, result) : t;
  32341. }
  32342. }
  32343. return result;
  32344. };
  32345. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  32346. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  32347. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  32348. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  32349. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  32350. task._textDivProperties.set(div, divProperties);
  32351. }
  32352. }
  32353. function expandBounds(width, height, boxes) {
  32354. var bounds = boxes.map(function (box, i) {
  32355. return {
  32356. x1: box.left,
  32357. y1: box.top,
  32358. x2: box.right,
  32359. y2: box.bottom,
  32360. index: i,
  32361. x1New: undefined,
  32362. x2New: undefined
  32363. };
  32364. });
  32365. expandBoundsLTR(width, bounds);
  32366. var expanded = new Array(boxes.length);
  32367. bounds.forEach(function (b) {
  32368. var i = b.index;
  32369. expanded[i] = {
  32370. left: b.x1New,
  32371. top: 0,
  32372. right: b.x2New,
  32373. bottom: 0
  32374. };
  32375. });
  32376. boxes.map(function (box, i) {
  32377. var e = expanded[i], b = bounds[i];
  32378. b.x1 = box.top;
  32379. b.y1 = width - e.right;
  32380. b.x2 = box.bottom;
  32381. b.y2 = width - e.left;
  32382. b.index = i;
  32383. b.x1New = undefined;
  32384. b.x2New = undefined;
  32385. });
  32386. expandBoundsLTR(height, bounds);
  32387. bounds.forEach(function (b) {
  32388. var i = b.index;
  32389. expanded[i].top = b.x1New;
  32390. expanded[i].bottom = b.x2New;
  32391. });
  32392. return expanded;
  32393. }
  32394. function expandBoundsLTR(width, bounds) {
  32395. bounds.sort(function (a, b) {
  32396. return a.x1 - b.x1 || a.index - b.index;
  32397. });
  32398. var fakeBoundary = {
  32399. x1: -Infinity,
  32400. y1: -Infinity,
  32401. x2: 0,
  32402. y2: Infinity,
  32403. index: -1,
  32404. x1New: 0,
  32405. x2New: 0
  32406. };
  32407. var horizon = [{
  32408. start: -Infinity,
  32409. end: Infinity,
  32410. boundary: fakeBoundary
  32411. }];
  32412. bounds.forEach(function (boundary) {
  32413. var i = 0;
  32414. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32415. i++;
  32416. }
  32417. var j = horizon.length - 1;
  32418. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32419. j--;
  32420. }
  32421. var horizonPart, affectedBoundary;
  32422. var q, k, maxXNew = -Infinity;
  32423. for (q = i; q <= j; q++) {
  32424. horizonPart = horizon[q];
  32425. affectedBoundary = horizonPart.boundary;
  32426. var xNew;
  32427. if (affectedBoundary.x2 > boundary.x1) {
  32428. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32429. } else if (affectedBoundary.x2New === undefined) {
  32430. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32431. } else {
  32432. xNew = affectedBoundary.x2New;
  32433. }
  32434. if (xNew > maxXNew) {
  32435. maxXNew = xNew;
  32436. }
  32437. }
  32438. boundary.x1New = maxXNew;
  32439. for (q = i; q <= j; q++) {
  32440. horizonPart = horizon[q];
  32441. affectedBoundary = horizonPart.boundary;
  32442. if (affectedBoundary.x2New === undefined) {
  32443. if (affectedBoundary.x2 > boundary.x1) {
  32444. if (affectedBoundary.index > boundary.index) {
  32445. affectedBoundary.x2New = affectedBoundary.x2;
  32446. }
  32447. } else {
  32448. affectedBoundary.x2New = maxXNew;
  32449. }
  32450. } else if (affectedBoundary.x2New > maxXNew) {
  32451. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32452. }
  32453. }
  32454. var changedHorizon = [], lastBoundary = null;
  32455. for (q = i; q <= j; q++) {
  32456. horizonPart = horizon[q];
  32457. affectedBoundary = horizonPart.boundary;
  32458. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32459. if (lastBoundary === useBoundary) {
  32460. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32461. } else {
  32462. changedHorizon.push({
  32463. start: horizonPart.start,
  32464. end: horizonPart.end,
  32465. boundary: useBoundary
  32466. });
  32467. lastBoundary = useBoundary;
  32468. }
  32469. }
  32470. if (horizon[i].start < boundary.y1) {
  32471. changedHorizon[0].start = boundary.y1;
  32472. changedHorizon.unshift({
  32473. start: horizon[i].start,
  32474. end: boundary.y1,
  32475. boundary: horizon[i].boundary
  32476. });
  32477. }
  32478. if (boundary.y2 < horizon[j].end) {
  32479. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32480. changedHorizon.push({
  32481. start: boundary.y2,
  32482. end: horizon[j].end,
  32483. boundary: horizon[j].boundary
  32484. });
  32485. }
  32486. for (q = i; q <= j; q++) {
  32487. horizonPart = horizon[q];
  32488. affectedBoundary = horizonPart.boundary;
  32489. if (affectedBoundary.x2New !== undefined) {
  32490. continue;
  32491. }
  32492. var used = false;
  32493. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32494. used = horizon[k].boundary === affectedBoundary;
  32495. }
  32496. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32497. used = horizon[k].boundary === affectedBoundary;
  32498. }
  32499. for (k = 0; !used && k < changedHorizon.length; k++) {
  32500. used = changedHorizon[k].boundary === affectedBoundary;
  32501. }
  32502. if (!used) {
  32503. affectedBoundary.x2New = maxXNew;
  32504. }
  32505. }
  32506. Array.prototype.splice.apply(horizon, [
  32507. i,
  32508. j - i + 1
  32509. ].concat(changedHorizon));
  32510. });
  32511. horizon.forEach(function (horizonPart) {
  32512. var affectedBoundary = horizonPart.boundary;
  32513. if (affectedBoundary.x2New === undefined) {
  32514. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32515. }
  32516. });
  32517. }
  32518. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32519. this._textContent = textContent;
  32520. this._container = container;
  32521. this._viewport = viewport;
  32522. this._textDivs = textDivs || [];
  32523. this._textDivProperties = new WeakMap();
  32524. this._renderingDone = false;
  32525. this._canceled = false;
  32526. this._capability = createPromiseCapability();
  32527. this._renderTimer = null;
  32528. this._bounds = [];
  32529. this._enhanceTextSelection = !!enhanceTextSelection;
  32530. }
  32531. TextLayerRenderTask.prototype = {
  32532. get promise() {
  32533. return this._capability.promise;
  32534. },
  32535. cancel: function TextLayer_cancel() {
  32536. this._canceled = true;
  32537. if (this._renderTimer !== null) {
  32538. clearTimeout(this._renderTimer);
  32539. this._renderTimer = null;
  32540. }
  32541. this._capability.reject('canceled');
  32542. },
  32543. _render: function TextLayer_render(timeout) {
  32544. var textItems = this._textContent.items;
  32545. var textStyles = this._textContent.styles;
  32546. for (var i = 0, len = textItems.length; i < len; i++) {
  32547. appendText(this, textItems[i], textStyles);
  32548. }
  32549. if (!timeout) {
  32550. render(this);
  32551. } else {
  32552. var self = this;
  32553. this._renderTimer = setTimeout(function () {
  32554. render(self);
  32555. self._renderTimer = null;
  32556. }, timeout);
  32557. }
  32558. },
  32559. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32560. if (!this._enhanceTextSelection || !this._renderingDone) {
  32561. return;
  32562. }
  32563. if (this._bounds !== null) {
  32564. expand(this);
  32565. this._bounds = null;
  32566. }
  32567. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32568. var div = this._textDivs[i];
  32569. var divProperties = this._textDivProperties.get(div);
  32570. if (divProperties.isWhitespace) {
  32571. continue;
  32572. }
  32573. if (expandDivs) {
  32574. var transform = '', padding = '';
  32575. if (divProperties.scale !== 1) {
  32576. transform = 'scaleX(' + divProperties.scale + ')';
  32577. }
  32578. if (divProperties.angle !== 0) {
  32579. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32580. }
  32581. if (divProperties.paddingLeft !== 0) {
  32582. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32583. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32584. }
  32585. if (divProperties.paddingTop !== 0) {
  32586. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32587. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32588. }
  32589. if (divProperties.paddingRight !== 0) {
  32590. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32591. }
  32592. if (divProperties.paddingBottom !== 0) {
  32593. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32594. }
  32595. if (padding !== '') {
  32596. div.setAttribute('style', divProperties.style + padding);
  32597. }
  32598. if (transform !== '') {
  32599. CustomStyle.setProp('transform', div, transform);
  32600. }
  32601. } else {
  32602. div.style.padding = 0;
  32603. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32604. }
  32605. }
  32606. }
  32607. };
  32608. function renderTextLayer(renderParameters) {
  32609. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32610. task._render(renderParameters.timeout);
  32611. return task;
  32612. }
  32613. return renderTextLayer;
  32614. }();
  32615. exports.renderTextLayer = renderTextLayer;
  32616. }));
  32617. (function (root, factory) {
  32618. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32619. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32620. var shadow = sharedUtil.shadow;
  32621. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32622. var WebGLUtils = function WebGLUtilsClosure() {
  32623. function loadShader(gl, code, shaderType) {
  32624. var shader = gl.createShader(shaderType);
  32625. gl.shaderSource(shader, code);
  32626. gl.compileShader(shader);
  32627. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32628. if (!compiled) {
  32629. var errorMsg = gl.getShaderInfoLog(shader);
  32630. throw new Error('Error during shader compilation: ' + errorMsg);
  32631. }
  32632. return shader;
  32633. }
  32634. function createVertexShader(gl, code) {
  32635. return loadShader(gl, code, gl.VERTEX_SHADER);
  32636. }
  32637. function createFragmentShader(gl, code) {
  32638. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32639. }
  32640. function createProgram(gl, shaders) {
  32641. var program = gl.createProgram();
  32642. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32643. gl.attachShader(program, shaders[i]);
  32644. }
  32645. gl.linkProgram(program);
  32646. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32647. if (!linked) {
  32648. var errorMsg = gl.getProgramInfoLog(program);
  32649. throw new Error('Error during program linking: ' + errorMsg);
  32650. }
  32651. return program;
  32652. }
  32653. function createTexture(gl, image, textureId) {
  32654. gl.activeTexture(textureId);
  32655. var texture = gl.createTexture();
  32656. gl.bindTexture(gl.TEXTURE_2D, texture);
  32657. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32658. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32659. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32660. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32661. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32662. return texture;
  32663. }
  32664. var currentGL, currentCanvas;
  32665. function generateGL() {
  32666. if (currentGL) {
  32667. return;
  32668. }
  32669. currentCanvas = document.createElement('canvas');
  32670. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32671. }
  32672. var smaskVertexShaderCode = '\
  32673. attribute vec2 a_position; \
  32674. attribute vec2 a_texCoord; \
  32675. \
  32676. uniform vec2 u_resolution; \
  32677. \
  32678. varying vec2 v_texCoord; \
  32679. \
  32680. void main() { \
  32681. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32682. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32683. \
  32684. v_texCoord = a_texCoord; \
  32685. } ';
  32686. var smaskFragmentShaderCode = '\
  32687. precision mediump float; \
  32688. \
  32689. uniform vec4 u_backdrop; \
  32690. uniform int u_subtype; \
  32691. uniform sampler2D u_image; \
  32692. uniform sampler2D u_mask; \
  32693. \
  32694. varying vec2 v_texCoord; \
  32695. \
  32696. void main() { \
  32697. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32698. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32699. if (u_backdrop.a > 0.0) { \
  32700. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32701. u_backdrop.rgb * (1.0 - maskColor.a); \
  32702. } \
  32703. float lum; \
  32704. if (u_subtype == 0) { \
  32705. lum = maskColor.a; \
  32706. } else { \
  32707. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32708. maskColor.b * 0.11; \
  32709. } \
  32710. imageColor.a *= lum; \
  32711. imageColor.rgb *= imageColor.a; \
  32712. gl_FragColor = imageColor; \
  32713. } ';
  32714. var smaskCache = null;
  32715. function initSmaskGL() {
  32716. var canvas, gl;
  32717. generateGL();
  32718. canvas = currentCanvas;
  32719. currentCanvas = null;
  32720. gl = currentGL;
  32721. currentGL = null;
  32722. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32723. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32724. var program = createProgram(gl, [
  32725. vertexShader,
  32726. fragmentShader
  32727. ]);
  32728. gl.useProgram(program);
  32729. var cache = {};
  32730. cache.gl = gl;
  32731. cache.canvas = canvas;
  32732. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32733. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32734. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32735. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32736. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32737. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32738. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32739. var texCoordBuffer = gl.createBuffer();
  32740. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32741. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32742. 0.0,
  32743. 0.0,
  32744. 1.0,
  32745. 0.0,
  32746. 0.0,
  32747. 1.0,
  32748. 0.0,
  32749. 1.0,
  32750. 1.0,
  32751. 0.0,
  32752. 1.0,
  32753. 1.0
  32754. ]), gl.STATIC_DRAW);
  32755. gl.enableVertexAttribArray(texCoordLocation);
  32756. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32757. gl.uniform1i(texLayerLocation, 0);
  32758. gl.uniform1i(texMaskLocation, 1);
  32759. smaskCache = cache;
  32760. }
  32761. function composeSMask(layer, mask, properties) {
  32762. var width = layer.width, height = layer.height;
  32763. if (!smaskCache) {
  32764. initSmaskGL();
  32765. }
  32766. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32767. canvas.width = width;
  32768. canvas.height = height;
  32769. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32770. gl.uniform2f(cache.resolutionLocation, width, height);
  32771. if (properties.backdrop) {
  32772. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32773. } else {
  32774. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32775. }
  32776. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32777. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32778. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32779. var buffer = gl.createBuffer();
  32780. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32781. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32782. 0,
  32783. 0,
  32784. width,
  32785. 0,
  32786. 0,
  32787. height,
  32788. 0,
  32789. height,
  32790. width,
  32791. 0,
  32792. width,
  32793. height
  32794. ]), gl.STATIC_DRAW);
  32795. gl.enableVertexAttribArray(cache.positionLocation);
  32796. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32797. gl.clearColor(0, 0, 0, 0);
  32798. gl.enable(gl.BLEND);
  32799. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32800. gl.clear(gl.COLOR_BUFFER_BIT);
  32801. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32802. gl.flush();
  32803. gl.deleteTexture(texture);
  32804. gl.deleteTexture(maskTexture);
  32805. gl.deleteBuffer(buffer);
  32806. return canvas;
  32807. }
  32808. var figuresVertexShaderCode = '\
  32809. attribute vec2 a_position; \
  32810. attribute vec3 a_color; \
  32811. \
  32812. uniform vec2 u_resolution; \
  32813. uniform vec2 u_scale; \
  32814. uniform vec2 u_offset; \
  32815. \
  32816. varying vec4 v_color; \
  32817. \
  32818. void main() { \
  32819. vec2 position = (a_position + u_offset) * u_scale; \
  32820. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32821. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32822. \
  32823. v_color = vec4(a_color / 255.0, 1.0); \
  32824. } ';
  32825. var figuresFragmentShaderCode = '\
  32826. precision mediump float; \
  32827. \
  32828. varying vec4 v_color; \
  32829. \
  32830. void main() { \
  32831. gl_FragColor = v_color; \
  32832. } ';
  32833. var figuresCache = null;
  32834. function initFiguresGL() {
  32835. var canvas, gl;
  32836. generateGL();
  32837. canvas = currentCanvas;
  32838. currentCanvas = null;
  32839. gl = currentGL;
  32840. currentGL = null;
  32841. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32842. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32843. var program = createProgram(gl, [
  32844. vertexShader,
  32845. fragmentShader
  32846. ]);
  32847. gl.useProgram(program);
  32848. var cache = {};
  32849. cache.gl = gl;
  32850. cache.canvas = canvas;
  32851. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32852. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32853. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32854. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32855. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32856. figuresCache = cache;
  32857. }
  32858. function drawFigures(width, height, backgroundColor, figures, context) {
  32859. if (!figuresCache) {
  32860. initFiguresGL();
  32861. }
  32862. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32863. canvas.width = width;
  32864. canvas.height = height;
  32865. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32866. gl.uniform2f(cache.resolutionLocation, width, height);
  32867. var count = 0;
  32868. var i, ii, rows;
  32869. for (i = 0, ii = figures.length; i < ii; i++) {
  32870. switch (figures[i].type) {
  32871. case 'lattice':
  32872. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32873. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32874. break;
  32875. case 'triangles':
  32876. count += figures[i].coords.length;
  32877. break;
  32878. }
  32879. }
  32880. var coords = new Float32Array(count * 2);
  32881. var colors = new Uint8Array(count * 3);
  32882. var coordsMap = context.coords, colorsMap = context.colors;
  32883. var pIndex = 0, cIndex = 0;
  32884. for (i = 0, ii = figures.length; i < ii; i++) {
  32885. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32886. switch (figure.type) {
  32887. case 'lattice':
  32888. var cols = figure.verticesPerRow;
  32889. rows = ps.length / cols | 0;
  32890. for (var row = 1; row < rows; row++) {
  32891. var offset = row * cols + 1;
  32892. for (var col = 1; col < cols; col++, offset++) {
  32893. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32894. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32895. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32896. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32897. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32898. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32899. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32900. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32901. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32902. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32903. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32904. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32905. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32906. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32907. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32908. coords[pIndex + 6] = coords[pIndex + 2];
  32909. coords[pIndex + 7] = coords[pIndex + 3];
  32910. coords[pIndex + 8] = coords[pIndex + 4];
  32911. coords[pIndex + 9] = coords[pIndex + 5];
  32912. coords[pIndex + 10] = coordsMap[ps[offset]];
  32913. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32914. colors[cIndex + 9] = colors[cIndex + 3];
  32915. colors[cIndex + 10] = colors[cIndex + 4];
  32916. colors[cIndex + 11] = colors[cIndex + 5];
  32917. colors[cIndex + 12] = colors[cIndex + 6];
  32918. colors[cIndex + 13] = colors[cIndex + 7];
  32919. colors[cIndex + 14] = colors[cIndex + 8];
  32920. colors[cIndex + 15] = colorsMap[cs[offset]];
  32921. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32922. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32923. pIndex += 12;
  32924. cIndex += 18;
  32925. }
  32926. }
  32927. break;
  32928. case 'triangles':
  32929. for (var j = 0, jj = ps.length; j < jj; j++) {
  32930. coords[pIndex] = coordsMap[ps[j]];
  32931. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32932. colors[cIndex] = colorsMap[cs[j]];
  32933. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32934. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32935. pIndex += 2;
  32936. cIndex += 3;
  32937. }
  32938. break;
  32939. }
  32940. }
  32941. if (backgroundColor) {
  32942. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32943. } else {
  32944. gl.clearColor(0, 0, 0, 0);
  32945. }
  32946. gl.clear(gl.COLOR_BUFFER_BIT);
  32947. var coordsBuffer = gl.createBuffer();
  32948. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32949. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32950. gl.enableVertexAttribArray(cache.positionLocation);
  32951. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32952. var colorsBuffer = gl.createBuffer();
  32953. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32954. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32955. gl.enableVertexAttribArray(cache.colorLocation);
  32956. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32957. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32958. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32959. gl.drawArrays(gl.TRIANGLES, 0, count);
  32960. gl.flush();
  32961. gl.deleteBuffer(coordsBuffer);
  32962. gl.deleteBuffer(colorsBuffer);
  32963. return canvas;
  32964. }
  32965. function cleanup() {
  32966. if (smaskCache && smaskCache.canvas) {
  32967. smaskCache.canvas.width = 0;
  32968. smaskCache.canvas.height = 0;
  32969. }
  32970. if (figuresCache && figuresCache.canvas) {
  32971. figuresCache.canvas.width = 0;
  32972. figuresCache.canvas.height = 0;
  32973. }
  32974. smaskCache = null;
  32975. figuresCache = null;
  32976. }
  32977. return {
  32978. get isEnabled() {
  32979. if (getDefaultSetting('disableWebGL')) {
  32980. return false;
  32981. }
  32982. var enabled = false;
  32983. try {
  32984. generateGL();
  32985. enabled = !!currentGL;
  32986. } catch (e) {
  32987. }
  32988. return shadow(this, 'isEnabled', enabled);
  32989. },
  32990. composeSMask: composeSMask,
  32991. drawFigures: drawFigures,
  32992. clear: cleanup
  32993. };
  32994. }();
  32995. exports.WebGLUtils = WebGLUtils;
  32996. }));
  32997. (function (root, factory) {
  32998. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32999. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  33000. var PasswordException = sharedUtil.PasswordException;
  33001. var PasswordResponses = sharedUtil.PasswordResponses;
  33002. var bytesToString = sharedUtil.bytesToString;
  33003. var warn = sharedUtil.warn;
  33004. var error = sharedUtil.error;
  33005. var assert = sharedUtil.assert;
  33006. var isInt = sharedUtil.isInt;
  33007. var stringToBytes = sharedUtil.stringToBytes;
  33008. var utf8StringToString = sharedUtil.utf8StringToString;
  33009. var Name = corePrimitives.Name;
  33010. var isName = corePrimitives.isName;
  33011. var isDict = corePrimitives.isDict;
  33012. var DecryptStream = coreStream.DecryptStream;
  33013. var ARCFourCipher = function ARCFourCipherClosure() {
  33014. function ARCFourCipher(key) {
  33015. this.a = 0;
  33016. this.b = 0;
  33017. var s = new Uint8Array(256);
  33018. var i, j = 0, tmp, keyLength = key.length;
  33019. for (i = 0; i < 256; ++i) {
  33020. s[i] = i;
  33021. }
  33022. for (i = 0; i < 256; ++i) {
  33023. tmp = s[i];
  33024. j = j + tmp + key[i % keyLength] & 0xFF;
  33025. s[i] = s[j];
  33026. s[j] = tmp;
  33027. }
  33028. this.s = s;
  33029. }
  33030. ARCFourCipher.prototype = {
  33031. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  33032. var i, n = data.length, tmp, tmp2;
  33033. var a = this.a, b = this.b, s = this.s;
  33034. var output = new Uint8Array(n);
  33035. for (i = 0; i < n; ++i) {
  33036. a = a + 1 & 0xFF;
  33037. tmp = s[a];
  33038. b = b + tmp & 0xFF;
  33039. tmp2 = s[b];
  33040. s[a] = tmp2;
  33041. s[b] = tmp;
  33042. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  33043. }
  33044. this.a = a;
  33045. this.b = b;
  33046. return output;
  33047. }
  33048. };
  33049. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  33050. return ARCFourCipher;
  33051. }();
  33052. var calculateMD5 = function calculateMD5Closure() {
  33053. var r = new Uint8Array([
  33054. 7,
  33055. 12,
  33056. 17,
  33057. 22,
  33058. 7,
  33059. 12,
  33060. 17,
  33061. 22,
  33062. 7,
  33063. 12,
  33064. 17,
  33065. 22,
  33066. 7,
  33067. 12,
  33068. 17,
  33069. 22,
  33070. 5,
  33071. 9,
  33072. 14,
  33073. 20,
  33074. 5,
  33075. 9,
  33076. 14,
  33077. 20,
  33078. 5,
  33079. 9,
  33080. 14,
  33081. 20,
  33082. 5,
  33083. 9,
  33084. 14,
  33085. 20,
  33086. 4,
  33087. 11,
  33088. 16,
  33089. 23,
  33090. 4,
  33091. 11,
  33092. 16,
  33093. 23,
  33094. 4,
  33095. 11,
  33096. 16,
  33097. 23,
  33098. 4,
  33099. 11,
  33100. 16,
  33101. 23,
  33102. 6,
  33103. 10,
  33104. 15,
  33105. 21,
  33106. 6,
  33107. 10,
  33108. 15,
  33109. 21,
  33110. 6,
  33111. 10,
  33112. 15,
  33113. 21,
  33114. 6,
  33115. 10,
  33116. 15,
  33117. 21
  33118. ]);
  33119. var k = new Int32Array([
  33120. -680876936,
  33121. -389564586,
  33122. 606105819,
  33123. -1044525330,
  33124. -176418897,
  33125. 1200080426,
  33126. -1473231341,
  33127. -45705983,
  33128. 1770035416,
  33129. -1958414417,
  33130. -42063,
  33131. -1990404162,
  33132. 1804603682,
  33133. -40341101,
  33134. -1502002290,
  33135. 1236535329,
  33136. -165796510,
  33137. -1069501632,
  33138. 643717713,
  33139. -373897302,
  33140. -701558691,
  33141. 38016083,
  33142. -660478335,
  33143. -405537848,
  33144. 568446438,
  33145. -1019803690,
  33146. -187363961,
  33147. 1163531501,
  33148. -1444681467,
  33149. -51403784,
  33150. 1735328473,
  33151. -1926607734,
  33152. -378558,
  33153. -2022574463,
  33154. 1839030562,
  33155. -35309556,
  33156. -1530992060,
  33157. 1272893353,
  33158. -155497632,
  33159. -1094730640,
  33160. 681279174,
  33161. -358537222,
  33162. -722521979,
  33163. 76029189,
  33164. -640364487,
  33165. -421815835,
  33166. 530742520,
  33167. -995338651,
  33168. -198630844,
  33169. 1126891415,
  33170. -1416354905,
  33171. -57434055,
  33172. 1700485571,
  33173. -1894986606,
  33174. -1051523,
  33175. -2054922799,
  33176. 1873313359,
  33177. -30611744,
  33178. -1560198380,
  33179. 1309151649,
  33180. -145523070,
  33181. -1120210379,
  33182. 718787259,
  33183. -343485551
  33184. ]);
  33185. function hash(data, offset, length) {
  33186. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  33187. var paddedLength = length + 72 & ~63;
  33188. var padded = new Uint8Array(paddedLength);
  33189. var i, j, n;
  33190. for (i = 0; i < length; ++i) {
  33191. padded[i] = data[offset++];
  33192. }
  33193. padded[i++] = 0x80;
  33194. n = paddedLength - 8;
  33195. while (i < n) {
  33196. padded[i++] = 0;
  33197. }
  33198. padded[i++] = length << 3 & 0xFF;
  33199. padded[i++] = length >> 5 & 0xFF;
  33200. padded[i++] = length >> 13 & 0xFF;
  33201. padded[i++] = length >> 21 & 0xFF;
  33202. padded[i++] = length >>> 29 & 0xFF;
  33203. padded[i++] = 0;
  33204. padded[i++] = 0;
  33205. padded[i++] = 0;
  33206. var w = new Int32Array(16);
  33207. for (i = 0; i < paddedLength;) {
  33208. for (j = 0; j < 16; ++j, i += 4) {
  33209. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  33210. }
  33211. var a = h0, b = h1, c = h2, d = h3, f, g;
  33212. for (j = 0; j < 64; ++j) {
  33213. if (j < 16) {
  33214. f = b & c | ~b & d;
  33215. g = j;
  33216. } else if (j < 32) {
  33217. f = d & b | ~d & c;
  33218. g = 5 * j + 1 & 15;
  33219. } else if (j < 48) {
  33220. f = b ^ c ^ d;
  33221. g = 3 * j + 5 & 15;
  33222. } else {
  33223. f = c ^ (b | ~d);
  33224. g = 7 * j & 15;
  33225. }
  33226. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  33227. d = c;
  33228. c = b;
  33229. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  33230. a = tmp;
  33231. }
  33232. h0 = h0 + a | 0;
  33233. h1 = h1 + b | 0;
  33234. h2 = h2 + c | 0;
  33235. h3 = h3 + d | 0;
  33236. }
  33237. return new Uint8Array([
  33238. h0 & 0xFF,
  33239. h0 >> 8 & 0xFF,
  33240. h0 >> 16 & 0xFF,
  33241. h0 >>> 24 & 0xFF,
  33242. h1 & 0xFF,
  33243. h1 >> 8 & 0xFF,
  33244. h1 >> 16 & 0xFF,
  33245. h1 >>> 24 & 0xFF,
  33246. h2 & 0xFF,
  33247. h2 >> 8 & 0xFF,
  33248. h2 >> 16 & 0xFF,
  33249. h2 >>> 24 & 0xFF,
  33250. h3 & 0xFF,
  33251. h3 >> 8 & 0xFF,
  33252. h3 >> 16 & 0xFF,
  33253. h3 >>> 24 & 0xFF
  33254. ]);
  33255. }
  33256. return hash;
  33257. }();
  33258. var Word64 = function Word64Closure() {
  33259. function Word64(highInteger, lowInteger) {
  33260. this.high = highInteger | 0;
  33261. this.low = lowInteger | 0;
  33262. }
  33263. Word64.prototype = {
  33264. and: function Word64_and(word) {
  33265. this.high &= word.high;
  33266. this.low &= word.low;
  33267. },
  33268. xor: function Word64_xor(word) {
  33269. this.high ^= word.high;
  33270. this.low ^= word.low;
  33271. },
  33272. or: function Word64_or(word) {
  33273. this.high |= word.high;
  33274. this.low |= word.low;
  33275. },
  33276. shiftRight: function Word64_shiftRight(places) {
  33277. if (places >= 32) {
  33278. this.low = this.high >>> places - 32 | 0;
  33279. this.high = 0;
  33280. } else {
  33281. this.low = this.low >>> places | this.high << 32 - places;
  33282. this.high = this.high >>> places | 0;
  33283. }
  33284. },
  33285. shiftLeft: function Word64_shiftLeft(places) {
  33286. if (places >= 32) {
  33287. this.high = this.low << places - 32;
  33288. this.low = 0;
  33289. } else {
  33290. this.high = this.high << places | this.low >>> 32 - places;
  33291. this.low = this.low << places;
  33292. }
  33293. },
  33294. rotateRight: function Word64_rotateRight(places) {
  33295. var low, high;
  33296. if (places & 32) {
  33297. high = this.low;
  33298. low = this.high;
  33299. } else {
  33300. low = this.low;
  33301. high = this.high;
  33302. }
  33303. places &= 31;
  33304. this.low = low >>> places | high << 32 - places;
  33305. this.high = high >>> places | low << 32 - places;
  33306. },
  33307. not: function Word64_not() {
  33308. this.high = ~this.high;
  33309. this.low = ~this.low;
  33310. },
  33311. add: function Word64_add(word) {
  33312. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  33313. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  33314. if (lowAdd > 0xFFFFFFFF) {
  33315. highAdd += 1;
  33316. }
  33317. this.low = lowAdd | 0;
  33318. this.high = highAdd | 0;
  33319. },
  33320. copyTo: function Word64_copyTo(bytes, offset) {
  33321. bytes[offset] = this.high >>> 24 & 0xFF;
  33322. bytes[offset + 1] = this.high >> 16 & 0xFF;
  33323. bytes[offset + 2] = this.high >> 8 & 0xFF;
  33324. bytes[offset + 3] = this.high & 0xFF;
  33325. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  33326. bytes[offset + 5] = this.low >> 16 & 0xFF;
  33327. bytes[offset + 6] = this.low >> 8 & 0xFF;
  33328. bytes[offset + 7] = this.low & 0xFF;
  33329. },
  33330. assign: function Word64_assign(word) {
  33331. this.high = word.high;
  33332. this.low = word.low;
  33333. }
  33334. };
  33335. return Word64;
  33336. }();
  33337. var calculateSHA256 = function calculateSHA256Closure() {
  33338. function rotr(x, n) {
  33339. return x >>> n | x << 32 - n;
  33340. }
  33341. function ch(x, y, z) {
  33342. return x & y ^ ~x & z;
  33343. }
  33344. function maj(x, y, z) {
  33345. return x & y ^ x & z ^ y & z;
  33346. }
  33347. function sigma(x) {
  33348. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  33349. }
  33350. function sigmaPrime(x) {
  33351. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  33352. }
  33353. function littleSigma(x) {
  33354. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  33355. }
  33356. function littleSigmaPrime(x) {
  33357. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  33358. }
  33359. var k = [
  33360. 0x428a2f98,
  33361. 0x71374491,
  33362. 0xb5c0fbcf,
  33363. 0xe9b5dba5,
  33364. 0x3956c25b,
  33365. 0x59f111f1,
  33366. 0x923f82a4,
  33367. 0xab1c5ed5,
  33368. 0xd807aa98,
  33369. 0x12835b01,
  33370. 0x243185be,
  33371. 0x550c7dc3,
  33372. 0x72be5d74,
  33373. 0x80deb1fe,
  33374. 0x9bdc06a7,
  33375. 0xc19bf174,
  33376. 0xe49b69c1,
  33377. 0xefbe4786,
  33378. 0x0fc19dc6,
  33379. 0x240ca1cc,
  33380. 0x2de92c6f,
  33381. 0x4a7484aa,
  33382. 0x5cb0a9dc,
  33383. 0x76f988da,
  33384. 0x983e5152,
  33385. 0xa831c66d,
  33386. 0xb00327c8,
  33387. 0xbf597fc7,
  33388. 0xc6e00bf3,
  33389. 0xd5a79147,
  33390. 0x06ca6351,
  33391. 0x14292967,
  33392. 0x27b70a85,
  33393. 0x2e1b2138,
  33394. 0x4d2c6dfc,
  33395. 0x53380d13,
  33396. 0x650a7354,
  33397. 0x766a0abb,
  33398. 0x81c2c92e,
  33399. 0x92722c85,
  33400. 0xa2bfe8a1,
  33401. 0xa81a664b,
  33402. 0xc24b8b70,
  33403. 0xc76c51a3,
  33404. 0xd192e819,
  33405. 0xd6990624,
  33406. 0xf40e3585,
  33407. 0x106aa070,
  33408. 0x19a4c116,
  33409. 0x1e376c08,
  33410. 0x2748774c,
  33411. 0x34b0bcb5,
  33412. 0x391c0cb3,
  33413. 0x4ed8aa4a,
  33414. 0x5b9cca4f,
  33415. 0x682e6ff3,
  33416. 0x748f82ee,
  33417. 0x78a5636f,
  33418. 0x84c87814,
  33419. 0x8cc70208,
  33420. 0x90befffa,
  33421. 0xa4506ceb,
  33422. 0xbef9a3f7,
  33423. 0xc67178f2
  33424. ];
  33425. function hash(data, offset, length) {
  33426. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33427. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33428. var padded = new Uint8Array(paddedLength);
  33429. var i, j, n;
  33430. for (i = 0; i < length; ++i) {
  33431. padded[i] = data[offset++];
  33432. }
  33433. padded[i++] = 0x80;
  33434. n = paddedLength - 8;
  33435. while (i < n) {
  33436. padded[i++] = 0;
  33437. }
  33438. padded[i++] = 0;
  33439. padded[i++] = 0;
  33440. padded[i++] = 0;
  33441. padded[i++] = length >>> 29 & 0xFF;
  33442. padded[i++] = length >> 21 & 0xFF;
  33443. padded[i++] = length >> 13 & 0xFF;
  33444. padded[i++] = length >> 5 & 0xFF;
  33445. padded[i++] = length << 3 & 0xFF;
  33446. var w = new Uint32Array(64);
  33447. for (i = 0; i < paddedLength;) {
  33448. for (j = 0; j < 16; ++j) {
  33449. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33450. i += 4;
  33451. }
  33452. for (j = 16; j < 64; ++j) {
  33453. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33454. }
  33455. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33456. for (j = 0; j < 64; ++j) {
  33457. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33458. t2 = sigma(a) + maj(a, b, c);
  33459. h = g;
  33460. g = f;
  33461. f = e;
  33462. e = d + t1 | 0;
  33463. d = c;
  33464. c = b;
  33465. b = a;
  33466. a = t1 + t2 | 0;
  33467. }
  33468. h0 = h0 + a | 0;
  33469. h1 = h1 + b | 0;
  33470. h2 = h2 + c | 0;
  33471. h3 = h3 + d | 0;
  33472. h4 = h4 + e | 0;
  33473. h5 = h5 + f | 0;
  33474. h6 = h6 + g | 0;
  33475. h7 = h7 + h | 0;
  33476. }
  33477. return new Uint8Array([
  33478. h0 >> 24 & 0xFF,
  33479. h0 >> 16 & 0xFF,
  33480. h0 >> 8 & 0xFF,
  33481. h0 & 0xFF,
  33482. h1 >> 24 & 0xFF,
  33483. h1 >> 16 & 0xFF,
  33484. h1 >> 8 & 0xFF,
  33485. h1 & 0xFF,
  33486. h2 >> 24 & 0xFF,
  33487. h2 >> 16 & 0xFF,
  33488. h2 >> 8 & 0xFF,
  33489. h2 & 0xFF,
  33490. h3 >> 24 & 0xFF,
  33491. h3 >> 16 & 0xFF,
  33492. h3 >> 8 & 0xFF,
  33493. h3 & 0xFF,
  33494. h4 >> 24 & 0xFF,
  33495. h4 >> 16 & 0xFF,
  33496. h4 >> 8 & 0xFF,
  33497. h4 & 0xFF,
  33498. h5 >> 24 & 0xFF,
  33499. h5 >> 16 & 0xFF,
  33500. h5 >> 8 & 0xFF,
  33501. h5 & 0xFF,
  33502. h6 >> 24 & 0xFF,
  33503. h6 >> 16 & 0xFF,
  33504. h6 >> 8 & 0xFF,
  33505. h6 & 0xFF,
  33506. h7 >> 24 & 0xFF,
  33507. h7 >> 16 & 0xFF,
  33508. h7 >> 8 & 0xFF,
  33509. h7 & 0xFF
  33510. ]);
  33511. }
  33512. return hash;
  33513. }();
  33514. var calculateSHA512 = function calculateSHA512Closure() {
  33515. function ch(result, x, y, z, tmp) {
  33516. result.assign(x);
  33517. result.and(y);
  33518. tmp.assign(x);
  33519. tmp.not();
  33520. tmp.and(z);
  33521. result.xor(tmp);
  33522. }
  33523. function maj(result, x, y, z, tmp) {
  33524. result.assign(x);
  33525. result.and(y);
  33526. tmp.assign(x);
  33527. tmp.and(z);
  33528. result.xor(tmp);
  33529. tmp.assign(y);
  33530. tmp.and(z);
  33531. result.xor(tmp);
  33532. }
  33533. function sigma(result, x, tmp) {
  33534. result.assign(x);
  33535. result.rotateRight(28);
  33536. tmp.assign(x);
  33537. tmp.rotateRight(34);
  33538. result.xor(tmp);
  33539. tmp.assign(x);
  33540. tmp.rotateRight(39);
  33541. result.xor(tmp);
  33542. }
  33543. function sigmaPrime(result, x, tmp) {
  33544. result.assign(x);
  33545. result.rotateRight(14);
  33546. tmp.assign(x);
  33547. tmp.rotateRight(18);
  33548. result.xor(tmp);
  33549. tmp.assign(x);
  33550. tmp.rotateRight(41);
  33551. result.xor(tmp);
  33552. }
  33553. function littleSigma(result, x, tmp) {
  33554. result.assign(x);
  33555. result.rotateRight(1);
  33556. tmp.assign(x);
  33557. tmp.rotateRight(8);
  33558. result.xor(tmp);
  33559. tmp.assign(x);
  33560. tmp.shiftRight(7);
  33561. result.xor(tmp);
  33562. }
  33563. function littleSigmaPrime(result, x, tmp) {
  33564. result.assign(x);
  33565. result.rotateRight(19);
  33566. tmp.assign(x);
  33567. tmp.rotateRight(61);
  33568. result.xor(tmp);
  33569. tmp.assign(x);
  33570. tmp.shiftRight(6);
  33571. result.xor(tmp);
  33572. }
  33573. var k = [
  33574. new Word64(0x428a2f98, 0xd728ae22),
  33575. new Word64(0x71374491, 0x23ef65cd),
  33576. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33577. new Word64(0xe9b5dba5, 0x8189dbbc),
  33578. new Word64(0x3956c25b, 0xf348b538),
  33579. new Word64(0x59f111f1, 0xb605d019),
  33580. new Word64(0x923f82a4, 0xaf194f9b),
  33581. new Word64(0xab1c5ed5, 0xda6d8118),
  33582. new Word64(0xd807aa98, 0xa3030242),
  33583. new Word64(0x12835b01, 0x45706fbe),
  33584. new Word64(0x243185be, 0x4ee4b28c),
  33585. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33586. new Word64(0x72be5d74, 0xf27b896f),
  33587. new Word64(0x80deb1fe, 0x3b1696b1),
  33588. new Word64(0x9bdc06a7, 0x25c71235),
  33589. new Word64(0xc19bf174, 0xcf692694),
  33590. new Word64(0xe49b69c1, 0x9ef14ad2),
  33591. new Word64(0xefbe4786, 0x384f25e3),
  33592. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33593. new Word64(0x240ca1cc, 0x77ac9c65),
  33594. new Word64(0x2de92c6f, 0x592b0275),
  33595. new Word64(0x4a7484aa, 0x6ea6e483),
  33596. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33597. new Word64(0x76f988da, 0x831153b5),
  33598. new Word64(0x983e5152, 0xee66dfab),
  33599. new Word64(0xa831c66d, 0x2db43210),
  33600. new Word64(0xb00327c8, 0x98fb213f),
  33601. new Word64(0xbf597fc7, 0xbeef0ee4),
  33602. new Word64(0xc6e00bf3, 0x3da88fc2),
  33603. new Word64(0xd5a79147, 0x930aa725),
  33604. new Word64(0x06ca6351, 0xe003826f),
  33605. new Word64(0x14292967, 0x0a0e6e70),
  33606. new Word64(0x27b70a85, 0x46d22ffc),
  33607. new Word64(0x2e1b2138, 0x5c26c926),
  33608. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33609. new Word64(0x53380d13, 0x9d95b3df),
  33610. new Word64(0x650a7354, 0x8baf63de),
  33611. new Word64(0x766a0abb, 0x3c77b2a8),
  33612. new Word64(0x81c2c92e, 0x47edaee6),
  33613. new Word64(0x92722c85, 0x1482353b),
  33614. new Word64(0xa2bfe8a1, 0x4cf10364),
  33615. new Word64(0xa81a664b, 0xbc423001),
  33616. new Word64(0xc24b8b70, 0xd0f89791),
  33617. new Word64(0xc76c51a3, 0x0654be30),
  33618. new Word64(0xd192e819, 0xd6ef5218),
  33619. new Word64(0xd6990624, 0x5565a910),
  33620. new Word64(0xf40e3585, 0x5771202a),
  33621. new Word64(0x106aa070, 0x32bbd1b8),
  33622. new Word64(0x19a4c116, 0xb8d2d0c8),
  33623. new Word64(0x1e376c08, 0x5141ab53),
  33624. new Word64(0x2748774c, 0xdf8eeb99),
  33625. new Word64(0x34b0bcb5, 0xe19b48a8),
  33626. new Word64(0x391c0cb3, 0xc5c95a63),
  33627. new Word64(0x4ed8aa4a, 0xe3418acb),
  33628. new Word64(0x5b9cca4f, 0x7763e373),
  33629. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33630. new Word64(0x748f82ee, 0x5defb2fc),
  33631. new Word64(0x78a5636f, 0x43172f60),
  33632. new Word64(0x84c87814, 0xa1f0ab72),
  33633. new Word64(0x8cc70208, 0x1a6439ec),
  33634. new Word64(0x90befffa, 0x23631e28),
  33635. new Word64(0xa4506ceb, 0xde82bde9),
  33636. new Word64(0xbef9a3f7, 0xb2c67915),
  33637. new Word64(0xc67178f2, 0xe372532b),
  33638. new Word64(0xca273ece, 0xea26619c),
  33639. new Word64(0xd186b8c7, 0x21c0c207),
  33640. new Word64(0xeada7dd6, 0xcde0eb1e),
  33641. new Word64(0xf57d4f7f, 0xee6ed178),
  33642. new Word64(0x06f067aa, 0x72176fba),
  33643. new Word64(0x0a637dc5, 0xa2c898a6),
  33644. new Word64(0x113f9804, 0xbef90dae),
  33645. new Word64(0x1b710b35, 0x131c471b),
  33646. new Word64(0x28db77f5, 0x23047d84),
  33647. new Word64(0x32caab7b, 0x40c72493),
  33648. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33649. new Word64(0x431d67c4, 0x9c100d4c),
  33650. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33651. new Word64(0x597f299c, 0xfc657e2a),
  33652. new Word64(0x5fcb6fab, 0x3ad6faec),
  33653. new Word64(0x6c44198c, 0x4a475817)
  33654. ];
  33655. function hash(data, offset, length, mode384) {
  33656. mode384 = !!mode384;
  33657. var h0, h1, h2, h3, h4, h5, h6, h7;
  33658. if (!mode384) {
  33659. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33660. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33661. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33662. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33663. h4 = new Word64(0x510e527f, 0xade682d1);
  33664. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33665. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33666. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33667. } else {
  33668. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33669. h1 = new Word64(0x629a292a, 0x367cd507);
  33670. h2 = new Word64(0x9159015a, 0x3070dd17);
  33671. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33672. h4 = new Word64(0x67332667, 0xffc00b31);
  33673. h5 = new Word64(0x8eb44a87, 0x68581511);
  33674. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33675. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33676. }
  33677. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33678. var padded = new Uint8Array(paddedLength);
  33679. var i, j, n;
  33680. for (i = 0; i < length; ++i) {
  33681. padded[i] = data[offset++];
  33682. }
  33683. padded[i++] = 0x80;
  33684. n = paddedLength - 16;
  33685. while (i < n) {
  33686. padded[i++] = 0;
  33687. }
  33688. padded[i++] = 0;
  33689. padded[i++] = 0;
  33690. padded[i++] = 0;
  33691. padded[i++] = 0;
  33692. padded[i++] = 0;
  33693. padded[i++] = 0;
  33694. padded[i++] = 0;
  33695. padded[i++] = 0;
  33696. padded[i++] = 0;
  33697. padded[i++] = 0;
  33698. padded[i++] = 0;
  33699. padded[i++] = length >>> 29 & 0xFF;
  33700. padded[i++] = length >> 21 & 0xFF;
  33701. padded[i++] = length >> 13 & 0xFF;
  33702. padded[i++] = length >> 5 & 0xFF;
  33703. padded[i++] = length << 3 & 0xFF;
  33704. var w = new Array(80);
  33705. for (i = 0; i < 80; i++) {
  33706. w[i] = new Word64(0, 0);
  33707. }
  33708. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33709. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33710. var g = new Word64(0, 0), h = new Word64(0, 0);
  33711. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33712. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33713. for (i = 0; i < paddedLength;) {
  33714. for (j = 0; j < 16; ++j) {
  33715. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33716. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33717. i += 8;
  33718. }
  33719. for (j = 16; j < 80; ++j) {
  33720. tmp3 = w[j];
  33721. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33722. tmp3.add(w[j - 7]);
  33723. littleSigma(tmp1, w[j - 15], tmp2);
  33724. tmp3.add(tmp1);
  33725. tmp3.add(w[j - 16]);
  33726. }
  33727. a.assign(h0);
  33728. b.assign(h1);
  33729. c.assign(h2);
  33730. d.assign(h3);
  33731. e.assign(h4);
  33732. f.assign(h5);
  33733. g.assign(h6);
  33734. h.assign(h7);
  33735. for (j = 0; j < 80; ++j) {
  33736. t1.assign(h);
  33737. sigmaPrime(tmp1, e, tmp2);
  33738. t1.add(tmp1);
  33739. ch(tmp1, e, f, g, tmp2);
  33740. t1.add(tmp1);
  33741. t1.add(k[j]);
  33742. t1.add(w[j]);
  33743. sigma(t2, a, tmp2);
  33744. maj(tmp1, a, b, c, tmp2);
  33745. t2.add(tmp1);
  33746. tmp3 = h;
  33747. h = g;
  33748. g = f;
  33749. f = e;
  33750. d.add(t1);
  33751. e = d;
  33752. d = c;
  33753. c = b;
  33754. b = a;
  33755. tmp3.assign(t1);
  33756. tmp3.add(t2);
  33757. a = tmp3;
  33758. }
  33759. h0.add(a);
  33760. h1.add(b);
  33761. h2.add(c);
  33762. h3.add(d);
  33763. h4.add(e);
  33764. h5.add(f);
  33765. h6.add(g);
  33766. h7.add(h);
  33767. }
  33768. var result;
  33769. if (!mode384) {
  33770. result = new Uint8Array(64);
  33771. h0.copyTo(result, 0);
  33772. h1.copyTo(result, 8);
  33773. h2.copyTo(result, 16);
  33774. h3.copyTo(result, 24);
  33775. h4.copyTo(result, 32);
  33776. h5.copyTo(result, 40);
  33777. h6.copyTo(result, 48);
  33778. h7.copyTo(result, 56);
  33779. } else {
  33780. result = new Uint8Array(48);
  33781. h0.copyTo(result, 0);
  33782. h1.copyTo(result, 8);
  33783. h2.copyTo(result, 16);
  33784. h3.copyTo(result, 24);
  33785. h4.copyTo(result, 32);
  33786. h5.copyTo(result, 40);
  33787. }
  33788. return result;
  33789. }
  33790. return hash;
  33791. }();
  33792. var calculateSHA384 = function calculateSHA384Closure() {
  33793. function hash(data, offset, length) {
  33794. return calculateSHA512(data, offset, length, true);
  33795. }
  33796. return hash;
  33797. }();
  33798. var NullCipher = function NullCipherClosure() {
  33799. function NullCipher() {
  33800. }
  33801. NullCipher.prototype = {
  33802. decryptBlock: function NullCipher_decryptBlock(data) {
  33803. return data;
  33804. }
  33805. };
  33806. return NullCipher;
  33807. }();
  33808. var AES128Cipher = function AES128CipherClosure() {
  33809. var rcon = new Uint8Array([
  33810. 0x8d,
  33811. 0x01,
  33812. 0x02,
  33813. 0x04,
  33814. 0x08,
  33815. 0x10,
  33816. 0x20,
  33817. 0x40,
  33818. 0x80,
  33819. 0x1b,
  33820. 0x36,
  33821. 0x6c,
  33822. 0xd8,
  33823. 0xab,
  33824. 0x4d,
  33825. 0x9a,
  33826. 0x2f,
  33827. 0x5e,
  33828. 0xbc,
  33829. 0x63,
  33830. 0xc6,
  33831. 0x97,
  33832. 0x35,
  33833. 0x6a,
  33834. 0xd4,
  33835. 0xb3,
  33836. 0x7d,
  33837. 0xfa,
  33838. 0xef,
  33839. 0xc5,
  33840. 0x91,
  33841. 0x39,
  33842. 0x72,
  33843. 0xe4,
  33844. 0xd3,
  33845. 0xbd,
  33846. 0x61,
  33847. 0xc2,
  33848. 0x9f,
  33849. 0x25,
  33850. 0x4a,
  33851. 0x94,
  33852. 0x33,
  33853. 0x66,
  33854. 0xcc,
  33855. 0x83,
  33856. 0x1d,
  33857. 0x3a,
  33858. 0x74,
  33859. 0xe8,
  33860. 0xcb,
  33861. 0x8d,
  33862. 0x01,
  33863. 0x02,
  33864. 0x04,
  33865. 0x08,
  33866. 0x10,
  33867. 0x20,
  33868. 0x40,
  33869. 0x80,
  33870. 0x1b,
  33871. 0x36,
  33872. 0x6c,
  33873. 0xd8,
  33874. 0xab,
  33875. 0x4d,
  33876. 0x9a,
  33877. 0x2f,
  33878. 0x5e,
  33879. 0xbc,
  33880. 0x63,
  33881. 0xc6,
  33882. 0x97,
  33883. 0x35,
  33884. 0x6a,
  33885. 0xd4,
  33886. 0xb3,
  33887. 0x7d,
  33888. 0xfa,
  33889. 0xef,
  33890. 0xc5,
  33891. 0x91,
  33892. 0x39,
  33893. 0x72,
  33894. 0xe4,
  33895. 0xd3,
  33896. 0xbd,
  33897. 0x61,
  33898. 0xc2,
  33899. 0x9f,
  33900. 0x25,
  33901. 0x4a,
  33902. 0x94,
  33903. 0x33,
  33904. 0x66,
  33905. 0xcc,
  33906. 0x83,
  33907. 0x1d,
  33908. 0x3a,
  33909. 0x74,
  33910. 0xe8,
  33911. 0xcb,
  33912. 0x8d,
  33913. 0x01,
  33914. 0x02,
  33915. 0x04,
  33916. 0x08,
  33917. 0x10,
  33918. 0x20,
  33919. 0x40,
  33920. 0x80,
  33921. 0x1b,
  33922. 0x36,
  33923. 0x6c,
  33924. 0xd8,
  33925. 0xab,
  33926. 0x4d,
  33927. 0x9a,
  33928. 0x2f,
  33929. 0x5e,
  33930. 0xbc,
  33931. 0x63,
  33932. 0xc6,
  33933. 0x97,
  33934. 0x35,
  33935. 0x6a,
  33936. 0xd4,
  33937. 0xb3,
  33938. 0x7d,
  33939. 0xfa,
  33940. 0xef,
  33941. 0xc5,
  33942. 0x91,
  33943. 0x39,
  33944. 0x72,
  33945. 0xe4,
  33946. 0xd3,
  33947. 0xbd,
  33948. 0x61,
  33949. 0xc2,
  33950. 0x9f,
  33951. 0x25,
  33952. 0x4a,
  33953. 0x94,
  33954. 0x33,
  33955. 0x66,
  33956. 0xcc,
  33957. 0x83,
  33958. 0x1d,
  33959. 0x3a,
  33960. 0x74,
  33961. 0xe8,
  33962. 0xcb,
  33963. 0x8d,
  33964. 0x01,
  33965. 0x02,
  33966. 0x04,
  33967. 0x08,
  33968. 0x10,
  33969. 0x20,
  33970. 0x40,
  33971. 0x80,
  33972. 0x1b,
  33973. 0x36,
  33974. 0x6c,
  33975. 0xd8,
  33976. 0xab,
  33977. 0x4d,
  33978. 0x9a,
  33979. 0x2f,
  33980. 0x5e,
  33981. 0xbc,
  33982. 0x63,
  33983. 0xc6,
  33984. 0x97,
  33985. 0x35,
  33986. 0x6a,
  33987. 0xd4,
  33988. 0xb3,
  33989. 0x7d,
  33990. 0xfa,
  33991. 0xef,
  33992. 0xc5,
  33993. 0x91,
  33994. 0x39,
  33995. 0x72,
  33996. 0xe4,
  33997. 0xd3,
  33998. 0xbd,
  33999. 0x61,
  34000. 0xc2,
  34001. 0x9f,
  34002. 0x25,
  34003. 0x4a,
  34004. 0x94,
  34005. 0x33,
  34006. 0x66,
  34007. 0xcc,
  34008. 0x83,
  34009. 0x1d,
  34010. 0x3a,
  34011. 0x74,
  34012. 0xe8,
  34013. 0xcb,
  34014. 0x8d,
  34015. 0x01,
  34016. 0x02,
  34017. 0x04,
  34018. 0x08,
  34019. 0x10,
  34020. 0x20,
  34021. 0x40,
  34022. 0x80,
  34023. 0x1b,
  34024. 0x36,
  34025. 0x6c,
  34026. 0xd8,
  34027. 0xab,
  34028. 0x4d,
  34029. 0x9a,
  34030. 0x2f,
  34031. 0x5e,
  34032. 0xbc,
  34033. 0x63,
  34034. 0xc6,
  34035. 0x97,
  34036. 0x35,
  34037. 0x6a,
  34038. 0xd4,
  34039. 0xb3,
  34040. 0x7d,
  34041. 0xfa,
  34042. 0xef,
  34043. 0xc5,
  34044. 0x91,
  34045. 0x39,
  34046. 0x72,
  34047. 0xe4,
  34048. 0xd3,
  34049. 0xbd,
  34050. 0x61,
  34051. 0xc2,
  34052. 0x9f,
  34053. 0x25,
  34054. 0x4a,
  34055. 0x94,
  34056. 0x33,
  34057. 0x66,
  34058. 0xcc,
  34059. 0x83,
  34060. 0x1d,
  34061. 0x3a,
  34062. 0x74,
  34063. 0xe8,
  34064. 0xcb,
  34065. 0x8d
  34066. ]);
  34067. var s = new Uint8Array([
  34068. 0x63,
  34069. 0x7c,
  34070. 0x77,
  34071. 0x7b,
  34072. 0xf2,
  34073. 0x6b,
  34074. 0x6f,
  34075. 0xc5,
  34076. 0x30,
  34077. 0x01,
  34078. 0x67,
  34079. 0x2b,
  34080. 0xfe,
  34081. 0xd7,
  34082. 0xab,
  34083. 0x76,
  34084. 0xca,
  34085. 0x82,
  34086. 0xc9,
  34087. 0x7d,
  34088. 0xfa,
  34089. 0x59,
  34090. 0x47,
  34091. 0xf0,
  34092. 0xad,
  34093. 0xd4,
  34094. 0xa2,
  34095. 0xaf,
  34096. 0x9c,
  34097. 0xa4,
  34098. 0x72,
  34099. 0xc0,
  34100. 0xb7,
  34101. 0xfd,
  34102. 0x93,
  34103. 0x26,
  34104. 0x36,
  34105. 0x3f,
  34106. 0xf7,
  34107. 0xcc,
  34108. 0x34,
  34109. 0xa5,
  34110. 0xe5,
  34111. 0xf1,
  34112. 0x71,
  34113. 0xd8,
  34114. 0x31,
  34115. 0x15,
  34116. 0x04,
  34117. 0xc7,
  34118. 0x23,
  34119. 0xc3,
  34120. 0x18,
  34121. 0x96,
  34122. 0x05,
  34123. 0x9a,
  34124. 0x07,
  34125. 0x12,
  34126. 0x80,
  34127. 0xe2,
  34128. 0xeb,
  34129. 0x27,
  34130. 0xb2,
  34131. 0x75,
  34132. 0x09,
  34133. 0x83,
  34134. 0x2c,
  34135. 0x1a,
  34136. 0x1b,
  34137. 0x6e,
  34138. 0x5a,
  34139. 0xa0,
  34140. 0x52,
  34141. 0x3b,
  34142. 0xd6,
  34143. 0xb3,
  34144. 0x29,
  34145. 0xe3,
  34146. 0x2f,
  34147. 0x84,
  34148. 0x53,
  34149. 0xd1,
  34150. 0x00,
  34151. 0xed,
  34152. 0x20,
  34153. 0xfc,
  34154. 0xb1,
  34155. 0x5b,
  34156. 0x6a,
  34157. 0xcb,
  34158. 0xbe,
  34159. 0x39,
  34160. 0x4a,
  34161. 0x4c,
  34162. 0x58,
  34163. 0xcf,
  34164. 0xd0,
  34165. 0xef,
  34166. 0xaa,
  34167. 0xfb,
  34168. 0x43,
  34169. 0x4d,
  34170. 0x33,
  34171. 0x85,
  34172. 0x45,
  34173. 0xf9,
  34174. 0x02,
  34175. 0x7f,
  34176. 0x50,
  34177. 0x3c,
  34178. 0x9f,
  34179. 0xa8,
  34180. 0x51,
  34181. 0xa3,
  34182. 0x40,
  34183. 0x8f,
  34184. 0x92,
  34185. 0x9d,
  34186. 0x38,
  34187. 0xf5,
  34188. 0xbc,
  34189. 0xb6,
  34190. 0xda,
  34191. 0x21,
  34192. 0x10,
  34193. 0xff,
  34194. 0xf3,
  34195. 0xd2,
  34196. 0xcd,
  34197. 0x0c,
  34198. 0x13,
  34199. 0xec,
  34200. 0x5f,
  34201. 0x97,
  34202. 0x44,
  34203. 0x17,
  34204. 0xc4,
  34205. 0xa7,
  34206. 0x7e,
  34207. 0x3d,
  34208. 0x64,
  34209. 0x5d,
  34210. 0x19,
  34211. 0x73,
  34212. 0x60,
  34213. 0x81,
  34214. 0x4f,
  34215. 0xdc,
  34216. 0x22,
  34217. 0x2a,
  34218. 0x90,
  34219. 0x88,
  34220. 0x46,
  34221. 0xee,
  34222. 0xb8,
  34223. 0x14,
  34224. 0xde,
  34225. 0x5e,
  34226. 0x0b,
  34227. 0xdb,
  34228. 0xe0,
  34229. 0x32,
  34230. 0x3a,
  34231. 0x0a,
  34232. 0x49,
  34233. 0x06,
  34234. 0x24,
  34235. 0x5c,
  34236. 0xc2,
  34237. 0xd3,
  34238. 0xac,
  34239. 0x62,
  34240. 0x91,
  34241. 0x95,
  34242. 0xe4,
  34243. 0x79,
  34244. 0xe7,
  34245. 0xc8,
  34246. 0x37,
  34247. 0x6d,
  34248. 0x8d,
  34249. 0xd5,
  34250. 0x4e,
  34251. 0xa9,
  34252. 0x6c,
  34253. 0x56,
  34254. 0xf4,
  34255. 0xea,
  34256. 0x65,
  34257. 0x7a,
  34258. 0xae,
  34259. 0x08,
  34260. 0xba,
  34261. 0x78,
  34262. 0x25,
  34263. 0x2e,
  34264. 0x1c,
  34265. 0xa6,
  34266. 0xb4,
  34267. 0xc6,
  34268. 0xe8,
  34269. 0xdd,
  34270. 0x74,
  34271. 0x1f,
  34272. 0x4b,
  34273. 0xbd,
  34274. 0x8b,
  34275. 0x8a,
  34276. 0x70,
  34277. 0x3e,
  34278. 0xb5,
  34279. 0x66,
  34280. 0x48,
  34281. 0x03,
  34282. 0xf6,
  34283. 0x0e,
  34284. 0x61,
  34285. 0x35,
  34286. 0x57,
  34287. 0xb9,
  34288. 0x86,
  34289. 0xc1,
  34290. 0x1d,
  34291. 0x9e,
  34292. 0xe1,
  34293. 0xf8,
  34294. 0x98,
  34295. 0x11,
  34296. 0x69,
  34297. 0xd9,
  34298. 0x8e,
  34299. 0x94,
  34300. 0x9b,
  34301. 0x1e,
  34302. 0x87,
  34303. 0xe9,
  34304. 0xce,
  34305. 0x55,
  34306. 0x28,
  34307. 0xdf,
  34308. 0x8c,
  34309. 0xa1,
  34310. 0x89,
  34311. 0x0d,
  34312. 0xbf,
  34313. 0xe6,
  34314. 0x42,
  34315. 0x68,
  34316. 0x41,
  34317. 0x99,
  34318. 0x2d,
  34319. 0x0f,
  34320. 0xb0,
  34321. 0x54,
  34322. 0xbb,
  34323. 0x16
  34324. ]);
  34325. var inv_s = new Uint8Array([
  34326. 0x52,
  34327. 0x09,
  34328. 0x6a,
  34329. 0xd5,
  34330. 0x30,
  34331. 0x36,
  34332. 0xa5,
  34333. 0x38,
  34334. 0xbf,
  34335. 0x40,
  34336. 0xa3,
  34337. 0x9e,
  34338. 0x81,
  34339. 0xf3,
  34340. 0xd7,
  34341. 0xfb,
  34342. 0x7c,
  34343. 0xe3,
  34344. 0x39,
  34345. 0x82,
  34346. 0x9b,
  34347. 0x2f,
  34348. 0xff,
  34349. 0x87,
  34350. 0x34,
  34351. 0x8e,
  34352. 0x43,
  34353. 0x44,
  34354. 0xc4,
  34355. 0xde,
  34356. 0xe9,
  34357. 0xcb,
  34358. 0x54,
  34359. 0x7b,
  34360. 0x94,
  34361. 0x32,
  34362. 0xa6,
  34363. 0xc2,
  34364. 0x23,
  34365. 0x3d,
  34366. 0xee,
  34367. 0x4c,
  34368. 0x95,
  34369. 0x0b,
  34370. 0x42,
  34371. 0xfa,
  34372. 0xc3,
  34373. 0x4e,
  34374. 0x08,
  34375. 0x2e,
  34376. 0xa1,
  34377. 0x66,
  34378. 0x28,
  34379. 0xd9,
  34380. 0x24,
  34381. 0xb2,
  34382. 0x76,
  34383. 0x5b,
  34384. 0xa2,
  34385. 0x49,
  34386. 0x6d,
  34387. 0x8b,
  34388. 0xd1,
  34389. 0x25,
  34390. 0x72,
  34391. 0xf8,
  34392. 0xf6,
  34393. 0x64,
  34394. 0x86,
  34395. 0x68,
  34396. 0x98,
  34397. 0x16,
  34398. 0xd4,
  34399. 0xa4,
  34400. 0x5c,
  34401. 0xcc,
  34402. 0x5d,
  34403. 0x65,
  34404. 0xb6,
  34405. 0x92,
  34406. 0x6c,
  34407. 0x70,
  34408. 0x48,
  34409. 0x50,
  34410. 0xfd,
  34411. 0xed,
  34412. 0xb9,
  34413. 0xda,
  34414. 0x5e,
  34415. 0x15,
  34416. 0x46,
  34417. 0x57,
  34418. 0xa7,
  34419. 0x8d,
  34420. 0x9d,
  34421. 0x84,
  34422. 0x90,
  34423. 0xd8,
  34424. 0xab,
  34425. 0x00,
  34426. 0x8c,
  34427. 0xbc,
  34428. 0xd3,
  34429. 0x0a,
  34430. 0xf7,
  34431. 0xe4,
  34432. 0x58,
  34433. 0x05,
  34434. 0xb8,
  34435. 0xb3,
  34436. 0x45,
  34437. 0x06,
  34438. 0xd0,
  34439. 0x2c,
  34440. 0x1e,
  34441. 0x8f,
  34442. 0xca,
  34443. 0x3f,
  34444. 0x0f,
  34445. 0x02,
  34446. 0xc1,
  34447. 0xaf,
  34448. 0xbd,
  34449. 0x03,
  34450. 0x01,
  34451. 0x13,
  34452. 0x8a,
  34453. 0x6b,
  34454. 0x3a,
  34455. 0x91,
  34456. 0x11,
  34457. 0x41,
  34458. 0x4f,
  34459. 0x67,
  34460. 0xdc,
  34461. 0xea,
  34462. 0x97,
  34463. 0xf2,
  34464. 0xcf,
  34465. 0xce,
  34466. 0xf0,
  34467. 0xb4,
  34468. 0xe6,
  34469. 0x73,
  34470. 0x96,
  34471. 0xac,
  34472. 0x74,
  34473. 0x22,
  34474. 0xe7,
  34475. 0xad,
  34476. 0x35,
  34477. 0x85,
  34478. 0xe2,
  34479. 0xf9,
  34480. 0x37,
  34481. 0xe8,
  34482. 0x1c,
  34483. 0x75,
  34484. 0xdf,
  34485. 0x6e,
  34486. 0x47,
  34487. 0xf1,
  34488. 0x1a,
  34489. 0x71,
  34490. 0x1d,
  34491. 0x29,
  34492. 0xc5,
  34493. 0x89,
  34494. 0x6f,
  34495. 0xb7,
  34496. 0x62,
  34497. 0x0e,
  34498. 0xaa,
  34499. 0x18,
  34500. 0xbe,
  34501. 0x1b,
  34502. 0xfc,
  34503. 0x56,
  34504. 0x3e,
  34505. 0x4b,
  34506. 0xc6,
  34507. 0xd2,
  34508. 0x79,
  34509. 0x20,
  34510. 0x9a,
  34511. 0xdb,
  34512. 0xc0,
  34513. 0xfe,
  34514. 0x78,
  34515. 0xcd,
  34516. 0x5a,
  34517. 0xf4,
  34518. 0x1f,
  34519. 0xdd,
  34520. 0xa8,
  34521. 0x33,
  34522. 0x88,
  34523. 0x07,
  34524. 0xc7,
  34525. 0x31,
  34526. 0xb1,
  34527. 0x12,
  34528. 0x10,
  34529. 0x59,
  34530. 0x27,
  34531. 0x80,
  34532. 0xec,
  34533. 0x5f,
  34534. 0x60,
  34535. 0x51,
  34536. 0x7f,
  34537. 0xa9,
  34538. 0x19,
  34539. 0xb5,
  34540. 0x4a,
  34541. 0x0d,
  34542. 0x2d,
  34543. 0xe5,
  34544. 0x7a,
  34545. 0x9f,
  34546. 0x93,
  34547. 0xc9,
  34548. 0x9c,
  34549. 0xef,
  34550. 0xa0,
  34551. 0xe0,
  34552. 0x3b,
  34553. 0x4d,
  34554. 0xae,
  34555. 0x2a,
  34556. 0xf5,
  34557. 0xb0,
  34558. 0xc8,
  34559. 0xeb,
  34560. 0xbb,
  34561. 0x3c,
  34562. 0x83,
  34563. 0x53,
  34564. 0x99,
  34565. 0x61,
  34566. 0x17,
  34567. 0x2b,
  34568. 0x04,
  34569. 0x7e,
  34570. 0xba,
  34571. 0x77,
  34572. 0xd6,
  34573. 0x26,
  34574. 0xe1,
  34575. 0x69,
  34576. 0x14,
  34577. 0x63,
  34578. 0x55,
  34579. 0x21,
  34580. 0x0c,
  34581. 0x7d
  34582. ]);
  34583. var mixCol = new Uint8Array(256);
  34584. for (var i = 0; i < 256; i++) {
  34585. if (i < 128) {
  34586. mixCol[i] = i << 1;
  34587. } else {
  34588. mixCol[i] = i << 1 ^ 0x1b;
  34589. }
  34590. }
  34591. var mix = new Uint32Array([
  34592. 0x00000000,
  34593. 0x0e090d0b,
  34594. 0x1c121a16,
  34595. 0x121b171d,
  34596. 0x3824342c,
  34597. 0x362d3927,
  34598. 0x24362e3a,
  34599. 0x2a3f2331,
  34600. 0x70486858,
  34601. 0x7e416553,
  34602. 0x6c5a724e,
  34603. 0x62537f45,
  34604. 0x486c5c74,
  34605. 0x4665517f,
  34606. 0x547e4662,
  34607. 0x5a774b69,
  34608. 0xe090d0b0,
  34609. 0xee99ddbb,
  34610. 0xfc82caa6,
  34611. 0xf28bc7ad,
  34612. 0xd8b4e49c,
  34613. 0xd6bde997,
  34614. 0xc4a6fe8a,
  34615. 0xcaaff381,
  34616. 0x90d8b8e8,
  34617. 0x9ed1b5e3,
  34618. 0x8ccaa2fe,
  34619. 0x82c3aff5,
  34620. 0xa8fc8cc4,
  34621. 0xa6f581cf,
  34622. 0xb4ee96d2,
  34623. 0xbae79bd9,
  34624. 0xdb3bbb7b,
  34625. 0xd532b670,
  34626. 0xc729a16d,
  34627. 0xc920ac66,
  34628. 0xe31f8f57,
  34629. 0xed16825c,
  34630. 0xff0d9541,
  34631. 0xf104984a,
  34632. 0xab73d323,
  34633. 0xa57ade28,
  34634. 0xb761c935,
  34635. 0xb968c43e,
  34636. 0x9357e70f,
  34637. 0x9d5eea04,
  34638. 0x8f45fd19,
  34639. 0x814cf012,
  34640. 0x3bab6bcb,
  34641. 0x35a266c0,
  34642. 0x27b971dd,
  34643. 0x29b07cd6,
  34644. 0x038f5fe7,
  34645. 0x0d8652ec,
  34646. 0x1f9d45f1,
  34647. 0x119448fa,
  34648. 0x4be30393,
  34649. 0x45ea0e98,
  34650. 0x57f11985,
  34651. 0x59f8148e,
  34652. 0x73c737bf,
  34653. 0x7dce3ab4,
  34654. 0x6fd52da9,
  34655. 0x61dc20a2,
  34656. 0xad766df6,
  34657. 0xa37f60fd,
  34658. 0xb16477e0,
  34659. 0xbf6d7aeb,
  34660. 0x955259da,
  34661. 0x9b5b54d1,
  34662. 0x894043cc,
  34663. 0x87494ec7,
  34664. 0xdd3e05ae,
  34665. 0xd33708a5,
  34666. 0xc12c1fb8,
  34667. 0xcf2512b3,
  34668. 0xe51a3182,
  34669. 0xeb133c89,
  34670. 0xf9082b94,
  34671. 0xf701269f,
  34672. 0x4de6bd46,
  34673. 0x43efb04d,
  34674. 0x51f4a750,
  34675. 0x5ffdaa5b,
  34676. 0x75c2896a,
  34677. 0x7bcb8461,
  34678. 0x69d0937c,
  34679. 0x67d99e77,
  34680. 0x3daed51e,
  34681. 0x33a7d815,
  34682. 0x21bccf08,
  34683. 0x2fb5c203,
  34684. 0x058ae132,
  34685. 0x0b83ec39,
  34686. 0x1998fb24,
  34687. 0x1791f62f,
  34688. 0x764dd68d,
  34689. 0x7844db86,
  34690. 0x6a5fcc9b,
  34691. 0x6456c190,
  34692. 0x4e69e2a1,
  34693. 0x4060efaa,
  34694. 0x527bf8b7,
  34695. 0x5c72f5bc,
  34696. 0x0605bed5,
  34697. 0x080cb3de,
  34698. 0x1a17a4c3,
  34699. 0x141ea9c8,
  34700. 0x3e218af9,
  34701. 0x302887f2,
  34702. 0x223390ef,
  34703. 0x2c3a9de4,
  34704. 0x96dd063d,
  34705. 0x98d40b36,
  34706. 0x8acf1c2b,
  34707. 0x84c61120,
  34708. 0xaef93211,
  34709. 0xa0f03f1a,
  34710. 0xb2eb2807,
  34711. 0xbce2250c,
  34712. 0xe6956e65,
  34713. 0xe89c636e,
  34714. 0xfa877473,
  34715. 0xf48e7978,
  34716. 0xdeb15a49,
  34717. 0xd0b85742,
  34718. 0xc2a3405f,
  34719. 0xccaa4d54,
  34720. 0x41ecdaf7,
  34721. 0x4fe5d7fc,
  34722. 0x5dfec0e1,
  34723. 0x53f7cdea,
  34724. 0x79c8eedb,
  34725. 0x77c1e3d0,
  34726. 0x65daf4cd,
  34727. 0x6bd3f9c6,
  34728. 0x31a4b2af,
  34729. 0x3fadbfa4,
  34730. 0x2db6a8b9,
  34731. 0x23bfa5b2,
  34732. 0x09808683,
  34733. 0x07898b88,
  34734. 0x15929c95,
  34735. 0x1b9b919e,
  34736. 0xa17c0a47,
  34737. 0xaf75074c,
  34738. 0xbd6e1051,
  34739. 0xb3671d5a,
  34740. 0x99583e6b,
  34741. 0x97513360,
  34742. 0x854a247d,
  34743. 0x8b432976,
  34744. 0xd134621f,
  34745. 0xdf3d6f14,
  34746. 0xcd267809,
  34747. 0xc32f7502,
  34748. 0xe9105633,
  34749. 0xe7195b38,
  34750. 0xf5024c25,
  34751. 0xfb0b412e,
  34752. 0x9ad7618c,
  34753. 0x94de6c87,
  34754. 0x86c57b9a,
  34755. 0x88cc7691,
  34756. 0xa2f355a0,
  34757. 0xacfa58ab,
  34758. 0xbee14fb6,
  34759. 0xb0e842bd,
  34760. 0xea9f09d4,
  34761. 0xe49604df,
  34762. 0xf68d13c2,
  34763. 0xf8841ec9,
  34764. 0xd2bb3df8,
  34765. 0xdcb230f3,
  34766. 0xcea927ee,
  34767. 0xc0a02ae5,
  34768. 0x7a47b13c,
  34769. 0x744ebc37,
  34770. 0x6655ab2a,
  34771. 0x685ca621,
  34772. 0x42638510,
  34773. 0x4c6a881b,
  34774. 0x5e719f06,
  34775. 0x5078920d,
  34776. 0x0a0fd964,
  34777. 0x0406d46f,
  34778. 0x161dc372,
  34779. 0x1814ce79,
  34780. 0x322bed48,
  34781. 0x3c22e043,
  34782. 0x2e39f75e,
  34783. 0x2030fa55,
  34784. 0xec9ab701,
  34785. 0xe293ba0a,
  34786. 0xf088ad17,
  34787. 0xfe81a01c,
  34788. 0xd4be832d,
  34789. 0xdab78e26,
  34790. 0xc8ac993b,
  34791. 0xc6a59430,
  34792. 0x9cd2df59,
  34793. 0x92dbd252,
  34794. 0x80c0c54f,
  34795. 0x8ec9c844,
  34796. 0xa4f6eb75,
  34797. 0xaaffe67e,
  34798. 0xb8e4f163,
  34799. 0xb6edfc68,
  34800. 0x0c0a67b1,
  34801. 0x02036aba,
  34802. 0x10187da7,
  34803. 0x1e1170ac,
  34804. 0x342e539d,
  34805. 0x3a275e96,
  34806. 0x283c498b,
  34807. 0x26354480,
  34808. 0x7c420fe9,
  34809. 0x724b02e2,
  34810. 0x605015ff,
  34811. 0x6e5918f4,
  34812. 0x44663bc5,
  34813. 0x4a6f36ce,
  34814. 0x587421d3,
  34815. 0x567d2cd8,
  34816. 0x37a10c7a,
  34817. 0x39a80171,
  34818. 0x2bb3166c,
  34819. 0x25ba1b67,
  34820. 0x0f853856,
  34821. 0x018c355d,
  34822. 0x13972240,
  34823. 0x1d9e2f4b,
  34824. 0x47e96422,
  34825. 0x49e06929,
  34826. 0x5bfb7e34,
  34827. 0x55f2733f,
  34828. 0x7fcd500e,
  34829. 0x71c45d05,
  34830. 0x63df4a18,
  34831. 0x6dd64713,
  34832. 0xd731dcca,
  34833. 0xd938d1c1,
  34834. 0xcb23c6dc,
  34835. 0xc52acbd7,
  34836. 0xef15e8e6,
  34837. 0xe11ce5ed,
  34838. 0xf307f2f0,
  34839. 0xfd0efffb,
  34840. 0xa779b492,
  34841. 0xa970b999,
  34842. 0xbb6bae84,
  34843. 0xb562a38f,
  34844. 0x9f5d80be,
  34845. 0x91548db5,
  34846. 0x834f9aa8,
  34847. 0x8d4697a3
  34848. ]);
  34849. function expandKey128(cipherKey) {
  34850. var b = 176, result = new Uint8Array(b);
  34851. result.set(cipherKey);
  34852. for (var j = 16, i = 1; j < b; ++i) {
  34853. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34854. t1 = s[t1];
  34855. t2 = s[t2];
  34856. t3 = s[t3];
  34857. t4 = s[t4];
  34858. t1 = t1 ^ rcon[i];
  34859. for (var n = 0; n < 4; ++n) {
  34860. result[j] = t1 ^= result[j - 16];
  34861. j++;
  34862. result[j] = t2 ^= result[j - 16];
  34863. j++;
  34864. result[j] = t3 ^= result[j - 16];
  34865. j++;
  34866. result[j] = t4 ^= result[j - 16];
  34867. j++;
  34868. }
  34869. }
  34870. return result;
  34871. }
  34872. function decrypt128(input, key) {
  34873. var state = new Uint8Array(16);
  34874. state.set(input);
  34875. var i, j, k;
  34876. var t, u, v;
  34877. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34878. state[j] ^= key[k];
  34879. }
  34880. for (i = 9; i >= 1; --i) {
  34881. t = state[13];
  34882. state[13] = state[9];
  34883. state[9] = state[5];
  34884. state[5] = state[1];
  34885. state[1] = t;
  34886. t = state[14];
  34887. u = state[10];
  34888. state[14] = state[6];
  34889. state[10] = state[2];
  34890. state[6] = t;
  34891. state[2] = u;
  34892. t = state[15];
  34893. u = state[11];
  34894. v = state[7];
  34895. state[15] = state[3];
  34896. state[11] = t;
  34897. state[7] = u;
  34898. state[3] = v;
  34899. for (j = 0; j < 16; ++j) {
  34900. state[j] = inv_s[state[j]];
  34901. }
  34902. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34903. state[j] ^= key[k];
  34904. }
  34905. for (j = 0; j < 16; j += 4) {
  34906. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34907. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34908. state[j] = t >>> 24 & 0xFF;
  34909. state[j + 1] = t >> 16 & 0xFF;
  34910. state[j + 2] = t >> 8 & 0xFF;
  34911. state[j + 3] = t & 0xFF;
  34912. }
  34913. }
  34914. t = state[13];
  34915. state[13] = state[9];
  34916. state[9] = state[5];
  34917. state[5] = state[1];
  34918. state[1] = t;
  34919. t = state[14];
  34920. u = state[10];
  34921. state[14] = state[6];
  34922. state[10] = state[2];
  34923. state[6] = t;
  34924. state[2] = u;
  34925. t = state[15];
  34926. u = state[11];
  34927. v = state[7];
  34928. state[15] = state[3];
  34929. state[11] = t;
  34930. state[7] = u;
  34931. state[3] = v;
  34932. for (j = 0; j < 16; ++j) {
  34933. state[j] = inv_s[state[j]];
  34934. state[j] ^= key[j];
  34935. }
  34936. return state;
  34937. }
  34938. function encrypt128(input, key) {
  34939. var t, u, v, k;
  34940. var state = new Uint8Array(16);
  34941. state.set(input);
  34942. for (j = 0; j < 16; ++j) {
  34943. state[j] ^= key[j];
  34944. }
  34945. for (i = 1; i < 10; i++) {
  34946. for (j = 0; j < 16; ++j) {
  34947. state[j] = s[state[j]];
  34948. }
  34949. v = state[1];
  34950. state[1] = state[5];
  34951. state[5] = state[9];
  34952. state[9] = state[13];
  34953. state[13] = v;
  34954. v = state[2];
  34955. u = state[6];
  34956. state[2] = state[10];
  34957. state[6] = state[14];
  34958. state[10] = v;
  34959. state[14] = u;
  34960. v = state[3];
  34961. u = state[7];
  34962. t = state[11];
  34963. state[3] = state[15];
  34964. state[7] = v;
  34965. state[11] = u;
  34966. state[15] = t;
  34967. for (var j = 0; j < 16; j += 4) {
  34968. var s0 = state[j + 0], s1 = state[j + 1];
  34969. var s2 = state[j + 2], s3 = state[j + 3];
  34970. t = s0 ^ s1 ^ s2 ^ s3;
  34971. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34972. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34973. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34974. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34975. }
  34976. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34977. state[j] ^= key[k];
  34978. }
  34979. }
  34980. for (j = 0; j < 16; ++j) {
  34981. state[j] = s[state[j]];
  34982. }
  34983. v = state[1];
  34984. state[1] = state[5];
  34985. state[5] = state[9];
  34986. state[9] = state[13];
  34987. state[13] = v;
  34988. v = state[2];
  34989. u = state[6];
  34990. state[2] = state[10];
  34991. state[6] = state[14];
  34992. state[10] = v;
  34993. state[14] = u;
  34994. v = state[3];
  34995. u = state[7];
  34996. t = state[11];
  34997. state[3] = state[15];
  34998. state[7] = v;
  34999. state[11] = u;
  35000. state[15] = t;
  35001. for (j = 0, k = 160; j < 16; ++j, ++k) {
  35002. state[j] ^= key[k];
  35003. }
  35004. return state;
  35005. }
  35006. function AES128Cipher(key) {
  35007. this.key = expandKey128(key);
  35008. this.buffer = new Uint8Array(16);
  35009. this.bufferPosition = 0;
  35010. }
  35011. function decryptBlock2(data, finalize) {
  35012. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  35013. for (i = 0; i < sourceLength; ++i) {
  35014. buffer[bufferLength] = data[i];
  35015. ++bufferLength;
  35016. if (bufferLength < 16) {
  35017. continue;
  35018. }
  35019. var plain = decrypt128(buffer, this.key);
  35020. for (j = 0; j < 16; ++j) {
  35021. plain[j] ^= iv[j];
  35022. }
  35023. iv = buffer;
  35024. result.push(plain);
  35025. buffer = new Uint8Array(16);
  35026. bufferLength = 0;
  35027. }
  35028. this.buffer = buffer;
  35029. this.bufferLength = bufferLength;
  35030. this.iv = iv;
  35031. if (result.length === 0) {
  35032. return new Uint8Array([]);
  35033. }
  35034. var outputLength = 16 * result.length;
  35035. if (finalize) {
  35036. var lastBlock = result[result.length - 1];
  35037. var psLen = lastBlock[15];
  35038. if (psLen <= 16) {
  35039. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  35040. if (lastBlock[i] !== psLen) {
  35041. psLen = 0;
  35042. break;
  35043. }
  35044. }
  35045. outputLength -= psLen;
  35046. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  35047. }
  35048. }
  35049. var output = new Uint8Array(outputLength);
  35050. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35051. output.set(result[i], j);
  35052. }
  35053. return output;
  35054. }
  35055. AES128Cipher.prototype = {
  35056. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  35057. var i, sourceLength = data.length;
  35058. var buffer = this.buffer, bufferLength = this.bufferPosition;
  35059. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  35060. buffer[bufferLength] = data[i];
  35061. }
  35062. if (bufferLength < 16) {
  35063. this.bufferLength = bufferLength;
  35064. return new Uint8Array([]);
  35065. }
  35066. this.iv = buffer;
  35067. this.buffer = new Uint8Array(16);
  35068. this.bufferLength = 0;
  35069. this.decryptBlock = decryptBlock2;
  35070. return this.decryptBlock(data.subarray(16), finalize);
  35071. },
  35072. encrypt: function AES128Cipher_encrypt(data, iv) {
  35073. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  35074. if (!iv) {
  35075. iv = new Uint8Array(16);
  35076. }
  35077. for (i = 0; i < sourceLength; ++i) {
  35078. buffer[bufferLength] = data[i];
  35079. ++bufferLength;
  35080. if (bufferLength < 16) {
  35081. continue;
  35082. }
  35083. for (j = 0; j < 16; ++j) {
  35084. buffer[j] ^= iv[j];
  35085. }
  35086. var cipher = encrypt128(buffer, this.key);
  35087. iv = cipher;
  35088. result.push(cipher);
  35089. buffer = new Uint8Array(16);
  35090. bufferLength = 0;
  35091. }
  35092. this.buffer = buffer;
  35093. this.bufferLength = bufferLength;
  35094. this.iv = iv;
  35095. if (result.length === 0) {
  35096. return new Uint8Array([]);
  35097. }
  35098. var outputLength = 16 * result.length;
  35099. var output = new Uint8Array(outputLength);
  35100. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35101. output.set(result[i], j);
  35102. }
  35103. return output;
  35104. }
  35105. };
  35106. return AES128Cipher;
  35107. }();
  35108. var AES256Cipher = function AES256CipherClosure() {
  35109. var s = new Uint8Array([
  35110. 0x63,
  35111. 0x7c,
  35112. 0x77,
  35113. 0x7b,
  35114. 0xf2,
  35115. 0x6b,
  35116. 0x6f,
  35117. 0xc5,
  35118. 0x30,
  35119. 0x01,
  35120. 0x67,
  35121. 0x2b,
  35122. 0xfe,
  35123. 0xd7,
  35124. 0xab,
  35125. 0x76,
  35126. 0xca,
  35127. 0x82,
  35128. 0xc9,
  35129. 0x7d,
  35130. 0xfa,
  35131. 0x59,
  35132. 0x47,
  35133. 0xf0,
  35134. 0xad,
  35135. 0xd4,
  35136. 0xa2,
  35137. 0xaf,
  35138. 0x9c,
  35139. 0xa4,
  35140. 0x72,
  35141. 0xc0,
  35142. 0xb7,
  35143. 0xfd,
  35144. 0x93,
  35145. 0x26,
  35146. 0x36,
  35147. 0x3f,
  35148. 0xf7,
  35149. 0xcc,
  35150. 0x34,
  35151. 0xa5,
  35152. 0xe5,
  35153. 0xf1,
  35154. 0x71,
  35155. 0xd8,
  35156. 0x31,
  35157. 0x15,
  35158. 0x04,
  35159. 0xc7,
  35160. 0x23,
  35161. 0xc3,
  35162. 0x18,
  35163. 0x96,
  35164. 0x05,
  35165. 0x9a,
  35166. 0x07,
  35167. 0x12,
  35168. 0x80,
  35169. 0xe2,
  35170. 0xeb,
  35171. 0x27,
  35172. 0xb2,
  35173. 0x75,
  35174. 0x09,
  35175. 0x83,
  35176. 0x2c,
  35177. 0x1a,
  35178. 0x1b,
  35179. 0x6e,
  35180. 0x5a,
  35181. 0xa0,
  35182. 0x52,
  35183. 0x3b,
  35184. 0xd6,
  35185. 0xb3,
  35186. 0x29,
  35187. 0xe3,
  35188. 0x2f,
  35189. 0x84,
  35190. 0x53,
  35191. 0xd1,
  35192. 0x00,
  35193. 0xed,
  35194. 0x20,
  35195. 0xfc,
  35196. 0xb1,
  35197. 0x5b,
  35198. 0x6a,
  35199. 0xcb,
  35200. 0xbe,
  35201. 0x39,
  35202. 0x4a,
  35203. 0x4c,
  35204. 0x58,
  35205. 0xcf,
  35206. 0xd0,
  35207. 0xef,
  35208. 0xaa,
  35209. 0xfb,
  35210. 0x43,
  35211. 0x4d,
  35212. 0x33,
  35213. 0x85,
  35214. 0x45,
  35215. 0xf9,
  35216. 0x02,
  35217. 0x7f,
  35218. 0x50,
  35219. 0x3c,
  35220. 0x9f,
  35221. 0xa8,
  35222. 0x51,
  35223. 0xa3,
  35224. 0x40,
  35225. 0x8f,
  35226. 0x92,
  35227. 0x9d,
  35228. 0x38,
  35229. 0xf5,
  35230. 0xbc,
  35231. 0xb6,
  35232. 0xda,
  35233. 0x21,
  35234. 0x10,
  35235. 0xff,
  35236. 0xf3,
  35237. 0xd2,
  35238. 0xcd,
  35239. 0x0c,
  35240. 0x13,
  35241. 0xec,
  35242. 0x5f,
  35243. 0x97,
  35244. 0x44,
  35245. 0x17,
  35246. 0xc4,
  35247. 0xa7,
  35248. 0x7e,
  35249. 0x3d,
  35250. 0x64,
  35251. 0x5d,
  35252. 0x19,
  35253. 0x73,
  35254. 0x60,
  35255. 0x81,
  35256. 0x4f,
  35257. 0xdc,
  35258. 0x22,
  35259. 0x2a,
  35260. 0x90,
  35261. 0x88,
  35262. 0x46,
  35263. 0xee,
  35264. 0xb8,
  35265. 0x14,
  35266. 0xde,
  35267. 0x5e,
  35268. 0x0b,
  35269. 0xdb,
  35270. 0xe0,
  35271. 0x32,
  35272. 0x3a,
  35273. 0x0a,
  35274. 0x49,
  35275. 0x06,
  35276. 0x24,
  35277. 0x5c,
  35278. 0xc2,
  35279. 0xd3,
  35280. 0xac,
  35281. 0x62,
  35282. 0x91,
  35283. 0x95,
  35284. 0xe4,
  35285. 0x79,
  35286. 0xe7,
  35287. 0xc8,
  35288. 0x37,
  35289. 0x6d,
  35290. 0x8d,
  35291. 0xd5,
  35292. 0x4e,
  35293. 0xa9,
  35294. 0x6c,
  35295. 0x56,
  35296. 0xf4,
  35297. 0xea,
  35298. 0x65,
  35299. 0x7a,
  35300. 0xae,
  35301. 0x08,
  35302. 0xba,
  35303. 0x78,
  35304. 0x25,
  35305. 0x2e,
  35306. 0x1c,
  35307. 0xa6,
  35308. 0xb4,
  35309. 0xc6,
  35310. 0xe8,
  35311. 0xdd,
  35312. 0x74,
  35313. 0x1f,
  35314. 0x4b,
  35315. 0xbd,
  35316. 0x8b,
  35317. 0x8a,
  35318. 0x70,
  35319. 0x3e,
  35320. 0xb5,
  35321. 0x66,
  35322. 0x48,
  35323. 0x03,
  35324. 0xf6,
  35325. 0x0e,
  35326. 0x61,
  35327. 0x35,
  35328. 0x57,
  35329. 0xb9,
  35330. 0x86,
  35331. 0xc1,
  35332. 0x1d,
  35333. 0x9e,
  35334. 0xe1,
  35335. 0xf8,
  35336. 0x98,
  35337. 0x11,
  35338. 0x69,
  35339. 0xd9,
  35340. 0x8e,
  35341. 0x94,
  35342. 0x9b,
  35343. 0x1e,
  35344. 0x87,
  35345. 0xe9,
  35346. 0xce,
  35347. 0x55,
  35348. 0x28,
  35349. 0xdf,
  35350. 0x8c,
  35351. 0xa1,
  35352. 0x89,
  35353. 0x0d,
  35354. 0xbf,
  35355. 0xe6,
  35356. 0x42,
  35357. 0x68,
  35358. 0x41,
  35359. 0x99,
  35360. 0x2d,
  35361. 0x0f,
  35362. 0xb0,
  35363. 0x54,
  35364. 0xbb,
  35365. 0x16
  35366. ]);
  35367. var inv_s = new Uint8Array([
  35368. 0x52,
  35369. 0x09,
  35370. 0x6a,
  35371. 0xd5,
  35372. 0x30,
  35373. 0x36,
  35374. 0xa5,
  35375. 0x38,
  35376. 0xbf,
  35377. 0x40,
  35378. 0xa3,
  35379. 0x9e,
  35380. 0x81,
  35381. 0xf3,
  35382. 0xd7,
  35383. 0xfb,
  35384. 0x7c,
  35385. 0xe3,
  35386. 0x39,
  35387. 0x82,
  35388. 0x9b,
  35389. 0x2f,
  35390. 0xff,
  35391. 0x87,
  35392. 0x34,
  35393. 0x8e,
  35394. 0x43,
  35395. 0x44,
  35396. 0xc4,
  35397. 0xde,
  35398. 0xe9,
  35399. 0xcb,
  35400. 0x54,
  35401. 0x7b,
  35402. 0x94,
  35403. 0x32,
  35404. 0xa6,
  35405. 0xc2,
  35406. 0x23,
  35407. 0x3d,
  35408. 0xee,
  35409. 0x4c,
  35410. 0x95,
  35411. 0x0b,
  35412. 0x42,
  35413. 0xfa,
  35414. 0xc3,
  35415. 0x4e,
  35416. 0x08,
  35417. 0x2e,
  35418. 0xa1,
  35419. 0x66,
  35420. 0x28,
  35421. 0xd9,
  35422. 0x24,
  35423. 0xb2,
  35424. 0x76,
  35425. 0x5b,
  35426. 0xa2,
  35427. 0x49,
  35428. 0x6d,
  35429. 0x8b,
  35430. 0xd1,
  35431. 0x25,
  35432. 0x72,
  35433. 0xf8,
  35434. 0xf6,
  35435. 0x64,
  35436. 0x86,
  35437. 0x68,
  35438. 0x98,
  35439. 0x16,
  35440. 0xd4,
  35441. 0xa4,
  35442. 0x5c,
  35443. 0xcc,
  35444. 0x5d,
  35445. 0x65,
  35446. 0xb6,
  35447. 0x92,
  35448. 0x6c,
  35449. 0x70,
  35450. 0x48,
  35451. 0x50,
  35452. 0xfd,
  35453. 0xed,
  35454. 0xb9,
  35455. 0xda,
  35456. 0x5e,
  35457. 0x15,
  35458. 0x46,
  35459. 0x57,
  35460. 0xa7,
  35461. 0x8d,
  35462. 0x9d,
  35463. 0x84,
  35464. 0x90,
  35465. 0xd8,
  35466. 0xab,
  35467. 0x00,
  35468. 0x8c,
  35469. 0xbc,
  35470. 0xd3,
  35471. 0x0a,
  35472. 0xf7,
  35473. 0xe4,
  35474. 0x58,
  35475. 0x05,
  35476. 0xb8,
  35477. 0xb3,
  35478. 0x45,
  35479. 0x06,
  35480. 0xd0,
  35481. 0x2c,
  35482. 0x1e,
  35483. 0x8f,
  35484. 0xca,
  35485. 0x3f,
  35486. 0x0f,
  35487. 0x02,
  35488. 0xc1,
  35489. 0xaf,
  35490. 0xbd,
  35491. 0x03,
  35492. 0x01,
  35493. 0x13,
  35494. 0x8a,
  35495. 0x6b,
  35496. 0x3a,
  35497. 0x91,
  35498. 0x11,
  35499. 0x41,
  35500. 0x4f,
  35501. 0x67,
  35502. 0xdc,
  35503. 0xea,
  35504. 0x97,
  35505. 0xf2,
  35506. 0xcf,
  35507. 0xce,
  35508. 0xf0,
  35509. 0xb4,
  35510. 0xe6,
  35511. 0x73,
  35512. 0x96,
  35513. 0xac,
  35514. 0x74,
  35515. 0x22,
  35516. 0xe7,
  35517. 0xad,
  35518. 0x35,
  35519. 0x85,
  35520. 0xe2,
  35521. 0xf9,
  35522. 0x37,
  35523. 0xe8,
  35524. 0x1c,
  35525. 0x75,
  35526. 0xdf,
  35527. 0x6e,
  35528. 0x47,
  35529. 0xf1,
  35530. 0x1a,
  35531. 0x71,
  35532. 0x1d,
  35533. 0x29,
  35534. 0xc5,
  35535. 0x89,
  35536. 0x6f,
  35537. 0xb7,
  35538. 0x62,
  35539. 0x0e,
  35540. 0xaa,
  35541. 0x18,
  35542. 0xbe,
  35543. 0x1b,
  35544. 0xfc,
  35545. 0x56,
  35546. 0x3e,
  35547. 0x4b,
  35548. 0xc6,
  35549. 0xd2,
  35550. 0x79,
  35551. 0x20,
  35552. 0x9a,
  35553. 0xdb,
  35554. 0xc0,
  35555. 0xfe,
  35556. 0x78,
  35557. 0xcd,
  35558. 0x5a,
  35559. 0xf4,
  35560. 0x1f,
  35561. 0xdd,
  35562. 0xa8,
  35563. 0x33,
  35564. 0x88,
  35565. 0x07,
  35566. 0xc7,
  35567. 0x31,
  35568. 0xb1,
  35569. 0x12,
  35570. 0x10,
  35571. 0x59,
  35572. 0x27,
  35573. 0x80,
  35574. 0xec,
  35575. 0x5f,
  35576. 0x60,
  35577. 0x51,
  35578. 0x7f,
  35579. 0xa9,
  35580. 0x19,
  35581. 0xb5,
  35582. 0x4a,
  35583. 0x0d,
  35584. 0x2d,
  35585. 0xe5,
  35586. 0x7a,
  35587. 0x9f,
  35588. 0x93,
  35589. 0xc9,
  35590. 0x9c,
  35591. 0xef,
  35592. 0xa0,
  35593. 0xe0,
  35594. 0x3b,
  35595. 0x4d,
  35596. 0xae,
  35597. 0x2a,
  35598. 0xf5,
  35599. 0xb0,
  35600. 0xc8,
  35601. 0xeb,
  35602. 0xbb,
  35603. 0x3c,
  35604. 0x83,
  35605. 0x53,
  35606. 0x99,
  35607. 0x61,
  35608. 0x17,
  35609. 0x2b,
  35610. 0x04,
  35611. 0x7e,
  35612. 0xba,
  35613. 0x77,
  35614. 0xd6,
  35615. 0x26,
  35616. 0xe1,
  35617. 0x69,
  35618. 0x14,
  35619. 0x63,
  35620. 0x55,
  35621. 0x21,
  35622. 0x0c,
  35623. 0x7d
  35624. ]);
  35625. var mixCol = new Uint8Array(256);
  35626. for (var i = 0; i < 256; i++) {
  35627. if (i < 128) {
  35628. mixCol[i] = i << 1;
  35629. } else {
  35630. mixCol[i] = i << 1 ^ 0x1b;
  35631. }
  35632. }
  35633. var mix = new Uint32Array([
  35634. 0x00000000,
  35635. 0x0e090d0b,
  35636. 0x1c121a16,
  35637. 0x121b171d,
  35638. 0x3824342c,
  35639. 0x362d3927,
  35640. 0x24362e3a,
  35641. 0x2a3f2331,
  35642. 0x70486858,
  35643. 0x7e416553,
  35644. 0x6c5a724e,
  35645. 0x62537f45,
  35646. 0x486c5c74,
  35647. 0x4665517f,
  35648. 0x547e4662,
  35649. 0x5a774b69,
  35650. 0xe090d0b0,
  35651. 0xee99ddbb,
  35652. 0xfc82caa6,
  35653. 0xf28bc7ad,
  35654. 0xd8b4e49c,
  35655. 0xd6bde997,
  35656. 0xc4a6fe8a,
  35657. 0xcaaff381,
  35658. 0x90d8b8e8,
  35659. 0x9ed1b5e3,
  35660. 0x8ccaa2fe,
  35661. 0x82c3aff5,
  35662. 0xa8fc8cc4,
  35663. 0xa6f581cf,
  35664. 0xb4ee96d2,
  35665. 0xbae79bd9,
  35666. 0xdb3bbb7b,
  35667. 0xd532b670,
  35668. 0xc729a16d,
  35669. 0xc920ac66,
  35670. 0xe31f8f57,
  35671. 0xed16825c,
  35672. 0xff0d9541,
  35673. 0xf104984a,
  35674. 0xab73d323,
  35675. 0xa57ade28,
  35676. 0xb761c935,
  35677. 0xb968c43e,
  35678. 0x9357e70f,
  35679. 0x9d5eea04,
  35680. 0x8f45fd19,
  35681. 0x814cf012,
  35682. 0x3bab6bcb,
  35683. 0x35a266c0,
  35684. 0x27b971dd,
  35685. 0x29b07cd6,
  35686. 0x038f5fe7,
  35687. 0x0d8652ec,
  35688. 0x1f9d45f1,
  35689. 0x119448fa,
  35690. 0x4be30393,
  35691. 0x45ea0e98,
  35692. 0x57f11985,
  35693. 0x59f8148e,
  35694. 0x73c737bf,
  35695. 0x7dce3ab4,
  35696. 0x6fd52da9,
  35697. 0x61dc20a2,
  35698. 0xad766df6,
  35699. 0xa37f60fd,
  35700. 0xb16477e0,
  35701. 0xbf6d7aeb,
  35702. 0x955259da,
  35703. 0x9b5b54d1,
  35704. 0x894043cc,
  35705. 0x87494ec7,
  35706. 0xdd3e05ae,
  35707. 0xd33708a5,
  35708. 0xc12c1fb8,
  35709. 0xcf2512b3,
  35710. 0xe51a3182,
  35711. 0xeb133c89,
  35712. 0xf9082b94,
  35713. 0xf701269f,
  35714. 0x4de6bd46,
  35715. 0x43efb04d,
  35716. 0x51f4a750,
  35717. 0x5ffdaa5b,
  35718. 0x75c2896a,
  35719. 0x7bcb8461,
  35720. 0x69d0937c,
  35721. 0x67d99e77,
  35722. 0x3daed51e,
  35723. 0x33a7d815,
  35724. 0x21bccf08,
  35725. 0x2fb5c203,
  35726. 0x058ae132,
  35727. 0x0b83ec39,
  35728. 0x1998fb24,
  35729. 0x1791f62f,
  35730. 0x764dd68d,
  35731. 0x7844db86,
  35732. 0x6a5fcc9b,
  35733. 0x6456c190,
  35734. 0x4e69e2a1,
  35735. 0x4060efaa,
  35736. 0x527bf8b7,
  35737. 0x5c72f5bc,
  35738. 0x0605bed5,
  35739. 0x080cb3de,
  35740. 0x1a17a4c3,
  35741. 0x141ea9c8,
  35742. 0x3e218af9,
  35743. 0x302887f2,
  35744. 0x223390ef,
  35745. 0x2c3a9de4,
  35746. 0x96dd063d,
  35747. 0x98d40b36,
  35748. 0x8acf1c2b,
  35749. 0x84c61120,
  35750. 0xaef93211,
  35751. 0xa0f03f1a,
  35752. 0xb2eb2807,
  35753. 0xbce2250c,
  35754. 0xe6956e65,
  35755. 0xe89c636e,
  35756. 0xfa877473,
  35757. 0xf48e7978,
  35758. 0xdeb15a49,
  35759. 0xd0b85742,
  35760. 0xc2a3405f,
  35761. 0xccaa4d54,
  35762. 0x41ecdaf7,
  35763. 0x4fe5d7fc,
  35764. 0x5dfec0e1,
  35765. 0x53f7cdea,
  35766. 0x79c8eedb,
  35767. 0x77c1e3d0,
  35768. 0x65daf4cd,
  35769. 0x6bd3f9c6,
  35770. 0x31a4b2af,
  35771. 0x3fadbfa4,
  35772. 0x2db6a8b9,
  35773. 0x23bfa5b2,
  35774. 0x09808683,
  35775. 0x07898b88,
  35776. 0x15929c95,
  35777. 0x1b9b919e,
  35778. 0xa17c0a47,
  35779. 0xaf75074c,
  35780. 0xbd6e1051,
  35781. 0xb3671d5a,
  35782. 0x99583e6b,
  35783. 0x97513360,
  35784. 0x854a247d,
  35785. 0x8b432976,
  35786. 0xd134621f,
  35787. 0xdf3d6f14,
  35788. 0xcd267809,
  35789. 0xc32f7502,
  35790. 0xe9105633,
  35791. 0xe7195b38,
  35792. 0xf5024c25,
  35793. 0xfb0b412e,
  35794. 0x9ad7618c,
  35795. 0x94de6c87,
  35796. 0x86c57b9a,
  35797. 0x88cc7691,
  35798. 0xa2f355a0,
  35799. 0xacfa58ab,
  35800. 0xbee14fb6,
  35801. 0xb0e842bd,
  35802. 0xea9f09d4,
  35803. 0xe49604df,
  35804. 0xf68d13c2,
  35805. 0xf8841ec9,
  35806. 0xd2bb3df8,
  35807. 0xdcb230f3,
  35808. 0xcea927ee,
  35809. 0xc0a02ae5,
  35810. 0x7a47b13c,
  35811. 0x744ebc37,
  35812. 0x6655ab2a,
  35813. 0x685ca621,
  35814. 0x42638510,
  35815. 0x4c6a881b,
  35816. 0x5e719f06,
  35817. 0x5078920d,
  35818. 0x0a0fd964,
  35819. 0x0406d46f,
  35820. 0x161dc372,
  35821. 0x1814ce79,
  35822. 0x322bed48,
  35823. 0x3c22e043,
  35824. 0x2e39f75e,
  35825. 0x2030fa55,
  35826. 0xec9ab701,
  35827. 0xe293ba0a,
  35828. 0xf088ad17,
  35829. 0xfe81a01c,
  35830. 0xd4be832d,
  35831. 0xdab78e26,
  35832. 0xc8ac993b,
  35833. 0xc6a59430,
  35834. 0x9cd2df59,
  35835. 0x92dbd252,
  35836. 0x80c0c54f,
  35837. 0x8ec9c844,
  35838. 0xa4f6eb75,
  35839. 0xaaffe67e,
  35840. 0xb8e4f163,
  35841. 0xb6edfc68,
  35842. 0x0c0a67b1,
  35843. 0x02036aba,
  35844. 0x10187da7,
  35845. 0x1e1170ac,
  35846. 0x342e539d,
  35847. 0x3a275e96,
  35848. 0x283c498b,
  35849. 0x26354480,
  35850. 0x7c420fe9,
  35851. 0x724b02e2,
  35852. 0x605015ff,
  35853. 0x6e5918f4,
  35854. 0x44663bc5,
  35855. 0x4a6f36ce,
  35856. 0x587421d3,
  35857. 0x567d2cd8,
  35858. 0x37a10c7a,
  35859. 0x39a80171,
  35860. 0x2bb3166c,
  35861. 0x25ba1b67,
  35862. 0x0f853856,
  35863. 0x018c355d,
  35864. 0x13972240,
  35865. 0x1d9e2f4b,
  35866. 0x47e96422,
  35867. 0x49e06929,
  35868. 0x5bfb7e34,
  35869. 0x55f2733f,
  35870. 0x7fcd500e,
  35871. 0x71c45d05,
  35872. 0x63df4a18,
  35873. 0x6dd64713,
  35874. 0xd731dcca,
  35875. 0xd938d1c1,
  35876. 0xcb23c6dc,
  35877. 0xc52acbd7,
  35878. 0xef15e8e6,
  35879. 0xe11ce5ed,
  35880. 0xf307f2f0,
  35881. 0xfd0efffb,
  35882. 0xa779b492,
  35883. 0xa970b999,
  35884. 0xbb6bae84,
  35885. 0xb562a38f,
  35886. 0x9f5d80be,
  35887. 0x91548db5,
  35888. 0x834f9aa8,
  35889. 0x8d4697a3
  35890. ]);
  35891. function expandKey256(cipherKey) {
  35892. var b = 240, result = new Uint8Array(b);
  35893. var r = 1;
  35894. result.set(cipherKey);
  35895. for (var j = 32, i = 1; j < b; ++i) {
  35896. if (j % 32 === 16) {
  35897. t1 = s[t1];
  35898. t2 = s[t2];
  35899. t3 = s[t3];
  35900. t4 = s[t4];
  35901. } else if (j % 32 === 0) {
  35902. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35903. t1 = s[t1];
  35904. t2 = s[t2];
  35905. t3 = s[t3];
  35906. t4 = s[t4];
  35907. t1 = t1 ^ r;
  35908. if ((r <<= 1) >= 256) {
  35909. r = (r ^ 0x1b) & 0xFF;
  35910. }
  35911. }
  35912. for (var n = 0; n < 4; ++n) {
  35913. result[j] = t1 ^= result[j - 32];
  35914. j++;
  35915. result[j] = t2 ^= result[j - 32];
  35916. j++;
  35917. result[j] = t3 ^= result[j - 32];
  35918. j++;
  35919. result[j] = t4 ^= result[j - 32];
  35920. j++;
  35921. }
  35922. }
  35923. return result;
  35924. }
  35925. function decrypt256(input, key) {
  35926. var state = new Uint8Array(16);
  35927. state.set(input);
  35928. var i, j, k;
  35929. var t, u, v;
  35930. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35931. state[j] ^= key[k];
  35932. }
  35933. for (i = 13; i >= 1; --i) {
  35934. t = state[13];
  35935. state[13] = state[9];
  35936. state[9] = state[5];
  35937. state[5] = state[1];
  35938. state[1] = t;
  35939. t = state[14];
  35940. u = state[10];
  35941. state[14] = state[6];
  35942. state[10] = state[2];
  35943. state[6] = t;
  35944. state[2] = u;
  35945. t = state[15];
  35946. u = state[11];
  35947. v = state[7];
  35948. state[15] = state[3];
  35949. state[11] = t;
  35950. state[7] = u;
  35951. state[3] = v;
  35952. for (j = 0; j < 16; ++j) {
  35953. state[j] = inv_s[state[j]];
  35954. }
  35955. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35956. state[j] ^= key[k];
  35957. }
  35958. for (j = 0; j < 16; j += 4) {
  35959. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35960. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35961. state[j] = t >>> 24 & 0xFF;
  35962. state[j + 1] = t >> 16 & 0xFF;
  35963. state[j + 2] = t >> 8 & 0xFF;
  35964. state[j + 3] = t & 0xFF;
  35965. }
  35966. }
  35967. t = state[13];
  35968. state[13] = state[9];
  35969. state[9] = state[5];
  35970. state[5] = state[1];
  35971. state[1] = t;
  35972. t = state[14];
  35973. u = state[10];
  35974. state[14] = state[6];
  35975. state[10] = state[2];
  35976. state[6] = t;
  35977. state[2] = u;
  35978. t = state[15];
  35979. u = state[11];
  35980. v = state[7];
  35981. state[15] = state[3];
  35982. state[11] = t;
  35983. state[7] = u;
  35984. state[3] = v;
  35985. for (j = 0; j < 16; ++j) {
  35986. state[j] = inv_s[state[j]];
  35987. state[j] ^= key[j];
  35988. }
  35989. return state;
  35990. }
  35991. function encrypt256(input, key) {
  35992. var t, u, v, k;
  35993. var state = new Uint8Array(16);
  35994. state.set(input);
  35995. for (j = 0; j < 16; ++j) {
  35996. state[j] ^= key[j];
  35997. }
  35998. for (i = 1; i < 14; i++) {
  35999. for (j = 0; j < 16; ++j) {
  36000. state[j] = s[state[j]];
  36001. }
  36002. v = state[1];
  36003. state[1] = state[5];
  36004. state[5] = state[9];
  36005. state[9] = state[13];
  36006. state[13] = v;
  36007. v = state[2];
  36008. u = state[6];
  36009. state[2] = state[10];
  36010. state[6] = state[14];
  36011. state[10] = v;
  36012. state[14] = u;
  36013. v = state[3];
  36014. u = state[7];
  36015. t = state[11];
  36016. state[3] = state[15];
  36017. state[7] = v;
  36018. state[11] = u;
  36019. state[15] = t;
  36020. for (var j = 0; j < 16; j += 4) {
  36021. var s0 = state[j + 0], s1 = state[j + 1];
  36022. var s2 = state[j + 2], s3 = state[j + 3];
  36023. t = s0 ^ s1 ^ s2 ^ s3;
  36024. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  36025. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  36026. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  36027. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  36028. }
  36029. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  36030. state[j] ^= key[k];
  36031. }
  36032. }
  36033. for (j = 0; j < 16; ++j) {
  36034. state[j] = s[state[j]];
  36035. }
  36036. v = state[1];
  36037. state[1] = state[5];
  36038. state[5] = state[9];
  36039. state[9] = state[13];
  36040. state[13] = v;
  36041. v = state[2];
  36042. u = state[6];
  36043. state[2] = state[10];
  36044. state[6] = state[14];
  36045. state[10] = v;
  36046. state[14] = u;
  36047. v = state[3];
  36048. u = state[7];
  36049. t = state[11];
  36050. state[3] = state[15];
  36051. state[7] = v;
  36052. state[11] = u;
  36053. state[15] = t;
  36054. for (j = 0, k = 224; j < 16; ++j, ++k) {
  36055. state[j] ^= key[k];
  36056. }
  36057. return state;
  36058. }
  36059. function AES256Cipher(key) {
  36060. this.key = expandKey256(key);
  36061. this.buffer = new Uint8Array(16);
  36062. this.bufferPosition = 0;
  36063. }
  36064. function decryptBlock2(data, finalize) {
  36065. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  36066. for (i = 0; i < sourceLength; ++i) {
  36067. buffer[bufferLength] = data[i];
  36068. ++bufferLength;
  36069. if (bufferLength < 16) {
  36070. continue;
  36071. }
  36072. var plain = decrypt256(buffer, this.key);
  36073. for (j = 0; j < 16; ++j) {
  36074. plain[j] ^= iv[j];
  36075. }
  36076. iv = buffer;
  36077. result.push(plain);
  36078. buffer = new Uint8Array(16);
  36079. bufferLength = 0;
  36080. }
  36081. this.buffer = buffer;
  36082. this.bufferLength = bufferLength;
  36083. this.iv = iv;
  36084. if (result.length === 0) {
  36085. return new Uint8Array([]);
  36086. }
  36087. var outputLength = 16 * result.length;
  36088. if (finalize) {
  36089. var lastBlock = result[result.length - 1];
  36090. var psLen = lastBlock[15];
  36091. if (psLen <= 16) {
  36092. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  36093. if (lastBlock[i] !== psLen) {
  36094. psLen = 0;
  36095. break;
  36096. }
  36097. }
  36098. outputLength -= psLen;
  36099. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  36100. }
  36101. }
  36102. var output = new Uint8Array(outputLength);
  36103. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36104. output.set(result[i], j);
  36105. }
  36106. return output;
  36107. }
  36108. AES256Cipher.prototype = {
  36109. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  36110. var i, sourceLength = data.length;
  36111. var buffer = this.buffer, bufferLength = this.bufferPosition;
  36112. if (iv) {
  36113. this.iv = iv;
  36114. } else {
  36115. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  36116. buffer[bufferLength] = data[i];
  36117. }
  36118. if (bufferLength < 16) {
  36119. this.bufferLength = bufferLength;
  36120. return new Uint8Array([]);
  36121. }
  36122. this.iv = buffer;
  36123. data = data.subarray(16);
  36124. }
  36125. this.buffer = new Uint8Array(16);
  36126. this.bufferLength = 0;
  36127. this.decryptBlock = decryptBlock2;
  36128. return this.decryptBlock(data, finalize);
  36129. },
  36130. encrypt: function AES256Cipher_encrypt(data, iv) {
  36131. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  36132. if (!iv) {
  36133. iv = new Uint8Array(16);
  36134. }
  36135. for (i = 0; i < sourceLength; ++i) {
  36136. buffer[bufferLength] = data[i];
  36137. ++bufferLength;
  36138. if (bufferLength < 16) {
  36139. continue;
  36140. }
  36141. for (j = 0; j < 16; ++j) {
  36142. buffer[j] ^= iv[j];
  36143. }
  36144. var cipher = encrypt256(buffer, this.key);
  36145. this.iv = cipher;
  36146. result.push(cipher);
  36147. buffer = new Uint8Array(16);
  36148. bufferLength = 0;
  36149. }
  36150. this.buffer = buffer;
  36151. this.bufferLength = bufferLength;
  36152. this.iv = iv;
  36153. if (result.length === 0) {
  36154. return new Uint8Array([]);
  36155. }
  36156. var outputLength = 16 * result.length;
  36157. var output = new Uint8Array(outputLength);
  36158. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36159. output.set(result[i], j);
  36160. }
  36161. return output;
  36162. }
  36163. };
  36164. return AES256Cipher;
  36165. }();
  36166. var PDF17 = function PDF17Closure() {
  36167. function compareByteArrays(array1, array2) {
  36168. if (array1.length !== array2.length) {
  36169. return false;
  36170. }
  36171. for (var i = 0; i < array1.length; i++) {
  36172. if (array1[i] !== array2[i]) {
  36173. return false;
  36174. }
  36175. }
  36176. return true;
  36177. }
  36178. function PDF17() {
  36179. }
  36180. PDF17.prototype = {
  36181. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36182. var hashData = new Uint8Array(password.length + 56);
  36183. hashData.set(password, 0);
  36184. hashData.set(ownerValidationSalt, password.length);
  36185. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36186. var result = calculateSHA256(hashData, 0, hashData.length);
  36187. return compareByteArrays(result, ownerPassword);
  36188. },
  36189. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36190. var hashData = new Uint8Array(password.length + 8);
  36191. hashData.set(password, 0);
  36192. hashData.set(userValidationSalt, password.length);
  36193. var result = calculateSHA256(hashData, 0, hashData.length);
  36194. return compareByteArrays(result, userPassword);
  36195. },
  36196. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36197. var hashData = new Uint8Array(password.length + 56);
  36198. hashData.set(password, 0);
  36199. hashData.set(ownerKeySalt, password.length);
  36200. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36201. var key = calculateSHA256(hashData, 0, hashData.length);
  36202. var cipher = new AES256Cipher(key);
  36203. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36204. },
  36205. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36206. var hashData = new Uint8Array(password.length + 8);
  36207. hashData.set(password, 0);
  36208. hashData.set(userKeySalt, password.length);
  36209. var key = calculateSHA256(hashData, 0, hashData.length);
  36210. var cipher = new AES256Cipher(key);
  36211. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36212. }
  36213. };
  36214. return PDF17;
  36215. }();
  36216. var PDF20 = function PDF20Closure() {
  36217. function concatArrays(array1, array2) {
  36218. var t = new Uint8Array(array1.length + array2.length);
  36219. t.set(array1, 0);
  36220. t.set(array2, array1.length);
  36221. return t;
  36222. }
  36223. function calculatePDF20Hash(password, input, userBytes) {
  36224. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36225. var e = [0];
  36226. var i = 0;
  36227. while (i < 64 || e[e.length - 1] > i - 32) {
  36228. var arrayLength = password.length + k.length + userBytes.length;
  36229. var k1 = new Uint8Array(arrayLength * 64);
  36230. var array = concatArrays(password, k);
  36231. array = concatArrays(array, userBytes);
  36232. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36233. k1.set(array, pos);
  36234. }
  36235. var cipher = new AES128Cipher(k.subarray(0, 16));
  36236. e = cipher.encrypt(k1, k.subarray(16, 32));
  36237. var remainder = 0;
  36238. for (var z = 0; z < 16; z++) {
  36239. remainder *= 256 % 3;
  36240. remainder %= 3;
  36241. remainder += (e[z] >>> 0) % 3;
  36242. remainder %= 3;
  36243. }
  36244. if (remainder === 0) {
  36245. k = calculateSHA256(e, 0, e.length);
  36246. } else if (remainder === 1) {
  36247. k = calculateSHA384(e, 0, e.length);
  36248. } else if (remainder === 2) {
  36249. k = calculateSHA512(e, 0, e.length);
  36250. }
  36251. i++;
  36252. }
  36253. return k.subarray(0, 32);
  36254. }
  36255. function PDF20() {
  36256. }
  36257. function compareByteArrays(array1, array2) {
  36258. if (array1.length !== array2.length) {
  36259. return false;
  36260. }
  36261. for (var i = 0; i < array1.length; i++) {
  36262. if (array1[i] !== array2[i]) {
  36263. return false;
  36264. }
  36265. }
  36266. return true;
  36267. }
  36268. PDF20.prototype = {
  36269. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36270. return calculatePDF20Hash(password, concatBytes, userBytes);
  36271. },
  36272. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36273. var hashData = new Uint8Array(password.length + 56);
  36274. hashData.set(password, 0);
  36275. hashData.set(ownerValidationSalt, password.length);
  36276. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36277. var result = calculatePDF20Hash(password, hashData, userBytes);
  36278. return compareByteArrays(result, ownerPassword);
  36279. },
  36280. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36281. var hashData = new Uint8Array(password.length + 8);
  36282. hashData.set(password, 0);
  36283. hashData.set(userValidationSalt, password.length);
  36284. var result = calculatePDF20Hash(password, hashData, []);
  36285. return compareByteArrays(result, userPassword);
  36286. },
  36287. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36288. var hashData = new Uint8Array(password.length + 56);
  36289. hashData.set(password, 0);
  36290. hashData.set(ownerKeySalt, password.length);
  36291. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36292. var key = calculatePDF20Hash(password, hashData, userBytes);
  36293. var cipher = new AES256Cipher(key);
  36294. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36295. },
  36296. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36297. var hashData = new Uint8Array(password.length + 8);
  36298. hashData.set(password, 0);
  36299. hashData.set(userKeySalt, password.length);
  36300. var key = calculatePDF20Hash(password, hashData, []);
  36301. var cipher = new AES256Cipher(key);
  36302. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36303. }
  36304. };
  36305. return PDF20;
  36306. }();
  36307. var CipherTransform = function CipherTransformClosure() {
  36308. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36309. this.StringCipherConstructor = stringCipherConstructor;
  36310. this.StreamCipherConstructor = streamCipherConstructor;
  36311. }
  36312. CipherTransform.prototype = {
  36313. createStream: function CipherTransform_createStream(stream, length) {
  36314. var cipher = new this.StreamCipherConstructor();
  36315. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36316. return cipher.decryptBlock(data, finalize);
  36317. });
  36318. },
  36319. decryptString: function CipherTransform_decryptString(s) {
  36320. var cipher = new this.StringCipherConstructor();
  36321. var data = stringToBytes(s);
  36322. data = cipher.decryptBlock(data, true);
  36323. return bytesToString(data);
  36324. }
  36325. };
  36326. return CipherTransform;
  36327. }();
  36328. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36329. var defaultPasswordBytes = new Uint8Array([
  36330. 0x28,
  36331. 0xBF,
  36332. 0x4E,
  36333. 0x5E,
  36334. 0x4E,
  36335. 0x75,
  36336. 0x8A,
  36337. 0x41,
  36338. 0x64,
  36339. 0x00,
  36340. 0x4E,
  36341. 0x56,
  36342. 0xFF,
  36343. 0xFA,
  36344. 0x01,
  36345. 0x08,
  36346. 0x2E,
  36347. 0x2E,
  36348. 0x00,
  36349. 0xB6,
  36350. 0xD0,
  36351. 0x68,
  36352. 0x3E,
  36353. 0x80,
  36354. 0x2F,
  36355. 0x0C,
  36356. 0xA9,
  36357. 0xFE,
  36358. 0x64,
  36359. 0x53,
  36360. 0x69,
  36361. 0x7A
  36362. ]);
  36363. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36364. if (password) {
  36365. var passwordLength = Math.min(127, password.length);
  36366. password = password.subarray(0, passwordLength);
  36367. } else {
  36368. password = [];
  36369. }
  36370. var pdfAlgorithm;
  36371. if (revision === 6) {
  36372. pdfAlgorithm = new PDF20();
  36373. } else {
  36374. pdfAlgorithm = new PDF17();
  36375. }
  36376. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36377. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36378. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36379. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36380. }
  36381. return null;
  36382. }
  36383. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36384. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36385. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36386. if (password) {
  36387. n = Math.min(32, password.length);
  36388. for (; i < n; ++i) {
  36389. hashData[i] = password[i];
  36390. }
  36391. }
  36392. j = 0;
  36393. while (i < 32) {
  36394. hashData[i++] = defaultPasswordBytes[j++];
  36395. }
  36396. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36397. hashData[i++] = ownerPassword[j];
  36398. }
  36399. hashData[i++] = flags & 0xFF;
  36400. hashData[i++] = flags >> 8 & 0xFF;
  36401. hashData[i++] = flags >> 16 & 0xFF;
  36402. hashData[i++] = flags >>> 24 & 0xFF;
  36403. for (j = 0, n = fileId.length; j < n; ++j) {
  36404. hashData[i++] = fileId[j];
  36405. }
  36406. if (revision >= 4 && !encryptMetadata) {
  36407. hashData[i++] = 0xFF;
  36408. hashData[i++] = 0xFF;
  36409. hashData[i++] = 0xFF;
  36410. hashData[i++] = 0xFF;
  36411. }
  36412. var hash = calculateMD5(hashData, 0, i);
  36413. var keyLengthInBytes = keyLength >> 3;
  36414. if (revision >= 3) {
  36415. for (j = 0; j < 50; ++j) {
  36416. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36417. }
  36418. }
  36419. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36420. var cipher, checkData;
  36421. if (revision >= 3) {
  36422. for (i = 0; i < 32; ++i) {
  36423. hashData[i] = defaultPasswordBytes[i];
  36424. }
  36425. for (j = 0, n = fileId.length; j < n; ++j) {
  36426. hashData[i++] = fileId[j];
  36427. }
  36428. cipher = new ARCFourCipher(encryptionKey);
  36429. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36430. n = encryptionKey.length;
  36431. var derivedKey = new Uint8Array(n), k;
  36432. for (j = 1; j <= 19; ++j) {
  36433. for (k = 0; k < n; ++k) {
  36434. derivedKey[k] = encryptionKey[k] ^ j;
  36435. }
  36436. cipher = new ARCFourCipher(derivedKey);
  36437. checkData = cipher.encryptBlock(checkData);
  36438. }
  36439. for (j = 0, n = checkData.length; j < n; ++j) {
  36440. if (userPassword[j] !== checkData[j]) {
  36441. return null;
  36442. }
  36443. }
  36444. } else {
  36445. cipher = new ARCFourCipher(encryptionKey);
  36446. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36447. for (j = 0, n = checkData.length; j < n; ++j) {
  36448. if (userPassword[j] !== checkData[j]) {
  36449. return null;
  36450. }
  36451. }
  36452. }
  36453. return encryptionKey;
  36454. }
  36455. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36456. var hashData = new Uint8Array(32), i = 0, j, n;
  36457. n = Math.min(32, password.length);
  36458. for (; i < n; ++i) {
  36459. hashData[i] = password[i];
  36460. }
  36461. j = 0;
  36462. while (i < 32) {
  36463. hashData[i++] = defaultPasswordBytes[j++];
  36464. }
  36465. var hash = calculateMD5(hashData, 0, i);
  36466. var keyLengthInBytes = keyLength >> 3;
  36467. if (revision >= 3) {
  36468. for (j = 0; j < 50; ++j) {
  36469. hash = calculateMD5(hash, 0, hash.length);
  36470. }
  36471. }
  36472. var cipher, userPassword;
  36473. if (revision >= 3) {
  36474. userPassword = ownerPassword;
  36475. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36476. for (j = 19; j >= 0; j--) {
  36477. for (k = 0; k < keyLengthInBytes; ++k) {
  36478. derivedKey[k] = hash[k] ^ j;
  36479. }
  36480. cipher = new ARCFourCipher(derivedKey);
  36481. userPassword = cipher.encryptBlock(userPassword);
  36482. }
  36483. } else {
  36484. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36485. userPassword = cipher.encryptBlock(ownerPassword);
  36486. }
  36487. return userPassword;
  36488. }
  36489. var identityName = Name.get('Identity');
  36490. function CipherTransformFactory(dict, fileId, password) {
  36491. var filter = dict.get('Filter');
  36492. if (!isName(filter, 'Standard')) {
  36493. error('unknown encryption method');
  36494. }
  36495. this.dict = dict;
  36496. var algorithm = dict.get('V');
  36497. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36498. error('unsupported encryption algorithm');
  36499. }
  36500. this.algorithm = algorithm;
  36501. var keyLength = dict.get('Length');
  36502. if (!keyLength) {
  36503. if (algorithm <= 3) {
  36504. keyLength = 40;
  36505. } else {
  36506. var cfDict = dict.get('CF');
  36507. var streamCryptoName = dict.get('StmF');
  36508. if (isDict(cfDict) && isName(streamCryptoName)) {
  36509. cfDict.suppressEncryption = true;
  36510. var handlerDict = cfDict.get(streamCryptoName.name);
  36511. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36512. if (keyLength < 40) {
  36513. keyLength <<= 3;
  36514. }
  36515. }
  36516. }
  36517. }
  36518. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36519. error('invalid key length');
  36520. }
  36521. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36522. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36523. var flags = dict.get('P');
  36524. var revision = dict.get('R');
  36525. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36526. this.encryptMetadata = encryptMetadata;
  36527. var fileIdBytes = stringToBytes(fileId);
  36528. var passwordBytes;
  36529. if (password) {
  36530. if (revision === 6) {
  36531. try {
  36532. password = utf8StringToString(password);
  36533. } catch (ex) {
  36534. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36535. }
  36536. }
  36537. passwordBytes = stringToBytes(password);
  36538. }
  36539. var encryptionKey;
  36540. if (algorithm !== 5) {
  36541. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36542. } else {
  36543. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36544. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36545. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36546. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36547. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36548. var ownerEncryption = stringToBytes(dict.get('OE'));
  36549. var userEncryption = stringToBytes(dict.get('UE'));
  36550. var perms = stringToBytes(dict.get('Perms'));
  36551. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36552. }
  36553. if (!encryptionKey && !password) {
  36554. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36555. } else if (!encryptionKey && password) {
  36556. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36557. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36558. }
  36559. if (!encryptionKey) {
  36560. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36561. }
  36562. this.encryptionKey = encryptionKey;
  36563. if (algorithm >= 4) {
  36564. var cf = dict.get('CF');
  36565. if (isDict(cf)) {
  36566. cf.suppressEncryption = true;
  36567. }
  36568. this.cf = cf;
  36569. this.stmf = dict.get('StmF') || identityName;
  36570. this.strf = dict.get('StrF') || identityName;
  36571. this.eff = dict.get('EFF') || this.stmf;
  36572. }
  36573. }
  36574. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36575. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36576. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36577. key[i] = encryptionKey[i];
  36578. }
  36579. key[i++] = num & 0xFF;
  36580. key[i++] = num >> 8 & 0xFF;
  36581. key[i++] = num >> 16 & 0xFF;
  36582. key[i++] = gen & 0xFF;
  36583. key[i++] = gen >> 8 & 0xFF;
  36584. if (isAes) {
  36585. key[i++] = 0x73;
  36586. key[i++] = 0x41;
  36587. key[i++] = 0x6C;
  36588. key[i++] = 0x54;
  36589. }
  36590. var hash = calculateMD5(key, 0, i);
  36591. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36592. }
  36593. function buildCipherConstructor(cf, name, num, gen, key) {
  36594. assert(isName(name), 'Invalid crypt filter name.');
  36595. var cryptFilter = cf.get(name.name);
  36596. var cfm;
  36597. if (cryptFilter !== null && cryptFilter !== undefined) {
  36598. cfm = cryptFilter.get('CFM');
  36599. }
  36600. if (!cfm || cfm.name === 'None') {
  36601. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36602. return new NullCipher();
  36603. };
  36604. }
  36605. if (cfm.name === 'V2') {
  36606. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36607. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36608. };
  36609. }
  36610. if (cfm.name === 'AESV2') {
  36611. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36612. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36613. };
  36614. }
  36615. if (cfm.name === 'AESV3') {
  36616. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36617. return new AES256Cipher(key);
  36618. };
  36619. }
  36620. error('Unknown crypto method');
  36621. }
  36622. CipherTransformFactory.prototype = {
  36623. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36624. if (this.algorithm === 4 || this.algorithm === 5) {
  36625. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36626. }
  36627. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36628. var cipherConstructor = function buildCipherCipherConstructor() {
  36629. return new ARCFourCipher(key);
  36630. };
  36631. return new CipherTransform(cipherConstructor, cipherConstructor);
  36632. }
  36633. };
  36634. return CipherTransformFactory;
  36635. }();
  36636. exports.AES128Cipher = AES128Cipher;
  36637. exports.AES256Cipher = AES256Cipher;
  36638. exports.ARCFourCipher = ARCFourCipher;
  36639. exports.CipherTransformFactory = CipherTransformFactory;
  36640. exports.PDF17 = PDF17;
  36641. exports.PDF20 = PDF20;
  36642. exports.calculateMD5 = calculateMD5;
  36643. exports.calculateSHA256 = calculateSHA256;
  36644. exports.calculateSHA384 = calculateSHA384;
  36645. exports.calculateSHA512 = calculateSHA512;
  36646. }));
  36647. (function (root, factory) {
  36648. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36649. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36650. var Util = sharedUtil.Util;
  36651. var bytesToString = sharedUtil.bytesToString;
  36652. var error = sharedUtil.error;
  36653. var Stream = coreStream.Stream;
  36654. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36655. var StandardEncoding = coreEncodings.StandardEncoding;
  36656. var CFFParser = coreCFFParser.CFFParser;
  36657. var FontRendererFactory = function FontRendererFactoryClosure() {
  36658. function getLong(data, offset) {
  36659. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36660. }
  36661. function getUshort(data, offset) {
  36662. return data[offset] << 8 | data[offset + 1];
  36663. }
  36664. function parseCmap(data, start, end) {
  36665. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36666. var format = getUshort(data, start + offset);
  36667. var ranges, p, i;
  36668. if (format === 4) {
  36669. getUshort(data, start + offset + 2);
  36670. var segCount = getUshort(data, start + offset + 6) >> 1;
  36671. p = start + offset + 14;
  36672. ranges = [];
  36673. for (i = 0; i < segCount; i++, p += 2) {
  36674. ranges[i] = { end: getUshort(data, p) };
  36675. }
  36676. p += 2;
  36677. for (i = 0; i < segCount; i++, p += 2) {
  36678. ranges[i].start = getUshort(data, p);
  36679. }
  36680. for (i = 0; i < segCount; i++, p += 2) {
  36681. ranges[i].idDelta = getUshort(data, p);
  36682. }
  36683. for (i = 0; i < segCount; i++, p += 2) {
  36684. var idOffset = getUshort(data, p);
  36685. if (idOffset === 0) {
  36686. continue;
  36687. }
  36688. ranges[i].ids = [];
  36689. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36690. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36691. idOffset += 2;
  36692. }
  36693. }
  36694. return ranges;
  36695. } else if (format === 12) {
  36696. getLong(data, start + offset + 4);
  36697. var groups = getLong(data, start + offset + 12);
  36698. p = start + offset + 16;
  36699. ranges = [];
  36700. for (i = 0; i < groups; i++) {
  36701. ranges.push({
  36702. start: getLong(data, p),
  36703. end: getLong(data, p + 4),
  36704. idDelta: getLong(data, p + 8) - getLong(data, p)
  36705. });
  36706. p += 12;
  36707. }
  36708. return ranges;
  36709. }
  36710. error('not supported cmap: ' + format);
  36711. }
  36712. function parseCff(data, start, end, seacAnalysisEnabled) {
  36713. var properties = {};
  36714. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36715. var cff = parser.parse();
  36716. return {
  36717. glyphs: cff.charStrings.objects,
  36718. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36719. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36720. };
  36721. }
  36722. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36723. var itemSize, itemDecode;
  36724. if (isGlyphLocationsLong) {
  36725. itemSize = 4;
  36726. itemDecode = function fontItemDecodeLong(data, offset) {
  36727. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36728. };
  36729. } else {
  36730. itemSize = 2;
  36731. itemDecode = function fontItemDecode(data, offset) {
  36732. return data[offset] << 9 | data[offset + 1] << 1;
  36733. };
  36734. }
  36735. var glyphs = [];
  36736. var startOffset = itemDecode(loca, 0);
  36737. for (var j = itemSize; j < loca.length; j += itemSize) {
  36738. var endOffset = itemDecode(loca, j);
  36739. glyphs.push(glyf.subarray(startOffset, endOffset));
  36740. startOffset = endOffset;
  36741. }
  36742. return glyphs;
  36743. }
  36744. function lookupCmap(ranges, unicode) {
  36745. var code = unicode.charCodeAt(0), gid = 0;
  36746. var l = 0, r = ranges.length - 1;
  36747. while (l < r) {
  36748. var c = l + r + 1 >> 1;
  36749. if (code < ranges[c].start) {
  36750. r = c - 1;
  36751. } else {
  36752. l = c;
  36753. }
  36754. }
  36755. if (ranges[l].start <= code && code <= ranges[l].end) {
  36756. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36757. }
  36758. return {
  36759. charCode: code,
  36760. glyphId: gid
  36761. };
  36762. }
  36763. function compileGlyf(code, cmds, font) {
  36764. function moveTo(x, y) {
  36765. cmds.push({
  36766. cmd: 'moveTo',
  36767. args: [
  36768. x,
  36769. y
  36770. ]
  36771. });
  36772. }
  36773. function lineTo(x, y) {
  36774. cmds.push({
  36775. cmd: 'lineTo',
  36776. args: [
  36777. x,
  36778. y
  36779. ]
  36780. });
  36781. }
  36782. function quadraticCurveTo(xa, ya, x, y) {
  36783. cmds.push({
  36784. cmd: 'quadraticCurveTo',
  36785. args: [
  36786. xa,
  36787. ya,
  36788. x,
  36789. y
  36790. ]
  36791. });
  36792. }
  36793. var i = 0;
  36794. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36795. var flags;
  36796. var x = 0, y = 0;
  36797. i += 10;
  36798. if (numberOfContours < 0) {
  36799. do {
  36800. flags = code[i] << 8 | code[i + 1];
  36801. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36802. i += 4;
  36803. var arg1, arg2;
  36804. if (flags & 0x01) {
  36805. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36806. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36807. i += 4;
  36808. } else {
  36809. arg1 = code[i++];
  36810. arg2 = code[i++];
  36811. }
  36812. if (flags & 0x02) {
  36813. x = arg1;
  36814. y = arg2;
  36815. } else {
  36816. x = 0;
  36817. y = 0;
  36818. }
  36819. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36820. if (flags & 0x08) {
  36821. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36822. i += 2;
  36823. } else if (flags & 0x40) {
  36824. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36825. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36826. i += 4;
  36827. } else if (flags & 0x80) {
  36828. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36829. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36830. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36831. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36832. i += 8;
  36833. }
  36834. var subglyph = font.glyphs[glyphIndex];
  36835. if (subglyph) {
  36836. cmds.push({ cmd: 'save' });
  36837. cmds.push({
  36838. cmd: 'transform',
  36839. args: [
  36840. scaleX,
  36841. scale01,
  36842. scale10,
  36843. scaleY,
  36844. x,
  36845. y
  36846. ]
  36847. });
  36848. compileGlyf(subglyph, cmds, font);
  36849. cmds.push({ cmd: 'restore' });
  36850. }
  36851. } while (flags & 0x20);
  36852. } else {
  36853. var endPtsOfContours = [];
  36854. var j, jj;
  36855. for (j = 0; j < numberOfContours; j++) {
  36856. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36857. i += 2;
  36858. }
  36859. var instructionLength = code[i] << 8 | code[i + 1];
  36860. i += 2 + instructionLength;
  36861. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36862. var points = [];
  36863. while (points.length < numberOfPoints) {
  36864. flags = code[i++];
  36865. var repeat = 1;
  36866. if (flags & 0x08) {
  36867. repeat += code[i++];
  36868. }
  36869. while (repeat-- > 0) {
  36870. points.push({ flags: flags });
  36871. }
  36872. }
  36873. for (j = 0; j < numberOfPoints; j++) {
  36874. switch (points[j].flags & 0x12) {
  36875. case 0x00:
  36876. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36877. i += 2;
  36878. break;
  36879. case 0x02:
  36880. x -= code[i++];
  36881. break;
  36882. case 0x12:
  36883. x += code[i++];
  36884. break;
  36885. }
  36886. points[j].x = x;
  36887. }
  36888. for (j = 0; j < numberOfPoints; j++) {
  36889. switch (points[j].flags & 0x24) {
  36890. case 0x00:
  36891. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36892. i += 2;
  36893. break;
  36894. case 0x04:
  36895. y -= code[i++];
  36896. break;
  36897. case 0x24:
  36898. y += code[i++];
  36899. break;
  36900. }
  36901. points[j].y = y;
  36902. }
  36903. var startPoint = 0;
  36904. for (i = 0; i < numberOfContours; i++) {
  36905. var endPoint = endPtsOfContours[i];
  36906. var contour = points.slice(startPoint, endPoint + 1);
  36907. if (contour[0].flags & 1) {
  36908. contour.push(contour[0]);
  36909. } else if (contour[contour.length - 1].flags & 1) {
  36910. contour.unshift(contour[contour.length - 1]);
  36911. } else {
  36912. var p = {
  36913. flags: 1,
  36914. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36915. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36916. };
  36917. contour.unshift(p);
  36918. contour.push(p);
  36919. }
  36920. moveTo(contour[0].x, contour[0].y);
  36921. for (j = 1, jj = contour.length; j < jj; j++) {
  36922. if (contour[j].flags & 1) {
  36923. lineTo(contour[j].x, contour[j].y);
  36924. } else if (contour[j + 1].flags & 1) {
  36925. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36926. j++;
  36927. } else {
  36928. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36929. }
  36930. }
  36931. startPoint = endPoint + 1;
  36932. }
  36933. }
  36934. }
  36935. function compileCharString(code, cmds, font) {
  36936. var stack = [];
  36937. var x = 0, y = 0;
  36938. var stems = 0;
  36939. function moveTo(x, y) {
  36940. cmds.push({
  36941. cmd: 'moveTo',
  36942. args: [
  36943. x,
  36944. y
  36945. ]
  36946. });
  36947. }
  36948. function lineTo(x, y) {
  36949. cmds.push({
  36950. cmd: 'lineTo',
  36951. args: [
  36952. x,
  36953. y
  36954. ]
  36955. });
  36956. }
  36957. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36958. cmds.push({
  36959. cmd: 'bezierCurveTo',
  36960. args: [
  36961. x1,
  36962. y1,
  36963. x2,
  36964. y2,
  36965. x,
  36966. y
  36967. ]
  36968. });
  36969. }
  36970. function parse(code) {
  36971. var i = 0;
  36972. while (i < code.length) {
  36973. var stackClean = false;
  36974. var v = code[i++];
  36975. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  36976. switch (v) {
  36977. case 1:
  36978. stems += stack.length >> 1;
  36979. stackClean = true;
  36980. break;
  36981. case 3:
  36982. stems += stack.length >> 1;
  36983. stackClean = true;
  36984. break;
  36985. case 4:
  36986. y += stack.pop();
  36987. moveTo(x, y);
  36988. stackClean = true;
  36989. break;
  36990. case 5:
  36991. while (stack.length > 0) {
  36992. x += stack.shift();
  36993. y += stack.shift();
  36994. lineTo(x, y);
  36995. }
  36996. break;
  36997. case 6:
  36998. while (stack.length > 0) {
  36999. x += stack.shift();
  37000. lineTo(x, y);
  37001. if (stack.length === 0) {
  37002. break;
  37003. }
  37004. y += stack.shift();
  37005. lineTo(x, y);
  37006. }
  37007. break;
  37008. case 7:
  37009. while (stack.length > 0) {
  37010. y += stack.shift();
  37011. lineTo(x, y);
  37012. if (stack.length === 0) {
  37013. break;
  37014. }
  37015. x += stack.shift();
  37016. lineTo(x, y);
  37017. }
  37018. break;
  37019. case 8:
  37020. while (stack.length > 0) {
  37021. xa = x + stack.shift();
  37022. ya = y + stack.shift();
  37023. xb = xa + stack.shift();
  37024. yb = ya + stack.shift();
  37025. x = xb + stack.shift();
  37026. y = yb + stack.shift();
  37027. bezierCurveTo(xa, ya, xb, yb, x, y);
  37028. }
  37029. break;
  37030. case 10:
  37031. n = stack.pop() + font.subrsBias;
  37032. subrCode = font.subrs[n];
  37033. if (subrCode) {
  37034. parse(subrCode);
  37035. }
  37036. break;
  37037. case 11:
  37038. return;
  37039. case 12:
  37040. v = code[i++];
  37041. switch (v) {
  37042. case 34:
  37043. xa = x + stack.shift();
  37044. xb = xa + stack.shift();
  37045. y1 = y + stack.shift();
  37046. x = xb + stack.shift();
  37047. bezierCurveTo(xa, y, xb, y1, x, y1);
  37048. xa = x + stack.shift();
  37049. xb = xa + stack.shift();
  37050. x = xb + stack.shift();
  37051. bezierCurveTo(xa, y1, xb, y, x, y);
  37052. break;
  37053. case 35:
  37054. xa = x + stack.shift();
  37055. ya = y + stack.shift();
  37056. xb = xa + stack.shift();
  37057. yb = ya + stack.shift();
  37058. x = xb + stack.shift();
  37059. y = yb + stack.shift();
  37060. bezierCurveTo(xa, ya, xb, yb, x, y);
  37061. xa = x + stack.shift();
  37062. ya = y + stack.shift();
  37063. xb = xa + stack.shift();
  37064. yb = ya + stack.shift();
  37065. x = xb + stack.shift();
  37066. y = yb + stack.shift();
  37067. bezierCurveTo(xa, ya, xb, yb, x, y);
  37068. stack.pop();
  37069. break;
  37070. case 36:
  37071. xa = x + stack.shift();
  37072. y1 = y + stack.shift();
  37073. xb = xa + stack.shift();
  37074. y2 = y1 + stack.shift();
  37075. x = xb + stack.shift();
  37076. bezierCurveTo(xa, y1, xb, y2, x, y2);
  37077. xa = x + stack.shift();
  37078. xb = xa + stack.shift();
  37079. y3 = y2 + stack.shift();
  37080. x = xb + stack.shift();
  37081. bezierCurveTo(xa, y2, xb, y3, x, y);
  37082. break;
  37083. case 37:
  37084. var x0 = x, y0 = y;
  37085. xa = x + stack.shift();
  37086. ya = y + stack.shift();
  37087. xb = xa + stack.shift();
  37088. yb = ya + stack.shift();
  37089. x = xb + stack.shift();
  37090. y = yb + stack.shift();
  37091. bezierCurveTo(xa, ya, xb, yb, x, y);
  37092. xa = x + stack.shift();
  37093. ya = y + stack.shift();
  37094. xb = xa + stack.shift();
  37095. yb = ya + stack.shift();
  37096. x = xb;
  37097. y = yb;
  37098. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  37099. x += stack.shift();
  37100. } else {
  37101. y += stack.shift();
  37102. }
  37103. bezierCurveTo(xa, ya, xb, yb, x, y);
  37104. break;
  37105. default:
  37106. error('unknown operator: 12 ' + v);
  37107. }
  37108. break;
  37109. case 14:
  37110. if (stack.length >= 4) {
  37111. var achar = stack.pop();
  37112. var bchar = stack.pop();
  37113. y = stack.pop();
  37114. x = stack.pop();
  37115. cmds.push({ cmd: 'save' });
  37116. cmds.push({
  37117. cmd: 'translate',
  37118. args: [
  37119. x,
  37120. y
  37121. ]
  37122. });
  37123. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  37124. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  37125. cmds.push({ cmd: 'restore' });
  37126. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  37127. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  37128. }
  37129. return;
  37130. case 18:
  37131. stems += stack.length >> 1;
  37132. stackClean = true;
  37133. break;
  37134. case 19:
  37135. stems += stack.length >> 1;
  37136. i += stems + 7 >> 3;
  37137. stackClean = true;
  37138. break;
  37139. case 20:
  37140. stems += stack.length >> 1;
  37141. i += stems + 7 >> 3;
  37142. stackClean = true;
  37143. break;
  37144. case 21:
  37145. y += stack.pop();
  37146. x += stack.pop();
  37147. moveTo(x, y);
  37148. stackClean = true;
  37149. break;
  37150. case 22:
  37151. x += stack.pop();
  37152. moveTo(x, y);
  37153. stackClean = true;
  37154. break;
  37155. case 23:
  37156. stems += stack.length >> 1;
  37157. stackClean = true;
  37158. break;
  37159. case 24:
  37160. while (stack.length > 2) {
  37161. xa = x + stack.shift();
  37162. ya = y + stack.shift();
  37163. xb = xa + stack.shift();
  37164. yb = ya + stack.shift();
  37165. x = xb + stack.shift();
  37166. y = yb + stack.shift();
  37167. bezierCurveTo(xa, ya, xb, yb, x, y);
  37168. }
  37169. x += stack.shift();
  37170. y += stack.shift();
  37171. lineTo(x, y);
  37172. break;
  37173. case 25:
  37174. while (stack.length > 6) {
  37175. x += stack.shift();
  37176. y += stack.shift();
  37177. lineTo(x, y);
  37178. }
  37179. xa = x + stack.shift();
  37180. ya = y + stack.shift();
  37181. xb = xa + stack.shift();
  37182. yb = ya + stack.shift();
  37183. x = xb + stack.shift();
  37184. y = yb + stack.shift();
  37185. bezierCurveTo(xa, ya, xb, yb, x, y);
  37186. break;
  37187. case 26:
  37188. if (stack.length % 2) {
  37189. x += stack.shift();
  37190. }
  37191. while (stack.length > 0) {
  37192. xa = x;
  37193. ya = y + stack.shift();
  37194. xb = xa + stack.shift();
  37195. yb = ya + stack.shift();
  37196. x = xb;
  37197. y = yb + stack.shift();
  37198. bezierCurveTo(xa, ya, xb, yb, x, y);
  37199. }
  37200. break;
  37201. case 27:
  37202. if (stack.length % 2) {
  37203. y += stack.shift();
  37204. }
  37205. while (stack.length > 0) {
  37206. xa = x + stack.shift();
  37207. ya = y;
  37208. xb = xa + stack.shift();
  37209. yb = ya + stack.shift();
  37210. x = xb + stack.shift();
  37211. y = yb;
  37212. bezierCurveTo(xa, ya, xb, yb, x, y);
  37213. }
  37214. break;
  37215. case 28:
  37216. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37217. i += 2;
  37218. break;
  37219. case 29:
  37220. n = stack.pop() + font.gsubrsBias;
  37221. subrCode = font.gsubrs[n];
  37222. if (subrCode) {
  37223. parse(subrCode);
  37224. }
  37225. break;
  37226. case 30:
  37227. while (stack.length > 0) {
  37228. xa = x;
  37229. ya = y + stack.shift();
  37230. xb = xa + stack.shift();
  37231. yb = ya + stack.shift();
  37232. x = xb + stack.shift();
  37233. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37234. bezierCurveTo(xa, ya, xb, yb, x, y);
  37235. if (stack.length === 0) {
  37236. break;
  37237. }
  37238. xa = x + stack.shift();
  37239. ya = y;
  37240. xb = xa + stack.shift();
  37241. yb = ya + stack.shift();
  37242. y = yb + stack.shift();
  37243. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37244. bezierCurveTo(xa, ya, xb, yb, x, y);
  37245. }
  37246. break;
  37247. case 31:
  37248. while (stack.length > 0) {
  37249. xa = x + stack.shift();
  37250. ya = y;
  37251. xb = xa + stack.shift();
  37252. yb = ya + stack.shift();
  37253. y = yb + stack.shift();
  37254. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37255. bezierCurveTo(xa, ya, xb, yb, x, y);
  37256. if (stack.length === 0) {
  37257. break;
  37258. }
  37259. xa = x;
  37260. ya = y + stack.shift();
  37261. xb = xa + stack.shift();
  37262. yb = ya + stack.shift();
  37263. x = xb + stack.shift();
  37264. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37265. bezierCurveTo(xa, ya, xb, yb, x, y);
  37266. }
  37267. break;
  37268. default:
  37269. if (v < 32) {
  37270. error('unknown operator: ' + v);
  37271. }
  37272. if (v < 247) {
  37273. stack.push(v - 139);
  37274. } else if (v < 251) {
  37275. stack.push((v - 247) * 256 + code[i++] + 108);
  37276. } else if (v < 255) {
  37277. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37278. } else {
  37279. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37280. i += 4;
  37281. }
  37282. break;
  37283. }
  37284. if (stackClean) {
  37285. stack.length = 0;
  37286. }
  37287. }
  37288. }
  37289. parse(code);
  37290. }
  37291. var noop = '';
  37292. function CompiledFont(fontMatrix) {
  37293. this.compiledGlyphs = Object.create(null);
  37294. this.compiledCharCodeToGlyphId = Object.create(null);
  37295. this.fontMatrix = fontMatrix;
  37296. }
  37297. CompiledFont.prototype = {
  37298. getPathJs: function (unicode) {
  37299. var cmap = lookupCmap(this.cmap, unicode);
  37300. var fn = this.compiledGlyphs[cmap.glyphId];
  37301. if (!fn) {
  37302. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37303. this.compiledGlyphs[cmap.glyphId] = fn;
  37304. }
  37305. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37306. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37307. }
  37308. return fn;
  37309. },
  37310. compileGlyph: function (code) {
  37311. if (!code || code.length === 0 || code[0] === 14) {
  37312. return noop;
  37313. }
  37314. var cmds = [];
  37315. cmds.push({ cmd: 'save' });
  37316. cmds.push({
  37317. cmd: 'transform',
  37318. args: this.fontMatrix.slice()
  37319. });
  37320. cmds.push({
  37321. cmd: 'scale',
  37322. args: [
  37323. 'size',
  37324. '-size'
  37325. ]
  37326. });
  37327. this.compileGlyphImpl(code, cmds);
  37328. cmds.push({ cmd: 'restore' });
  37329. return cmds;
  37330. },
  37331. compileGlyphImpl: function () {
  37332. error('Children classes should implement this.');
  37333. },
  37334. hasBuiltPath: function (unicode) {
  37335. var cmap = lookupCmap(this.cmap, unicode);
  37336. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37337. }
  37338. };
  37339. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37340. fontMatrix = fontMatrix || [
  37341. 0.000488,
  37342. 0,
  37343. 0,
  37344. 0.000488,
  37345. 0,
  37346. 0
  37347. ];
  37348. CompiledFont.call(this, fontMatrix);
  37349. this.glyphs = glyphs;
  37350. this.cmap = cmap;
  37351. }
  37352. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37353. compileGlyphImpl: function (code, cmds) {
  37354. compileGlyf(code, cmds, this);
  37355. }
  37356. });
  37357. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37358. fontMatrix = fontMatrix || [
  37359. 0.001,
  37360. 0,
  37361. 0,
  37362. 0.001,
  37363. 0,
  37364. 0
  37365. ];
  37366. CompiledFont.call(this, fontMatrix);
  37367. this.glyphs = cffInfo.glyphs;
  37368. this.gsubrs = cffInfo.gsubrs || [];
  37369. this.subrs = cffInfo.subrs || [];
  37370. this.cmap = cmap;
  37371. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37372. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37373. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37374. }
  37375. Util.inherit(Type2Compiled, CompiledFont, {
  37376. compileGlyphImpl: function (code, cmds) {
  37377. compileCharString(code, cmds, this);
  37378. }
  37379. });
  37380. return {
  37381. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37382. var data = new Uint8Array(font.data);
  37383. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37384. var numTables = getUshort(data, 4);
  37385. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37386. var tag = bytesToString(data.subarray(p, p + 4));
  37387. var offset = getLong(data, p + 8);
  37388. var length = getLong(data, p + 12);
  37389. switch (tag) {
  37390. case 'cmap':
  37391. cmap = parseCmap(data, offset, offset + length);
  37392. break;
  37393. case 'glyf':
  37394. glyf = data.subarray(offset, offset + length);
  37395. break;
  37396. case 'loca':
  37397. loca = data.subarray(offset, offset + length);
  37398. break;
  37399. case 'head':
  37400. unitsPerEm = getUshort(data, offset + 18);
  37401. indexToLocFormat = getUshort(data, offset + 50);
  37402. break;
  37403. case 'CFF ':
  37404. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37405. break;
  37406. }
  37407. }
  37408. if (glyf) {
  37409. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37410. 1 / unitsPerEm,
  37411. 0,
  37412. 0,
  37413. 1 / unitsPerEm,
  37414. 0,
  37415. 0
  37416. ];
  37417. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37418. }
  37419. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37420. }
  37421. };
  37422. }();
  37423. exports.FontRendererFactory = FontRendererFactory;
  37424. }));
  37425. (function (root, factory) {
  37426. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  37427. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  37428. var error = sharedUtil.error;
  37429. var info = sharedUtil.info;
  37430. var isArray = sharedUtil.isArray;
  37431. var isBool = sharedUtil.isBool;
  37432. var isDict = corePrimitives.isDict;
  37433. var isStream = corePrimitives.isStream;
  37434. var PostScriptLexer = corePsParser.PostScriptLexer;
  37435. var PostScriptParser = corePsParser.PostScriptParser;
  37436. var PDFFunction = function PDFFunctionClosure() {
  37437. var CONSTRUCT_SAMPLED = 0;
  37438. var CONSTRUCT_INTERPOLATED = 2;
  37439. var CONSTRUCT_STICHED = 3;
  37440. var CONSTRUCT_POSTSCRIPT = 4;
  37441. return {
  37442. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  37443. var i, ii;
  37444. var length = 1;
  37445. for (i = 0, ii = size.length; i < ii; i++) {
  37446. length *= size[i];
  37447. }
  37448. length *= outputSize;
  37449. var array = new Array(length);
  37450. var codeSize = 0;
  37451. var codeBuf = 0;
  37452. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  37453. var strBytes = str.getBytes((length * bps + 7) / 8);
  37454. var strIdx = 0;
  37455. for (i = 0; i < length; i++) {
  37456. while (codeSize < bps) {
  37457. codeBuf <<= 8;
  37458. codeBuf |= strBytes[strIdx++];
  37459. codeSize += 8;
  37460. }
  37461. codeSize -= bps;
  37462. array[i] = (codeBuf >> codeSize) * sampleMul;
  37463. codeBuf &= (1 << codeSize) - 1;
  37464. }
  37465. return array;
  37466. },
  37467. getIR: function PDFFunction_getIR(xref, fn) {
  37468. var dict = fn.dict;
  37469. if (!dict) {
  37470. dict = fn;
  37471. }
  37472. var types = [
  37473. this.constructSampled,
  37474. null,
  37475. this.constructInterpolated,
  37476. this.constructStiched,
  37477. this.constructPostScript
  37478. ];
  37479. var typeNum = dict.get('FunctionType');
  37480. var typeFn = types[typeNum];
  37481. if (!typeFn) {
  37482. error('Unknown type of function');
  37483. }
  37484. return typeFn.call(this, fn, dict, xref);
  37485. },
  37486. fromIR: function PDFFunction_fromIR(IR) {
  37487. var type = IR[0];
  37488. switch (type) {
  37489. case CONSTRUCT_SAMPLED:
  37490. return this.constructSampledFromIR(IR);
  37491. case CONSTRUCT_INTERPOLATED:
  37492. return this.constructInterpolatedFromIR(IR);
  37493. case CONSTRUCT_STICHED:
  37494. return this.constructStichedFromIR(IR);
  37495. default:
  37496. return this.constructPostScriptFromIR(IR);
  37497. }
  37498. },
  37499. parse: function PDFFunction_parse(xref, fn) {
  37500. var IR = this.getIR(xref, fn);
  37501. return this.fromIR(IR);
  37502. },
  37503. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  37504. if (!isArray(fnObj)) {
  37505. return this.parse(xref, fnObj);
  37506. }
  37507. var fnArray = [];
  37508. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  37509. var obj = xref.fetchIfRef(fnObj[j]);
  37510. fnArray.push(PDFFunction.parse(xref, obj));
  37511. }
  37512. return function (src, srcOffset, dest, destOffset) {
  37513. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  37514. fnArray[i](src, srcOffset, dest, destOffset + i);
  37515. }
  37516. };
  37517. },
  37518. constructSampled: function PDFFunction_constructSampled(str, dict) {
  37519. function toMultiArray(arr) {
  37520. var inputLength = arr.length;
  37521. var out = [];
  37522. var index = 0;
  37523. for (var i = 0; i < inputLength; i += 2) {
  37524. out[index] = [
  37525. arr[i],
  37526. arr[i + 1]
  37527. ];
  37528. ++index;
  37529. }
  37530. return out;
  37531. }
  37532. var domain = dict.getArray('Domain');
  37533. var range = dict.getArray('Range');
  37534. if (!domain || !range) {
  37535. error('No domain or range');
  37536. }
  37537. var inputSize = domain.length / 2;
  37538. var outputSize = range.length / 2;
  37539. domain = toMultiArray(domain);
  37540. range = toMultiArray(range);
  37541. var size = dict.get('Size');
  37542. var bps = dict.get('BitsPerSample');
  37543. var order = dict.get('Order') || 1;
  37544. if (order !== 1) {
  37545. info('No support for cubic spline interpolation: ' + order);
  37546. }
  37547. var encode = dict.getArray('Encode');
  37548. if (!encode) {
  37549. encode = [];
  37550. for (var i = 0; i < inputSize; ++i) {
  37551. encode.push(0);
  37552. encode.push(size[i] - 1);
  37553. }
  37554. }
  37555. encode = toMultiArray(encode);
  37556. var decode = dict.getArray('Decode');
  37557. if (!decode) {
  37558. decode = range;
  37559. } else {
  37560. decode = toMultiArray(decode);
  37561. }
  37562. var samples = this.getSampleArray(size, outputSize, bps, str);
  37563. return [
  37564. CONSTRUCT_SAMPLED,
  37565. inputSize,
  37566. domain,
  37567. encode,
  37568. decode,
  37569. samples,
  37570. size,
  37571. outputSize,
  37572. Math.pow(2, bps) - 1,
  37573. range
  37574. ];
  37575. },
  37576. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  37577. function interpolate(x, xmin, xmax, ymin, ymax) {
  37578. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  37579. }
  37580. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  37581. var m = IR[1];
  37582. var domain = IR[2];
  37583. var encode = IR[3];
  37584. var decode = IR[4];
  37585. var samples = IR[5];
  37586. var size = IR[6];
  37587. var n = IR[7];
  37588. var range = IR[9];
  37589. var cubeVertices = 1 << m;
  37590. var cubeN = new Float64Array(cubeVertices);
  37591. var cubeVertex = new Uint32Array(cubeVertices);
  37592. var i, j;
  37593. for (j = 0; j < cubeVertices; j++) {
  37594. cubeN[j] = 1;
  37595. }
  37596. var k = n, pos = 1;
  37597. for (i = 0; i < m; ++i) {
  37598. var domain_2i = domain[i][0];
  37599. var domain_2i_1 = domain[i][1];
  37600. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  37601. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  37602. var size_i = size[i];
  37603. e = Math.min(Math.max(e, 0), size_i - 1);
  37604. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  37605. var n0 = e0 + 1 - e;
  37606. var n1 = e - e0;
  37607. var offset0 = e0 * k;
  37608. var offset1 = offset0 + k;
  37609. for (j = 0; j < cubeVertices; j++) {
  37610. if (j & pos) {
  37611. cubeN[j] *= n1;
  37612. cubeVertex[j] += offset1;
  37613. } else {
  37614. cubeN[j] *= n0;
  37615. cubeVertex[j] += offset0;
  37616. }
  37617. }
  37618. k *= size_i;
  37619. pos <<= 1;
  37620. }
  37621. for (j = 0; j < n; ++j) {
  37622. var rj = 0;
  37623. for (i = 0; i < cubeVertices; i++) {
  37624. rj += samples[cubeVertex[i] + j] * cubeN[i];
  37625. }
  37626. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  37627. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  37628. }
  37629. };
  37630. },
  37631. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  37632. var c0 = dict.getArray('C0') || [0];
  37633. var c1 = dict.getArray('C1') || [1];
  37634. var n = dict.get('N');
  37635. if (!isArray(c0) || !isArray(c1)) {
  37636. error('Illegal dictionary for interpolated function');
  37637. }
  37638. var length = c0.length;
  37639. var diff = [];
  37640. for (var i = 0; i < length; ++i) {
  37641. diff.push(c1[i] - c0[i]);
  37642. }
  37643. return [
  37644. CONSTRUCT_INTERPOLATED,
  37645. c0,
  37646. diff,
  37647. n
  37648. ];
  37649. },
  37650. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  37651. var c0 = IR[1];
  37652. var diff = IR[2];
  37653. var n = IR[3];
  37654. var length = diff.length;
  37655. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  37656. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  37657. for (var j = 0; j < length; ++j) {
  37658. dest[destOffset + j] = c0[j] + x * diff[j];
  37659. }
  37660. };
  37661. },
  37662. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  37663. var domain = dict.getArray('Domain');
  37664. if (!domain) {
  37665. error('No domain');
  37666. }
  37667. var inputSize = domain.length / 2;
  37668. if (inputSize !== 1) {
  37669. error('Bad domain for stiched function');
  37670. }
  37671. var fnRefs = dict.get('Functions');
  37672. var fns = [];
  37673. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  37674. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  37675. }
  37676. var bounds = dict.getArray('Bounds');
  37677. var encode = dict.getArray('Encode');
  37678. return [
  37679. CONSTRUCT_STICHED,
  37680. domain,
  37681. bounds,
  37682. encode,
  37683. fns
  37684. ];
  37685. },
  37686. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  37687. var domain = IR[1];
  37688. var bounds = IR[2];
  37689. var encode = IR[3];
  37690. var fnsIR = IR[4];
  37691. var fns = [];
  37692. var tmpBuf = new Float32Array(1);
  37693. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  37694. fns.push(PDFFunction.fromIR(fnsIR[i]));
  37695. }
  37696. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  37697. var clip = function constructStichedFromIRClip(v, min, max) {
  37698. if (v > max) {
  37699. v = max;
  37700. } else if (v < min) {
  37701. v = min;
  37702. }
  37703. return v;
  37704. };
  37705. var v = clip(src[srcOffset], domain[0], domain[1]);
  37706. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  37707. if (v < bounds[i]) {
  37708. break;
  37709. }
  37710. }
  37711. var dmin = domain[0];
  37712. if (i > 0) {
  37713. dmin = bounds[i - 1];
  37714. }
  37715. var dmax = domain[1];
  37716. if (i < bounds.length) {
  37717. dmax = bounds[i];
  37718. }
  37719. var rmin = encode[2 * i];
  37720. var rmax = encode[2 * i + 1];
  37721. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  37722. fns[i](tmpBuf, 0, dest, destOffset);
  37723. };
  37724. },
  37725. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  37726. var domain = dict.getArray('Domain');
  37727. var range = dict.getArray('Range');
  37728. if (!domain) {
  37729. error('No domain.');
  37730. }
  37731. if (!range) {
  37732. error('No range.');
  37733. }
  37734. var lexer = new PostScriptLexer(fn);
  37735. var parser = new PostScriptParser(lexer);
  37736. var code = parser.parse();
  37737. return [
  37738. CONSTRUCT_POSTSCRIPT,
  37739. domain,
  37740. range,
  37741. code
  37742. ];
  37743. },
  37744. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  37745. var domain = IR[1];
  37746. var range = IR[2];
  37747. var code = IR[3];
  37748. var compiled = new PostScriptCompiler().compile(code, domain, range);
  37749. if (compiled) {
  37750. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  37751. }
  37752. info('Unable to compile PS function');
  37753. var numOutputs = range.length >> 1;
  37754. var numInputs = domain.length >> 1;
  37755. var evaluator = new PostScriptEvaluator(code);
  37756. var cache = Object.create(null);
  37757. var MAX_CACHE_SIZE = 2048 * 4;
  37758. var cache_available = MAX_CACHE_SIZE;
  37759. var tmpBuf = new Float32Array(numInputs);
  37760. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  37761. var i, value;
  37762. var key = '';
  37763. var input = tmpBuf;
  37764. for (i = 0; i < numInputs; i++) {
  37765. value = src[srcOffset + i];
  37766. input[i] = value;
  37767. key += value + '_';
  37768. }
  37769. var cachedValue = cache[key];
  37770. if (cachedValue !== undefined) {
  37771. dest.set(cachedValue, destOffset);
  37772. return;
  37773. }
  37774. var output = new Float32Array(numOutputs);
  37775. var stack = evaluator.execute(input);
  37776. var stackIndex = stack.length - numOutputs;
  37777. for (i = 0; i < numOutputs; i++) {
  37778. value = stack[stackIndex + i];
  37779. var bound = range[i * 2];
  37780. if (value < bound) {
  37781. value = bound;
  37782. } else {
  37783. bound = range[i * 2 + 1];
  37784. if (value > bound) {
  37785. value = bound;
  37786. }
  37787. }
  37788. output[i] = value;
  37789. }
  37790. if (cache_available > 0) {
  37791. cache_available--;
  37792. cache[key] = output;
  37793. }
  37794. dest.set(output, destOffset);
  37795. };
  37796. }
  37797. };
  37798. }();
  37799. function isPDFFunction(v) {
  37800. var fnDict;
  37801. if (typeof v !== 'object') {
  37802. return false;
  37803. } else if (isDict(v)) {
  37804. fnDict = v;
  37805. } else if (isStream(v)) {
  37806. fnDict = v.dict;
  37807. } else {
  37808. return false;
  37809. }
  37810. return fnDict.has('FunctionType');
  37811. }
  37812. var PostScriptStack = function PostScriptStackClosure() {
  37813. var MAX_STACK_SIZE = 100;
  37814. function PostScriptStack(initialStack) {
  37815. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  37816. }
  37817. PostScriptStack.prototype = {
  37818. push: function PostScriptStack_push(value) {
  37819. if (this.stack.length >= MAX_STACK_SIZE) {
  37820. error('PostScript function stack overflow.');
  37821. }
  37822. this.stack.push(value);
  37823. },
  37824. pop: function PostScriptStack_pop() {
  37825. if (this.stack.length <= 0) {
  37826. error('PostScript function stack underflow.');
  37827. }
  37828. return this.stack.pop();
  37829. },
  37830. copy: function PostScriptStack_copy(n) {
  37831. if (this.stack.length + n >= MAX_STACK_SIZE) {
  37832. error('PostScript function stack overflow.');
  37833. }
  37834. var stack = this.stack;
  37835. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  37836. stack.push(stack[i]);
  37837. }
  37838. },
  37839. index: function PostScriptStack_index(n) {
  37840. this.push(this.stack[this.stack.length - n - 1]);
  37841. },
  37842. roll: function PostScriptStack_roll(n, p) {
  37843. var stack = this.stack;
  37844. var l = stack.length - n;
  37845. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  37846. for (i = l, j = r; i < j; i++, j--) {
  37847. t = stack[i];
  37848. stack[i] = stack[j];
  37849. stack[j] = t;
  37850. }
  37851. for (i = l, j = c - 1; i < j; i++, j--) {
  37852. t = stack[i];
  37853. stack[i] = stack[j];
  37854. stack[j] = t;
  37855. }
  37856. for (i = c, j = r; i < j; i++, j--) {
  37857. t = stack[i];
  37858. stack[i] = stack[j];
  37859. stack[j] = t;
  37860. }
  37861. }
  37862. };
  37863. return PostScriptStack;
  37864. }();
  37865. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  37866. function PostScriptEvaluator(operators) {
  37867. this.operators = operators;
  37868. }
  37869. PostScriptEvaluator.prototype = {
  37870. execute: function PostScriptEvaluator_execute(initialStack) {
  37871. var stack = new PostScriptStack(initialStack);
  37872. var counter = 0;
  37873. var operators = this.operators;
  37874. var length = operators.length;
  37875. var operator, a, b;
  37876. while (counter < length) {
  37877. operator = operators[counter++];
  37878. if (typeof operator === 'number') {
  37879. stack.push(operator);
  37880. continue;
  37881. }
  37882. switch (operator) {
  37883. case 'jz':
  37884. b = stack.pop();
  37885. a = stack.pop();
  37886. if (!a) {
  37887. counter = b;
  37888. }
  37889. break;
  37890. case 'j':
  37891. a = stack.pop();
  37892. counter = a;
  37893. break;
  37894. case 'abs':
  37895. a = stack.pop();
  37896. stack.push(Math.abs(a));
  37897. break;
  37898. case 'add':
  37899. b = stack.pop();
  37900. a = stack.pop();
  37901. stack.push(a + b);
  37902. break;
  37903. case 'and':
  37904. b = stack.pop();
  37905. a = stack.pop();
  37906. if (isBool(a) && isBool(b)) {
  37907. stack.push(a && b);
  37908. } else {
  37909. stack.push(a & b);
  37910. }
  37911. break;
  37912. case 'atan':
  37913. a = stack.pop();
  37914. stack.push(Math.atan(a));
  37915. break;
  37916. case 'bitshift':
  37917. b = stack.pop();
  37918. a = stack.pop();
  37919. if (a > 0) {
  37920. stack.push(a << b);
  37921. } else {
  37922. stack.push(a >> b);
  37923. }
  37924. break;
  37925. case 'ceiling':
  37926. a = stack.pop();
  37927. stack.push(Math.ceil(a));
  37928. break;
  37929. case 'copy':
  37930. a = stack.pop();
  37931. stack.copy(a);
  37932. break;
  37933. case 'cos':
  37934. a = stack.pop();
  37935. stack.push(Math.cos(a));
  37936. break;
  37937. case 'cvi':
  37938. a = stack.pop() | 0;
  37939. stack.push(a);
  37940. break;
  37941. case 'cvr':
  37942. break;
  37943. case 'div':
  37944. b = stack.pop();
  37945. a = stack.pop();
  37946. stack.push(a / b);
  37947. break;
  37948. case 'dup':
  37949. stack.copy(1);
  37950. break;
  37951. case 'eq':
  37952. b = stack.pop();
  37953. a = stack.pop();
  37954. stack.push(a === b);
  37955. break;
  37956. case 'exch':
  37957. stack.roll(2, 1);
  37958. break;
  37959. case 'exp':
  37960. b = stack.pop();
  37961. a = stack.pop();
  37962. stack.push(Math.pow(a, b));
  37963. break;
  37964. case 'false':
  37965. stack.push(false);
  37966. break;
  37967. case 'floor':
  37968. a = stack.pop();
  37969. stack.push(Math.floor(a));
  37970. break;
  37971. case 'ge':
  37972. b = stack.pop();
  37973. a = stack.pop();
  37974. stack.push(a >= b);
  37975. break;
  37976. case 'gt':
  37977. b = stack.pop();
  37978. a = stack.pop();
  37979. stack.push(a > b);
  37980. break;
  37981. case 'idiv':
  37982. b = stack.pop();
  37983. a = stack.pop();
  37984. stack.push(a / b | 0);
  37985. break;
  37986. case 'index':
  37987. a = stack.pop();
  37988. stack.index(a);
  37989. break;
  37990. case 'le':
  37991. b = stack.pop();
  37992. a = stack.pop();
  37993. stack.push(a <= b);
  37994. break;
  37995. case 'ln':
  37996. a = stack.pop();
  37997. stack.push(Math.log(a));
  37998. break;
  37999. case 'log':
  38000. a = stack.pop();
  38001. stack.push(Math.log(a) / Math.LN10);
  38002. break;
  38003. case 'lt':
  38004. b = stack.pop();
  38005. a = stack.pop();
  38006. stack.push(a < b);
  38007. break;
  38008. case 'mod':
  38009. b = stack.pop();
  38010. a = stack.pop();
  38011. stack.push(a % b);
  38012. break;
  38013. case 'mul':
  38014. b = stack.pop();
  38015. a = stack.pop();
  38016. stack.push(a * b);
  38017. break;
  38018. case 'ne':
  38019. b = stack.pop();
  38020. a = stack.pop();
  38021. stack.push(a !== b);
  38022. break;
  38023. case 'neg':
  38024. a = stack.pop();
  38025. stack.push(-a);
  38026. break;
  38027. case 'not':
  38028. a = stack.pop();
  38029. if (isBool(a)) {
  38030. stack.push(!a);
  38031. } else {
  38032. stack.push(~a);
  38033. }
  38034. break;
  38035. case 'or':
  38036. b = stack.pop();
  38037. a = stack.pop();
  38038. if (isBool(a) && isBool(b)) {
  38039. stack.push(a || b);
  38040. } else {
  38041. stack.push(a | b);
  38042. }
  38043. break;
  38044. case 'pop':
  38045. stack.pop();
  38046. break;
  38047. case 'roll':
  38048. b = stack.pop();
  38049. a = stack.pop();
  38050. stack.roll(a, b);
  38051. break;
  38052. case 'round':
  38053. a = stack.pop();
  38054. stack.push(Math.round(a));
  38055. break;
  38056. case 'sin':
  38057. a = stack.pop();
  38058. stack.push(Math.sin(a));
  38059. break;
  38060. case 'sqrt':
  38061. a = stack.pop();
  38062. stack.push(Math.sqrt(a));
  38063. break;
  38064. case 'sub':
  38065. b = stack.pop();
  38066. a = stack.pop();
  38067. stack.push(a - b);
  38068. break;
  38069. case 'true':
  38070. stack.push(true);
  38071. break;
  38072. case 'truncate':
  38073. a = stack.pop();
  38074. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  38075. stack.push(a);
  38076. break;
  38077. case 'xor':
  38078. b = stack.pop();
  38079. a = stack.pop();
  38080. if (isBool(a) && isBool(b)) {
  38081. stack.push(a !== b);
  38082. } else {
  38083. stack.push(a ^ b);
  38084. }
  38085. break;
  38086. default:
  38087. error('Unknown operator ' + operator);
  38088. break;
  38089. }
  38090. }
  38091. return stack.stack;
  38092. }
  38093. };
  38094. return PostScriptEvaluator;
  38095. }();
  38096. var PostScriptCompiler = function PostScriptCompilerClosure() {
  38097. function AstNode(type) {
  38098. this.type = type;
  38099. }
  38100. AstNode.prototype.visit = function (visitor) {
  38101. throw new Error('abstract method');
  38102. };
  38103. function AstArgument(index, min, max) {
  38104. AstNode.call(this, 'args');
  38105. this.index = index;
  38106. this.min = min;
  38107. this.max = max;
  38108. }
  38109. AstArgument.prototype = Object.create(AstNode.prototype);
  38110. AstArgument.prototype.visit = function (visitor) {
  38111. visitor.visitArgument(this);
  38112. };
  38113. function AstLiteral(number) {
  38114. AstNode.call(this, 'literal');
  38115. this.number = number;
  38116. this.min = number;
  38117. this.max = number;
  38118. }
  38119. AstLiteral.prototype = Object.create(AstNode.prototype);
  38120. AstLiteral.prototype.visit = function (visitor) {
  38121. visitor.visitLiteral(this);
  38122. };
  38123. function AstBinaryOperation(op, arg1, arg2, min, max) {
  38124. AstNode.call(this, 'binary');
  38125. this.op = op;
  38126. this.arg1 = arg1;
  38127. this.arg2 = arg2;
  38128. this.min = min;
  38129. this.max = max;
  38130. }
  38131. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  38132. AstBinaryOperation.prototype.visit = function (visitor) {
  38133. visitor.visitBinaryOperation(this);
  38134. };
  38135. function AstMin(arg, max) {
  38136. AstNode.call(this, 'max');
  38137. this.arg = arg;
  38138. this.min = arg.min;
  38139. this.max = max;
  38140. }
  38141. AstMin.prototype = Object.create(AstNode.prototype);
  38142. AstMin.prototype.visit = function (visitor) {
  38143. visitor.visitMin(this);
  38144. };
  38145. function AstVariable(index, min, max) {
  38146. AstNode.call(this, 'var');
  38147. this.index = index;
  38148. this.min = min;
  38149. this.max = max;
  38150. }
  38151. AstVariable.prototype = Object.create(AstNode.prototype);
  38152. AstVariable.prototype.visit = function (visitor) {
  38153. visitor.visitVariable(this);
  38154. };
  38155. function AstVariableDefinition(variable, arg) {
  38156. AstNode.call(this, 'definition');
  38157. this.variable = variable;
  38158. this.arg = arg;
  38159. }
  38160. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  38161. AstVariableDefinition.prototype.visit = function (visitor) {
  38162. visitor.visitVariableDefinition(this);
  38163. };
  38164. function ExpressionBuilderVisitor() {
  38165. this.parts = [];
  38166. }
  38167. ExpressionBuilderVisitor.prototype = {
  38168. visitArgument: function (arg) {
  38169. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  38170. },
  38171. visitVariable: function (variable) {
  38172. this.parts.push('v', variable.index);
  38173. },
  38174. visitLiteral: function (literal) {
  38175. this.parts.push(literal.number);
  38176. },
  38177. visitBinaryOperation: function (operation) {
  38178. this.parts.push('(');
  38179. operation.arg1.visit(this);
  38180. this.parts.push(' ', operation.op, ' ');
  38181. operation.arg2.visit(this);
  38182. this.parts.push(')');
  38183. },
  38184. visitVariableDefinition: function (definition) {
  38185. this.parts.push('var ');
  38186. definition.variable.visit(this);
  38187. this.parts.push(' = ');
  38188. definition.arg.visit(this);
  38189. this.parts.push(';');
  38190. },
  38191. visitMin: function (max) {
  38192. this.parts.push('Math.min(');
  38193. max.arg.visit(this);
  38194. this.parts.push(', ', max.max, ')');
  38195. },
  38196. toString: function () {
  38197. return this.parts.join('');
  38198. }
  38199. };
  38200. function buildAddOperation(num1, num2) {
  38201. if (num2.type === 'literal' && num2.number === 0) {
  38202. return num1;
  38203. }
  38204. if (num1.type === 'literal' && num1.number === 0) {
  38205. return num2;
  38206. }
  38207. if (num2.type === 'literal' && num1.type === 'literal') {
  38208. return new AstLiteral(num1.number + num2.number);
  38209. }
  38210. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  38211. }
  38212. function buildMulOperation(num1, num2) {
  38213. if (num2.type === 'literal') {
  38214. if (num2.number === 0) {
  38215. return new AstLiteral(0);
  38216. } else if (num2.number === 1) {
  38217. return num1;
  38218. } else if (num1.type === 'literal') {
  38219. return new AstLiteral(num1.number * num2.number);
  38220. }
  38221. }
  38222. if (num1.type === 'literal') {
  38223. if (num1.number === 0) {
  38224. return new AstLiteral(0);
  38225. } else if (num1.number === 1) {
  38226. return num2;
  38227. }
  38228. }
  38229. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  38230. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  38231. return new AstBinaryOperation('*', num1, num2, min, max);
  38232. }
  38233. function buildSubOperation(num1, num2) {
  38234. if (num2.type === 'literal') {
  38235. if (num2.number === 0) {
  38236. return num1;
  38237. } else if (num1.type === 'literal') {
  38238. return new AstLiteral(num1.number - num2.number);
  38239. }
  38240. }
  38241. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  38242. return num2.arg2;
  38243. }
  38244. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  38245. }
  38246. function buildMinOperation(num1, max) {
  38247. if (num1.min >= max) {
  38248. return new AstLiteral(max);
  38249. } else if (num1.max <= max) {
  38250. return num1;
  38251. }
  38252. return new AstMin(num1, max);
  38253. }
  38254. function PostScriptCompiler() {
  38255. }
  38256. PostScriptCompiler.prototype = {
  38257. compile: function PostScriptCompiler_compile(code, domain, range) {
  38258. var stack = [];
  38259. var i, ii;
  38260. var instructions = [];
  38261. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  38262. var lastRegister = 0;
  38263. var n, j;
  38264. var num1, num2, ast1, ast2, tmpVar, item;
  38265. for (i = 0; i < inputSize; i++) {
  38266. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  38267. }
  38268. for (i = 0, ii = code.length; i < ii; i++) {
  38269. item = code[i];
  38270. if (typeof item === 'number') {
  38271. stack.push(new AstLiteral(item));
  38272. continue;
  38273. }
  38274. switch (item) {
  38275. case 'add':
  38276. if (stack.length < 2) {
  38277. return null;
  38278. }
  38279. num2 = stack.pop();
  38280. num1 = stack.pop();
  38281. stack.push(buildAddOperation(num1, num2));
  38282. break;
  38283. case 'cvr':
  38284. if (stack.length < 1) {
  38285. return null;
  38286. }
  38287. break;
  38288. case 'mul':
  38289. if (stack.length < 2) {
  38290. return null;
  38291. }
  38292. num2 = stack.pop();
  38293. num1 = stack.pop();
  38294. stack.push(buildMulOperation(num1, num2));
  38295. break;
  38296. case 'sub':
  38297. if (stack.length < 2) {
  38298. return null;
  38299. }
  38300. num2 = stack.pop();
  38301. num1 = stack.pop();
  38302. stack.push(buildSubOperation(num1, num2));
  38303. break;
  38304. case 'exch':
  38305. if (stack.length < 2) {
  38306. return null;
  38307. }
  38308. ast1 = stack.pop();
  38309. ast2 = stack.pop();
  38310. stack.push(ast1, ast2);
  38311. break;
  38312. case 'pop':
  38313. if (stack.length < 1) {
  38314. return null;
  38315. }
  38316. stack.pop();
  38317. break;
  38318. case 'index':
  38319. if (stack.length < 1) {
  38320. return null;
  38321. }
  38322. num1 = stack.pop();
  38323. if (num1.type !== 'literal') {
  38324. return null;
  38325. }
  38326. n = num1.number;
  38327. if (n < 0 || (n | 0) !== n || stack.length < n) {
  38328. return null;
  38329. }
  38330. ast1 = stack[stack.length - n - 1];
  38331. if (ast1.type === 'literal' || ast1.type === 'var') {
  38332. stack.push(ast1);
  38333. break;
  38334. }
  38335. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  38336. stack[stack.length - n - 1] = tmpVar;
  38337. stack.push(tmpVar);
  38338. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  38339. break;
  38340. case 'dup':
  38341. if (stack.length < 1) {
  38342. return null;
  38343. }
  38344. if (typeof code[i + 1] === 'number' && code[i + 2] === 'gt' && code[i + 3] === i + 7 && code[i + 4] === 'jz' && code[i + 5] === 'pop' && code[i + 6] === code[i + 1]) {
  38345. num1 = stack.pop();
  38346. stack.push(buildMinOperation(num1, code[i + 1]));
  38347. i += 6;
  38348. break;
  38349. }
  38350. ast1 = stack[stack.length - 1];
  38351. if (ast1.type === 'literal' || ast1.type === 'var') {
  38352. stack.push(ast1);
  38353. break;
  38354. }
  38355. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  38356. stack[stack.length - 1] = tmpVar;
  38357. stack.push(tmpVar);
  38358. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  38359. break;
  38360. case 'roll':
  38361. if (stack.length < 2) {
  38362. return null;
  38363. }
  38364. num2 = stack.pop();
  38365. num1 = stack.pop();
  38366. if (num2.type !== 'literal' || num1.type !== 'literal') {
  38367. return null;
  38368. }
  38369. j = num2.number;
  38370. n = num1.number;
  38371. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  38372. return null;
  38373. }
  38374. j = (j % n + n) % n;
  38375. if (j === 0) {
  38376. break;
  38377. }
  38378. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  38379. break;
  38380. default:
  38381. return null;
  38382. }
  38383. }
  38384. if (stack.length !== outputSize) {
  38385. return null;
  38386. }
  38387. var result = [];
  38388. instructions.forEach(function (instruction) {
  38389. var statementBuilder = new ExpressionBuilderVisitor();
  38390. instruction.visit(statementBuilder);
  38391. result.push(statementBuilder.toString());
  38392. });
  38393. stack.forEach(function (expr, i) {
  38394. var statementBuilder = new ExpressionBuilderVisitor();
  38395. expr.visit(statementBuilder);
  38396. var min = range[i * 2], max = range[i * 2 + 1];
  38397. var out = [statementBuilder.toString()];
  38398. if (min > expr.min) {
  38399. out.unshift('Math.max(', min, ', ');
  38400. out.push(')');
  38401. }
  38402. if (max < expr.max) {
  38403. out.unshift('Math.min(', max, ', ');
  38404. out.push(')');
  38405. }
  38406. out.unshift('dest[destOffset + ', i, '] = ');
  38407. out.push(';');
  38408. result.push(out.join(''));
  38409. });
  38410. return result.join('\n');
  38411. }
  38412. };
  38413. return PostScriptCompiler;
  38414. }();
  38415. exports.isPDFFunction = isPDFFunction;
  38416. exports.PDFFunction = PDFFunction;
  38417. exports.PostScriptEvaluator = PostScriptEvaluator;
  38418. exports.PostScriptCompiler = PostScriptCompiler;
  38419. }));
  38420. (function (root, factory) {
  38421. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  38422. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  38423. var MissingDataException = sharedUtil.MissingDataException;
  38424. var StreamType = sharedUtil.StreamType;
  38425. var assert = sharedUtil.assert;
  38426. var error = sharedUtil.error;
  38427. var info = sharedUtil.info;
  38428. var isArray = sharedUtil.isArray;
  38429. var isInt = sharedUtil.isInt;
  38430. var isNum = sharedUtil.isNum;
  38431. var isString = sharedUtil.isString;
  38432. var warn = sharedUtil.warn;
  38433. var EOF = corePrimitives.EOF;
  38434. var Cmd = corePrimitives.Cmd;
  38435. var Dict = corePrimitives.Dict;
  38436. var Name = corePrimitives.Name;
  38437. var Ref = corePrimitives.Ref;
  38438. var isEOF = corePrimitives.isEOF;
  38439. var isCmd = corePrimitives.isCmd;
  38440. var isDict = corePrimitives.isDict;
  38441. var isName = corePrimitives.isName;
  38442. var Ascii85Stream = coreStream.Ascii85Stream;
  38443. var AsciiHexStream = coreStream.AsciiHexStream;
  38444. var CCITTFaxStream = coreStream.CCITTFaxStream;
  38445. var FlateStream = coreStream.FlateStream;
  38446. var Jbig2Stream = coreStream.Jbig2Stream;
  38447. var JpegStream = coreStream.JpegStream;
  38448. var JpxStream = coreStream.JpxStream;
  38449. var LZWStream = coreStream.LZWStream;
  38450. var NullStream = coreStream.NullStream;
  38451. var PredictorStream = coreStream.PredictorStream;
  38452. var RunLengthStream = coreStream.RunLengthStream;
  38453. var MAX_LENGTH_TO_CACHE = 1000;
  38454. var Parser = function ParserClosure() {
  38455. function Parser(lexer, allowStreams, xref, recoveryMode) {
  38456. this.lexer = lexer;
  38457. this.allowStreams = allowStreams;
  38458. this.xref = xref;
  38459. this.recoveryMode = recoveryMode || false;
  38460. this.imageCache = Object.create(null);
  38461. this.refill();
  38462. }
  38463. Parser.prototype = {
  38464. refill: function Parser_refill() {
  38465. this.buf1 = this.lexer.getObj();
  38466. this.buf2 = this.lexer.getObj();
  38467. },
  38468. shift: function Parser_shift() {
  38469. if (isCmd(this.buf2, 'ID')) {
  38470. this.buf1 = this.buf2;
  38471. this.buf2 = null;
  38472. } else {
  38473. this.buf1 = this.buf2;
  38474. this.buf2 = this.lexer.getObj();
  38475. }
  38476. },
  38477. tryShift: function Parser_tryShift() {
  38478. try {
  38479. this.shift();
  38480. return true;
  38481. } catch (e) {
  38482. if (e instanceof MissingDataException) {
  38483. throw e;
  38484. }
  38485. return false;
  38486. }
  38487. },
  38488. getObj: function Parser_getObj(cipherTransform) {
  38489. var buf1 = this.buf1;
  38490. this.shift();
  38491. if (buf1 instanceof Cmd) {
  38492. switch (buf1.cmd) {
  38493. case 'BI':
  38494. return this.makeInlineImage(cipherTransform);
  38495. case '[':
  38496. var array = [];
  38497. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  38498. array.push(this.getObj(cipherTransform));
  38499. }
  38500. if (isEOF(this.buf1)) {
  38501. if (!this.recoveryMode) {
  38502. error('End of file inside array');
  38503. }
  38504. return array;
  38505. }
  38506. this.shift();
  38507. return array;
  38508. case '<<':
  38509. var dict = new Dict(this.xref);
  38510. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  38511. if (!isName(this.buf1)) {
  38512. info('Malformed dictionary: key must be a name object');
  38513. this.shift();
  38514. continue;
  38515. }
  38516. var key = this.buf1.name;
  38517. this.shift();
  38518. if (isEOF(this.buf1)) {
  38519. break;
  38520. }
  38521. dict.set(key, this.getObj(cipherTransform));
  38522. }
  38523. if (isEOF(this.buf1)) {
  38524. if (!this.recoveryMode) {
  38525. error('End of file inside dictionary');
  38526. }
  38527. return dict;
  38528. }
  38529. if (isCmd(this.buf2, 'stream')) {
  38530. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  38531. }
  38532. this.shift();
  38533. return dict;
  38534. default:
  38535. return buf1;
  38536. }
  38537. }
  38538. if (isInt(buf1)) {
  38539. var num = buf1;
  38540. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  38541. var ref = new Ref(num, this.buf1);
  38542. this.shift();
  38543. this.shift();
  38544. return ref;
  38545. }
  38546. return num;
  38547. }
  38548. if (isString(buf1)) {
  38549. var str = buf1;
  38550. if (cipherTransform) {
  38551. str = cipherTransform.decryptString(str);
  38552. }
  38553. return str;
  38554. }
  38555. return buf1;
  38556. },
  38557. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  38558. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  38559. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  38560. while ((ch = stream.getByte()) !== -1) {
  38561. if (state === 0) {
  38562. state = ch === E ? 1 : 0;
  38563. } else if (state === 1) {
  38564. state = ch === I ? 2 : 0;
  38565. } else {
  38566. assert(state === 2);
  38567. if (ch === SPACE || ch === LF || ch === CR) {
  38568. n = 5;
  38569. followingBytes = stream.peekBytes(n);
  38570. for (i = 0; i < n; i++) {
  38571. ch = followingBytes[i];
  38572. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  38573. state = 0;
  38574. break;
  38575. }
  38576. }
  38577. if (state === 2) {
  38578. break;
  38579. }
  38580. } else
  38581. {
  38582. state = 0;
  38583. }
  38584. }
  38585. }
  38586. return stream.pos - 4 - startPos;
  38587. },
  38588. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  38589. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  38590. while ((b = stream.getByte()) !== -1) {
  38591. if (b !== 0xFF) {
  38592. continue;
  38593. }
  38594. switch (stream.getByte()) {
  38595. case 0x00:
  38596. break;
  38597. case 0xFF:
  38598. stream.skip(-1);
  38599. break;
  38600. case 0xD9:
  38601. foundEOI = true;
  38602. break;
  38603. case 0xC0:
  38604. case 0xC1:
  38605. case 0xC2:
  38606. case 0xC3:
  38607. case 0xC5:
  38608. case 0xC6:
  38609. case 0xC7:
  38610. case 0xC9:
  38611. case 0xCA:
  38612. case 0xCB:
  38613. case 0xCD:
  38614. case 0xCE:
  38615. case 0xCF:
  38616. case 0xC4:
  38617. case 0xCC:
  38618. case 0xDA:
  38619. case 0xDB:
  38620. case 0xDC:
  38621. case 0xDD:
  38622. case 0xDE:
  38623. case 0xDF:
  38624. case 0xE0:
  38625. case 0xE1:
  38626. case 0xE2:
  38627. case 0xE3:
  38628. case 0xE4:
  38629. case 0xE5:
  38630. case 0xE6:
  38631. case 0xE7:
  38632. case 0xE8:
  38633. case 0xE9:
  38634. case 0xEA:
  38635. case 0xEB:
  38636. case 0xEC:
  38637. case 0xED:
  38638. case 0xEE:
  38639. case 0xEF:
  38640. case 0xFE:
  38641. markerLength = stream.getUint16();
  38642. if (markerLength > 2) {
  38643. stream.skip(markerLength - 2);
  38644. } else
  38645. {
  38646. stream.skip(-2);
  38647. }
  38648. break;
  38649. }
  38650. if (foundEOI) {
  38651. break;
  38652. }
  38653. }
  38654. length = stream.pos - startPos;
  38655. if (b === -1) {
  38656. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  38657. stream.skip(-length);
  38658. return this.findDefaultInlineStreamEnd(stream);
  38659. }
  38660. this.inlineStreamSkipEI(stream);
  38661. return length;
  38662. },
  38663. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  38664. var TILDE = 0x7E, GT = 0x3E;
  38665. var startPos = stream.pos, ch, length;
  38666. while ((ch = stream.getByte()) !== -1) {
  38667. if (ch === TILDE && stream.peekByte() === GT) {
  38668. stream.skip();
  38669. break;
  38670. }
  38671. }
  38672. length = stream.pos - startPos;
  38673. if (ch === -1) {
  38674. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  38675. stream.skip(-length);
  38676. return this.findDefaultInlineStreamEnd(stream);
  38677. }
  38678. this.inlineStreamSkipEI(stream);
  38679. return length;
  38680. },
  38681. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  38682. var GT = 0x3E;
  38683. var startPos = stream.pos, ch, length;
  38684. while ((ch = stream.getByte()) !== -1) {
  38685. if (ch === GT) {
  38686. break;
  38687. }
  38688. }
  38689. length = stream.pos - startPos;
  38690. if (ch === -1) {
  38691. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  38692. stream.skip(-length);
  38693. return this.findDefaultInlineStreamEnd(stream);
  38694. }
  38695. this.inlineStreamSkipEI(stream);
  38696. return length;
  38697. },
  38698. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  38699. var E = 0x45, I = 0x49;
  38700. var state = 0, ch;
  38701. while ((ch = stream.getByte()) !== -1) {
  38702. if (state === 0) {
  38703. state = ch === E ? 1 : 0;
  38704. } else if (state === 1) {
  38705. state = ch === I ? 2 : 0;
  38706. } else if (state === 2) {
  38707. break;
  38708. }
  38709. }
  38710. },
  38711. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  38712. var lexer = this.lexer;
  38713. var stream = lexer.stream;
  38714. var dict = new Dict(this.xref);
  38715. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  38716. if (!isName(this.buf1)) {
  38717. error('Dictionary key must be a name object');
  38718. }
  38719. var key = this.buf1.name;
  38720. this.shift();
  38721. if (isEOF(this.buf1)) {
  38722. break;
  38723. }
  38724. dict.set(key, this.getObj(cipherTransform));
  38725. }
  38726. var filter = dict.get('Filter', 'F'), filterName;
  38727. if (isName(filter)) {
  38728. filterName = filter.name;
  38729. } else if (isArray(filter)) {
  38730. var filterZero = this.xref.fetchIfRef(filter[0]);
  38731. if (isName(filterZero)) {
  38732. filterName = filterZero.name;
  38733. }
  38734. }
  38735. var startPos = stream.pos, length, i, ii;
  38736. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  38737. length = this.findDCTDecodeInlineStreamEnd(stream);
  38738. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  38739. length = this.findASCII85DecodeInlineStreamEnd(stream);
  38740. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  38741. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  38742. } else {
  38743. length = this.findDefaultInlineStreamEnd(stream);
  38744. }
  38745. var imageStream = stream.makeSubStream(startPos, length, dict);
  38746. var adler32;
  38747. if (length < MAX_LENGTH_TO_CACHE) {
  38748. var imageBytes = imageStream.getBytes();
  38749. imageStream.reset();
  38750. var a = 1;
  38751. var b = 0;
  38752. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  38753. a += imageBytes[i] & 0xff;
  38754. b += a;
  38755. }
  38756. adler32 = b % 65521 << 16 | a % 65521;
  38757. if (this.imageCache.adler32 === adler32) {
  38758. this.buf2 = Cmd.get('EI');
  38759. this.shift();
  38760. this.imageCache[adler32].reset();
  38761. return this.imageCache[adler32];
  38762. }
  38763. }
  38764. if (cipherTransform) {
  38765. imageStream = cipherTransform.createStream(imageStream, length);
  38766. }
  38767. imageStream = this.filter(imageStream, dict, length);
  38768. imageStream.dict = dict;
  38769. if (adler32 !== undefined) {
  38770. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  38771. this.imageCache[adler32] = imageStream;
  38772. }
  38773. this.buf2 = Cmd.get('EI');
  38774. this.shift();
  38775. return imageStream;
  38776. },
  38777. makeStream: function Parser_makeStream(dict, cipherTransform) {
  38778. var lexer = this.lexer;
  38779. var stream = lexer.stream;
  38780. lexer.skipToNextLine();
  38781. var pos = stream.pos - 1;
  38782. var length = dict.get('Length');
  38783. if (!isInt(length)) {
  38784. info('Bad ' + length + ' attribute in stream');
  38785. length = 0;
  38786. }
  38787. stream.pos = pos + length;
  38788. lexer.nextChar();
  38789. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  38790. this.shift();
  38791. } else
  38792. {
  38793. stream.pos = pos;
  38794. var SCAN_BLOCK_SIZE = 2048;
  38795. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  38796. var ENDSTREAM_SIGNATURE = [
  38797. 0x65,
  38798. 0x6E,
  38799. 0x64,
  38800. 0x73,
  38801. 0x74,
  38802. 0x72,
  38803. 0x65,
  38804. 0x61,
  38805. 0x6D
  38806. ];
  38807. var skipped = 0, found = false, i, j;
  38808. while (stream.pos < stream.end) {
  38809. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  38810. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  38811. if (scanLength <= 0) {
  38812. break;
  38813. }
  38814. found = false;
  38815. i = 0;
  38816. while (i < scanLength) {
  38817. j = 0;
  38818. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  38819. j++;
  38820. }
  38821. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  38822. found = true;
  38823. break;
  38824. }
  38825. i++;
  38826. }
  38827. if (found) {
  38828. skipped += i;
  38829. stream.pos += i;
  38830. break;
  38831. }
  38832. skipped += scanLength;
  38833. stream.pos += scanLength;
  38834. }
  38835. if (!found) {
  38836. error('Missing endstream');
  38837. }
  38838. length = skipped;
  38839. lexer.nextChar();
  38840. this.shift();
  38841. this.shift();
  38842. }
  38843. this.shift();
  38844. stream = stream.makeSubStream(pos, length, dict);
  38845. if (cipherTransform) {
  38846. stream = cipherTransform.createStream(stream, length);
  38847. }
  38848. stream = this.filter(stream, dict, length);
  38849. stream.dict = dict;
  38850. return stream;
  38851. },
  38852. filter: function Parser_filter(stream, dict, length) {
  38853. var filter = dict.get('Filter', 'F');
  38854. var params = dict.get('DecodeParms', 'DP');
  38855. if (isName(filter)) {
  38856. if (isArray(params)) {
  38857. params = this.xref.fetchIfRef(params[0]);
  38858. }
  38859. return this.makeFilter(stream, filter.name, length, params);
  38860. }
  38861. var maybeLength = length;
  38862. if (isArray(filter)) {
  38863. var filterArray = filter;
  38864. var paramsArray = params;
  38865. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  38866. filter = this.xref.fetchIfRef(filterArray[i]);
  38867. if (!isName(filter)) {
  38868. error('Bad filter name: ' + filter);
  38869. }
  38870. params = null;
  38871. if (isArray(paramsArray) && i in paramsArray) {
  38872. params = this.xref.fetchIfRef(paramsArray[i]);
  38873. }
  38874. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  38875. maybeLength = null;
  38876. }
  38877. }
  38878. return stream;
  38879. },
  38880. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  38881. if (maybeLength === 0) {
  38882. warn('Empty "' + name + '" stream.');
  38883. return new NullStream(stream);
  38884. }
  38885. try {
  38886. var xrefStreamStats = this.xref.stats.streamTypes;
  38887. if (name === 'FlateDecode' || name === 'Fl') {
  38888. xrefStreamStats[StreamType.FLATE] = true;
  38889. if (params) {
  38890. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  38891. }
  38892. return new FlateStream(stream, maybeLength);
  38893. }
  38894. if (name === 'LZWDecode' || name === 'LZW') {
  38895. xrefStreamStats[StreamType.LZW] = true;
  38896. var earlyChange = 1;
  38897. if (params) {
  38898. if (params.has('EarlyChange')) {
  38899. earlyChange = params.get('EarlyChange');
  38900. }
  38901. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  38902. }
  38903. return new LZWStream(stream, maybeLength, earlyChange);
  38904. }
  38905. if (name === 'DCTDecode' || name === 'DCT') {
  38906. xrefStreamStats[StreamType.DCT] = true;
  38907. return new JpegStream(stream, maybeLength, stream.dict, params);
  38908. }
  38909. if (name === 'JPXDecode' || name === 'JPX') {
  38910. xrefStreamStats[StreamType.JPX] = true;
  38911. return new JpxStream(stream, maybeLength, stream.dict, params);
  38912. }
  38913. if (name === 'ASCII85Decode' || name === 'A85') {
  38914. xrefStreamStats[StreamType.A85] = true;
  38915. return new Ascii85Stream(stream, maybeLength);
  38916. }
  38917. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  38918. xrefStreamStats[StreamType.AHX] = true;
  38919. return new AsciiHexStream(stream, maybeLength);
  38920. }
  38921. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  38922. xrefStreamStats[StreamType.CCF] = true;
  38923. return new CCITTFaxStream(stream, maybeLength, params);
  38924. }
  38925. if (name === 'RunLengthDecode' || name === 'RL') {
  38926. xrefStreamStats[StreamType.RL] = true;
  38927. return new RunLengthStream(stream, maybeLength);
  38928. }
  38929. if (name === 'JBIG2Decode') {
  38930. xrefStreamStats[StreamType.JBIG] = true;
  38931. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  38932. }
  38933. warn('filter "' + name + '" not supported yet');
  38934. return stream;
  38935. } catch (ex) {
  38936. if (ex instanceof MissingDataException) {
  38937. throw ex;
  38938. }
  38939. warn('Invalid stream: \"' + ex + '\"');
  38940. return new NullStream(stream);
  38941. }
  38942. }
  38943. };
  38944. return Parser;
  38945. }();
  38946. var Lexer = function LexerClosure() {
  38947. function Lexer(stream, knownCommands) {
  38948. this.stream = stream;
  38949. this.nextChar();
  38950. this.strBuf = [];
  38951. this.knownCommands = knownCommands;
  38952. }
  38953. var specialChars = [
  38954. 1,
  38955. 0,
  38956. 0,
  38957. 0,
  38958. 0,
  38959. 0,
  38960. 0,
  38961. 0,
  38962. 0,
  38963. 1,
  38964. 1,
  38965. 0,
  38966. 1,
  38967. 1,
  38968. 0,
  38969. 0,
  38970. 0,
  38971. 0,
  38972. 0,
  38973. 0,
  38974. 0,
  38975. 0,
  38976. 0,
  38977. 0,
  38978. 0,
  38979. 0,
  38980. 0,
  38981. 0,
  38982. 0,
  38983. 0,
  38984. 0,
  38985. 0,
  38986. 1,
  38987. 0,
  38988. 0,
  38989. 0,
  38990. 0,
  38991. 2,
  38992. 0,
  38993. 0,
  38994. 2,
  38995. 2,
  38996. 0,
  38997. 0,
  38998. 0,
  38999. 0,
  39000. 0,
  39001. 2,
  39002. 0,
  39003. 0,
  39004. 0,
  39005. 0,
  39006. 0,
  39007. 0,
  39008. 0,
  39009. 0,
  39010. 0,
  39011. 0,
  39012. 0,
  39013. 0,
  39014. 2,
  39015. 0,
  39016. 2,
  39017. 0,
  39018. 0,
  39019. 0,
  39020. 0,
  39021. 0,
  39022. 0,
  39023. 0,
  39024. 0,
  39025. 0,
  39026. 0,
  39027. 0,
  39028. 0,
  39029. 0,
  39030. 0,
  39031. 0,
  39032. 0,
  39033. 0,
  39034. 0,
  39035. 0,
  39036. 0,
  39037. 0,
  39038. 0,
  39039. 0,
  39040. 0,
  39041. 0,
  39042. 0,
  39043. 0,
  39044. 0,
  39045. 2,
  39046. 0,
  39047. 2,
  39048. 0,
  39049. 0,
  39050. 0,
  39051. 0,
  39052. 0,
  39053. 0,
  39054. 0,
  39055. 0,
  39056. 0,
  39057. 0,
  39058. 0,
  39059. 0,
  39060. 0,
  39061. 0,
  39062. 0,
  39063. 0,
  39064. 0,
  39065. 0,
  39066. 0,
  39067. 0,
  39068. 0,
  39069. 0,
  39070. 0,
  39071. 0,
  39072. 0,
  39073. 0,
  39074. 0,
  39075. 0,
  39076. 0,
  39077. 2,
  39078. 0,
  39079. 2,
  39080. 0,
  39081. 0,
  39082. 0,
  39083. 0,
  39084. 0,
  39085. 0,
  39086. 0,
  39087. 0,
  39088. 0,
  39089. 0,
  39090. 0,
  39091. 0,
  39092. 0,
  39093. 0,
  39094. 0,
  39095. 0,
  39096. 0,
  39097. 0,
  39098. 0,
  39099. 0,
  39100. 0,
  39101. 0,
  39102. 0,
  39103. 0,
  39104. 0,
  39105. 0,
  39106. 0,
  39107. 0,
  39108. 0,
  39109. 0,
  39110. 0,
  39111. 0,
  39112. 0,
  39113. 0,
  39114. 0,
  39115. 0,
  39116. 0,
  39117. 0,
  39118. 0,
  39119. 0,
  39120. 0,
  39121. 0,
  39122. 0,
  39123. 0,
  39124. 0,
  39125. 0,
  39126. 0,
  39127. 0,
  39128. 0,
  39129. 0,
  39130. 0,
  39131. 0,
  39132. 0,
  39133. 0,
  39134. 0,
  39135. 0,
  39136. 0,
  39137. 0,
  39138. 0,
  39139. 0,
  39140. 0,
  39141. 0,
  39142. 0,
  39143. 0,
  39144. 0,
  39145. 0,
  39146. 0,
  39147. 0,
  39148. 0,
  39149. 0,
  39150. 0,
  39151. 0,
  39152. 0,
  39153. 0,
  39154. 0,
  39155. 0,
  39156. 0,
  39157. 0,
  39158. 0,
  39159. 0,
  39160. 0,
  39161. 0,
  39162. 0,
  39163. 0,
  39164. 0,
  39165. 0,
  39166. 0,
  39167. 0,
  39168. 0,
  39169. 0,
  39170. 0,
  39171. 0,
  39172. 0,
  39173. 0,
  39174. 0,
  39175. 0,
  39176. 0,
  39177. 0,
  39178. 0,
  39179. 0,
  39180. 0,
  39181. 0,
  39182. 0,
  39183. 0,
  39184. 0,
  39185. 0,
  39186. 0,
  39187. 0,
  39188. 0,
  39189. 0,
  39190. 0,
  39191. 0,
  39192. 0,
  39193. 0,
  39194. 0,
  39195. 0,
  39196. 0,
  39197. 0,
  39198. 0,
  39199. 0,
  39200. 0,
  39201. 0,
  39202. 0,
  39203. 0,
  39204. 0,
  39205. 0,
  39206. 0,
  39207. 0,
  39208. 0,
  39209. 0
  39210. ];
  39211. function toHexDigit(ch) {
  39212. if (ch >= 0x30 && ch <= 0x39) {
  39213. return ch & 0x0F;
  39214. }
  39215. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  39216. return (ch & 0x0F) + 9;
  39217. }
  39218. return -1;
  39219. }
  39220. Lexer.prototype = {
  39221. nextChar: function Lexer_nextChar() {
  39222. return this.currentChar = this.stream.getByte();
  39223. },
  39224. peekChar: function Lexer_peekChar() {
  39225. return this.stream.peekByte();
  39226. },
  39227. getNumber: function Lexer_getNumber() {
  39228. var ch = this.currentChar;
  39229. var eNotation = false;
  39230. var divideBy = 0;
  39231. var sign = 1;
  39232. if (ch === 0x2D) {
  39233. sign = -1;
  39234. ch = this.nextChar();
  39235. if (ch === 0x2D) {
  39236. ch = this.nextChar();
  39237. }
  39238. } else if (ch === 0x2B) {
  39239. ch = this.nextChar();
  39240. }
  39241. if (ch === 0x2E) {
  39242. divideBy = 10;
  39243. ch = this.nextChar();
  39244. }
  39245. if (ch < 0x30 || ch > 0x39) {
  39246. error('Invalid number: ' + String.fromCharCode(ch));
  39247. return 0;
  39248. }
  39249. var baseValue = ch - 0x30;
  39250. var powerValue = 0;
  39251. var powerValueSign = 1;
  39252. while ((ch = this.nextChar()) >= 0) {
  39253. if (0x30 <= ch && ch <= 0x39) {
  39254. var currentDigit = ch - 0x30;
  39255. if (eNotation) {
  39256. powerValue = powerValue * 10 + currentDigit;
  39257. } else {
  39258. if (divideBy !== 0) {
  39259. divideBy *= 10;
  39260. }
  39261. baseValue = baseValue * 10 + currentDigit;
  39262. }
  39263. } else if (ch === 0x2E) {
  39264. if (divideBy === 0) {
  39265. divideBy = 1;
  39266. } else {
  39267. break;
  39268. }
  39269. } else if (ch === 0x2D) {
  39270. warn('Badly formatted number');
  39271. } else if (ch === 0x45 || ch === 0x65) {
  39272. ch = this.peekChar();
  39273. if (ch === 0x2B || ch === 0x2D) {
  39274. powerValueSign = ch === 0x2D ? -1 : 1;
  39275. this.nextChar();
  39276. } else if (ch < 0x30 || ch > 0x39) {
  39277. break;
  39278. }
  39279. eNotation = true;
  39280. } else {
  39281. break;
  39282. }
  39283. }
  39284. if (divideBy !== 0) {
  39285. baseValue /= divideBy;
  39286. }
  39287. if (eNotation) {
  39288. baseValue *= Math.pow(10, powerValueSign * powerValue);
  39289. }
  39290. return sign * baseValue;
  39291. },
  39292. getString: function Lexer_getString() {
  39293. var numParen = 1;
  39294. var done = false;
  39295. var strBuf = this.strBuf;
  39296. strBuf.length = 0;
  39297. var ch = this.nextChar();
  39298. while (true) {
  39299. var charBuffered = false;
  39300. switch (ch | 0) {
  39301. case -1:
  39302. warn('Unterminated string');
  39303. done = true;
  39304. break;
  39305. case 0x28:
  39306. ++numParen;
  39307. strBuf.push('(');
  39308. break;
  39309. case 0x29:
  39310. if (--numParen === 0) {
  39311. this.nextChar();
  39312. done = true;
  39313. } else {
  39314. strBuf.push(')');
  39315. }
  39316. break;
  39317. case 0x5C:
  39318. ch = this.nextChar();
  39319. switch (ch) {
  39320. case -1:
  39321. warn('Unterminated string');
  39322. done = true;
  39323. break;
  39324. case 0x6E:
  39325. strBuf.push('\n');
  39326. break;
  39327. case 0x72:
  39328. strBuf.push('\r');
  39329. break;
  39330. case 0x74:
  39331. strBuf.push('\t');
  39332. break;
  39333. case 0x62:
  39334. strBuf.push('\b');
  39335. break;
  39336. case 0x66:
  39337. strBuf.push('\f');
  39338. break;
  39339. case 0x5C:
  39340. case 0x28:
  39341. case 0x29:
  39342. strBuf.push(String.fromCharCode(ch));
  39343. break;
  39344. case 0x30:
  39345. case 0x31:
  39346. case 0x32:
  39347. case 0x33:
  39348. case 0x34:
  39349. case 0x35:
  39350. case 0x36:
  39351. case 0x37:
  39352. var x = ch & 0x0F;
  39353. ch = this.nextChar();
  39354. charBuffered = true;
  39355. if (ch >= 0x30 && ch <= 0x37) {
  39356. x = (x << 3) + (ch & 0x0F);
  39357. ch = this.nextChar();
  39358. if (ch >= 0x30 && ch <= 0x37) {
  39359. charBuffered = false;
  39360. x = (x << 3) + (ch & 0x0F);
  39361. }
  39362. }
  39363. strBuf.push(String.fromCharCode(x));
  39364. break;
  39365. case 0x0D:
  39366. if (this.peekChar() === 0x0A) {
  39367. this.nextChar();
  39368. }
  39369. break;
  39370. case 0x0A:
  39371. break;
  39372. default:
  39373. strBuf.push(String.fromCharCode(ch));
  39374. break;
  39375. }
  39376. break;
  39377. default:
  39378. strBuf.push(String.fromCharCode(ch));
  39379. break;
  39380. }
  39381. if (done) {
  39382. break;
  39383. }
  39384. if (!charBuffered) {
  39385. ch = this.nextChar();
  39386. }
  39387. }
  39388. return strBuf.join('');
  39389. },
  39390. getName: function Lexer_getName() {
  39391. var ch, previousCh;
  39392. var strBuf = this.strBuf;
  39393. strBuf.length = 0;
  39394. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  39395. if (ch === 0x23) {
  39396. ch = this.nextChar();
  39397. if (specialChars[ch]) {
  39398. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  39399. strBuf.push('#');
  39400. break;
  39401. }
  39402. var x = toHexDigit(ch);
  39403. if (x !== -1) {
  39404. previousCh = ch;
  39405. ch = this.nextChar();
  39406. var x2 = toHexDigit(ch);
  39407. if (x2 === -1) {
  39408. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  39409. strBuf.push('#', String.fromCharCode(previousCh));
  39410. if (specialChars[ch]) {
  39411. break;
  39412. }
  39413. strBuf.push(String.fromCharCode(ch));
  39414. continue;
  39415. }
  39416. strBuf.push(String.fromCharCode(x << 4 | x2));
  39417. } else {
  39418. strBuf.push('#', String.fromCharCode(ch));
  39419. }
  39420. } else {
  39421. strBuf.push(String.fromCharCode(ch));
  39422. }
  39423. }
  39424. if (strBuf.length > 127) {
  39425. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  39426. }
  39427. return Name.get(strBuf.join(''));
  39428. },
  39429. getHexString: function Lexer_getHexString() {
  39430. var strBuf = this.strBuf;
  39431. strBuf.length = 0;
  39432. var ch = this.currentChar;
  39433. var isFirstHex = true;
  39434. var firstDigit;
  39435. var secondDigit;
  39436. while (true) {
  39437. if (ch < 0) {
  39438. warn('Unterminated hex string');
  39439. break;
  39440. } else if (ch === 0x3E) {
  39441. this.nextChar();
  39442. break;
  39443. } else if (specialChars[ch] === 1) {
  39444. ch = this.nextChar();
  39445. continue;
  39446. } else {
  39447. if (isFirstHex) {
  39448. firstDigit = toHexDigit(ch);
  39449. if (firstDigit === -1) {
  39450. warn('Ignoring invalid character "' + ch + '" in hex string');
  39451. ch = this.nextChar();
  39452. continue;
  39453. }
  39454. } else {
  39455. secondDigit = toHexDigit(ch);
  39456. if (secondDigit === -1) {
  39457. warn('Ignoring invalid character "' + ch + '" in hex string');
  39458. ch = this.nextChar();
  39459. continue;
  39460. }
  39461. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  39462. }
  39463. isFirstHex = !isFirstHex;
  39464. ch = this.nextChar();
  39465. }
  39466. }
  39467. return strBuf.join('');
  39468. },
  39469. getObj: function Lexer_getObj() {
  39470. var comment = false;
  39471. var ch = this.currentChar;
  39472. while (true) {
  39473. if (ch < 0) {
  39474. return EOF;
  39475. }
  39476. if (comment) {
  39477. if (ch === 0x0A || ch === 0x0D) {
  39478. comment = false;
  39479. }
  39480. } else if (ch === 0x25) {
  39481. comment = true;
  39482. } else if (specialChars[ch] !== 1) {
  39483. break;
  39484. }
  39485. ch = this.nextChar();
  39486. }
  39487. switch (ch | 0) {
  39488. case 0x30:
  39489. case 0x31:
  39490. case 0x32:
  39491. case 0x33:
  39492. case 0x34:
  39493. case 0x35:
  39494. case 0x36:
  39495. case 0x37:
  39496. case 0x38:
  39497. case 0x39:
  39498. case 0x2B:
  39499. case 0x2D:
  39500. case 0x2E:
  39501. return this.getNumber();
  39502. case 0x28:
  39503. return this.getString();
  39504. case 0x2F:
  39505. return this.getName();
  39506. case 0x5B:
  39507. this.nextChar();
  39508. return Cmd.get('[');
  39509. case 0x5D:
  39510. this.nextChar();
  39511. return Cmd.get(']');
  39512. case 0x3C:
  39513. ch = this.nextChar();
  39514. if (ch === 0x3C) {
  39515. this.nextChar();
  39516. return Cmd.get('<<');
  39517. }
  39518. return this.getHexString();
  39519. case 0x3E:
  39520. ch = this.nextChar();
  39521. if (ch === 0x3E) {
  39522. this.nextChar();
  39523. return Cmd.get('>>');
  39524. }
  39525. return Cmd.get('>');
  39526. case 0x7B:
  39527. this.nextChar();
  39528. return Cmd.get('{');
  39529. case 0x7D:
  39530. this.nextChar();
  39531. return Cmd.get('}');
  39532. case 0x29:
  39533. error('Illegal character: ' + ch);
  39534. break;
  39535. }
  39536. var str = String.fromCharCode(ch);
  39537. var knownCommands = this.knownCommands;
  39538. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  39539. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  39540. var possibleCommand = str + String.fromCharCode(ch);
  39541. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  39542. break;
  39543. }
  39544. if (str.length === 128) {
  39545. error('Command token too long: ' + str.length);
  39546. }
  39547. str = possibleCommand;
  39548. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  39549. }
  39550. if (str === 'true') {
  39551. return true;
  39552. }
  39553. if (str === 'false') {
  39554. return false;
  39555. }
  39556. if (str === 'null') {
  39557. return null;
  39558. }
  39559. return Cmd.get(str);
  39560. },
  39561. skipToNextLine: function Lexer_skipToNextLine() {
  39562. var ch = this.currentChar;
  39563. while (ch >= 0) {
  39564. if (ch === 0x0D) {
  39565. ch = this.nextChar();
  39566. if (ch === 0x0A) {
  39567. this.nextChar();
  39568. }
  39569. break;
  39570. } else if (ch === 0x0A) {
  39571. this.nextChar();
  39572. break;
  39573. }
  39574. ch = this.nextChar();
  39575. }
  39576. }
  39577. };
  39578. return Lexer;
  39579. }();
  39580. var Linearization = {
  39581. create: function LinearizationCreate(stream) {
  39582. function getInt(name, allowZeroValue) {
  39583. var obj = linDict.get(name);
  39584. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  39585. return obj;
  39586. }
  39587. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  39588. }
  39589. function getHints() {
  39590. var hints = linDict.get('H'), hintsLength, item;
  39591. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  39592. for (var index = 0; index < hintsLength; index++) {
  39593. if (!(isInt(item = hints[index]) && item > 0)) {
  39594. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  39595. }
  39596. }
  39597. return hints;
  39598. }
  39599. throw new Error('Hint array in the linearization dictionary is invalid.');
  39600. }
  39601. var parser = new Parser(new Lexer(stream), false, null);
  39602. var obj1 = parser.getObj();
  39603. var obj2 = parser.getObj();
  39604. var obj3 = parser.getObj();
  39605. var linDict = parser.getObj();
  39606. var obj, length;
  39607. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  39608. return null;
  39609. } else if ((length = getInt('L')) !== stream.length) {
  39610. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  39611. }
  39612. return {
  39613. length: length,
  39614. hints: getHints(),
  39615. objectNumberFirst: getInt('O'),
  39616. endFirst: getInt('E'),
  39617. numPages: getInt('N'),
  39618. mainXRefEntriesOffset: getInt('T'),
  39619. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  39620. };
  39621. }
  39622. };
  39623. exports.Lexer = Lexer;
  39624. exports.Linearization = Linearization;
  39625. exports.Parser = Parser;
  39626. }));
  39627. (function (root, factory) {
  39628. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  39629. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  39630. var warn = sharedUtil.warn;
  39631. var isSpace = sharedUtil.isSpace;
  39632. var Stream = coreStream.Stream;
  39633. var getEncoding = coreEncodings.getEncoding;
  39634. var HINTING_ENABLED = false;
  39635. var Type1CharString = function Type1CharStringClosure() {
  39636. var COMMAND_MAP = {
  39637. 'hstem': [1],
  39638. 'vstem': [3],
  39639. 'vmoveto': [4],
  39640. 'rlineto': [5],
  39641. 'hlineto': [6],
  39642. 'vlineto': [7],
  39643. 'rrcurveto': [8],
  39644. 'callsubr': [10],
  39645. 'flex': [
  39646. 12,
  39647. 35
  39648. ],
  39649. 'drop': [
  39650. 12,
  39651. 18
  39652. ],
  39653. 'endchar': [14],
  39654. 'rmoveto': [21],
  39655. 'hmoveto': [22],
  39656. 'vhcurveto': [30],
  39657. 'hvcurveto': [31]
  39658. };
  39659. function Type1CharString() {
  39660. this.width = 0;
  39661. this.lsb = 0;
  39662. this.flexing = false;
  39663. this.output = [];
  39664. this.stack = [];
  39665. }
  39666. Type1CharString.prototype = {
  39667. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  39668. var count = encoded.length;
  39669. var error = false;
  39670. var wx, sbx, subrNumber;
  39671. for (var i = 0; i < count; i++) {
  39672. var value = encoded[i];
  39673. if (value < 32) {
  39674. if (value === 12) {
  39675. value = (value << 8) + encoded[++i];
  39676. }
  39677. switch (value) {
  39678. case 1:
  39679. if (!HINTING_ENABLED) {
  39680. this.stack = [];
  39681. break;
  39682. }
  39683. error = this.executeCommand(2, COMMAND_MAP.hstem);
  39684. break;
  39685. case 3:
  39686. if (!HINTING_ENABLED) {
  39687. this.stack = [];
  39688. break;
  39689. }
  39690. error = this.executeCommand(2, COMMAND_MAP.vstem);
  39691. break;
  39692. case 4:
  39693. if (this.flexing) {
  39694. if (this.stack.length < 1) {
  39695. error = true;
  39696. break;
  39697. }
  39698. var dy = this.stack.pop();
  39699. this.stack.push(0, dy);
  39700. break;
  39701. }
  39702. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  39703. break;
  39704. case 5:
  39705. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  39706. break;
  39707. case 6:
  39708. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  39709. break;
  39710. case 7:
  39711. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  39712. break;
  39713. case 8:
  39714. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  39715. break;
  39716. case 9:
  39717. this.stack = [];
  39718. break;
  39719. case 10:
  39720. if (this.stack.length < 1) {
  39721. error = true;
  39722. break;
  39723. }
  39724. subrNumber = this.stack.pop();
  39725. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  39726. break;
  39727. case 11:
  39728. return error;
  39729. case 13:
  39730. if (this.stack.length < 2) {
  39731. error = true;
  39732. break;
  39733. }
  39734. wx = this.stack.pop();
  39735. sbx = this.stack.pop();
  39736. this.lsb = sbx;
  39737. this.width = wx;
  39738. this.stack.push(wx, sbx);
  39739. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  39740. break;
  39741. case 14:
  39742. this.output.push(COMMAND_MAP.endchar[0]);
  39743. break;
  39744. case 21:
  39745. if (this.flexing) {
  39746. break;
  39747. }
  39748. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  39749. break;
  39750. case 22:
  39751. if (this.flexing) {
  39752. this.stack.push(0);
  39753. break;
  39754. }
  39755. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  39756. break;
  39757. case 30:
  39758. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  39759. break;
  39760. case 31:
  39761. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  39762. break;
  39763. case (12 << 8) + 0:
  39764. this.stack = [];
  39765. break;
  39766. case (12 << 8) + 1:
  39767. if (!HINTING_ENABLED) {
  39768. this.stack = [];
  39769. break;
  39770. }
  39771. error = this.executeCommand(2, COMMAND_MAP.vstem);
  39772. break;
  39773. case (12 << 8) + 2:
  39774. if (!HINTING_ENABLED) {
  39775. this.stack = [];
  39776. break;
  39777. }
  39778. error = this.executeCommand(2, COMMAND_MAP.hstem);
  39779. break;
  39780. case (12 << 8) + 6:
  39781. if (seacAnalysisEnabled) {
  39782. this.seac = this.stack.splice(-4, 4);
  39783. error = this.executeCommand(0, COMMAND_MAP.endchar);
  39784. } else {
  39785. error = this.executeCommand(4, COMMAND_MAP.endchar);
  39786. }
  39787. break;
  39788. case (12 << 8) + 7:
  39789. if (this.stack.length < 4) {
  39790. error = true;
  39791. break;
  39792. }
  39793. this.stack.pop();
  39794. wx = this.stack.pop();
  39795. var sby = this.stack.pop();
  39796. sbx = this.stack.pop();
  39797. this.lsb = sbx;
  39798. this.width = wx;
  39799. this.stack.push(wx, sbx, sby);
  39800. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  39801. break;
  39802. case (12 << 8) + 12:
  39803. if (this.stack.length < 2) {
  39804. error = true;
  39805. break;
  39806. }
  39807. var num2 = this.stack.pop();
  39808. var num1 = this.stack.pop();
  39809. this.stack.push(num1 / num2);
  39810. break;
  39811. case (12 << 8) + 16:
  39812. if (this.stack.length < 2) {
  39813. error = true;
  39814. break;
  39815. }
  39816. subrNumber = this.stack.pop();
  39817. var numArgs = this.stack.pop();
  39818. if (subrNumber === 0 && numArgs === 3) {
  39819. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  39820. this.stack.push(flexArgs[2] + flexArgs[0], flexArgs[3] + flexArgs[1], flexArgs[4], flexArgs[5], flexArgs[6], flexArgs[7], flexArgs[8], flexArgs[9], flexArgs[10], flexArgs[11], flexArgs[12], flexArgs[13], flexArgs[14]);
  39821. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  39822. this.flexing = false;
  39823. this.stack.push(flexArgs[15], flexArgs[16]);
  39824. } else if (subrNumber === 1 && numArgs === 0) {
  39825. this.flexing = true;
  39826. }
  39827. break;
  39828. case (12 << 8) + 17:
  39829. break;
  39830. case (12 << 8) + 33:
  39831. this.stack = [];
  39832. break;
  39833. default:
  39834. warn('Unknown type 1 charstring command of "' + value + '"');
  39835. break;
  39836. }
  39837. if (error) {
  39838. break;
  39839. }
  39840. continue;
  39841. } else if (value <= 246) {
  39842. value = value - 139;
  39843. } else if (value <= 250) {
  39844. value = (value - 247) * 256 + encoded[++i] + 108;
  39845. } else if (value <= 254) {
  39846. value = -((value - 251) * 256) - encoded[++i] - 108;
  39847. } else {
  39848. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  39849. }
  39850. this.stack.push(value);
  39851. }
  39852. return error;
  39853. },
  39854. executeCommand: function (howManyArgs, command, keepStack) {
  39855. var stackLength = this.stack.length;
  39856. if (howManyArgs > stackLength) {
  39857. return true;
  39858. }
  39859. var start = stackLength - howManyArgs;
  39860. for (var i = start; i < stackLength; i++) {
  39861. var value = this.stack[i];
  39862. if (value === (value | 0)) {
  39863. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  39864. } else {
  39865. value = 65536 * value | 0;
  39866. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  39867. }
  39868. }
  39869. this.output.push.apply(this.output, command);
  39870. if (keepStack) {
  39871. this.stack.splice(start, howManyArgs);
  39872. } else {
  39873. this.stack.length = 0;
  39874. }
  39875. return false;
  39876. }
  39877. };
  39878. return Type1CharString;
  39879. }();
  39880. var Type1Parser = function Type1ParserClosure() {
  39881. var EEXEC_ENCRYPT_KEY = 55665;
  39882. var CHAR_STRS_ENCRYPT_KEY = 4330;
  39883. function isHexDigit(code) {
  39884. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  39885. }
  39886. function decrypt(data, key, discardNumber) {
  39887. if (discardNumber >= data.length) {
  39888. return new Uint8Array(0);
  39889. }
  39890. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  39891. for (i = 0; i < discardNumber; i++) {
  39892. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  39893. }
  39894. var count = data.length - discardNumber;
  39895. var decrypted = new Uint8Array(count);
  39896. for (i = discardNumber, j = 0; j < count; i++, j++) {
  39897. var value = data[i];
  39898. decrypted[j] = value ^ r >> 8;
  39899. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  39900. }
  39901. return decrypted;
  39902. }
  39903. function decryptAscii(data, key, discardNumber) {
  39904. var r = key | 0, c1 = 52845, c2 = 22719;
  39905. var count = data.length, maybeLength = count >>> 1;
  39906. var decrypted = new Uint8Array(maybeLength);
  39907. var i, j;
  39908. for (i = 0, j = 0; i < count; i++) {
  39909. var digit1 = data[i];
  39910. if (!isHexDigit(digit1)) {
  39911. continue;
  39912. }
  39913. i++;
  39914. var digit2;
  39915. while (i < count && !isHexDigit(digit2 = data[i])) {
  39916. i++;
  39917. }
  39918. if (i < count) {
  39919. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  39920. decrypted[j++] = value ^ r >> 8;
  39921. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  39922. }
  39923. }
  39924. return Array.prototype.slice.call(decrypted, discardNumber, j);
  39925. }
  39926. function isSpecial(c) {
  39927. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  39928. }
  39929. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  39930. if (encrypted) {
  39931. var data = stream.getBytes();
  39932. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  39933. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  39934. }
  39935. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  39936. this.stream = stream;
  39937. this.nextChar();
  39938. }
  39939. Type1Parser.prototype = {
  39940. readNumberArray: function Type1Parser_readNumberArray() {
  39941. this.getToken();
  39942. var array = [];
  39943. while (true) {
  39944. var token = this.getToken();
  39945. if (token === null || token === ']' || token === '}') {
  39946. break;
  39947. }
  39948. array.push(parseFloat(token || 0));
  39949. }
  39950. return array;
  39951. },
  39952. readNumber: function Type1Parser_readNumber() {
  39953. var token = this.getToken();
  39954. return parseFloat(token || 0);
  39955. },
  39956. readInt: function Type1Parser_readInt() {
  39957. var token = this.getToken();
  39958. return parseInt(token || 0, 10) | 0;
  39959. },
  39960. readBoolean: function Type1Parser_readBoolean() {
  39961. var token = this.getToken();
  39962. return token === 'true' ? 1 : 0;
  39963. },
  39964. nextChar: function Type1_nextChar() {
  39965. return this.currentChar = this.stream.getByte();
  39966. },
  39967. getToken: function Type1Parser_getToken() {
  39968. var comment = false;
  39969. var ch = this.currentChar;
  39970. while (true) {
  39971. if (ch === -1) {
  39972. return null;
  39973. }
  39974. if (comment) {
  39975. if (ch === 0x0A || ch === 0x0D) {
  39976. comment = false;
  39977. }
  39978. } else if (ch === 0x25) {
  39979. comment = true;
  39980. } else if (!isSpace(ch)) {
  39981. break;
  39982. }
  39983. ch = this.nextChar();
  39984. }
  39985. if (isSpecial(ch)) {
  39986. this.nextChar();
  39987. return String.fromCharCode(ch);
  39988. }
  39989. var token = '';
  39990. do {
  39991. token += String.fromCharCode(ch);
  39992. ch = this.nextChar();
  39993. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  39994. return token;
  39995. },
  39996. extractFontProgram: function Type1Parser_extractFontProgram() {
  39997. var stream = this.stream;
  39998. var subrs = [], charstrings = [];
  39999. var privateData = Object.create(null);
  40000. privateData['lenIV'] = 4;
  40001. var program = {
  40002. subrs: [],
  40003. charstrings: [],
  40004. properties: { 'privateData': privateData }
  40005. };
  40006. var token, length, data, lenIV, encoded;
  40007. while ((token = this.getToken()) !== null) {
  40008. if (token !== '/') {
  40009. continue;
  40010. }
  40011. token = this.getToken();
  40012. switch (token) {
  40013. case 'CharStrings':
  40014. this.getToken();
  40015. this.getToken();
  40016. this.getToken();
  40017. this.getToken();
  40018. while (true) {
  40019. token = this.getToken();
  40020. if (token === null || token === 'end') {
  40021. break;
  40022. }
  40023. if (token !== '/') {
  40024. continue;
  40025. }
  40026. var glyph = this.getToken();
  40027. length = this.readInt();
  40028. this.getToken();
  40029. data = stream.makeSubStream(stream.pos, length);
  40030. lenIV = program.properties.privateData['lenIV'];
  40031. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  40032. stream.skip(length);
  40033. this.nextChar();
  40034. token = this.getToken();
  40035. if (token === 'noaccess') {
  40036. this.getToken();
  40037. }
  40038. charstrings.push({
  40039. glyph: glyph,
  40040. encoded: encoded
  40041. });
  40042. }
  40043. break;
  40044. case 'Subrs':
  40045. this.readInt();
  40046. this.getToken();
  40047. while ((token = this.getToken()) === 'dup') {
  40048. var index = this.readInt();
  40049. length = this.readInt();
  40050. this.getToken();
  40051. data = stream.makeSubStream(stream.pos, length);
  40052. lenIV = program.properties.privateData['lenIV'];
  40053. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  40054. stream.skip(length);
  40055. this.nextChar();
  40056. token = this.getToken();
  40057. if (token === 'noaccess') {
  40058. this.getToken();
  40059. }
  40060. subrs[index] = encoded;
  40061. }
  40062. break;
  40063. case 'BlueValues':
  40064. case 'OtherBlues':
  40065. case 'FamilyBlues':
  40066. case 'FamilyOtherBlues':
  40067. var blueArray = this.readNumberArray();
  40068. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  40069. program.properties.privateData[token] = blueArray;
  40070. }
  40071. break;
  40072. case 'StemSnapH':
  40073. case 'StemSnapV':
  40074. program.properties.privateData[token] = this.readNumberArray();
  40075. break;
  40076. case 'StdHW':
  40077. case 'StdVW':
  40078. program.properties.privateData[token] = this.readNumberArray()[0];
  40079. break;
  40080. case 'BlueShift':
  40081. case 'lenIV':
  40082. case 'BlueFuzz':
  40083. case 'BlueScale':
  40084. case 'LanguageGroup':
  40085. case 'ExpansionFactor':
  40086. program.properties.privateData[token] = this.readNumber();
  40087. break;
  40088. case 'ForceBold':
  40089. program.properties.privateData[token] = this.readBoolean();
  40090. break;
  40091. }
  40092. }
  40093. for (var i = 0; i < charstrings.length; i++) {
  40094. glyph = charstrings[i].glyph;
  40095. encoded = charstrings[i].encoded;
  40096. var charString = new Type1CharString();
  40097. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  40098. var output = charString.output;
  40099. if (error) {
  40100. output = [14];
  40101. }
  40102. program.charstrings.push({
  40103. glyphName: glyph,
  40104. charstring: output,
  40105. width: charString.width,
  40106. lsb: charString.lsb,
  40107. seac: charString.seac
  40108. });
  40109. }
  40110. return program;
  40111. },
  40112. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  40113. var token;
  40114. while ((token = this.getToken()) !== null) {
  40115. if (token !== '/') {
  40116. continue;
  40117. }
  40118. token = this.getToken();
  40119. switch (token) {
  40120. case 'FontMatrix':
  40121. var matrix = this.readNumberArray();
  40122. properties.fontMatrix = matrix;
  40123. break;
  40124. case 'Encoding':
  40125. var encodingArg = this.getToken();
  40126. var encoding;
  40127. if (!/^\d+$/.test(encodingArg)) {
  40128. encoding = getEncoding(encodingArg);
  40129. } else {
  40130. encoding = [];
  40131. var size = parseInt(encodingArg, 10) | 0;
  40132. this.getToken();
  40133. for (var j = 0; j < size; j++) {
  40134. token = this.getToken();
  40135. while (token !== 'dup' && token !== 'def') {
  40136. token = this.getToken();
  40137. if (token === null) {
  40138. return;
  40139. }
  40140. }
  40141. if (token === 'def') {
  40142. break;
  40143. }
  40144. var index = this.readInt();
  40145. this.getToken();
  40146. var glyph = this.getToken();
  40147. encoding[index] = glyph;
  40148. this.getToken();
  40149. }
  40150. }
  40151. properties.builtInEncoding = encoding;
  40152. break;
  40153. case 'FontBBox':
  40154. var fontBBox = this.readNumberArray();
  40155. properties.ascent = fontBBox[3];
  40156. properties.descent = fontBBox[1];
  40157. properties.ascentScaled = true;
  40158. break;
  40159. }
  40160. }
  40161. }
  40162. };
  40163. return Type1Parser;
  40164. }();
  40165. exports.Type1Parser = Type1Parser;
  40166. }));
  40167. (function (root, factory) {
  40168. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  40169. }(this, function (exports, sharedUtil, displayWebGL) {
  40170. var Util = sharedUtil.Util;
  40171. var info = sharedUtil.info;
  40172. var isArray = sharedUtil.isArray;
  40173. var error = sharedUtil.error;
  40174. var WebGLUtils = displayWebGL.WebGLUtils;
  40175. var ShadingIRs = {};
  40176. ShadingIRs.RadialAxial = {
  40177. fromIR: function RadialAxial_fromIR(raw) {
  40178. var type = raw[1];
  40179. var colorStops = raw[2];
  40180. var p0 = raw[3];
  40181. var p1 = raw[4];
  40182. var r0 = raw[5];
  40183. var r1 = raw[6];
  40184. return {
  40185. type: 'Pattern',
  40186. getPattern: function RadialAxial_getPattern(ctx) {
  40187. var grad;
  40188. if (type === 'axial') {
  40189. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  40190. } else if (type === 'radial') {
  40191. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  40192. }
  40193. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  40194. var c = colorStops[i];
  40195. grad.addColorStop(c[0], c[1]);
  40196. }
  40197. return grad;
  40198. }
  40199. };
  40200. }
  40201. };
  40202. var createMeshCanvas = function createMeshCanvasClosure() {
  40203. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  40204. var coords = context.coords, colors = context.colors;
  40205. var bytes = data.data, rowSize = data.width * 4;
  40206. var tmp;
  40207. if (coords[p1 + 1] > coords[p2 + 1]) {
  40208. tmp = p1;
  40209. p1 = p2;
  40210. p2 = tmp;
  40211. tmp = c1;
  40212. c1 = c2;
  40213. c2 = tmp;
  40214. }
  40215. if (coords[p2 + 1] > coords[p3 + 1]) {
  40216. tmp = p2;
  40217. p2 = p3;
  40218. p3 = tmp;
  40219. tmp = c2;
  40220. c2 = c3;
  40221. c3 = tmp;
  40222. }
  40223. if (coords[p1 + 1] > coords[p2 + 1]) {
  40224. tmp = p1;
  40225. p1 = p2;
  40226. p2 = tmp;
  40227. tmp = c1;
  40228. c1 = c2;
  40229. c2 = tmp;
  40230. }
  40231. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  40232. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  40233. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  40234. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  40235. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  40236. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  40237. if (y1 >= y3) {
  40238. return;
  40239. }
  40240. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  40241. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  40242. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  40243. var minY = Math.round(y1), maxY = Math.round(y3);
  40244. var xa, car, cag, cab;
  40245. var xb, cbr, cbg, cbb;
  40246. var k;
  40247. for (var y = minY; y <= maxY; y++) {
  40248. if (y < y2) {
  40249. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  40250. xa = x1 - (x1 - x2) * k;
  40251. car = c1r - (c1r - c2r) * k;
  40252. cag = c1g - (c1g - c2g) * k;
  40253. cab = c1b - (c1b - c2b) * k;
  40254. } else {
  40255. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  40256. xa = x2 - (x2 - x3) * k;
  40257. car = c2r - (c2r - c3r) * k;
  40258. cag = c2g - (c2g - c3g) * k;
  40259. cab = c2b - (c2b - c3b) * k;
  40260. }
  40261. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  40262. xb = x1 - (x1 - x3) * k;
  40263. cbr = c1r - (c1r - c3r) * k;
  40264. cbg = c1g - (c1g - c3g) * k;
  40265. cbb = c1b - (c1b - c3b) * k;
  40266. var x1_ = Math.round(Math.min(xa, xb));
  40267. var x2_ = Math.round(Math.max(xa, xb));
  40268. var j = rowSize * y + x1_ * 4;
  40269. for (var x = x1_; x <= x2_; x++) {
  40270. k = (xa - x) / (xa - xb);
  40271. k = k < 0 ? 0 : k > 1 ? 1 : k;
  40272. bytes[j++] = car - (car - cbr) * k | 0;
  40273. bytes[j++] = cag - (cag - cbg) * k | 0;
  40274. bytes[j++] = cab - (cab - cbb) * k | 0;
  40275. bytes[j++] = 255;
  40276. }
  40277. }
  40278. }
  40279. function drawFigure(data, figure, context) {
  40280. var ps = figure.coords;
  40281. var cs = figure.colors;
  40282. var i, ii;
  40283. switch (figure.type) {
  40284. case 'lattice':
  40285. var verticesPerRow = figure.verticesPerRow;
  40286. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  40287. var cols = verticesPerRow - 1;
  40288. for (i = 0; i < rows; i++) {
  40289. var q = i * verticesPerRow;
  40290. for (var j = 0; j < cols; j++, q++) {
  40291. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  40292. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  40293. }
  40294. }
  40295. break;
  40296. case 'triangles':
  40297. for (i = 0, ii = ps.length; i < ii; i += 3) {
  40298. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  40299. }
  40300. break;
  40301. default:
  40302. error('illigal figure');
  40303. break;
  40304. }
  40305. }
  40306. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  40307. var EXPECTED_SCALE = 1.1;
  40308. var MAX_PATTERN_SIZE = 3000;
  40309. var BORDER_SIZE = 2;
  40310. var offsetX = Math.floor(bounds[0]);
  40311. var offsetY = Math.floor(bounds[1]);
  40312. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  40313. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  40314. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  40315. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  40316. var scaleX = boundsWidth / width;
  40317. var scaleY = boundsHeight / height;
  40318. var context = {
  40319. coords: coords,
  40320. colors: colors,
  40321. offsetX: -offsetX,
  40322. offsetY: -offsetY,
  40323. scaleX: 1 / scaleX,
  40324. scaleY: 1 / scaleY
  40325. };
  40326. var paddedWidth = width + BORDER_SIZE * 2;
  40327. var paddedHeight = height + BORDER_SIZE * 2;
  40328. var canvas, tmpCanvas, i, ii;
  40329. if (WebGLUtils.isEnabled) {
  40330. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  40331. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  40332. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  40333. canvas = tmpCanvas.canvas;
  40334. } else {
  40335. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  40336. var tmpCtx = tmpCanvas.context;
  40337. var data = tmpCtx.createImageData(width, height);
  40338. if (backgroundColor) {
  40339. var bytes = data.data;
  40340. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  40341. bytes[i] = backgroundColor[0];
  40342. bytes[i + 1] = backgroundColor[1];
  40343. bytes[i + 2] = backgroundColor[2];
  40344. bytes[i + 3] = 255;
  40345. }
  40346. }
  40347. for (i = 0; i < figures.length; i++) {
  40348. drawFigure(data, figures[i], context);
  40349. }
  40350. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  40351. canvas = tmpCanvas.canvas;
  40352. }
  40353. return {
  40354. canvas: canvas,
  40355. offsetX: offsetX - BORDER_SIZE * scaleX,
  40356. offsetY: offsetY - BORDER_SIZE * scaleY,
  40357. scaleX: scaleX,
  40358. scaleY: scaleY
  40359. };
  40360. }
  40361. return createMeshCanvas;
  40362. }();
  40363. ShadingIRs.Mesh = {
  40364. fromIR: function Mesh_fromIR(raw) {
  40365. var coords = raw[2];
  40366. var colors = raw[3];
  40367. var figures = raw[4];
  40368. var bounds = raw[5];
  40369. var matrix = raw[6];
  40370. var background = raw[8];
  40371. return {
  40372. type: 'Pattern',
  40373. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  40374. var scale;
  40375. if (shadingFill) {
  40376. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  40377. } else {
  40378. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  40379. if (matrix) {
  40380. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  40381. scale = [
  40382. scale[0] * matrixScale[0],
  40383. scale[1] * matrixScale[1]
  40384. ];
  40385. }
  40386. }
  40387. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  40388. if (!shadingFill) {
  40389. ctx.setTransform.apply(ctx, owner.baseTransform);
  40390. if (matrix) {
  40391. ctx.transform.apply(ctx, matrix);
  40392. }
  40393. }
  40394. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  40395. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  40396. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  40397. }
  40398. };
  40399. }
  40400. };
  40401. ShadingIRs.Dummy = {
  40402. fromIR: function Dummy_fromIR() {
  40403. return {
  40404. type: 'Pattern',
  40405. getPattern: function Dummy_fromIR_getPattern() {
  40406. return 'hotpink';
  40407. }
  40408. };
  40409. }
  40410. };
  40411. function getShadingPatternFromIR(raw) {
  40412. var shadingIR = ShadingIRs[raw[0]];
  40413. if (!shadingIR) {
  40414. error('Unknown IR type: ' + raw[0]);
  40415. }
  40416. return shadingIR.fromIR(raw);
  40417. }
  40418. var TilingPattern = function TilingPatternClosure() {
  40419. var PaintType = {
  40420. COLORED: 1,
  40421. UNCOLORED: 2
  40422. };
  40423. var MAX_PATTERN_SIZE = 3000;
  40424. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  40425. this.operatorList = IR[2];
  40426. this.matrix = IR[3] || [
  40427. 1,
  40428. 0,
  40429. 0,
  40430. 1,
  40431. 0,
  40432. 0
  40433. ];
  40434. this.bbox = IR[4];
  40435. this.xstep = IR[5];
  40436. this.ystep = IR[6];
  40437. this.paintType = IR[7];
  40438. this.tilingType = IR[8];
  40439. this.color = color;
  40440. this.canvasGraphicsFactory = canvasGraphicsFactory;
  40441. this.baseTransform = baseTransform;
  40442. this.type = 'Pattern';
  40443. this.ctx = ctx;
  40444. }
  40445. TilingPattern.prototype = {
  40446. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  40447. var operatorList = this.operatorList;
  40448. var bbox = this.bbox;
  40449. var xstep = this.xstep;
  40450. var ystep = this.ystep;
  40451. var paintType = this.paintType;
  40452. var tilingType = this.tilingType;
  40453. var color = this.color;
  40454. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  40455. info('TilingType: ' + tilingType);
  40456. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  40457. var topLeft = [
  40458. x0,
  40459. y0
  40460. ];
  40461. var botRight = [
  40462. x0 + xstep,
  40463. y0 + ystep
  40464. ];
  40465. var width = botRight[0] - topLeft[0];
  40466. var height = botRight[1] - topLeft[1];
  40467. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  40468. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  40469. var combinedScale = [
  40470. matrixScale[0] * curMatrixScale[0],
  40471. matrixScale[1] * curMatrixScale[1]
  40472. ];
  40473. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  40474. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  40475. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  40476. var tmpCtx = tmpCanvas.context;
  40477. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  40478. graphics.groupLevel = owner.groupLevel;
  40479. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  40480. this.setScale(width, height, xstep, ystep);
  40481. this.transformToScale(graphics);
  40482. var tmpTranslate = [
  40483. 1,
  40484. 0,
  40485. 0,
  40486. 1,
  40487. -topLeft[0],
  40488. -topLeft[1]
  40489. ];
  40490. graphics.transform.apply(graphics, tmpTranslate);
  40491. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  40492. graphics.executeOperatorList(operatorList);
  40493. return tmpCanvas.canvas;
  40494. },
  40495. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  40496. this.scale = [
  40497. width / xstep,
  40498. height / ystep
  40499. ];
  40500. },
  40501. transformToScale: function TilingPattern_transformToScale(graphics) {
  40502. var scale = this.scale;
  40503. var tmpScale = [
  40504. scale[0],
  40505. 0,
  40506. 0,
  40507. scale[1],
  40508. 0,
  40509. 0
  40510. ];
  40511. graphics.transform.apply(graphics, tmpScale);
  40512. },
  40513. scaleToContext: function TilingPattern_scaleToContext() {
  40514. var scale = this.scale;
  40515. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  40516. },
  40517. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  40518. if (bbox && isArray(bbox) && bbox.length === 4) {
  40519. var bboxWidth = x1 - x0;
  40520. var bboxHeight = y1 - y0;
  40521. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  40522. graphics.clip();
  40523. graphics.endPath();
  40524. }
  40525. },
  40526. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  40527. switch (paintType) {
  40528. case PaintType.COLORED:
  40529. var ctx = this.ctx;
  40530. context.fillStyle = ctx.fillStyle;
  40531. context.strokeStyle = ctx.strokeStyle;
  40532. break;
  40533. case PaintType.UNCOLORED:
  40534. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  40535. context.fillStyle = cssColor;
  40536. context.strokeStyle = cssColor;
  40537. break;
  40538. default:
  40539. error('Unsupported paint type: ' + paintType);
  40540. }
  40541. },
  40542. getPattern: function TilingPattern_getPattern(ctx, owner) {
  40543. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  40544. ctx = this.ctx;
  40545. ctx.setTransform.apply(ctx, this.baseTransform);
  40546. ctx.transform.apply(ctx, this.matrix);
  40547. this.scaleToContext();
  40548. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  40549. }
  40550. };
  40551. return TilingPattern;
  40552. }();
  40553. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  40554. exports.TilingPattern = TilingPattern;
  40555. }));
  40556. (function (root, factory) {
  40557. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  40558. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  40559. var Util = sharedUtil.Util;
  40560. var assert = sharedUtil.assert;
  40561. var warn = sharedUtil.warn;
  40562. var error = sharedUtil.error;
  40563. var isInt = sharedUtil.isInt;
  40564. var isString = sharedUtil.isString;
  40565. var MissingDataException = sharedUtil.MissingDataException;
  40566. var isEOF = corePrimitives.isEOF;
  40567. var isName = corePrimitives.isName;
  40568. var isCmd = corePrimitives.isCmd;
  40569. var isStream = corePrimitives.isStream;
  40570. var StringStream = coreStream.StringStream;
  40571. var Lexer = coreParser.Lexer;
  40572. var BUILT_IN_CMAPS = [
  40573. 'Adobe-GB1-UCS2',
  40574. 'Adobe-CNS1-UCS2',
  40575. 'Adobe-Japan1-UCS2',
  40576. 'Adobe-Korea1-UCS2',
  40577. '78-EUC-H',
  40578. '78-EUC-V',
  40579. '78-H',
  40580. '78-RKSJ-H',
  40581. '78-RKSJ-V',
  40582. '78-V',
  40583. '78ms-RKSJ-H',
  40584. '78ms-RKSJ-V',
  40585. '83pv-RKSJ-H',
  40586. '90ms-RKSJ-H',
  40587. '90ms-RKSJ-V',
  40588. '90msp-RKSJ-H',
  40589. '90msp-RKSJ-V',
  40590. '90pv-RKSJ-H',
  40591. '90pv-RKSJ-V',
  40592. 'Add-H',
  40593. 'Add-RKSJ-H',
  40594. 'Add-RKSJ-V',
  40595. 'Add-V',
  40596. 'Adobe-CNS1-0',
  40597. 'Adobe-CNS1-1',
  40598. 'Adobe-CNS1-2',
  40599. 'Adobe-CNS1-3',
  40600. 'Adobe-CNS1-4',
  40601. 'Adobe-CNS1-5',
  40602. 'Adobe-CNS1-6',
  40603. 'Adobe-GB1-0',
  40604. 'Adobe-GB1-1',
  40605. 'Adobe-GB1-2',
  40606. 'Adobe-GB1-3',
  40607. 'Adobe-GB1-4',
  40608. 'Adobe-GB1-5',
  40609. 'Adobe-Japan1-0',
  40610. 'Adobe-Japan1-1',
  40611. 'Adobe-Japan1-2',
  40612. 'Adobe-Japan1-3',
  40613. 'Adobe-Japan1-4',
  40614. 'Adobe-Japan1-5',
  40615. 'Adobe-Japan1-6',
  40616. 'Adobe-Korea1-0',
  40617. 'Adobe-Korea1-1',
  40618. 'Adobe-Korea1-2',
  40619. 'B5-H',
  40620. 'B5-V',
  40621. 'B5pc-H',
  40622. 'B5pc-V',
  40623. 'CNS-EUC-H',
  40624. 'CNS-EUC-V',
  40625. 'CNS1-H',
  40626. 'CNS1-V',
  40627. 'CNS2-H',
  40628. 'CNS2-V',
  40629. 'ETHK-B5-H',
  40630. 'ETHK-B5-V',
  40631. 'ETen-B5-H',
  40632. 'ETen-B5-V',
  40633. 'ETenms-B5-H',
  40634. 'ETenms-B5-V',
  40635. 'EUC-H',
  40636. 'EUC-V',
  40637. 'Ext-H',
  40638. 'Ext-RKSJ-H',
  40639. 'Ext-RKSJ-V',
  40640. 'Ext-V',
  40641. 'GB-EUC-H',
  40642. 'GB-EUC-V',
  40643. 'GB-H',
  40644. 'GB-V',
  40645. 'GBK-EUC-H',
  40646. 'GBK-EUC-V',
  40647. 'GBK2K-H',
  40648. 'GBK2K-V',
  40649. 'GBKp-EUC-H',
  40650. 'GBKp-EUC-V',
  40651. 'GBT-EUC-H',
  40652. 'GBT-EUC-V',
  40653. 'GBT-H',
  40654. 'GBT-V',
  40655. 'GBTpc-EUC-H',
  40656. 'GBTpc-EUC-V',
  40657. 'GBpc-EUC-H',
  40658. 'GBpc-EUC-V',
  40659. 'H',
  40660. 'HKdla-B5-H',
  40661. 'HKdla-B5-V',
  40662. 'HKdlb-B5-H',
  40663. 'HKdlb-B5-V',
  40664. 'HKgccs-B5-H',
  40665. 'HKgccs-B5-V',
  40666. 'HKm314-B5-H',
  40667. 'HKm314-B5-V',
  40668. 'HKm471-B5-H',
  40669. 'HKm471-B5-V',
  40670. 'HKscs-B5-H',
  40671. 'HKscs-B5-V',
  40672. 'Hankaku',
  40673. 'Hiragana',
  40674. 'KSC-EUC-H',
  40675. 'KSC-EUC-V',
  40676. 'KSC-H',
  40677. 'KSC-Johab-H',
  40678. 'KSC-Johab-V',
  40679. 'KSC-V',
  40680. 'KSCms-UHC-H',
  40681. 'KSCms-UHC-HW-H',
  40682. 'KSCms-UHC-HW-V',
  40683. 'KSCms-UHC-V',
  40684. 'KSCpc-EUC-H',
  40685. 'KSCpc-EUC-V',
  40686. 'Katakana',
  40687. 'NWP-H',
  40688. 'NWP-V',
  40689. 'RKSJ-H',
  40690. 'RKSJ-V',
  40691. 'Roman',
  40692. 'UniCNS-UCS2-H',
  40693. 'UniCNS-UCS2-V',
  40694. 'UniCNS-UTF16-H',
  40695. 'UniCNS-UTF16-V',
  40696. 'UniCNS-UTF32-H',
  40697. 'UniCNS-UTF32-V',
  40698. 'UniCNS-UTF8-H',
  40699. 'UniCNS-UTF8-V',
  40700. 'UniGB-UCS2-H',
  40701. 'UniGB-UCS2-V',
  40702. 'UniGB-UTF16-H',
  40703. 'UniGB-UTF16-V',
  40704. 'UniGB-UTF32-H',
  40705. 'UniGB-UTF32-V',
  40706. 'UniGB-UTF8-H',
  40707. 'UniGB-UTF8-V',
  40708. 'UniJIS-UCS2-H',
  40709. 'UniJIS-UCS2-HW-H',
  40710. 'UniJIS-UCS2-HW-V',
  40711. 'UniJIS-UCS2-V',
  40712. 'UniJIS-UTF16-H',
  40713. 'UniJIS-UTF16-V',
  40714. 'UniJIS-UTF32-H',
  40715. 'UniJIS-UTF32-V',
  40716. 'UniJIS-UTF8-H',
  40717. 'UniJIS-UTF8-V',
  40718. 'UniJIS2004-UTF16-H',
  40719. 'UniJIS2004-UTF16-V',
  40720. 'UniJIS2004-UTF32-H',
  40721. 'UniJIS2004-UTF32-V',
  40722. 'UniJIS2004-UTF8-H',
  40723. 'UniJIS2004-UTF8-V',
  40724. 'UniJISPro-UCS2-HW-V',
  40725. 'UniJISPro-UCS2-V',
  40726. 'UniJISPro-UTF8-V',
  40727. 'UniJISX0213-UTF32-H',
  40728. 'UniJISX0213-UTF32-V',
  40729. 'UniJISX02132004-UTF32-H',
  40730. 'UniJISX02132004-UTF32-V',
  40731. 'UniKS-UCS2-H',
  40732. 'UniKS-UCS2-V',
  40733. 'UniKS-UTF16-H',
  40734. 'UniKS-UTF16-V',
  40735. 'UniKS-UTF32-H',
  40736. 'UniKS-UTF32-V',
  40737. 'UniKS-UTF8-H',
  40738. 'UniKS-UTF8-V',
  40739. 'V',
  40740. 'WP-Symbol'
  40741. ];
  40742. var CMap = function CMapClosure() {
  40743. function CMap(builtInCMap) {
  40744. this.codespaceRanges = [
  40745. [],
  40746. [],
  40747. [],
  40748. []
  40749. ];
  40750. this.numCodespaceRanges = 0;
  40751. this._map = [];
  40752. this.name = '';
  40753. this.vertical = false;
  40754. this.useCMap = null;
  40755. this.builtInCMap = builtInCMap;
  40756. }
  40757. CMap.prototype = {
  40758. addCodespaceRange: function (n, low, high) {
  40759. this.codespaceRanges[n - 1].push(low, high);
  40760. this.numCodespaceRanges++;
  40761. },
  40762. mapCidRange: function (low, high, dstLow) {
  40763. while (low <= high) {
  40764. this._map[low++] = dstLow++;
  40765. }
  40766. },
  40767. mapBfRange: function (low, high, dstLow) {
  40768. var lastByte = dstLow.length - 1;
  40769. while (low <= high) {
  40770. this._map[low++] = dstLow;
  40771. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  40772. }
  40773. },
  40774. mapBfRangeToArray: function (low, high, array) {
  40775. var i = 0, ii = array.length;
  40776. while (low <= high && i < ii) {
  40777. this._map[low] = array[i++];
  40778. ++low;
  40779. }
  40780. },
  40781. mapOne: function (src, dst) {
  40782. this._map[src] = dst;
  40783. },
  40784. lookup: function (code) {
  40785. return this._map[code];
  40786. },
  40787. contains: function (code) {
  40788. return this._map[code] !== undefined;
  40789. },
  40790. forEach: function (callback) {
  40791. var map = this._map;
  40792. var length = map.length;
  40793. var i;
  40794. if (length <= 0x10000) {
  40795. for (i = 0; i < length; i++) {
  40796. if (map[i] !== undefined) {
  40797. callback(i, map[i]);
  40798. }
  40799. }
  40800. } else {
  40801. for (i in this._map) {
  40802. callback(i, map[i]);
  40803. }
  40804. }
  40805. },
  40806. charCodeOf: function (value) {
  40807. return this._map.indexOf(value);
  40808. },
  40809. getMap: function () {
  40810. return this._map;
  40811. },
  40812. readCharCode: function (str, offset, out) {
  40813. var c = 0;
  40814. var codespaceRanges = this.codespaceRanges;
  40815. var codespaceRangesLen = this.codespaceRanges.length;
  40816. for (var n = 0; n < codespaceRangesLen; n++) {
  40817. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  40818. var codespaceRange = codespaceRanges[n];
  40819. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  40820. var low = codespaceRange[k++];
  40821. var high = codespaceRange[k++];
  40822. if (c >= low && c <= high) {
  40823. out.charcode = c;
  40824. out.length = n + 1;
  40825. return;
  40826. }
  40827. }
  40828. }
  40829. out.charcode = 0;
  40830. out.length = 1;
  40831. },
  40832. get length() {
  40833. return this._map.length;
  40834. },
  40835. get isIdentityCMap() {
  40836. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  40837. return false;
  40838. }
  40839. if (this._map.length !== 0x10000) {
  40840. return false;
  40841. }
  40842. for (var i = 0; i < 0x10000; i++) {
  40843. if (this._map[i] !== i) {
  40844. return false;
  40845. }
  40846. }
  40847. return true;
  40848. }
  40849. };
  40850. return CMap;
  40851. }();
  40852. var IdentityCMap = function IdentityCMapClosure() {
  40853. function IdentityCMap(vertical, n) {
  40854. CMap.call(this);
  40855. this.vertical = vertical;
  40856. this.addCodespaceRange(n, 0, 0xffff);
  40857. }
  40858. Util.inherit(IdentityCMap, CMap, {});
  40859. IdentityCMap.prototype = {
  40860. addCodespaceRange: CMap.prototype.addCodespaceRange,
  40861. mapCidRange: function (low, high, dstLow) {
  40862. error('should not call mapCidRange');
  40863. },
  40864. mapBfRange: function (low, high, dstLow) {
  40865. error('should not call mapBfRange');
  40866. },
  40867. mapBfRangeToArray: function (low, high, array) {
  40868. error('should not call mapBfRangeToArray');
  40869. },
  40870. mapOne: function (src, dst) {
  40871. error('should not call mapCidOne');
  40872. },
  40873. lookup: function (code) {
  40874. return isInt(code) && code <= 0xffff ? code : undefined;
  40875. },
  40876. contains: function (code) {
  40877. return isInt(code) && code <= 0xffff;
  40878. },
  40879. forEach: function (callback) {
  40880. for (var i = 0; i <= 0xffff; i++) {
  40881. callback(i, i);
  40882. }
  40883. },
  40884. charCodeOf: function (value) {
  40885. return isInt(value) && value <= 0xffff ? value : -1;
  40886. },
  40887. getMap: function () {
  40888. var map = new Array(0x10000);
  40889. for (var i = 0; i <= 0xffff; i++) {
  40890. map[i] = i;
  40891. }
  40892. return map;
  40893. },
  40894. readCharCode: CMap.prototype.readCharCode,
  40895. get length() {
  40896. return 0x10000;
  40897. },
  40898. get isIdentityCMap() {
  40899. error('should not access .isIdentityCMap');
  40900. }
  40901. };
  40902. return IdentityCMap;
  40903. }();
  40904. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  40905. function fetchBinaryData(url) {
  40906. return new Promise(function (resolve, reject) {
  40907. var request = new XMLHttpRequest();
  40908. request.open('GET', url, true);
  40909. request.responseType = 'arraybuffer';
  40910. request.onreadystatechange = function () {
  40911. if (request.readyState === XMLHttpRequest.DONE) {
  40912. if (!request.response || request.status !== 200 && request.status !== 0) {
  40913. reject(new Error('Unable to get binary cMap at: ' + url));
  40914. } else {
  40915. resolve(new Uint8Array(request.response));
  40916. }
  40917. }
  40918. };
  40919. request.send(null);
  40920. });
  40921. }
  40922. function hexToInt(a, size) {
  40923. var n = 0;
  40924. for (var i = 0; i <= size; i++) {
  40925. n = n << 8 | a[i];
  40926. }
  40927. return n >>> 0;
  40928. }
  40929. function hexToStr(a, size) {
  40930. if (size === 1) {
  40931. return String.fromCharCode(a[0], a[1]);
  40932. }
  40933. if (size === 3) {
  40934. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  40935. }
  40936. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  40937. }
  40938. function addHex(a, b, size) {
  40939. var c = 0;
  40940. for (var i = size; i >= 0; i--) {
  40941. c += a[i] + b[i];
  40942. a[i] = c & 255;
  40943. c >>= 8;
  40944. }
  40945. }
  40946. function incHex(a, size) {
  40947. var c = 1;
  40948. for (var i = size; i >= 0 && c > 0; i--) {
  40949. c += a[i];
  40950. a[i] = c & 255;
  40951. c >>= 8;
  40952. }
  40953. }
  40954. var MAX_NUM_SIZE = 16;
  40955. var MAX_ENCODED_NUM_SIZE = 19;
  40956. function BinaryCMapStream(data) {
  40957. this.buffer = data;
  40958. this.pos = 0;
  40959. this.end = data.length;
  40960. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  40961. }
  40962. BinaryCMapStream.prototype = {
  40963. readByte: function () {
  40964. if (this.pos >= this.end) {
  40965. return -1;
  40966. }
  40967. return this.buffer[this.pos++];
  40968. },
  40969. readNumber: function () {
  40970. var n = 0;
  40971. var last;
  40972. do {
  40973. var b = this.readByte();
  40974. if (b < 0) {
  40975. error('unexpected EOF in bcmap');
  40976. }
  40977. last = !(b & 0x80);
  40978. n = n << 7 | b & 0x7F;
  40979. } while (!last);
  40980. return n;
  40981. },
  40982. readSigned: function () {
  40983. var n = this.readNumber();
  40984. return n & 1 ? ~(n >>> 1) : n >>> 1;
  40985. },
  40986. readHex: function (num, size) {
  40987. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  40988. this.pos += size + 1;
  40989. },
  40990. readHexNumber: function (num, size) {
  40991. var last;
  40992. var stack = this.tmpBuf, sp = 0;
  40993. do {
  40994. var b = this.readByte();
  40995. if (b < 0) {
  40996. error('unexpected EOF in bcmap');
  40997. }
  40998. last = !(b & 0x80);
  40999. stack[sp++] = b & 0x7F;
  41000. } while (!last);
  41001. var i = size, buffer = 0, bufferSize = 0;
  41002. while (i >= 0) {
  41003. while (bufferSize < 8 && stack.length > 0) {
  41004. buffer = stack[--sp] << bufferSize | buffer;
  41005. bufferSize += 7;
  41006. }
  41007. num[i] = buffer & 255;
  41008. i--;
  41009. buffer >>= 8;
  41010. bufferSize -= 8;
  41011. }
  41012. },
  41013. readHexSigned: function (num, size) {
  41014. this.readHexNumber(num, size);
  41015. var sign = num[size] & 1 ? 255 : 0;
  41016. var c = 0;
  41017. for (var i = 0; i <= size; i++) {
  41018. c = (c & 1) << 8 | num[i];
  41019. num[i] = c >> 1 ^ sign;
  41020. }
  41021. },
  41022. readString: function () {
  41023. var len = this.readNumber();
  41024. var s = '';
  41025. for (var i = 0; i < len; i++) {
  41026. s += String.fromCharCode(this.readNumber());
  41027. }
  41028. return s;
  41029. }
  41030. };
  41031. function processBinaryCMap(url, cMap, extend) {
  41032. return fetchBinaryData(url).then(function (data) {
  41033. var stream = new BinaryCMapStream(data);
  41034. var header = stream.readByte();
  41035. cMap.vertical = !!(header & 1);
  41036. var useCMap = null;
  41037. var start = new Uint8Array(MAX_NUM_SIZE);
  41038. var end = new Uint8Array(MAX_NUM_SIZE);
  41039. var char = new Uint8Array(MAX_NUM_SIZE);
  41040. var charCode = new Uint8Array(MAX_NUM_SIZE);
  41041. var tmp = new Uint8Array(MAX_NUM_SIZE);
  41042. var code;
  41043. var b;
  41044. while ((b = stream.readByte()) >= 0) {
  41045. var type = b >> 5;
  41046. if (type === 7) {
  41047. switch (b & 0x1F) {
  41048. case 0:
  41049. stream.readString();
  41050. break;
  41051. case 1:
  41052. useCMap = stream.readString();
  41053. break;
  41054. }
  41055. continue;
  41056. }
  41057. var sequence = !!(b & 0x10);
  41058. var dataSize = b & 15;
  41059. assert(dataSize + 1 <= MAX_NUM_SIZE);
  41060. var ucs2DataSize = 1;
  41061. var subitemsCount = stream.readNumber();
  41062. var i;
  41063. switch (type) {
  41064. case 0:
  41065. stream.readHex(start, dataSize);
  41066. stream.readHexNumber(end, dataSize);
  41067. addHex(end, start, dataSize);
  41068. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41069. for (i = 1; i < subitemsCount; i++) {
  41070. incHex(end, dataSize);
  41071. stream.readHexNumber(start, dataSize);
  41072. addHex(start, end, dataSize);
  41073. stream.readHexNumber(end, dataSize);
  41074. addHex(end, start, dataSize);
  41075. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  41076. }
  41077. break;
  41078. case 1:
  41079. stream.readHex(start, dataSize);
  41080. stream.readHexNumber(end, dataSize);
  41081. addHex(end, start, dataSize);
  41082. code = stream.readNumber();
  41083. for (i = 1; i < subitemsCount; i++) {
  41084. incHex(end, dataSize);
  41085. stream.readHexNumber(start, dataSize);
  41086. addHex(start, end, dataSize);
  41087. stream.readHexNumber(end, dataSize);
  41088. addHex(end, start, dataSize);
  41089. code = stream.readNumber();
  41090. }
  41091. break;
  41092. case 2:
  41093. stream.readHex(char, dataSize);
  41094. code = stream.readNumber();
  41095. cMap.mapOne(hexToInt(char, dataSize), code);
  41096. for (i = 1; i < subitemsCount; i++) {
  41097. incHex(char, dataSize);
  41098. if (!sequence) {
  41099. stream.readHexNumber(tmp, dataSize);
  41100. addHex(char, tmp, dataSize);
  41101. }
  41102. code = stream.readSigned() + (code + 1);
  41103. cMap.mapOne(hexToInt(char, dataSize), code);
  41104. }
  41105. break;
  41106. case 3:
  41107. stream.readHex(start, dataSize);
  41108. stream.readHexNumber(end, dataSize);
  41109. addHex(end, start, dataSize);
  41110. code = stream.readNumber();
  41111. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41112. for (i = 1; i < subitemsCount; i++) {
  41113. incHex(end, dataSize);
  41114. if (!sequence) {
  41115. stream.readHexNumber(start, dataSize);
  41116. addHex(start, end, dataSize);
  41117. } else {
  41118. start.set(end);
  41119. }
  41120. stream.readHexNumber(end, dataSize);
  41121. addHex(end, start, dataSize);
  41122. code = stream.readNumber();
  41123. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  41124. }
  41125. break;
  41126. case 4:
  41127. stream.readHex(char, ucs2DataSize);
  41128. stream.readHex(charCode, dataSize);
  41129. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41130. for (i = 1; i < subitemsCount; i++) {
  41131. incHex(char, ucs2DataSize);
  41132. if (!sequence) {
  41133. stream.readHexNumber(tmp, ucs2DataSize);
  41134. addHex(char, tmp, ucs2DataSize);
  41135. }
  41136. incHex(charCode, dataSize);
  41137. stream.readHexSigned(tmp, dataSize);
  41138. addHex(charCode, tmp, dataSize);
  41139. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  41140. }
  41141. break;
  41142. case 5:
  41143. stream.readHex(start, ucs2DataSize);
  41144. stream.readHexNumber(end, ucs2DataSize);
  41145. addHex(end, start, ucs2DataSize);
  41146. stream.readHex(charCode, dataSize);
  41147. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41148. for (i = 1; i < subitemsCount; i++) {
  41149. incHex(end, ucs2DataSize);
  41150. if (!sequence) {
  41151. stream.readHexNumber(start, ucs2DataSize);
  41152. addHex(start, end, ucs2DataSize);
  41153. } else {
  41154. start.set(end);
  41155. }
  41156. stream.readHexNumber(end, ucs2DataSize);
  41157. addHex(end, start, ucs2DataSize);
  41158. stream.readHex(charCode, dataSize);
  41159. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  41160. }
  41161. break;
  41162. default:
  41163. error('Unknown type: ' + type);
  41164. break;
  41165. }
  41166. }
  41167. if (useCMap) {
  41168. return extend(useCMap);
  41169. }
  41170. return cMap;
  41171. });
  41172. }
  41173. function BinaryCMapReader() {
  41174. }
  41175. BinaryCMapReader.prototype = { read: processBinaryCMap };
  41176. return BinaryCMapReader;
  41177. }();
  41178. var CMapFactory = function CMapFactoryClosure() {
  41179. function strToInt(str) {
  41180. var a = 0;
  41181. for (var i = 0; i < str.length; i++) {
  41182. a = a << 8 | str.charCodeAt(i);
  41183. }
  41184. return a >>> 0;
  41185. }
  41186. function expectString(obj) {
  41187. if (!isString(obj)) {
  41188. error('Malformed CMap: expected string.');
  41189. }
  41190. }
  41191. function expectInt(obj) {
  41192. if (!isInt(obj)) {
  41193. error('Malformed CMap: expected int.');
  41194. }
  41195. }
  41196. function parseBfChar(cMap, lexer) {
  41197. while (true) {
  41198. var obj = lexer.getObj();
  41199. if (isEOF(obj)) {
  41200. break;
  41201. }
  41202. if (isCmd(obj, 'endbfchar')) {
  41203. return;
  41204. }
  41205. expectString(obj);
  41206. var src = strToInt(obj);
  41207. obj = lexer.getObj();
  41208. expectString(obj);
  41209. var dst = obj;
  41210. cMap.mapOne(src, dst);
  41211. }
  41212. }
  41213. function parseBfRange(cMap, lexer) {
  41214. while (true) {
  41215. var obj = lexer.getObj();
  41216. if (isEOF(obj)) {
  41217. break;
  41218. }
  41219. if (isCmd(obj, 'endbfrange')) {
  41220. return;
  41221. }
  41222. expectString(obj);
  41223. var low = strToInt(obj);
  41224. obj = lexer.getObj();
  41225. expectString(obj);
  41226. var high = strToInt(obj);
  41227. obj = lexer.getObj();
  41228. if (isInt(obj) || isString(obj)) {
  41229. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  41230. cMap.mapBfRange(low, high, dstLow);
  41231. } else if (isCmd(obj, '[')) {
  41232. obj = lexer.getObj();
  41233. var array = [];
  41234. while (!isCmd(obj, ']') && !isEOF(obj)) {
  41235. array.push(obj);
  41236. obj = lexer.getObj();
  41237. }
  41238. cMap.mapBfRangeToArray(low, high, array);
  41239. } else {
  41240. break;
  41241. }
  41242. }
  41243. error('Invalid bf range.');
  41244. }
  41245. function parseCidChar(cMap, lexer) {
  41246. while (true) {
  41247. var obj = lexer.getObj();
  41248. if (isEOF(obj)) {
  41249. break;
  41250. }
  41251. if (isCmd(obj, 'endcidchar')) {
  41252. return;
  41253. }
  41254. expectString(obj);
  41255. var src = strToInt(obj);
  41256. obj = lexer.getObj();
  41257. expectInt(obj);
  41258. var dst = obj;
  41259. cMap.mapOne(src, dst);
  41260. }
  41261. }
  41262. function parseCidRange(cMap, lexer) {
  41263. while (true) {
  41264. var obj = lexer.getObj();
  41265. if (isEOF(obj)) {
  41266. break;
  41267. }
  41268. if (isCmd(obj, 'endcidrange')) {
  41269. return;
  41270. }
  41271. expectString(obj);
  41272. var low = strToInt(obj);
  41273. obj = lexer.getObj();
  41274. expectString(obj);
  41275. var high = strToInt(obj);
  41276. obj = lexer.getObj();
  41277. expectInt(obj);
  41278. var dstLow = obj;
  41279. cMap.mapCidRange(low, high, dstLow);
  41280. }
  41281. }
  41282. function parseCodespaceRange(cMap, lexer) {
  41283. while (true) {
  41284. var obj = lexer.getObj();
  41285. if (isEOF(obj)) {
  41286. break;
  41287. }
  41288. if (isCmd(obj, 'endcodespacerange')) {
  41289. return;
  41290. }
  41291. if (!isString(obj)) {
  41292. break;
  41293. }
  41294. var low = strToInt(obj);
  41295. obj = lexer.getObj();
  41296. if (!isString(obj)) {
  41297. break;
  41298. }
  41299. var high = strToInt(obj);
  41300. cMap.addCodespaceRange(obj.length, low, high);
  41301. }
  41302. error('Invalid codespace range.');
  41303. }
  41304. function parseWMode(cMap, lexer) {
  41305. var obj = lexer.getObj();
  41306. if (isInt(obj)) {
  41307. cMap.vertical = !!obj;
  41308. }
  41309. }
  41310. function parseCMapName(cMap, lexer) {
  41311. var obj = lexer.getObj();
  41312. if (isName(obj) && isString(obj.name)) {
  41313. cMap.name = obj.name;
  41314. }
  41315. }
  41316. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  41317. var previous;
  41318. var embededUseCMap;
  41319. objLoop:
  41320. while (true) {
  41321. try {
  41322. var obj = lexer.getObj();
  41323. if (isEOF(obj)) {
  41324. break;
  41325. } else if (isName(obj)) {
  41326. if (obj.name === 'WMode') {
  41327. parseWMode(cMap, lexer);
  41328. } else if (obj.name === 'CMapName') {
  41329. parseCMapName(cMap, lexer);
  41330. }
  41331. previous = obj;
  41332. } else if (isCmd(obj)) {
  41333. switch (obj.cmd) {
  41334. case 'endcmap':
  41335. break objLoop;
  41336. case 'usecmap':
  41337. if (isName(previous)) {
  41338. embededUseCMap = previous.name;
  41339. }
  41340. break;
  41341. case 'begincodespacerange':
  41342. parseCodespaceRange(cMap, lexer);
  41343. break;
  41344. case 'beginbfchar':
  41345. parseBfChar(cMap, lexer);
  41346. break;
  41347. case 'begincidchar':
  41348. parseCidChar(cMap, lexer);
  41349. break;
  41350. case 'beginbfrange':
  41351. parseBfRange(cMap, lexer);
  41352. break;
  41353. case 'begincidrange':
  41354. parseCidRange(cMap, lexer);
  41355. break;
  41356. }
  41357. }
  41358. } catch (ex) {
  41359. if (ex instanceof MissingDataException) {
  41360. throw ex;
  41361. }
  41362. warn('Invalid cMap data: ' + ex);
  41363. continue;
  41364. }
  41365. }
  41366. if (!useCMap && embededUseCMap) {
  41367. useCMap = embededUseCMap;
  41368. }
  41369. if (useCMap) {
  41370. return extendCMap(cMap, builtInCMapParams, useCMap);
  41371. }
  41372. return Promise.resolve(cMap);
  41373. }
  41374. function extendCMap(cMap, builtInCMapParams, useCMap) {
  41375. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  41376. cMap.useCMap = newCMap;
  41377. if (cMap.numCodespaceRanges === 0) {
  41378. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  41379. for (var i = 0; i < useCodespaceRanges.length; i++) {
  41380. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  41381. }
  41382. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  41383. }
  41384. cMap.useCMap.forEach(function (key, value) {
  41385. if (!cMap.contains(key)) {
  41386. cMap.mapOne(key, cMap.useCMap.lookup(key));
  41387. }
  41388. });
  41389. return cMap;
  41390. });
  41391. }
  41392. function parseBinaryCMap(name, builtInCMapParams) {
  41393. var url = builtInCMapParams.url + name + '.bcmap';
  41394. var cMap = new CMap(true);
  41395. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  41396. return extendCMap(cMap, builtInCMapParams, useCMap);
  41397. });
  41398. }
  41399. function createBuiltInCMap(name, builtInCMapParams) {
  41400. if (name === 'Identity-H') {
  41401. return Promise.resolve(new IdentityCMap(false, 2));
  41402. } else if (name === 'Identity-V') {
  41403. return Promise.resolve(new IdentityCMap(true, 2));
  41404. }
  41405. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  41406. return Promise.reject(new Error('Unknown cMap name: ' + name));
  41407. }
  41408. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  41409. if (builtInCMapParams.packed) {
  41410. return parseBinaryCMap(name, builtInCMapParams);
  41411. }
  41412. return new Promise(function (resolve, reject) {
  41413. var url = builtInCMapParams.url + name;
  41414. var request = new XMLHttpRequest();
  41415. request.onreadystatechange = function () {
  41416. if (request.readyState === XMLHttpRequest.DONE) {
  41417. if (request.status === 200 || request.status === 0) {
  41418. var cMap = new CMap(true);
  41419. var lexer = new Lexer(new StringStream(request.responseText));
  41420. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  41421. resolve(parsedCMap);
  41422. });
  41423. } else {
  41424. reject(new Error('Unable to get cMap at: ' + url));
  41425. }
  41426. }
  41427. };
  41428. request.open('GET', url, true);
  41429. request.send(null);
  41430. });
  41431. }
  41432. return {
  41433. create: function (encoding, builtInCMapParams, useCMap) {
  41434. if (isName(encoding)) {
  41435. return createBuiltInCMap(encoding.name, builtInCMapParams);
  41436. } else if (isStream(encoding)) {
  41437. var cMap = new CMap();
  41438. var lexer = new Lexer(encoding);
  41439. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  41440. if (parsedCMap.isIdentityCMap) {
  41441. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  41442. }
  41443. return parsedCMap;
  41444. });
  41445. }
  41446. return Promise.reject(new Error('Encoding required.'));
  41447. }
  41448. };
  41449. }();
  41450. exports.CMap = CMap;
  41451. exports.CMapFactory = CMapFactory;
  41452. exports.IdentityCMap = IdentityCMap;
  41453. }));
  41454. (function (root, factory) {
  41455. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  41456. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  41457. var error = sharedUtil.error;
  41458. var info = sharedUtil.info;
  41459. var isArray = sharedUtil.isArray;
  41460. var isString = sharedUtil.isString;
  41461. var shadow = sharedUtil.shadow;
  41462. var warn = sharedUtil.warn;
  41463. var isDict = corePrimitives.isDict;
  41464. var isName = corePrimitives.isName;
  41465. var isStream = corePrimitives.isStream;
  41466. var PDFFunction = coreFunction.PDFFunction;
  41467. var ColorSpace = function ColorSpaceClosure() {
  41468. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  41469. var COMPONENTS = 3;
  41470. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  41471. var xRatio = w1 / w2;
  41472. var yRatio = h1 / h2;
  41473. var i, j, py, newIndex = 0, oldIndex;
  41474. var xScaled = new Uint16Array(w2);
  41475. var w1Scanline = w1 * COMPONENTS;
  41476. for (i = 0; i < w2; i++) {
  41477. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  41478. }
  41479. for (i = 0; i < h2; i++) {
  41480. py = Math.floor(i * yRatio) * w1Scanline;
  41481. for (j = 0; j < w2; j++) {
  41482. oldIndex = py + xScaled[j];
  41483. dest[newIndex++] = src[oldIndex++];
  41484. dest[newIndex++] = src[oldIndex++];
  41485. dest[newIndex++] = src[oldIndex++];
  41486. newIndex += alpha01;
  41487. }
  41488. }
  41489. }
  41490. function ColorSpace() {
  41491. error('should not call ColorSpace constructor');
  41492. }
  41493. ColorSpace.prototype = {
  41494. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  41495. var rgb = new Uint8Array(3);
  41496. this.getRgbItem(src, srcOffset, rgb, 0);
  41497. return rgb;
  41498. },
  41499. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  41500. error('Should not call ColorSpace.getRgbItem');
  41501. },
  41502. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41503. error('Should not call ColorSpace.getRgbBuffer');
  41504. },
  41505. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  41506. error('Should not call ColorSpace.getOutputLength');
  41507. },
  41508. isPassthrough: function ColorSpace_isPassthrough(bits) {
  41509. return false;
  41510. },
  41511. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  41512. var count = originalWidth * originalHeight;
  41513. var rgbBuf = null;
  41514. var numComponentColors = 1 << bpc;
  41515. var needsResizing = originalHeight !== height || originalWidth !== width;
  41516. var i, ii;
  41517. if (this.isPassthrough(bpc)) {
  41518. rgbBuf = comps;
  41519. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  41520. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  41521. var key;
  41522. for (i = 0; i < numComponentColors; i++) {
  41523. allColors[i] = i;
  41524. }
  41525. var colorMap = new Uint8Array(numComponentColors * 3);
  41526. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  41527. var destPos, rgbPos;
  41528. if (!needsResizing) {
  41529. destPos = 0;
  41530. for (i = 0; i < count; ++i) {
  41531. key = comps[i] * 3;
  41532. dest[destPos++] = colorMap[key];
  41533. dest[destPos++] = colorMap[key + 1];
  41534. dest[destPos++] = colorMap[key + 2];
  41535. destPos += alpha01;
  41536. }
  41537. } else {
  41538. rgbBuf = new Uint8Array(count * 3);
  41539. rgbPos = 0;
  41540. for (i = 0; i < count; ++i) {
  41541. key = comps[i] * 3;
  41542. rgbBuf[rgbPos++] = colorMap[key];
  41543. rgbBuf[rgbPos++] = colorMap[key + 1];
  41544. rgbBuf[rgbPos++] = colorMap[key + 2];
  41545. }
  41546. }
  41547. } else {
  41548. if (!needsResizing) {
  41549. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  41550. } else {
  41551. rgbBuf = new Uint8Array(count * 3);
  41552. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  41553. }
  41554. }
  41555. if (rgbBuf) {
  41556. if (needsResizing) {
  41557. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  41558. } else {
  41559. rgbPos = 0;
  41560. destPos = 0;
  41561. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  41562. dest[destPos++] = rgbBuf[rgbPos++];
  41563. dest[destPos++] = rgbBuf[rgbPos++];
  41564. dest[destPos++] = rgbBuf[rgbPos++];
  41565. destPos += alpha01;
  41566. }
  41567. }
  41568. }
  41569. },
  41570. usesZeroToOneRange: true
  41571. };
  41572. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  41573. var IR = ColorSpace.parseToIR(cs, xref, res);
  41574. if (IR instanceof AlternateCS) {
  41575. return IR;
  41576. }
  41577. return ColorSpace.fromIR(IR);
  41578. };
  41579. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  41580. var name = isArray(IR) ? IR[0] : IR;
  41581. var whitePoint, blackPoint, gamma;
  41582. switch (name) {
  41583. case 'DeviceGrayCS':
  41584. return this.singletons.gray;
  41585. case 'DeviceRgbCS':
  41586. return this.singletons.rgb;
  41587. case 'DeviceCmykCS':
  41588. return this.singletons.cmyk;
  41589. case 'CalGrayCS':
  41590. whitePoint = IR[1];
  41591. blackPoint = IR[2];
  41592. gamma = IR[3];
  41593. return new CalGrayCS(whitePoint, blackPoint, gamma);
  41594. case 'CalRGBCS':
  41595. whitePoint = IR[1];
  41596. blackPoint = IR[2];
  41597. gamma = IR[3];
  41598. var matrix = IR[4];
  41599. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  41600. case 'PatternCS':
  41601. var basePatternCS = IR[1];
  41602. if (basePatternCS) {
  41603. basePatternCS = ColorSpace.fromIR(basePatternCS);
  41604. }
  41605. return new PatternCS(basePatternCS);
  41606. case 'IndexedCS':
  41607. var baseIndexedCS = IR[1];
  41608. var hiVal = IR[2];
  41609. var lookup = IR[3];
  41610. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  41611. case 'AlternateCS':
  41612. var numComps = IR[1];
  41613. var alt = IR[2];
  41614. var tintFnIR = IR[3];
  41615. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  41616. case 'LabCS':
  41617. whitePoint = IR[1];
  41618. blackPoint = IR[2];
  41619. var range = IR[3];
  41620. return new LabCS(whitePoint, blackPoint, range);
  41621. default:
  41622. error('Unknown name ' + name);
  41623. }
  41624. return null;
  41625. };
  41626. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  41627. if (isName(cs)) {
  41628. var colorSpaces = res.get('ColorSpace');
  41629. if (isDict(colorSpaces)) {
  41630. var refcs = colorSpaces.get(cs.name);
  41631. if (refcs) {
  41632. cs = refcs;
  41633. }
  41634. }
  41635. }
  41636. cs = xref.fetchIfRef(cs);
  41637. if (isName(cs)) {
  41638. switch (cs.name) {
  41639. case 'DeviceGray':
  41640. case 'G':
  41641. return 'DeviceGrayCS';
  41642. case 'DeviceRGB':
  41643. case 'RGB':
  41644. return 'DeviceRgbCS';
  41645. case 'DeviceCMYK':
  41646. case 'CMYK':
  41647. return 'DeviceCmykCS';
  41648. case 'Pattern':
  41649. return [
  41650. 'PatternCS',
  41651. null
  41652. ];
  41653. default:
  41654. error('unrecognized colorspace ' + cs.name);
  41655. }
  41656. } else if (isArray(cs)) {
  41657. var mode = xref.fetchIfRef(cs[0]).name;
  41658. var numComps, params, alt, whitePoint, blackPoint, gamma;
  41659. switch (mode) {
  41660. case 'DeviceGray':
  41661. case 'G':
  41662. return 'DeviceGrayCS';
  41663. case 'DeviceRGB':
  41664. case 'RGB':
  41665. return 'DeviceRgbCS';
  41666. case 'DeviceCMYK':
  41667. case 'CMYK':
  41668. return 'DeviceCmykCS';
  41669. case 'CalGray':
  41670. params = xref.fetchIfRef(cs[1]);
  41671. whitePoint = params.getArray('WhitePoint');
  41672. blackPoint = params.getArray('BlackPoint');
  41673. gamma = params.get('Gamma');
  41674. return [
  41675. 'CalGrayCS',
  41676. whitePoint,
  41677. blackPoint,
  41678. gamma
  41679. ];
  41680. case 'CalRGB':
  41681. params = xref.fetchIfRef(cs[1]);
  41682. whitePoint = params.getArray('WhitePoint');
  41683. blackPoint = params.getArray('BlackPoint');
  41684. gamma = params.getArray('Gamma');
  41685. var matrix = params.getArray('Matrix');
  41686. return [
  41687. 'CalRGBCS',
  41688. whitePoint,
  41689. blackPoint,
  41690. gamma,
  41691. matrix
  41692. ];
  41693. case 'ICCBased':
  41694. var stream = xref.fetchIfRef(cs[1]);
  41695. var dict = stream.dict;
  41696. numComps = dict.get('N');
  41697. alt = dict.get('Alternate');
  41698. if (alt) {
  41699. var altIR = ColorSpace.parseToIR(alt, xref, res);
  41700. var altCS = ColorSpace.fromIR(altIR);
  41701. if (altCS.numComps === numComps) {
  41702. return altIR;
  41703. }
  41704. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  41705. }
  41706. if (numComps === 1) {
  41707. return 'DeviceGrayCS';
  41708. } else if (numComps === 3) {
  41709. return 'DeviceRgbCS';
  41710. } else if (numComps === 4) {
  41711. return 'DeviceCmykCS';
  41712. }
  41713. break;
  41714. case 'Pattern':
  41715. var basePatternCS = cs[1] || null;
  41716. if (basePatternCS) {
  41717. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  41718. }
  41719. return [
  41720. 'PatternCS',
  41721. basePatternCS
  41722. ];
  41723. case 'Indexed':
  41724. case 'I':
  41725. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  41726. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  41727. var lookup = xref.fetchIfRef(cs[3]);
  41728. if (isStream(lookup)) {
  41729. lookup = lookup.getBytes();
  41730. }
  41731. return [
  41732. 'IndexedCS',
  41733. baseIndexedCS,
  41734. hiVal,
  41735. lookup
  41736. ];
  41737. case 'Separation':
  41738. case 'DeviceN':
  41739. var name = xref.fetchIfRef(cs[1]);
  41740. numComps = isArray(name) ? name.length : 1;
  41741. alt = ColorSpace.parseToIR(cs[2], xref, res);
  41742. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  41743. return [
  41744. 'AlternateCS',
  41745. numComps,
  41746. alt,
  41747. tintFnIR
  41748. ];
  41749. case 'Lab':
  41750. params = xref.fetchIfRef(cs[1]);
  41751. whitePoint = params.getArray('WhitePoint');
  41752. blackPoint = params.getArray('BlackPoint');
  41753. var range = params.getArray('Range');
  41754. return [
  41755. 'LabCS',
  41756. whitePoint,
  41757. blackPoint,
  41758. range
  41759. ];
  41760. default:
  41761. error('unimplemented color space object "' + mode + '"');
  41762. }
  41763. } else {
  41764. error('unrecognized color space object: "' + cs + '"');
  41765. }
  41766. return null;
  41767. };
  41768. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  41769. if (!isArray(decode)) {
  41770. return true;
  41771. }
  41772. if (n * 2 !== decode.length) {
  41773. warn('The decode map is not the correct length');
  41774. return true;
  41775. }
  41776. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  41777. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  41778. return false;
  41779. }
  41780. }
  41781. return true;
  41782. };
  41783. ColorSpace.singletons = {
  41784. get gray() {
  41785. return shadow(this, 'gray', new DeviceGrayCS());
  41786. },
  41787. get rgb() {
  41788. return shadow(this, 'rgb', new DeviceRgbCS());
  41789. },
  41790. get cmyk() {
  41791. return shadow(this, 'cmyk', new DeviceCmykCS());
  41792. }
  41793. };
  41794. return ColorSpace;
  41795. }();
  41796. var AlternateCS = function AlternateCSClosure() {
  41797. function AlternateCS(numComps, base, tintFn) {
  41798. this.name = 'Alternate';
  41799. this.numComps = numComps;
  41800. this.defaultColor = new Float32Array(numComps);
  41801. for (var i = 0; i < numComps; ++i) {
  41802. this.defaultColor[i] = 1;
  41803. }
  41804. this.base = base;
  41805. this.tintFn = tintFn;
  41806. this.tmpBuf = new Float32Array(base.numComps);
  41807. }
  41808. AlternateCS.prototype = {
  41809. getRgb: ColorSpace.prototype.getRgb,
  41810. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41811. var tmpBuf = this.tmpBuf;
  41812. this.tintFn(src, srcOffset, tmpBuf, 0);
  41813. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  41814. },
  41815. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41816. var tintFn = this.tintFn;
  41817. var base = this.base;
  41818. var scale = 1 / ((1 << bits) - 1);
  41819. var baseNumComps = base.numComps;
  41820. var usesZeroToOneRange = base.usesZeroToOneRange;
  41821. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  41822. var pos = isPassthrough ? destOffset : 0;
  41823. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  41824. var numComps = this.numComps;
  41825. var scaled = new Float32Array(numComps);
  41826. var tinted = new Float32Array(baseNumComps);
  41827. var i, j;
  41828. for (i = 0; i < count; i++) {
  41829. for (j = 0; j < numComps; j++) {
  41830. scaled[j] = src[srcOffset++] * scale;
  41831. }
  41832. tintFn(scaled, 0, tinted, 0);
  41833. if (usesZeroToOneRange) {
  41834. for (j = 0; j < baseNumComps; j++) {
  41835. baseBuf[pos++] = tinted[j] * 255;
  41836. }
  41837. } else {
  41838. base.getRgbItem(tinted, 0, baseBuf, pos);
  41839. pos += baseNumComps;
  41840. }
  41841. }
  41842. if (!isPassthrough) {
  41843. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  41844. }
  41845. },
  41846. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  41847. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  41848. },
  41849. isPassthrough: ColorSpace.prototype.isPassthrough,
  41850. fillRgb: ColorSpace.prototype.fillRgb,
  41851. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  41852. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41853. },
  41854. usesZeroToOneRange: true
  41855. };
  41856. return AlternateCS;
  41857. }();
  41858. var PatternCS = function PatternCSClosure() {
  41859. function PatternCS(baseCS) {
  41860. this.name = 'Pattern';
  41861. this.base = baseCS;
  41862. }
  41863. PatternCS.prototype = {};
  41864. return PatternCS;
  41865. }();
  41866. var IndexedCS = function IndexedCSClosure() {
  41867. function IndexedCS(base, highVal, lookup) {
  41868. this.name = 'Indexed';
  41869. this.numComps = 1;
  41870. this.defaultColor = new Uint8Array(this.numComps);
  41871. this.base = base;
  41872. this.highVal = highVal;
  41873. var baseNumComps = base.numComps;
  41874. var length = baseNumComps * highVal;
  41875. if (isStream(lookup)) {
  41876. this.lookup = new Uint8Array(length);
  41877. var bytes = lookup.getBytes(length);
  41878. this.lookup.set(bytes);
  41879. } else if (isString(lookup)) {
  41880. this.lookup = new Uint8Array(length);
  41881. for (var i = 0; i < length; ++i) {
  41882. this.lookup[i] = lookup.charCodeAt(i);
  41883. }
  41884. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  41885. this.lookup = lookup;
  41886. } else {
  41887. error('Unrecognized lookup table: ' + lookup);
  41888. }
  41889. }
  41890. IndexedCS.prototype = {
  41891. getRgb: ColorSpace.prototype.getRgb,
  41892. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41893. var numComps = this.base.numComps;
  41894. var start = src[srcOffset] * numComps;
  41895. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  41896. },
  41897. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41898. var base = this.base;
  41899. var numComps = base.numComps;
  41900. var outputDelta = base.getOutputLength(numComps, alpha01);
  41901. var lookup = this.lookup;
  41902. for (var i = 0; i < count; ++i) {
  41903. var lookupPos = src[srcOffset++] * numComps;
  41904. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  41905. destOffset += outputDelta;
  41906. }
  41907. },
  41908. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  41909. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  41910. },
  41911. isPassthrough: ColorSpace.prototype.isPassthrough,
  41912. fillRgb: ColorSpace.prototype.fillRgb,
  41913. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  41914. return true;
  41915. },
  41916. usesZeroToOneRange: true
  41917. };
  41918. return IndexedCS;
  41919. }();
  41920. var DeviceGrayCS = function DeviceGrayCSClosure() {
  41921. function DeviceGrayCS() {
  41922. this.name = 'DeviceGray';
  41923. this.numComps = 1;
  41924. this.defaultColor = new Float32Array(this.numComps);
  41925. }
  41926. DeviceGrayCS.prototype = {
  41927. getRgb: ColorSpace.prototype.getRgb,
  41928. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41929. var c = src[srcOffset] * 255 | 0;
  41930. c = c < 0 ? 0 : c > 255 ? 255 : c;
  41931. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  41932. },
  41933. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41934. var scale = 255 / ((1 << bits) - 1);
  41935. var j = srcOffset, q = destOffset;
  41936. for (var i = 0; i < count; ++i) {
  41937. var c = scale * src[j++] | 0;
  41938. dest[q++] = c;
  41939. dest[q++] = c;
  41940. dest[q++] = c;
  41941. q += alpha01;
  41942. }
  41943. },
  41944. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  41945. return inputLength * (3 + alpha01);
  41946. },
  41947. isPassthrough: ColorSpace.prototype.isPassthrough,
  41948. fillRgb: ColorSpace.prototype.fillRgb,
  41949. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  41950. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41951. },
  41952. usesZeroToOneRange: true
  41953. };
  41954. return DeviceGrayCS;
  41955. }();
  41956. var DeviceRgbCS = function DeviceRgbCSClosure() {
  41957. function DeviceRgbCS() {
  41958. this.name = 'DeviceRGB';
  41959. this.numComps = 3;
  41960. this.defaultColor = new Float32Array(this.numComps);
  41961. }
  41962. DeviceRgbCS.prototype = {
  41963. getRgb: ColorSpace.prototype.getRgb,
  41964. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41965. var r = src[srcOffset] * 255 | 0;
  41966. var g = src[srcOffset + 1] * 255 | 0;
  41967. var b = src[srcOffset + 2] * 255 | 0;
  41968. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  41969. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  41970. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  41971. },
  41972. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41973. if (bits === 8 && alpha01 === 0) {
  41974. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  41975. return;
  41976. }
  41977. var scale = 255 / ((1 << bits) - 1);
  41978. var j = srcOffset, q = destOffset;
  41979. for (var i = 0; i < count; ++i) {
  41980. dest[q++] = scale * src[j++] | 0;
  41981. dest[q++] = scale * src[j++] | 0;
  41982. dest[q++] = scale * src[j++] | 0;
  41983. q += alpha01;
  41984. }
  41985. },
  41986. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  41987. return inputLength * (3 + alpha01) / 3 | 0;
  41988. },
  41989. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  41990. return bits === 8;
  41991. },
  41992. fillRgb: ColorSpace.prototype.fillRgb,
  41993. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  41994. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41995. },
  41996. usesZeroToOneRange: true
  41997. };
  41998. return DeviceRgbCS;
  41999. }();
  42000. var DeviceCmykCS = function DeviceCmykCSClosure() {
  42001. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  42002. var c = src[srcOffset + 0] * srcScale;
  42003. var m = src[srcOffset + 1] * srcScale;
  42004. var y = src[srcOffset + 2] * srcScale;
  42005. var k = src[srcOffset + 3] * srcScale;
  42006. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747) + 255 | 0;
  42007. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578) + 255 | 0;
  42008. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367) + 255 | 0;
  42009. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  42010. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  42011. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  42012. }
  42013. function DeviceCmykCS() {
  42014. this.name = 'DeviceCMYK';
  42015. this.numComps = 4;
  42016. this.defaultColor = new Float32Array(this.numComps);
  42017. this.defaultColor[3] = 1;
  42018. }
  42019. DeviceCmykCS.prototype = {
  42020. getRgb: ColorSpace.prototype.getRgb,
  42021. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42022. convertToRgb(src, srcOffset, 1, dest, destOffset);
  42023. },
  42024. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42025. var scale = 1 / ((1 << bits) - 1);
  42026. for (var i = 0; i < count; i++) {
  42027. convertToRgb(src, srcOffset, scale, dest, destOffset);
  42028. srcOffset += 4;
  42029. destOffset += 3 + alpha01;
  42030. }
  42031. },
  42032. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  42033. return inputLength / 4 * (3 + alpha01) | 0;
  42034. },
  42035. isPassthrough: ColorSpace.prototype.isPassthrough,
  42036. fillRgb: ColorSpace.prototype.fillRgb,
  42037. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  42038. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  42039. },
  42040. usesZeroToOneRange: true
  42041. };
  42042. return DeviceCmykCS;
  42043. }();
  42044. var CalGrayCS = function CalGrayCSClosure() {
  42045. function CalGrayCS(whitePoint, blackPoint, gamma) {
  42046. this.name = 'CalGray';
  42047. this.numComps = 1;
  42048. this.defaultColor = new Float32Array(this.numComps);
  42049. if (!whitePoint) {
  42050. error('WhitePoint missing - required for color space CalGray');
  42051. }
  42052. blackPoint = blackPoint || [
  42053. 0,
  42054. 0,
  42055. 0
  42056. ];
  42057. gamma = gamma || 1;
  42058. this.XW = whitePoint[0];
  42059. this.YW = whitePoint[1];
  42060. this.ZW = whitePoint[2];
  42061. this.XB = blackPoint[0];
  42062. this.YB = blackPoint[1];
  42063. this.ZB = blackPoint[2];
  42064. this.G = gamma;
  42065. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  42066. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  42067. }
  42068. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  42069. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  42070. this.XB = this.YB = this.ZB = 0;
  42071. }
  42072. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  42073. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  42074. }
  42075. if (this.G < 1) {
  42076. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  42077. this.G = 1;
  42078. }
  42079. }
  42080. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  42081. var A = src[srcOffset] * scale;
  42082. var AG = Math.pow(A, cs.G);
  42083. var L = cs.YW * AG;
  42084. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  42085. dest[destOffset] = val;
  42086. dest[destOffset + 1] = val;
  42087. dest[destOffset + 2] = val;
  42088. }
  42089. CalGrayCS.prototype = {
  42090. getRgb: ColorSpace.prototype.getRgb,
  42091. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42092. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  42093. },
  42094. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42095. var scale = 1 / ((1 << bits) - 1);
  42096. for (var i = 0; i < count; ++i) {
  42097. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  42098. srcOffset += 1;
  42099. destOffset += 3 + alpha01;
  42100. }
  42101. },
  42102. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  42103. return inputLength * (3 + alpha01);
  42104. },
  42105. isPassthrough: ColorSpace.prototype.isPassthrough,
  42106. fillRgb: ColorSpace.prototype.fillRgb,
  42107. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  42108. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  42109. },
  42110. usesZeroToOneRange: true
  42111. };
  42112. return CalGrayCS;
  42113. }();
  42114. var CalRGBCS = function CalRGBCSClosure() {
  42115. var BRADFORD_SCALE_MATRIX = new Float32Array([
  42116. 0.8951,
  42117. 0.2664,
  42118. -0.1614,
  42119. -0.7502,
  42120. 1.7135,
  42121. 0.0367,
  42122. 0.0389,
  42123. -0.0685,
  42124. 1.0296
  42125. ]);
  42126. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  42127. 0.9869929,
  42128. -0.1470543,
  42129. 0.1599627,
  42130. 0.4323053,
  42131. 0.5183603,
  42132. 0.0492912,
  42133. -0.0085287,
  42134. 0.0400428,
  42135. 0.9684867
  42136. ]);
  42137. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  42138. 3.2404542,
  42139. -1.5371385,
  42140. -0.4985314,
  42141. -0.9692660,
  42142. 1.8760108,
  42143. 0.0415560,
  42144. 0.0556434,
  42145. -0.2040259,
  42146. 1.0572252
  42147. ]);
  42148. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  42149. 1,
  42150. 1,
  42151. 1
  42152. ]);
  42153. var tempNormalizeMatrix = new Float32Array(3);
  42154. var tempConvertMatrix1 = new Float32Array(3);
  42155. var tempConvertMatrix2 = new Float32Array(3);
  42156. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  42157. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  42158. this.name = 'CalRGB';
  42159. this.numComps = 3;
  42160. this.defaultColor = new Float32Array(this.numComps);
  42161. if (!whitePoint) {
  42162. error('WhitePoint missing - required for color space CalRGB');
  42163. }
  42164. blackPoint = blackPoint || new Float32Array(3);
  42165. gamma = gamma || new Float32Array([
  42166. 1,
  42167. 1,
  42168. 1
  42169. ]);
  42170. matrix = matrix || new Float32Array([
  42171. 1,
  42172. 0,
  42173. 0,
  42174. 0,
  42175. 1,
  42176. 0,
  42177. 0,
  42178. 0,
  42179. 1
  42180. ]);
  42181. var XW = whitePoint[0];
  42182. var YW = whitePoint[1];
  42183. var ZW = whitePoint[2];
  42184. this.whitePoint = whitePoint;
  42185. var XB = blackPoint[0];
  42186. var YB = blackPoint[1];
  42187. var ZB = blackPoint[2];
  42188. this.blackPoint = blackPoint;
  42189. this.GR = gamma[0];
  42190. this.GG = gamma[1];
  42191. this.GB = gamma[2];
  42192. this.MXA = matrix[0];
  42193. this.MYA = matrix[1];
  42194. this.MZA = matrix[2];
  42195. this.MXB = matrix[3];
  42196. this.MYB = matrix[4];
  42197. this.MZB = matrix[5];
  42198. this.MXC = matrix[6];
  42199. this.MYC = matrix[7];
  42200. this.MZC = matrix[8];
  42201. if (XW < 0 || ZW < 0 || YW !== 1) {
  42202. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  42203. }
  42204. if (XB < 0 || YB < 0 || ZB < 0) {
  42205. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  42206. this.blackPoint = new Float32Array(3);
  42207. }
  42208. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  42209. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  42210. this.GR = this.GG = this.GB = 1;
  42211. }
  42212. if (this.MXA < 0 || this.MYA < 0 || this.MZA < 0 || this.MXB < 0 || this.MYB < 0 || this.MZB < 0 || this.MXC < 0 || this.MYC < 0 || this.MZC < 0) {
  42213. info('Invalid Matrix for ' + this.name + ' [' + this.MXA + ', ' + this.MYA + ', ' + this.MZA + this.MXB + ', ' + this.MYB + ', ' + this.MZB + this.MXC + ', ' + this.MYC + ', ' + this.MZC + '], falling back to default');
  42214. this.MXA = this.MYB = this.MZC = 1;
  42215. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  42216. }
  42217. }
  42218. function matrixProduct(a, b, result) {
  42219. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  42220. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  42221. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  42222. }
  42223. function convertToFlat(sourceWhitePoint, LMS, result) {
  42224. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  42225. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  42226. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  42227. }
  42228. function convertToD65(sourceWhitePoint, LMS, result) {
  42229. var D65X = 0.95047;
  42230. var D65Y = 1;
  42231. var D65Z = 1.08883;
  42232. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  42233. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  42234. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  42235. }
  42236. function sRGBTransferFunction(color) {
  42237. if (color <= 0.0031308) {
  42238. return adjustToRange(0, 1, 12.92 * color);
  42239. }
  42240. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  42241. }
  42242. function adjustToRange(min, max, value) {
  42243. return Math.max(min, Math.min(max, value));
  42244. }
  42245. function decodeL(L) {
  42246. if (L < 0) {
  42247. return -decodeL(-L);
  42248. }
  42249. if (L > 8.0) {
  42250. return Math.pow((L + 16) / 116, 3);
  42251. }
  42252. return L * DECODE_L_CONSTANT;
  42253. }
  42254. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  42255. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  42256. result[0] = XYZ_Flat[0];
  42257. result[1] = XYZ_Flat[1];
  42258. result[2] = XYZ_Flat[2];
  42259. return;
  42260. }
  42261. var zeroDecodeL = decodeL(0);
  42262. var X_DST = zeroDecodeL;
  42263. var X_SRC = decodeL(sourceBlackPoint[0]);
  42264. var Y_DST = zeroDecodeL;
  42265. var Y_SRC = decodeL(sourceBlackPoint[1]);
  42266. var Z_DST = zeroDecodeL;
  42267. var Z_SRC = decodeL(sourceBlackPoint[2]);
  42268. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  42269. var X_Offset = 1 - X_Scale;
  42270. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  42271. var Y_Offset = 1 - Y_Scale;
  42272. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  42273. var Z_Offset = 1 - Z_Scale;
  42274. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  42275. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  42276. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  42277. }
  42278. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  42279. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  42280. result[0] = XYZ_In[0];
  42281. result[1] = XYZ_In[1];
  42282. result[2] = XYZ_In[2];
  42283. return;
  42284. }
  42285. var LMS = result;
  42286. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  42287. var LMS_Flat = tempNormalizeMatrix;
  42288. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  42289. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  42290. }
  42291. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  42292. var LMS = result;
  42293. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  42294. var LMS_D65 = tempNormalizeMatrix;
  42295. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  42296. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  42297. }
  42298. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  42299. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  42300. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  42301. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  42302. var AGR = Math.pow(A, cs.GR);
  42303. var BGG = Math.pow(B, cs.GG);
  42304. var CGB = Math.pow(C, cs.GB);
  42305. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  42306. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  42307. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  42308. var XYZ = tempConvertMatrix1;
  42309. XYZ[0] = X;
  42310. XYZ[1] = Y;
  42311. XYZ[2] = Z;
  42312. var XYZ_Flat = tempConvertMatrix2;
  42313. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  42314. var XYZ_Black = tempConvertMatrix1;
  42315. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  42316. var XYZ_D65 = tempConvertMatrix2;
  42317. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  42318. var SRGB = tempConvertMatrix1;
  42319. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  42320. var sR = sRGBTransferFunction(SRGB[0]);
  42321. var sG = sRGBTransferFunction(SRGB[1]);
  42322. var sB = sRGBTransferFunction(SRGB[2]);
  42323. dest[destOffset] = Math.round(sR * 255);
  42324. dest[destOffset + 1] = Math.round(sG * 255);
  42325. dest[destOffset + 2] = Math.round(sB * 255);
  42326. }
  42327. CalRGBCS.prototype = {
  42328. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  42329. var rgb = new Uint8Array(3);
  42330. this.getRgbItem(src, srcOffset, rgb, 0);
  42331. return rgb;
  42332. },
  42333. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42334. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  42335. },
  42336. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42337. var scale = 1 / ((1 << bits) - 1);
  42338. for (var i = 0; i < count; ++i) {
  42339. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  42340. srcOffset += 3;
  42341. destOffset += 3 + alpha01;
  42342. }
  42343. },
  42344. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  42345. return inputLength * (3 + alpha01) / 3 | 0;
  42346. },
  42347. isPassthrough: ColorSpace.prototype.isPassthrough,
  42348. fillRgb: ColorSpace.prototype.fillRgb,
  42349. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  42350. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  42351. },
  42352. usesZeroToOneRange: true
  42353. };
  42354. return CalRGBCS;
  42355. }();
  42356. var LabCS = function LabCSClosure() {
  42357. function LabCS(whitePoint, blackPoint, range) {
  42358. this.name = 'Lab';
  42359. this.numComps = 3;
  42360. this.defaultColor = new Float32Array(this.numComps);
  42361. if (!whitePoint) {
  42362. error('WhitePoint missing - required for color space Lab');
  42363. }
  42364. blackPoint = blackPoint || [
  42365. 0,
  42366. 0,
  42367. 0
  42368. ];
  42369. range = range || [
  42370. -100,
  42371. 100,
  42372. -100,
  42373. 100
  42374. ];
  42375. this.XW = whitePoint[0];
  42376. this.YW = whitePoint[1];
  42377. this.ZW = whitePoint[2];
  42378. this.amin = range[0];
  42379. this.amax = range[1];
  42380. this.bmin = range[2];
  42381. this.bmax = range[3];
  42382. this.XB = blackPoint[0];
  42383. this.YB = blackPoint[1];
  42384. this.ZB = blackPoint[2];
  42385. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  42386. error('Invalid WhitePoint components, no fallback available');
  42387. }
  42388. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  42389. info('Invalid BlackPoint, falling back to default');
  42390. this.XB = this.YB = this.ZB = 0;
  42391. }
  42392. if (this.amin > this.amax || this.bmin > this.bmax) {
  42393. info('Invalid Range, falling back to defaults');
  42394. this.amin = -100;
  42395. this.amax = 100;
  42396. this.bmin = -100;
  42397. this.bmax = 100;
  42398. }
  42399. }
  42400. function fn_g(x) {
  42401. var result;
  42402. if (x >= 6 / 29) {
  42403. result = x * x * x;
  42404. } else {
  42405. result = 108 / 841 * (x - 4 / 29);
  42406. }
  42407. return result;
  42408. }
  42409. function decode(value, high1, low2, high2) {
  42410. return low2 + value * (high2 - low2) / high1;
  42411. }
  42412. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  42413. var Ls = src[srcOffset];
  42414. var as = src[srcOffset + 1];
  42415. var bs = src[srcOffset + 2];
  42416. if (maxVal !== false) {
  42417. Ls = decode(Ls, maxVal, 0, 100);
  42418. as = decode(as, maxVal, cs.amin, cs.amax);
  42419. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  42420. }
  42421. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  42422. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  42423. var M = (Ls + 16) / 116;
  42424. var L = M + as / 500;
  42425. var N = M - bs / 200;
  42426. var X = cs.XW * fn_g(L);
  42427. var Y = cs.YW * fn_g(M);
  42428. var Z = cs.ZW * fn_g(N);
  42429. var r, g, b;
  42430. if (cs.ZW < 1) {
  42431. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  42432. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  42433. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  42434. } else {
  42435. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  42436. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  42437. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  42438. }
  42439. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  42440. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  42441. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  42442. }
  42443. LabCS.prototype = {
  42444. getRgb: ColorSpace.prototype.getRgb,
  42445. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42446. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  42447. },
  42448. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42449. var maxVal = (1 << bits) - 1;
  42450. for (var i = 0; i < count; i++) {
  42451. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  42452. srcOffset += 3;
  42453. destOffset += 3 + alpha01;
  42454. }
  42455. },
  42456. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  42457. return inputLength * (3 + alpha01) / 3 | 0;
  42458. },
  42459. isPassthrough: ColorSpace.prototype.isPassthrough,
  42460. fillRgb: ColorSpace.prototype.fillRgb,
  42461. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  42462. return true;
  42463. },
  42464. usesZeroToOneRange: false
  42465. };
  42466. return LabCS;
  42467. }();
  42468. exports.ColorSpace = ColorSpace;
  42469. }));
  42470. (function (root, factory) {
  42471. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  42472. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  42473. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  42474. var FontType = sharedUtil.FontType;
  42475. var assert = sharedUtil.assert;
  42476. var bytesToString = sharedUtil.bytesToString;
  42477. var error = sharedUtil.error;
  42478. var info = sharedUtil.info;
  42479. var isArray = sharedUtil.isArray;
  42480. var isInt = sharedUtil.isInt;
  42481. var isNum = sharedUtil.isNum;
  42482. var readUint32 = sharedUtil.readUint32;
  42483. var shadow = sharedUtil.shadow;
  42484. var string32 = sharedUtil.string32;
  42485. var warn = sharedUtil.warn;
  42486. var MissingDataException = sharedUtil.MissingDataException;
  42487. var isSpace = sharedUtil.isSpace;
  42488. var Stream = coreStream.Stream;
  42489. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  42490. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  42491. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  42492. var StandardEncoding = coreEncodings.StandardEncoding;
  42493. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  42494. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  42495. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  42496. var getEncoding = coreEncodings.getEncoding;
  42497. var getStdFontMap = coreStandardFonts.getStdFontMap;
  42498. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  42499. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  42500. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  42501. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  42502. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  42503. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  42504. var Type1Parser = coreType1Parser.Type1Parser;
  42505. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  42506. var CFFParser = coreCFFParser.CFFParser;
  42507. var CFFCompiler = coreCFFParser.CFFCompiler;
  42508. var CFF = coreCFFParser.CFF;
  42509. var CFFHeader = coreCFFParser.CFFHeader;
  42510. var CFFTopDict = coreCFFParser.CFFTopDict;
  42511. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  42512. var CFFStrings = coreCFFParser.CFFStrings;
  42513. var CFFIndex = coreCFFParser.CFFIndex;
  42514. var CFFCharset = coreCFFParser.CFFCharset;
  42515. var PRIVATE_USE_OFFSET_START = 0xE000;
  42516. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  42517. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  42518. var PDF_GLYPH_SPACE_UNITS = 1000;
  42519. var SEAC_ANALYSIS_ENABLED = false;
  42520. var FontFlags = {
  42521. FixedPitch: 1,
  42522. Serif: 2,
  42523. Symbolic: 4,
  42524. Script: 8,
  42525. Nonsymbolic: 32,
  42526. Italic: 64,
  42527. AllCap: 65536,
  42528. SmallCap: 131072,
  42529. ForceBold: 262144
  42530. };
  42531. var MacStandardGlyphOrdering = [
  42532. '.notdef',
  42533. '.null',
  42534. 'nonmarkingreturn',
  42535. 'space',
  42536. 'exclam',
  42537. 'quotedbl',
  42538. 'numbersign',
  42539. 'dollar',
  42540. 'percent',
  42541. 'ampersand',
  42542. 'quotesingle',
  42543. 'parenleft',
  42544. 'parenright',
  42545. 'asterisk',
  42546. 'plus',
  42547. 'comma',
  42548. 'hyphen',
  42549. 'period',
  42550. 'slash',
  42551. 'zero',
  42552. 'one',
  42553. 'two',
  42554. 'three',
  42555. 'four',
  42556. 'five',
  42557. 'six',
  42558. 'seven',
  42559. 'eight',
  42560. 'nine',
  42561. 'colon',
  42562. 'semicolon',
  42563. 'less',
  42564. 'equal',
  42565. 'greater',
  42566. 'question',
  42567. 'at',
  42568. 'A',
  42569. 'B',
  42570. 'C',
  42571. 'D',
  42572. 'E',
  42573. 'F',
  42574. 'G',
  42575. 'H',
  42576. 'I',
  42577. 'J',
  42578. 'K',
  42579. 'L',
  42580. 'M',
  42581. 'N',
  42582. 'O',
  42583. 'P',
  42584. 'Q',
  42585. 'R',
  42586. 'S',
  42587. 'T',
  42588. 'U',
  42589. 'V',
  42590. 'W',
  42591. 'X',
  42592. 'Y',
  42593. 'Z',
  42594. 'bracketleft',
  42595. 'backslash',
  42596. 'bracketright',
  42597. 'asciicircum',
  42598. 'underscore',
  42599. 'grave',
  42600. 'a',
  42601. 'b',
  42602. 'c',
  42603. 'd',
  42604. 'e',
  42605. 'f',
  42606. 'g',
  42607. 'h',
  42608. 'i',
  42609. 'j',
  42610. 'k',
  42611. 'l',
  42612. 'm',
  42613. 'n',
  42614. 'o',
  42615. 'p',
  42616. 'q',
  42617. 'r',
  42618. 's',
  42619. 't',
  42620. 'u',
  42621. 'v',
  42622. 'w',
  42623. 'x',
  42624. 'y',
  42625. 'z',
  42626. 'braceleft',
  42627. 'bar',
  42628. 'braceright',
  42629. 'asciitilde',
  42630. 'Adieresis',
  42631. 'Aring',
  42632. 'Ccedilla',
  42633. 'Eacute',
  42634. 'Ntilde',
  42635. 'Odieresis',
  42636. 'Udieresis',
  42637. 'aacute',
  42638. 'agrave',
  42639. 'acircumflex',
  42640. 'adieresis',
  42641. 'atilde',
  42642. 'aring',
  42643. 'ccedilla',
  42644. 'eacute',
  42645. 'egrave',
  42646. 'ecircumflex',
  42647. 'edieresis',
  42648. 'iacute',
  42649. 'igrave',
  42650. 'icircumflex',
  42651. 'idieresis',
  42652. 'ntilde',
  42653. 'oacute',
  42654. 'ograve',
  42655. 'ocircumflex',
  42656. 'odieresis',
  42657. 'otilde',
  42658. 'uacute',
  42659. 'ugrave',
  42660. 'ucircumflex',
  42661. 'udieresis',
  42662. 'dagger',
  42663. 'degree',
  42664. 'cent',
  42665. 'sterling',
  42666. 'section',
  42667. 'bullet',
  42668. 'paragraph',
  42669. 'germandbls',
  42670. 'registered',
  42671. 'copyright',
  42672. 'trademark',
  42673. 'acute',
  42674. 'dieresis',
  42675. 'notequal',
  42676. 'AE',
  42677. 'Oslash',
  42678. 'infinity',
  42679. 'plusminus',
  42680. 'lessequal',
  42681. 'greaterequal',
  42682. 'yen',
  42683. 'mu',
  42684. 'partialdiff',
  42685. 'summation',
  42686. 'product',
  42687. 'pi',
  42688. 'integral',
  42689. 'ordfeminine',
  42690. 'ordmasculine',
  42691. 'Omega',
  42692. 'ae',
  42693. 'oslash',
  42694. 'questiondown',
  42695. 'exclamdown',
  42696. 'logicalnot',
  42697. 'radical',
  42698. 'florin',
  42699. 'approxequal',
  42700. 'Delta',
  42701. 'guillemotleft',
  42702. 'guillemotright',
  42703. 'ellipsis',
  42704. 'nonbreakingspace',
  42705. 'Agrave',
  42706. 'Atilde',
  42707. 'Otilde',
  42708. 'OE',
  42709. 'oe',
  42710. 'endash',
  42711. 'emdash',
  42712. 'quotedblleft',
  42713. 'quotedblright',
  42714. 'quoteleft',
  42715. 'quoteright',
  42716. 'divide',
  42717. 'lozenge',
  42718. 'ydieresis',
  42719. 'Ydieresis',
  42720. 'fraction',
  42721. 'currency',
  42722. 'guilsinglleft',
  42723. 'guilsinglright',
  42724. 'fi',
  42725. 'fl',
  42726. 'daggerdbl',
  42727. 'periodcentered',
  42728. 'quotesinglbase',
  42729. 'quotedblbase',
  42730. 'perthousand',
  42731. 'Acircumflex',
  42732. 'Ecircumflex',
  42733. 'Aacute',
  42734. 'Edieresis',
  42735. 'Egrave',
  42736. 'Iacute',
  42737. 'Icircumflex',
  42738. 'Idieresis',
  42739. 'Igrave',
  42740. 'Oacute',
  42741. 'Ocircumflex',
  42742. 'apple',
  42743. 'Ograve',
  42744. 'Uacute',
  42745. 'Ucircumflex',
  42746. 'Ugrave',
  42747. 'dotlessi',
  42748. 'circumflex',
  42749. 'tilde',
  42750. 'macron',
  42751. 'breve',
  42752. 'dotaccent',
  42753. 'ring',
  42754. 'cedilla',
  42755. 'hungarumlaut',
  42756. 'ogonek',
  42757. 'caron',
  42758. 'Lslash',
  42759. 'lslash',
  42760. 'Scaron',
  42761. 'scaron',
  42762. 'Zcaron',
  42763. 'zcaron',
  42764. 'brokenbar',
  42765. 'Eth',
  42766. 'eth',
  42767. 'Yacute',
  42768. 'yacute',
  42769. 'Thorn',
  42770. 'thorn',
  42771. 'minus',
  42772. 'multiply',
  42773. 'onesuperior',
  42774. 'twosuperior',
  42775. 'threesuperior',
  42776. 'onehalf',
  42777. 'onequarter',
  42778. 'threequarters',
  42779. 'franc',
  42780. 'Gbreve',
  42781. 'gbreve',
  42782. 'Idotaccent',
  42783. 'Scedilla',
  42784. 'scedilla',
  42785. 'Cacute',
  42786. 'cacute',
  42787. 'Ccaron',
  42788. 'ccaron',
  42789. 'dcroat'
  42790. ];
  42791. function adjustWidths(properties) {
  42792. if (!properties.fontMatrix) {
  42793. return;
  42794. }
  42795. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  42796. return;
  42797. }
  42798. var scale = 0.001 / properties.fontMatrix[0];
  42799. var glyphsWidths = properties.widths;
  42800. for (var glyph in glyphsWidths) {
  42801. glyphsWidths[glyph] *= scale;
  42802. }
  42803. properties.defaultWidth *= scale;
  42804. }
  42805. function adjustToUnicode(properties, builtInEncoding) {
  42806. if (properties.hasIncludedToUnicodeMap) {
  42807. return;
  42808. }
  42809. if (properties.hasEncoding) {
  42810. return;
  42811. }
  42812. if (builtInEncoding === properties.defaultEncoding) {
  42813. return;
  42814. }
  42815. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  42816. return;
  42817. }
  42818. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  42819. for (var charCode in builtInEncoding) {
  42820. var glyphName = builtInEncoding[charCode];
  42821. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  42822. if (unicode !== -1) {
  42823. toUnicode[charCode] = String.fromCharCode(unicode);
  42824. }
  42825. }
  42826. properties.toUnicode.amend(toUnicode);
  42827. }
  42828. function getFontType(type, subtype) {
  42829. switch (type) {
  42830. case 'Type1':
  42831. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  42832. case 'CIDFontType0':
  42833. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  42834. case 'OpenType':
  42835. return FontType.OPENTYPE;
  42836. case 'TrueType':
  42837. return FontType.TRUETYPE;
  42838. case 'CIDFontType2':
  42839. return FontType.CIDFONTTYPE2;
  42840. case 'MMType1':
  42841. return FontType.MMTYPE1;
  42842. case 'Type0':
  42843. return FontType.TYPE0;
  42844. default:
  42845. return FontType.UNKNOWN;
  42846. }
  42847. }
  42848. function recoverGlyphName(name, glyphsUnicodeMap) {
  42849. if (glyphsUnicodeMap[name] !== undefined) {
  42850. return name;
  42851. }
  42852. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  42853. if (unicode !== -1) {
  42854. for (var key in glyphsUnicodeMap) {
  42855. if (glyphsUnicodeMap[key] === unicode) {
  42856. return key;
  42857. }
  42858. }
  42859. }
  42860. info('Unable to recover a standard glyph name for: ' + name);
  42861. return name;
  42862. }
  42863. var Glyph = function GlyphClosure() {
  42864. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  42865. this.fontChar = fontChar;
  42866. this.unicode = unicode;
  42867. this.accent = accent;
  42868. this.width = width;
  42869. this.vmetric = vmetric;
  42870. this.operatorListId = operatorListId;
  42871. this.isSpace = isSpace;
  42872. this.isInFont = isInFont;
  42873. }
  42874. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  42875. return this.fontChar === fontChar && this.unicode === unicode && this.accent === accent && this.width === width && this.vmetric === vmetric && this.operatorListId === operatorListId && this.isSpace === isSpace && this.isInFont === isInFont;
  42876. };
  42877. return Glyph;
  42878. }();
  42879. var ToUnicodeMap = function ToUnicodeMapClosure() {
  42880. function ToUnicodeMap(cmap) {
  42881. this._map = cmap;
  42882. }
  42883. ToUnicodeMap.prototype = {
  42884. get length() {
  42885. return this._map.length;
  42886. },
  42887. forEach: function (callback) {
  42888. for (var charCode in this._map) {
  42889. callback(charCode, this._map[charCode].charCodeAt(0));
  42890. }
  42891. },
  42892. has: function (i) {
  42893. return this._map[i] !== undefined;
  42894. },
  42895. get: function (i) {
  42896. return this._map[i];
  42897. },
  42898. charCodeOf: function (v) {
  42899. return this._map.indexOf(v);
  42900. },
  42901. amend: function (map) {
  42902. for (var charCode in map) {
  42903. this._map[charCode] = map[charCode];
  42904. }
  42905. }
  42906. };
  42907. return ToUnicodeMap;
  42908. }();
  42909. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  42910. function IdentityToUnicodeMap(firstChar, lastChar) {
  42911. this.firstChar = firstChar;
  42912. this.lastChar = lastChar;
  42913. }
  42914. IdentityToUnicodeMap.prototype = {
  42915. get length() {
  42916. return this.lastChar + 1 - this.firstChar;
  42917. },
  42918. forEach: function (callback) {
  42919. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  42920. callback(i, i);
  42921. }
  42922. },
  42923. has: function (i) {
  42924. return this.firstChar <= i && i <= this.lastChar;
  42925. },
  42926. get: function (i) {
  42927. if (this.firstChar <= i && i <= this.lastChar) {
  42928. return String.fromCharCode(i);
  42929. }
  42930. return undefined;
  42931. },
  42932. charCodeOf: function (v) {
  42933. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  42934. },
  42935. amend: function (map) {
  42936. error('Should not call amend()');
  42937. }
  42938. };
  42939. return IdentityToUnicodeMap;
  42940. }();
  42941. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  42942. function writeInt16(dest, offset, num) {
  42943. dest[offset] = num >> 8 & 0xFF;
  42944. dest[offset + 1] = num & 0xFF;
  42945. }
  42946. function writeInt32(dest, offset, num) {
  42947. dest[offset] = num >> 24 & 0xFF;
  42948. dest[offset + 1] = num >> 16 & 0xFF;
  42949. dest[offset + 2] = num >> 8 & 0xFF;
  42950. dest[offset + 3] = num & 0xFF;
  42951. }
  42952. function writeData(dest, offset, data) {
  42953. var i, ii;
  42954. if (data instanceof Uint8Array) {
  42955. dest.set(data, offset);
  42956. } else if (typeof data === 'string') {
  42957. for (i = 0, ii = data.length; i < ii; i++) {
  42958. dest[offset++] = data.charCodeAt(i) & 0xFF;
  42959. }
  42960. } else {
  42961. for (i = 0, ii = data.length; i < ii; i++) {
  42962. dest[offset++] = data[i] & 0xFF;
  42963. }
  42964. }
  42965. }
  42966. function OpenTypeFileBuilder(sfnt) {
  42967. this.sfnt = sfnt;
  42968. this.tables = Object.create(null);
  42969. }
  42970. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  42971. var maxPower2 = 1, log2 = 0;
  42972. while ((maxPower2 ^ entriesCount) > maxPower2) {
  42973. maxPower2 <<= 1;
  42974. log2++;
  42975. }
  42976. var searchRange = maxPower2 * entrySize;
  42977. return {
  42978. range: searchRange,
  42979. entry: log2,
  42980. rangeShift: entrySize * entriesCount - searchRange
  42981. };
  42982. };
  42983. var OTF_HEADER_SIZE = 12;
  42984. var OTF_TABLE_ENTRY_SIZE = 16;
  42985. OpenTypeFileBuilder.prototype = {
  42986. toArray: function OpenTypeFileBuilder_toArray() {
  42987. var sfnt = this.sfnt;
  42988. var tables = this.tables;
  42989. var tablesNames = Object.keys(tables);
  42990. tablesNames.sort();
  42991. var numTables = tablesNames.length;
  42992. var i, j, jj, table, tableName;
  42993. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  42994. var tableOffsets = [offset];
  42995. for (i = 0; i < numTables; i++) {
  42996. table = tables[tablesNames[i]];
  42997. var paddedLength = (table.length + 3 & ~3) >>> 0;
  42998. offset += paddedLength;
  42999. tableOffsets.push(offset);
  43000. }
  43001. var file = new Uint8Array(offset);
  43002. for (i = 0; i < numTables; i++) {
  43003. table = tables[tablesNames[i]];
  43004. writeData(file, tableOffsets[i], table);
  43005. }
  43006. if (sfnt === 'true') {
  43007. sfnt = string32(0x00010000);
  43008. }
  43009. file[0] = sfnt.charCodeAt(0) & 0xFF;
  43010. file[1] = sfnt.charCodeAt(1) & 0xFF;
  43011. file[2] = sfnt.charCodeAt(2) & 0xFF;
  43012. file[3] = sfnt.charCodeAt(3) & 0xFF;
  43013. writeInt16(file, 4, numTables);
  43014. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  43015. writeInt16(file, 6, searchParams.range);
  43016. writeInt16(file, 8, searchParams.entry);
  43017. writeInt16(file, 10, searchParams.rangeShift);
  43018. offset = OTF_HEADER_SIZE;
  43019. for (i = 0; i < numTables; i++) {
  43020. tableName = tablesNames[i];
  43021. file[offset] = tableName.charCodeAt(0) & 0xFF;
  43022. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  43023. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  43024. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  43025. var checksum = 0;
  43026. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  43027. var quad = readUint32(file, j);
  43028. checksum = checksum + quad >>> 0;
  43029. }
  43030. writeInt32(file, offset + 4, checksum);
  43031. writeInt32(file, offset + 8, tableOffsets[i]);
  43032. writeInt32(file, offset + 12, tables[tableName].length);
  43033. offset += OTF_TABLE_ENTRY_SIZE;
  43034. }
  43035. return file;
  43036. },
  43037. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  43038. if (tag in this.tables) {
  43039. throw new Error('Table ' + tag + ' already exists');
  43040. }
  43041. this.tables[tag] = data;
  43042. }
  43043. };
  43044. return OpenTypeFileBuilder;
  43045. }();
  43046. var ProblematicCharRanges = new Int32Array([
  43047. 0x0000,
  43048. 0x0020,
  43049. 0x007F,
  43050. 0x00A1,
  43051. 0x00AD,
  43052. 0x00AE,
  43053. 0x0600,
  43054. 0x0780,
  43055. 0x08A0,
  43056. 0x10A0,
  43057. 0x1780,
  43058. 0x1800,
  43059. 0x1C00,
  43060. 0x1C50,
  43061. 0x2000,
  43062. 0x2010,
  43063. 0x2011,
  43064. 0x2012,
  43065. 0x2028,
  43066. 0x2030,
  43067. 0x205F,
  43068. 0x2070,
  43069. 0x25CC,
  43070. 0x25CD,
  43071. 0x3000,
  43072. 0x3001,
  43073. 0xAA60,
  43074. 0xAA80,
  43075. 0xFFF0,
  43076. 0x10000
  43077. ]);
  43078. var Font = function FontClosure() {
  43079. function Font(name, file, properties) {
  43080. var charCode, glyphName, unicode;
  43081. this.name = name;
  43082. this.loadedName = properties.loadedName;
  43083. this.isType3Font = properties.isType3Font;
  43084. this.sizes = [];
  43085. this.missingFile = false;
  43086. this.glyphCache = Object.create(null);
  43087. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  43088. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  43089. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  43090. var type = properties.type;
  43091. var subtype = properties.subtype;
  43092. this.type = type;
  43093. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  43094. this.differences = properties.differences;
  43095. this.widths = properties.widths;
  43096. this.defaultWidth = properties.defaultWidth;
  43097. this.composite = properties.composite;
  43098. this.wideChars = properties.wideChars;
  43099. this.cMap = properties.cMap;
  43100. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  43101. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  43102. this.fontMatrix = properties.fontMatrix;
  43103. this.bbox = properties.bbox;
  43104. this.toUnicode = properties.toUnicode;
  43105. this.toFontChar = [];
  43106. if (properties.type === 'Type3') {
  43107. for (charCode = 0; charCode < 256; charCode++) {
  43108. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  43109. }
  43110. this.fontType = FontType.TYPE3;
  43111. return;
  43112. }
  43113. this.cidEncoding = properties.cidEncoding;
  43114. this.vertical = properties.vertical;
  43115. if (this.vertical) {
  43116. this.vmetrics = properties.vmetrics;
  43117. this.defaultVMetrics = properties.defaultVMetrics;
  43118. }
  43119. var glyphsUnicodeMap;
  43120. if (!file || file.isEmpty) {
  43121. if (file) {
  43122. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  43123. }
  43124. this.missingFile = true;
  43125. var fontName = name.replace(/[,_]/g, '-');
  43126. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  43127. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  43128. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  43129. this.bold = fontName.search(/bold/gi) !== -1;
  43130. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  43131. this.black = name.search(/Black/g) !== -1;
  43132. this.remeasure = Object.keys(this.widths).length > 0;
  43133. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  43134. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  43135. var map = [];
  43136. for (charCode in GlyphMapForStandardFonts) {
  43137. map[+charCode] = GlyphMapForStandardFonts[charCode];
  43138. }
  43139. if (/Arial-?Black/i.test(name)) {
  43140. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  43141. for (charCode in SupplementalGlyphMapForArialBlack) {
  43142. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  43143. }
  43144. }
  43145. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  43146. if (!isIdentityUnicode) {
  43147. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43148. map[+charCode] = unicodeCharCode;
  43149. });
  43150. }
  43151. this.toFontChar = map;
  43152. this.toUnicode = new ToUnicodeMap(map);
  43153. } else if (/Symbol/i.test(fontName)) {
  43154. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  43155. } else if (/Dingbats/i.test(fontName)) {
  43156. if (/Wingdings/i.test(name)) {
  43157. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  43158. }
  43159. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  43160. } else if (isStandardFont) {
  43161. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  43162. } else {
  43163. glyphsUnicodeMap = getGlyphsUnicode();
  43164. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  43165. if (!this.composite) {
  43166. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  43167. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  43168. if (unicode !== -1) {
  43169. unicodeCharCode = unicode;
  43170. }
  43171. }
  43172. this.toFontChar[charCode] = unicodeCharCode;
  43173. }.bind(this));
  43174. }
  43175. this.loadedName = fontName.split('-')[0];
  43176. this.loading = false;
  43177. this.fontType = getFontType(type, subtype);
  43178. return;
  43179. }
  43180. if (subtype === 'Type1C') {
  43181. if (type !== 'Type1' && type !== 'MMType1') {
  43182. if (isTrueTypeFile(file)) {
  43183. subtype = 'TrueType';
  43184. } else {
  43185. type = 'Type1';
  43186. }
  43187. } else if (isOpenTypeFile(file)) {
  43188. type = subtype = 'OpenType';
  43189. }
  43190. }
  43191. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  43192. type = 'CIDFontType0';
  43193. }
  43194. if (subtype === 'OpenType') {
  43195. type = 'OpenType';
  43196. }
  43197. if (type === 'CIDFontType0') {
  43198. if (isType1File(file)) {
  43199. subtype = 'CIDFontType0';
  43200. } else if (isOpenTypeFile(file)) {
  43201. type = subtype = 'OpenType';
  43202. } else {
  43203. subtype = 'CIDFontType0C';
  43204. }
  43205. }
  43206. var data;
  43207. switch (type) {
  43208. case 'MMType1':
  43209. info('MMType1 font (' + name + '), falling back to Type1.');
  43210. case 'Type1':
  43211. case 'CIDFontType0':
  43212. this.mimetype = 'font/opentype';
  43213. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  43214. adjustWidths(properties);
  43215. data = this.convert(name, cff, properties);
  43216. break;
  43217. case 'OpenType':
  43218. case 'TrueType':
  43219. case 'CIDFontType2':
  43220. this.mimetype = 'font/opentype';
  43221. data = this.checkAndRepair(name, file, properties);
  43222. if (this.isOpenType) {
  43223. adjustWidths(properties);
  43224. type = 'OpenType';
  43225. }
  43226. break;
  43227. default:
  43228. error('Font ' + type + ' is not supported');
  43229. break;
  43230. }
  43231. this.data = data;
  43232. this.fontType = getFontType(type, subtype);
  43233. this.fontMatrix = properties.fontMatrix;
  43234. this.widths = properties.widths;
  43235. this.defaultWidth = properties.defaultWidth;
  43236. this.toUnicode = properties.toUnicode;
  43237. this.encoding = properties.baseEncoding;
  43238. this.seacMap = properties.seacMap;
  43239. this.loading = true;
  43240. }
  43241. Font.getFontID = function () {
  43242. var ID = 1;
  43243. return function Font_getFontID() {
  43244. return String(ID++);
  43245. };
  43246. }();
  43247. function int16(b0, b1) {
  43248. return (b0 << 8) + b1;
  43249. }
  43250. function signedInt16(b0, b1) {
  43251. var value = (b0 << 8) + b1;
  43252. return value & 1 << 15 ? value - 0x10000 : value;
  43253. }
  43254. function int32(b0, b1, b2, b3) {
  43255. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  43256. }
  43257. function string16(value) {
  43258. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43259. }
  43260. function safeString16(value) {
  43261. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  43262. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  43263. }
  43264. function isTrueTypeFile(file) {
  43265. var header = file.peekBytes(4);
  43266. return readUint32(header, 0) === 0x00010000;
  43267. }
  43268. function isOpenTypeFile(file) {
  43269. var header = file.peekBytes(4);
  43270. return bytesToString(header) === 'OTTO';
  43271. }
  43272. function isType1File(file) {
  43273. var header = file.peekBytes(2);
  43274. if (header[0] === 0x25 && header[1] === 0x21) {
  43275. return true;
  43276. }
  43277. if (header[0] === 0x80 && header[1] === 0x01) {
  43278. return true;
  43279. }
  43280. return false;
  43281. }
  43282. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  43283. var toFontChar = [], unicode;
  43284. for (var i = 0, ii = encoding.length; i < ii; i++) {
  43285. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  43286. if (unicode !== -1) {
  43287. toFontChar[i] = unicode;
  43288. }
  43289. }
  43290. for (var charCode in differences) {
  43291. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  43292. if (unicode !== -1) {
  43293. toFontChar[+charCode] = unicode;
  43294. }
  43295. }
  43296. return toFontChar;
  43297. }
  43298. function isProblematicUnicodeLocation(code) {
  43299. var i = 0, j = ProblematicCharRanges.length - 1;
  43300. while (i < j) {
  43301. var c = i + j + 1 >> 1;
  43302. if (code < ProblematicCharRanges[c]) {
  43303. j = c - 1;
  43304. } else {
  43305. i = c;
  43306. }
  43307. }
  43308. return !(i & 1);
  43309. }
  43310. function adjustMapping(charCodeToGlyphId, properties) {
  43311. var toUnicode = properties.toUnicode;
  43312. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  43313. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  43314. var newMap = Object.create(null);
  43315. var toFontChar = [];
  43316. var usedFontCharCodes = [];
  43317. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  43318. for (var originalCharCode in charCodeToGlyphId) {
  43319. originalCharCode |= 0;
  43320. var glyphId = charCodeToGlyphId[originalCharCode];
  43321. var fontCharCode = originalCharCode;
  43322. var hasUnicodeValue = false;
  43323. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  43324. hasUnicodeValue = true;
  43325. var unicode = toUnicode.get(fontCharCode);
  43326. if (unicode.length === 1) {
  43327. fontCharCode = unicode.charCodeAt(0);
  43328. }
  43329. }
  43330. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  43331. do {
  43332. fontCharCode = nextAvailableFontCharCode++;
  43333. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  43334. fontCharCode = 0xF020;
  43335. nextAvailableFontCharCode = fontCharCode + 1;
  43336. }
  43337. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  43338. }
  43339. newMap[fontCharCode] = glyphId;
  43340. toFontChar[originalCharCode] = fontCharCode;
  43341. usedFontCharCodes[fontCharCode] = true;
  43342. }
  43343. return {
  43344. toFontChar: toFontChar,
  43345. charCodeToGlyphId: newMap,
  43346. nextAvailableFontCharCode: nextAvailableFontCharCode
  43347. };
  43348. }
  43349. function getRanges(glyphs, numGlyphs) {
  43350. var codes = [];
  43351. for (var charCode in glyphs) {
  43352. if (glyphs[charCode] >= numGlyphs) {
  43353. continue;
  43354. }
  43355. codes.push({
  43356. fontCharCode: charCode | 0,
  43357. glyphId: glyphs[charCode]
  43358. });
  43359. }
  43360. codes.sort(function fontGetRangesSort(a, b) {
  43361. return a.fontCharCode - b.fontCharCode;
  43362. });
  43363. var ranges = [];
  43364. var length = codes.length;
  43365. for (var n = 0; n < length;) {
  43366. var start = codes[n].fontCharCode;
  43367. var codeIndices = [codes[n].glyphId];
  43368. ++n;
  43369. var end = start;
  43370. while (n < length && end + 1 === codes[n].fontCharCode) {
  43371. codeIndices.push(codes[n].glyphId);
  43372. ++end;
  43373. ++n;
  43374. if (end === 0xFFFF) {
  43375. break;
  43376. }
  43377. }
  43378. ranges.push([
  43379. start,
  43380. end,
  43381. codeIndices
  43382. ]);
  43383. }
  43384. return ranges;
  43385. }
  43386. function createCmapTable(glyphs, numGlyphs) {
  43387. var ranges = getRanges(glyphs, numGlyphs);
  43388. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  43389. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  43390. var i, ii, j, jj;
  43391. for (i = ranges.length - 1; i >= 0; --i) {
  43392. if (ranges[i][0] <= 0xFFFF) {
  43393. break;
  43394. }
  43395. }
  43396. var bmpLength = i + 1;
  43397. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  43398. ranges[i][1] = 0xFFFE;
  43399. }
  43400. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  43401. var segCount = bmpLength + trailingRangesCount;
  43402. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  43403. var startCount = '';
  43404. var endCount = '';
  43405. var idDeltas = '';
  43406. var idRangeOffsets = '';
  43407. var glyphsIds = '';
  43408. var bias = 0;
  43409. var range, start, end, codes;
  43410. for (i = 0, ii = bmpLength; i < ii; i++) {
  43411. range = ranges[i];
  43412. start = range[0];
  43413. end = range[1];
  43414. startCount += string16(start);
  43415. endCount += string16(end);
  43416. codes = range[2];
  43417. var contiguous = true;
  43418. for (j = 1, jj = codes.length; j < jj; ++j) {
  43419. if (codes[j] !== codes[j - 1] + 1) {
  43420. contiguous = false;
  43421. break;
  43422. }
  43423. }
  43424. if (!contiguous) {
  43425. var offset = (segCount - i) * 2 + bias * 2;
  43426. bias += end - start + 1;
  43427. idDeltas += string16(0);
  43428. idRangeOffsets += string16(offset);
  43429. for (j = 0, jj = codes.length; j < jj; ++j) {
  43430. glyphsIds += string16(codes[j]);
  43431. }
  43432. } else {
  43433. var startCode = codes[0];
  43434. idDeltas += string16(startCode - start & 0xFFFF);
  43435. idRangeOffsets += string16(0);
  43436. }
  43437. }
  43438. if (trailingRangesCount > 0) {
  43439. endCount += '\xFF\xFF';
  43440. startCount += '\xFF\xFF';
  43441. idDeltas += '\x00\x01';
  43442. idRangeOffsets += '\x00\x00';
  43443. }
  43444. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  43445. var format31012 = '';
  43446. var header31012 = '';
  43447. if (numTables > 1) {
  43448. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  43449. format31012 = '';
  43450. for (i = 0, ii = ranges.length; i < ii; i++) {
  43451. range = ranges[i];
  43452. start = range[0];
  43453. codes = range[2];
  43454. var code = codes[0];
  43455. for (j = 1, jj = codes.length; j < jj; ++j) {
  43456. if (codes[j] !== codes[j - 1] + 1) {
  43457. end = range[0] + j - 1;
  43458. format31012 += string32(start) + string32(end) + string32(code);
  43459. start = end + 1;
  43460. code = codes[j];
  43461. }
  43462. }
  43463. format31012 += string32(start) + string32(range[1]) + string32(code);
  43464. }
  43465. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  43466. }
  43467. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  43468. }
  43469. function validateOS2Table(os2) {
  43470. var stream = new Stream(os2.data);
  43471. var version = stream.getUint16();
  43472. stream.getBytes(60);
  43473. var selection = stream.getUint16();
  43474. if (version < 4 && selection & 0x0300) {
  43475. return false;
  43476. }
  43477. var firstChar = stream.getUint16();
  43478. var lastChar = stream.getUint16();
  43479. if (firstChar > lastChar) {
  43480. return false;
  43481. }
  43482. stream.getBytes(6);
  43483. var usWinAscent = stream.getUint16();
  43484. if (usWinAscent === 0) {
  43485. return false;
  43486. }
  43487. os2.data[8] = os2.data[9] = 0;
  43488. return true;
  43489. }
  43490. function createOS2Table(properties, charstrings, override) {
  43491. override = override || {
  43492. unitsPerEm: 0,
  43493. yMax: 0,
  43494. yMin: 0,
  43495. ascent: 0,
  43496. descent: 0
  43497. };
  43498. var ulUnicodeRange1 = 0;
  43499. var ulUnicodeRange2 = 0;
  43500. var ulUnicodeRange3 = 0;
  43501. var ulUnicodeRange4 = 0;
  43502. var firstCharIndex = null;
  43503. var lastCharIndex = 0;
  43504. if (charstrings) {
  43505. for (var code in charstrings) {
  43506. code |= 0;
  43507. if (firstCharIndex > code || !firstCharIndex) {
  43508. firstCharIndex = code;
  43509. }
  43510. if (lastCharIndex < code) {
  43511. lastCharIndex = code;
  43512. }
  43513. var position = getUnicodeRangeFor(code);
  43514. if (position < 32) {
  43515. ulUnicodeRange1 |= 1 << position;
  43516. } else if (position < 64) {
  43517. ulUnicodeRange2 |= 1 << position - 32;
  43518. } else if (position < 96) {
  43519. ulUnicodeRange3 |= 1 << position - 64;
  43520. } else if (position < 123) {
  43521. ulUnicodeRange4 |= 1 << position - 96;
  43522. } else {
  43523. error('Unicode ranges Bits > 123 are reserved for internal usage');
  43524. }
  43525. }
  43526. } else {
  43527. firstCharIndex = 0;
  43528. lastCharIndex = 255;
  43529. }
  43530. var bbox = properties.bbox || [
  43531. 0,
  43532. 0,
  43533. 0,
  43534. 0
  43535. ];
  43536. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  43537. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  43538. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  43539. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  43540. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  43541. typoDescent = -typoDescent;
  43542. }
  43543. var winAscent = override.yMax || typoAscent;
  43544. var winDescent = -override.yMin || -typoDescent;
  43545. return '\x00\x03' + '\x02\x24' + '\x01\xF4' + '\x00\x05' + '\x00\x00' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x00\x8C' + '\x02\x8A' + '\x02\xBB' + '\x00\x00' + '\x01\xDF' + '\x00\x31' + '\x01\x02' + '\x00\x00' + '\x00\x00\x06' + String.fromCharCode(properties.fixedPitch ? 0x09 : 0x00) + '\x00\x00\x00\x00\x00\x00' + string32(ulUnicodeRange1) + string32(ulUnicodeRange2) + string32(ulUnicodeRange3) + string32(ulUnicodeRange4) + '\x2A\x32\x31\x2A' + string16(properties.italicAngle ? 1 : 0) + string16(firstCharIndex || properties.firstChar) + string16(lastCharIndex || properties.lastChar) + string16(typoAscent) + string16(typoDescent) + '\x00\x64' + string16(winAscent) + string16(winDescent) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + string16(properties.xHeight) + string16(properties.capHeight) + string16(0) + string16(firstCharIndex || properties.firstChar) + '\x00\x03';
  43546. }
  43547. function createPostTable(properties) {
  43548. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  43549. return '\x00\x03\x00\x00' + string32(angle) + '\x00\x00' + '\x00\x00' + string32(properties.fixedPitch) + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00' + '\x00\x00\x00\x00';
  43550. }
  43551. function createNameTable(name, proto) {
  43552. if (!proto) {
  43553. proto = [
  43554. [],
  43555. []
  43556. ];
  43557. }
  43558. var strings = [
  43559. proto[0][0] || 'Original licence',
  43560. proto[0][1] || name,
  43561. proto[0][2] || 'Unknown',
  43562. proto[0][3] || 'uniqueID',
  43563. proto[0][4] || name,
  43564. proto[0][5] || 'Version 0.11',
  43565. proto[0][6] || '',
  43566. proto[0][7] || 'Unknown',
  43567. proto[0][8] || 'Unknown',
  43568. proto[0][9] || 'Unknown'
  43569. ];
  43570. var stringsUnicode = [];
  43571. var i, ii, j, jj, str;
  43572. for (i = 0, ii = strings.length; i < ii; i++) {
  43573. str = proto[1][i] || strings[i];
  43574. var strBufUnicode = [];
  43575. for (j = 0, jj = str.length; j < jj; j++) {
  43576. strBufUnicode.push(string16(str.charCodeAt(j)));
  43577. }
  43578. stringsUnicode.push(strBufUnicode.join(''));
  43579. }
  43580. var names = [
  43581. strings,
  43582. stringsUnicode
  43583. ];
  43584. var platforms = [
  43585. '\x00\x01',
  43586. '\x00\x03'
  43587. ];
  43588. var encodings = [
  43589. '\x00\x00',
  43590. '\x00\x01'
  43591. ];
  43592. var languages = [
  43593. '\x00\x00',
  43594. '\x04\x09'
  43595. ];
  43596. var namesRecordCount = strings.length * platforms.length;
  43597. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  43598. var strOffset = 0;
  43599. for (i = 0, ii = platforms.length; i < ii; i++) {
  43600. var strs = names[i];
  43601. for (j = 0, jj = strs.length; j < jj; j++) {
  43602. str = strs[j];
  43603. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  43604. nameTable += nameRecord;
  43605. strOffset += str.length;
  43606. }
  43607. }
  43608. nameTable += strings.join('') + stringsUnicode.join('');
  43609. return nameTable;
  43610. }
  43611. Font.prototype = {
  43612. name: null,
  43613. font: null,
  43614. mimetype: null,
  43615. encoding: null,
  43616. get renderer() {
  43617. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  43618. return shadow(this, 'renderer', renderer);
  43619. },
  43620. exportData: function Font_exportData() {
  43621. var data = {};
  43622. for (var i in this) {
  43623. if (this.hasOwnProperty(i)) {
  43624. data[i] = this[i];
  43625. }
  43626. }
  43627. return data;
  43628. },
  43629. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  43630. function readTableEntry(file) {
  43631. var tag = bytesToString(file.getBytes(4));
  43632. var checksum = file.getInt32() >>> 0;
  43633. var offset = file.getInt32() >>> 0;
  43634. var length = file.getInt32() >>> 0;
  43635. var previousPosition = file.pos;
  43636. file.pos = file.start ? file.start : 0;
  43637. file.skip(offset);
  43638. var data = file.getBytes(length);
  43639. file.pos = previousPosition;
  43640. if (tag === 'head') {
  43641. data[8] = data[9] = data[10] = data[11] = 0;
  43642. data[17] |= 0x20;
  43643. }
  43644. return {
  43645. tag: tag,
  43646. checksum: checksum,
  43647. length: length,
  43648. offset: offset,
  43649. data: data
  43650. };
  43651. }
  43652. function readOpenTypeHeader(ttf) {
  43653. return {
  43654. version: bytesToString(ttf.getBytes(4)),
  43655. numTables: ttf.getUint16(),
  43656. searchRange: ttf.getUint16(),
  43657. entrySelector: ttf.getUint16(),
  43658. rangeShift: ttf.getUint16()
  43659. };
  43660. }
  43661. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  43662. if (!cmap) {
  43663. warn('No cmap table available.');
  43664. return {
  43665. platformId: -1,
  43666. encodingId: -1,
  43667. mappings: [],
  43668. hasShortCmap: false
  43669. };
  43670. }
  43671. var segment;
  43672. var start = (font.start ? font.start : 0) + cmap.offset;
  43673. font.pos = start;
  43674. font.getUint16();
  43675. var numTables = font.getUint16();
  43676. var potentialTable;
  43677. var canBreak = false;
  43678. for (var i = 0; i < numTables; i++) {
  43679. var platformId = font.getUint16();
  43680. var encodingId = font.getUint16();
  43681. var offset = font.getInt32() >>> 0;
  43682. var useTable = false;
  43683. if (platformId === 0 && encodingId === 0) {
  43684. useTable = true;
  43685. } else if (platformId === 1 && encodingId === 0) {
  43686. useTable = true;
  43687. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  43688. useTable = true;
  43689. if (!isSymbolicFont) {
  43690. canBreak = true;
  43691. }
  43692. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  43693. useTable = true;
  43694. canBreak = true;
  43695. }
  43696. if (useTable) {
  43697. potentialTable = {
  43698. platformId: platformId,
  43699. encodingId: encodingId,
  43700. offset: offset
  43701. };
  43702. }
  43703. if (canBreak) {
  43704. break;
  43705. }
  43706. }
  43707. if (potentialTable) {
  43708. font.pos = start + potentialTable.offset;
  43709. }
  43710. if (!potentialTable || font.peekByte() === -1) {
  43711. warn('Could not find a preferred cmap table.');
  43712. return {
  43713. platformId: -1,
  43714. encodingId: -1,
  43715. mappings: [],
  43716. hasShortCmap: false
  43717. };
  43718. }
  43719. var format = font.getUint16();
  43720. font.getUint16();
  43721. font.getUint16();
  43722. var hasShortCmap = false;
  43723. var mappings = [];
  43724. var j, glyphId;
  43725. if (format === 0) {
  43726. for (j = 0; j < 256; j++) {
  43727. var index = font.getByte();
  43728. if (!index) {
  43729. continue;
  43730. }
  43731. mappings.push({
  43732. charCode: j,
  43733. glyphId: index
  43734. });
  43735. }
  43736. hasShortCmap = true;
  43737. } else if (format === 4) {
  43738. var segCount = font.getUint16() >> 1;
  43739. font.getBytes(6);
  43740. var segIndex, segments = [];
  43741. for (segIndex = 0; segIndex < segCount; segIndex++) {
  43742. segments.push({ end: font.getUint16() });
  43743. }
  43744. font.getUint16();
  43745. for (segIndex = 0; segIndex < segCount; segIndex++) {
  43746. segments[segIndex].start = font.getUint16();
  43747. }
  43748. for (segIndex = 0; segIndex < segCount; segIndex++) {
  43749. segments[segIndex].delta = font.getUint16();
  43750. }
  43751. var offsetsCount = 0;
  43752. for (segIndex = 0; segIndex < segCount; segIndex++) {
  43753. segment = segments[segIndex];
  43754. var rangeOffset = font.getUint16();
  43755. if (!rangeOffset) {
  43756. segment.offsetIndex = -1;
  43757. continue;
  43758. }
  43759. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  43760. segment.offsetIndex = offsetIndex;
  43761. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  43762. }
  43763. var offsets = [];
  43764. for (j = 0; j < offsetsCount; j++) {
  43765. offsets.push(font.getUint16());
  43766. }
  43767. for (segIndex = 0; segIndex < segCount; segIndex++) {
  43768. segment = segments[segIndex];
  43769. start = segment.start;
  43770. var end = segment.end;
  43771. var delta = segment.delta;
  43772. offsetIndex = segment.offsetIndex;
  43773. for (j = start; j <= end; j++) {
  43774. if (j === 0xFFFF) {
  43775. continue;
  43776. }
  43777. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  43778. glyphId = glyphId + delta & 0xFFFF;
  43779. if (glyphId === 0) {
  43780. continue;
  43781. }
  43782. mappings.push({
  43783. charCode: j,
  43784. glyphId: glyphId
  43785. });
  43786. }
  43787. }
  43788. } else if (format === 6) {
  43789. var firstCode = font.getUint16();
  43790. var entryCount = font.getUint16();
  43791. for (j = 0; j < entryCount; j++) {
  43792. glyphId = font.getUint16();
  43793. var charCode = firstCode + j;
  43794. mappings.push({
  43795. charCode: charCode,
  43796. glyphId: glyphId
  43797. });
  43798. }
  43799. } else {
  43800. warn('cmap table has unsupported format: ' + format);
  43801. return {
  43802. platformId: -1,
  43803. encodingId: -1,
  43804. mappings: [],
  43805. hasShortCmap: false
  43806. };
  43807. }
  43808. mappings.sort(function (a, b) {
  43809. return a.charCode - b.charCode;
  43810. });
  43811. for (i = 1; i < mappings.length; i++) {
  43812. if (mappings[i - 1].charCode === mappings[i].charCode) {
  43813. mappings.splice(i, 1);
  43814. i--;
  43815. }
  43816. }
  43817. return {
  43818. platformId: potentialTable.platformId,
  43819. encodingId: potentialTable.encodingId,
  43820. mappings: mappings,
  43821. hasShortCmap: hasShortCmap
  43822. };
  43823. }
  43824. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  43825. if (!header) {
  43826. if (metrics) {
  43827. metrics.data = null;
  43828. }
  43829. return;
  43830. }
  43831. font.pos = (font.start ? font.start : 0) + header.offset;
  43832. font.pos += header.length - 2;
  43833. var numOfMetrics = font.getUint16();
  43834. if (numOfMetrics > numGlyphs) {
  43835. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  43836. numOfMetrics = numGlyphs;
  43837. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  43838. header.data[35] = numOfMetrics & 0x00ff;
  43839. }
  43840. var numOfSidebearings = numGlyphs - numOfMetrics;
  43841. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  43842. if (numMissing > 0) {
  43843. var entries = new Uint8Array(metrics.length + numMissing * 2);
  43844. entries.set(metrics.data);
  43845. metrics.data = entries;
  43846. }
  43847. }
  43848. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  43849. if (sourceEnd - sourceStart <= 12) {
  43850. return 0;
  43851. }
  43852. var glyf = source.subarray(sourceStart, sourceEnd);
  43853. var contoursCount = glyf[0] << 8 | glyf[1];
  43854. if (contoursCount & 0x8000) {
  43855. dest.set(glyf, destStart);
  43856. return glyf.length;
  43857. }
  43858. var i, j = 10, flagsCount = 0;
  43859. for (i = 0; i < contoursCount; i++) {
  43860. var endPoint = glyf[j] << 8 | glyf[j + 1];
  43861. flagsCount = endPoint + 1;
  43862. j += 2;
  43863. }
  43864. var instructionsStart = j;
  43865. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  43866. j += 2 + instructionsLength;
  43867. var instructionsEnd = j;
  43868. var coordinatesLength = 0;
  43869. for (i = 0; i < flagsCount; i++) {
  43870. var flag = glyf[j++];
  43871. if (flag & 0xC0) {
  43872. glyf[j - 1] = flag & 0x3F;
  43873. }
  43874. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  43875. coordinatesLength += xyLength;
  43876. if (flag & 8) {
  43877. var repeat = glyf[j++];
  43878. i += repeat;
  43879. coordinatesLength += repeat * xyLength;
  43880. }
  43881. }
  43882. if (coordinatesLength === 0) {
  43883. return 0;
  43884. }
  43885. var glyphDataLength = j + coordinatesLength;
  43886. if (glyphDataLength > glyf.length) {
  43887. return 0;
  43888. }
  43889. if (!hintsValid && instructionsLength > 0) {
  43890. dest.set(glyf.subarray(0, instructionsStart), destStart);
  43891. dest.set([
  43892. 0,
  43893. 0
  43894. ], destStart + instructionsStart);
  43895. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  43896. glyphDataLength -= instructionsLength;
  43897. if (glyf.length - glyphDataLength > 3) {
  43898. glyphDataLength = glyphDataLength + 3 & ~3;
  43899. }
  43900. return glyphDataLength;
  43901. }
  43902. if (glyf.length - glyphDataLength > 3) {
  43903. glyphDataLength = glyphDataLength + 3 & ~3;
  43904. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  43905. return glyphDataLength;
  43906. }
  43907. dest.set(glyf, destStart);
  43908. return glyf.length;
  43909. }
  43910. function sanitizeHead(head, numGlyphs, locaLength) {
  43911. var data = head.data;
  43912. var version = int32(data[0], data[1], data[2], data[3]);
  43913. if (version >> 16 !== 1) {
  43914. info('Attempting to fix invalid version in head table: ' + version);
  43915. data[0] = 0;
  43916. data[1] = 1;
  43917. data[2] = 0;
  43918. data[3] = 0;
  43919. }
  43920. var indexToLocFormat = int16(data[50], data[51]);
  43921. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  43922. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  43923. var numGlyphsPlusOne = numGlyphs + 1;
  43924. if (locaLength === numGlyphsPlusOne << 1) {
  43925. data[50] = 0;
  43926. data[51] = 0;
  43927. } else if (locaLength === numGlyphsPlusOne << 2) {
  43928. data[50] = 0;
  43929. data[51] = 1;
  43930. } else {
  43931. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  43932. }
  43933. }
  43934. }
  43935. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  43936. var itemSize, itemDecode, itemEncode;
  43937. if (isGlyphLocationsLong) {
  43938. itemSize = 4;
  43939. itemDecode = function fontItemDecodeLong(data, offset) {
  43940. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  43941. };
  43942. itemEncode = function fontItemEncodeLong(data, offset, value) {
  43943. data[offset] = value >>> 24 & 0xFF;
  43944. data[offset + 1] = value >> 16 & 0xFF;
  43945. data[offset + 2] = value >> 8 & 0xFF;
  43946. data[offset + 3] = value & 0xFF;
  43947. };
  43948. } else {
  43949. itemSize = 2;
  43950. itemDecode = function fontItemDecode(data, offset) {
  43951. return data[offset] << 9 | data[offset + 1] << 1;
  43952. };
  43953. itemEncode = function fontItemEncode(data, offset, value) {
  43954. data[offset] = value >> 9 & 0xFF;
  43955. data[offset + 1] = value >> 1 & 0xFF;
  43956. };
  43957. }
  43958. var locaData = loca.data;
  43959. var locaDataSize = itemSize * (1 + numGlyphs);
  43960. if (locaData.length !== locaDataSize) {
  43961. locaData = new Uint8Array(locaDataSize);
  43962. locaData.set(loca.data.subarray(0, locaDataSize));
  43963. loca.data = locaData;
  43964. }
  43965. var oldGlyfData = glyf.data;
  43966. var oldGlyfDataLength = oldGlyfData.length;
  43967. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  43968. var startOffset = itemDecode(locaData, 0);
  43969. var writeOffset = 0;
  43970. var missingGlyphData = Object.create(null);
  43971. itemEncode(locaData, 0, writeOffset);
  43972. var i, j;
  43973. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  43974. var endOffset = itemDecode(locaData, j);
  43975. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  43976. endOffset = oldGlyfDataLength;
  43977. }
  43978. if (endOffset > oldGlyfDataLength) {
  43979. itemEncode(locaData, j, writeOffset);
  43980. startOffset = endOffset;
  43981. continue;
  43982. }
  43983. if (startOffset === endOffset) {
  43984. missingGlyphData[i] = true;
  43985. }
  43986. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  43987. writeOffset += newLength;
  43988. itemEncode(locaData, j, writeOffset);
  43989. startOffset = endOffset;
  43990. }
  43991. if (writeOffset === 0) {
  43992. var simpleGlyph = new Uint8Array([
  43993. 0,
  43994. 1,
  43995. 0,
  43996. 0,
  43997. 0,
  43998. 0,
  43999. 0,
  44000. 0,
  44001. 0,
  44002. 0,
  44003. 0,
  44004. 0,
  44005. 0,
  44006. 0,
  44007. 49,
  44008. 0
  44009. ]);
  44010. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  44011. itemEncode(locaData, j, simpleGlyph.length);
  44012. }
  44013. glyf.data = simpleGlyph;
  44014. return missingGlyphData;
  44015. }
  44016. if (dupFirstEntry) {
  44017. var firstEntryLength = itemDecode(locaData, itemSize);
  44018. if (newGlyfData.length > firstEntryLength + writeOffset) {
  44019. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  44020. } else {
  44021. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  44022. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  44023. }
  44024. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  44025. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  44026. } else {
  44027. glyf.data = newGlyfData.subarray(0, writeOffset);
  44028. }
  44029. return missingGlyphData;
  44030. }
  44031. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  44032. var start = (font.start ? font.start : 0) + post.offset;
  44033. font.pos = start;
  44034. var length = post.length, end = start + length;
  44035. var version = font.getInt32();
  44036. font.getBytes(28);
  44037. var glyphNames;
  44038. var valid = true;
  44039. var i;
  44040. switch (version) {
  44041. case 0x00010000:
  44042. glyphNames = MacStandardGlyphOrdering;
  44043. break;
  44044. case 0x00020000:
  44045. var numGlyphs = font.getUint16();
  44046. if (numGlyphs !== maxpNumGlyphs) {
  44047. valid = false;
  44048. break;
  44049. }
  44050. var glyphNameIndexes = [];
  44051. for (i = 0; i < numGlyphs; ++i) {
  44052. var index = font.getUint16();
  44053. if (index >= 32768) {
  44054. valid = false;
  44055. break;
  44056. }
  44057. glyphNameIndexes.push(index);
  44058. }
  44059. if (!valid) {
  44060. break;
  44061. }
  44062. var customNames = [];
  44063. var strBuf = [];
  44064. while (font.pos < end) {
  44065. var stringLength = font.getByte();
  44066. strBuf.length = stringLength;
  44067. for (i = 0; i < stringLength; ++i) {
  44068. strBuf[i] = String.fromCharCode(font.getByte());
  44069. }
  44070. customNames.push(strBuf.join(''));
  44071. }
  44072. glyphNames = [];
  44073. for (i = 0; i < numGlyphs; ++i) {
  44074. var j = glyphNameIndexes[i];
  44075. if (j < 258) {
  44076. glyphNames.push(MacStandardGlyphOrdering[j]);
  44077. continue;
  44078. }
  44079. glyphNames.push(customNames[j - 258]);
  44080. }
  44081. break;
  44082. case 0x00030000:
  44083. break;
  44084. default:
  44085. warn('Unknown/unsupported post table version ' + version);
  44086. valid = false;
  44087. if (properties.defaultEncoding) {
  44088. glyphNames = properties.defaultEncoding;
  44089. }
  44090. break;
  44091. }
  44092. properties.glyphNames = glyphNames;
  44093. return valid;
  44094. }
  44095. function readNameTable(nameTable) {
  44096. var start = (font.start ? font.start : 0) + nameTable.offset;
  44097. font.pos = start;
  44098. var names = [
  44099. [],
  44100. []
  44101. ];
  44102. var length = nameTable.length, end = start + length;
  44103. var format = font.getUint16();
  44104. var FORMAT_0_HEADER_LENGTH = 6;
  44105. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  44106. return names;
  44107. }
  44108. var numRecords = font.getUint16();
  44109. var stringsStart = font.getUint16();
  44110. var records = [];
  44111. var NAME_RECORD_LENGTH = 12;
  44112. var i, ii;
  44113. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  44114. var r = {
  44115. platform: font.getUint16(),
  44116. encoding: font.getUint16(),
  44117. language: font.getUint16(),
  44118. name: font.getUint16(),
  44119. length: font.getUint16(),
  44120. offset: font.getUint16()
  44121. };
  44122. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  44123. records.push(r);
  44124. }
  44125. }
  44126. for (i = 0, ii = records.length; i < ii; i++) {
  44127. var record = records[i];
  44128. if (record.length <= 0) {
  44129. continue;
  44130. }
  44131. var pos = start + stringsStart + record.offset;
  44132. if (pos + record.length > end) {
  44133. continue;
  44134. }
  44135. font.pos = pos;
  44136. var nameIndex = record.name;
  44137. if (record.encoding) {
  44138. var str = '';
  44139. for (var j = 0, jj = record.length; j < jj; j += 2) {
  44140. str += String.fromCharCode(font.getUint16());
  44141. }
  44142. names[1][nameIndex] = str;
  44143. } else {
  44144. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  44145. }
  44146. }
  44147. return names;
  44148. }
  44149. var TTOpsStackDeltas = [
  44150. 0,
  44151. 0,
  44152. 0,
  44153. 0,
  44154. 0,
  44155. 0,
  44156. 0,
  44157. 0,
  44158. -2,
  44159. -2,
  44160. -2,
  44161. -2,
  44162. 0,
  44163. 0,
  44164. -2,
  44165. -5,
  44166. -1,
  44167. -1,
  44168. -1,
  44169. -1,
  44170. -1,
  44171. -1,
  44172. -1,
  44173. -1,
  44174. 0,
  44175. 0,
  44176. -1,
  44177. 0,
  44178. -1,
  44179. -1,
  44180. -1,
  44181. -1,
  44182. 1,
  44183. -1,
  44184. -999,
  44185. 0,
  44186. 1,
  44187. 0,
  44188. -1,
  44189. -2,
  44190. 0,
  44191. -1,
  44192. -2,
  44193. -1,
  44194. -1,
  44195. 0,
  44196. -1,
  44197. -1,
  44198. 0,
  44199. 0,
  44200. -999,
  44201. -999,
  44202. -1,
  44203. -1,
  44204. -1,
  44205. -1,
  44206. -2,
  44207. -999,
  44208. -2,
  44209. -2,
  44210. -999,
  44211. 0,
  44212. -2,
  44213. -2,
  44214. 0,
  44215. 0,
  44216. -2,
  44217. 0,
  44218. -2,
  44219. 0,
  44220. 0,
  44221. 0,
  44222. -2,
  44223. -1,
  44224. -1,
  44225. 1,
  44226. 1,
  44227. 0,
  44228. 0,
  44229. -1,
  44230. -1,
  44231. -1,
  44232. -1,
  44233. -1,
  44234. -1,
  44235. -1,
  44236. 0,
  44237. 0,
  44238. -1,
  44239. 0,
  44240. -1,
  44241. -1,
  44242. 0,
  44243. -999,
  44244. -1,
  44245. -1,
  44246. -1,
  44247. -1,
  44248. -1,
  44249. -1,
  44250. 0,
  44251. 0,
  44252. 0,
  44253. 0,
  44254. 0,
  44255. 0,
  44256. 0,
  44257. 0,
  44258. 0,
  44259. 0,
  44260. 0,
  44261. 0,
  44262. -2,
  44263. -999,
  44264. -999,
  44265. -999,
  44266. -999,
  44267. -999,
  44268. -1,
  44269. -1,
  44270. -2,
  44271. -2,
  44272. 0,
  44273. 0,
  44274. 0,
  44275. 0,
  44276. -1,
  44277. -1,
  44278. -999,
  44279. -2,
  44280. -2,
  44281. 0,
  44282. 0,
  44283. -1,
  44284. -2,
  44285. -2,
  44286. 0,
  44287. 0,
  44288. 0,
  44289. -1,
  44290. -1,
  44291. -1,
  44292. -2
  44293. ];
  44294. function sanitizeTTProgram(table, ttContext) {
  44295. var data = table.data;
  44296. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  44297. var stack = [];
  44298. var callstack = [];
  44299. var functionsCalled = [];
  44300. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  44301. var inFDEF = false, ifLevel = 0, inELSE = 0;
  44302. for (var ii = data.length; i < ii;) {
  44303. var op = data[i++];
  44304. if (op === 0x40) {
  44305. n = data[i++];
  44306. if (inFDEF || inELSE) {
  44307. i += n;
  44308. } else {
  44309. for (j = 0; j < n; j++) {
  44310. stack.push(data[i++]);
  44311. }
  44312. }
  44313. } else if (op === 0x41) {
  44314. n = data[i++];
  44315. if (inFDEF || inELSE) {
  44316. i += n * 2;
  44317. } else {
  44318. for (j = 0; j < n; j++) {
  44319. b = data[i++];
  44320. stack.push(b << 8 | data[i++]);
  44321. }
  44322. }
  44323. } else if ((op & 0xF8) === 0xB0) {
  44324. n = op - 0xB0 + 1;
  44325. if (inFDEF || inELSE) {
  44326. i += n;
  44327. } else {
  44328. for (j = 0; j < n; j++) {
  44329. stack.push(data[i++]);
  44330. }
  44331. }
  44332. } else if ((op & 0xF8) === 0xB8) {
  44333. n = op - 0xB8 + 1;
  44334. if (inFDEF || inELSE) {
  44335. i += n * 2;
  44336. } else {
  44337. for (j = 0; j < n; j++) {
  44338. b = data[i++];
  44339. stack.push(b << 8 | data[i++]);
  44340. }
  44341. }
  44342. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  44343. if (!inFDEF && !inELSE) {
  44344. funcId = stack[stack.length - 1];
  44345. ttContext.functionsUsed[funcId] = true;
  44346. if (funcId in ttContext.functionsStackDeltas) {
  44347. stack.length += ttContext.functionsStackDeltas[funcId];
  44348. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  44349. callstack.push({
  44350. data: data,
  44351. i: i,
  44352. stackTop: stack.length - 1
  44353. });
  44354. functionsCalled.push(funcId);
  44355. pc = ttContext.functionsDefined[funcId];
  44356. if (!pc) {
  44357. warn('TT: CALL non-existent function');
  44358. ttContext.hintsValid = false;
  44359. return;
  44360. }
  44361. data = pc.data;
  44362. i = pc.i;
  44363. }
  44364. }
  44365. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  44366. if (inFDEF || inELSE) {
  44367. warn('TT: nested FDEFs not allowed');
  44368. tooComplexToFollowFunctions = true;
  44369. }
  44370. inFDEF = true;
  44371. lastDeff = i;
  44372. funcId = stack.pop();
  44373. ttContext.functionsDefined[funcId] = {
  44374. data: data,
  44375. i: i
  44376. };
  44377. } else if (op === 0x2D) {
  44378. if (inFDEF) {
  44379. inFDEF = false;
  44380. lastEndf = i;
  44381. } else {
  44382. pc = callstack.pop();
  44383. if (!pc) {
  44384. warn('TT: ENDF bad stack');
  44385. ttContext.hintsValid = false;
  44386. return;
  44387. }
  44388. funcId = functionsCalled.pop();
  44389. data = pc.data;
  44390. i = pc.i;
  44391. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  44392. }
  44393. } else if (op === 0x89) {
  44394. if (inFDEF || inELSE) {
  44395. warn('TT: nested IDEFs not allowed');
  44396. tooComplexToFollowFunctions = true;
  44397. }
  44398. inFDEF = true;
  44399. lastDeff = i;
  44400. } else if (op === 0x58) {
  44401. ++ifLevel;
  44402. } else if (op === 0x1B) {
  44403. inELSE = ifLevel;
  44404. } else if (op === 0x59) {
  44405. if (inELSE === ifLevel) {
  44406. inELSE = 0;
  44407. }
  44408. --ifLevel;
  44409. } else if (op === 0x1C) {
  44410. if (!inFDEF && !inELSE) {
  44411. var offset = stack[stack.length - 1];
  44412. if (offset > 0) {
  44413. i += offset - 1;
  44414. }
  44415. }
  44416. }
  44417. if (!inFDEF && !inELSE) {
  44418. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  44419. if (op >= 0x71 && op <= 0x75) {
  44420. n = stack.pop();
  44421. if (!isNaN(n)) {
  44422. stackDelta = -n * 2;
  44423. }
  44424. }
  44425. while (stackDelta < 0 && stack.length > 0) {
  44426. stack.pop();
  44427. stackDelta++;
  44428. }
  44429. while (stackDelta > 0) {
  44430. stack.push(NaN);
  44431. stackDelta--;
  44432. }
  44433. }
  44434. }
  44435. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  44436. var content = [data];
  44437. if (i > data.length) {
  44438. content.push(new Uint8Array(i - data.length));
  44439. }
  44440. if (lastDeff > lastEndf) {
  44441. warn('TT: complementing a missing function tail');
  44442. content.push(new Uint8Array([
  44443. 0x22,
  44444. 0x2D
  44445. ]));
  44446. }
  44447. foldTTTable(table, content);
  44448. }
  44449. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  44450. if (ttContext.tooComplexToFollowFunctions) {
  44451. return;
  44452. }
  44453. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  44454. warn('TT: more functions defined than expected');
  44455. ttContext.hintsValid = false;
  44456. return;
  44457. }
  44458. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  44459. if (j > maxFunctionDefs) {
  44460. warn('TT: invalid function id: ' + j);
  44461. ttContext.hintsValid = false;
  44462. return;
  44463. }
  44464. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  44465. warn('TT: undefined function: ' + j);
  44466. ttContext.hintsValid = false;
  44467. return;
  44468. }
  44469. }
  44470. }
  44471. function foldTTTable(table, content) {
  44472. if (content.length > 1) {
  44473. var newLength = 0;
  44474. var j, jj;
  44475. for (j = 0, jj = content.length; j < jj; j++) {
  44476. newLength += content[j].length;
  44477. }
  44478. newLength = newLength + 3 & ~3;
  44479. var result = new Uint8Array(newLength);
  44480. var pos = 0;
  44481. for (j = 0, jj = content.length; j < jj; j++) {
  44482. result.set(content[j], pos);
  44483. pos += content[j].length;
  44484. }
  44485. table.data = result;
  44486. table.length = newLength;
  44487. }
  44488. }
  44489. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  44490. var ttContext = {
  44491. functionsDefined: [],
  44492. functionsUsed: [],
  44493. functionsStackDeltas: [],
  44494. tooComplexToFollowFunctions: false,
  44495. hintsValid: true
  44496. };
  44497. if (fpgm) {
  44498. sanitizeTTProgram(fpgm, ttContext);
  44499. }
  44500. if (prep) {
  44501. sanitizeTTProgram(prep, ttContext);
  44502. }
  44503. if (fpgm) {
  44504. checkInvalidFunctions(ttContext, maxFunctionDefs);
  44505. }
  44506. if (cvt && cvt.length & 1) {
  44507. var cvtData = new Uint8Array(cvt.length + 1);
  44508. cvtData.set(cvt.data);
  44509. cvt.data = cvtData;
  44510. }
  44511. return ttContext.hintsValid;
  44512. }
  44513. font = new Stream(new Uint8Array(font.getBytes()));
  44514. var VALID_TABLES = [
  44515. 'OS/2',
  44516. 'cmap',
  44517. 'head',
  44518. 'hhea',
  44519. 'hmtx',
  44520. 'maxp',
  44521. 'name',
  44522. 'post',
  44523. 'loca',
  44524. 'glyf',
  44525. 'fpgm',
  44526. 'prep',
  44527. 'cvt ',
  44528. 'CFF '
  44529. ];
  44530. var header = readOpenTypeHeader(font);
  44531. var numTables = header.numTables;
  44532. var cff, cffFile;
  44533. var tables = Object.create(null);
  44534. tables['OS/2'] = null;
  44535. tables['cmap'] = null;
  44536. tables['head'] = null;
  44537. tables['hhea'] = null;
  44538. tables['hmtx'] = null;
  44539. tables['maxp'] = null;
  44540. tables['name'] = null;
  44541. tables['post'] = null;
  44542. var table;
  44543. for (var i = 0; i < numTables; i++) {
  44544. table = readTableEntry(font);
  44545. if (VALID_TABLES.indexOf(table.tag) < 0) {
  44546. continue;
  44547. }
  44548. if (table.length === 0) {
  44549. continue;
  44550. }
  44551. tables[table.tag] = table;
  44552. }
  44553. var isTrueType = !tables['CFF '];
  44554. if (!isTrueType) {
  44555. if (header.version === 'OTTO' && !properties.composite || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  44556. cffFile = new Stream(tables['CFF '].data);
  44557. cff = new CFFFont(cffFile, properties);
  44558. adjustWidths(properties);
  44559. return this.convert(name, cff, properties);
  44560. }
  44561. delete tables['glyf'];
  44562. delete tables['loca'];
  44563. delete tables['fpgm'];
  44564. delete tables['prep'];
  44565. delete tables['cvt '];
  44566. this.isOpenType = true;
  44567. } else {
  44568. if (!tables['loca']) {
  44569. error('Required "loca" table is not found');
  44570. }
  44571. if (!tables['glyf']) {
  44572. warn('Required "glyf" table is not found -- trying to recover.');
  44573. tables['glyf'] = {
  44574. tag: 'glyf',
  44575. data: new Uint8Array(0)
  44576. };
  44577. }
  44578. this.isOpenType = false;
  44579. }
  44580. if (!tables['maxp']) {
  44581. error('Required "maxp" table is not found');
  44582. }
  44583. font.pos = (font.start || 0) + tables['maxp'].offset;
  44584. var version = font.getInt32();
  44585. var numGlyphs = font.getUint16();
  44586. var maxFunctionDefs = 0;
  44587. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  44588. font.pos += 8;
  44589. var maxZones = font.getUint16();
  44590. if (maxZones > 2) {
  44591. tables['maxp'].data[14] = 0;
  44592. tables['maxp'].data[15] = 2;
  44593. }
  44594. font.pos += 4;
  44595. maxFunctionDefs = font.getUint16();
  44596. }
  44597. var dupFirstEntry = false;
  44598. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  44599. dupFirstEntry = true;
  44600. numGlyphs++;
  44601. tables['maxp'].data[4] = numGlyphs >> 8;
  44602. tables['maxp'].data[5] = numGlyphs & 255;
  44603. }
  44604. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  44605. if (!hintsValid) {
  44606. delete tables['fpgm'];
  44607. delete tables['prep'];
  44608. delete tables['cvt '];
  44609. }
  44610. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  44611. if (!tables['head']) {
  44612. error('Required "head" table is not found');
  44613. }
  44614. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  44615. var missingGlyphs = Object.create(null);
  44616. if (isTrueType) {
  44617. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  44618. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  44619. }
  44620. if (!tables['hhea']) {
  44621. error('Required "hhea" table is not found');
  44622. }
  44623. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  44624. tables['hhea'].data[10] = 0xFF;
  44625. tables['hhea'].data[11] = 0xFF;
  44626. }
  44627. var metricsOverride = {
  44628. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  44629. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  44630. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  44631. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  44632. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  44633. };
  44634. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  44635. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  44636. if (tables['post']) {
  44637. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  44638. if (!valid) {
  44639. tables['post'] = null;
  44640. }
  44641. }
  44642. var charCodeToGlyphId = [], charCode;
  44643. var toUnicode = properties.toUnicode, widths = properties.widths;
  44644. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  44645. function hasGlyph(glyphId, charCode, widthCode) {
  44646. if (!missingGlyphs[glyphId]) {
  44647. return true;
  44648. }
  44649. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  44650. return true;
  44651. }
  44652. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  44653. return true;
  44654. }
  44655. return false;
  44656. }
  44657. if (properties.composite) {
  44658. var cidToGidMap = properties.cidToGidMap || [];
  44659. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  44660. properties.cMap.forEach(function (charCode, cid) {
  44661. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  44662. var glyphId = -1;
  44663. if (isCidToGidMapEmpty) {
  44664. glyphId = cid;
  44665. } else if (cidToGidMap[cid] !== undefined) {
  44666. glyphId = cidToGidMap[cid];
  44667. }
  44668. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  44669. charCodeToGlyphId[charCode] = glyphId;
  44670. }
  44671. });
  44672. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  44673. charCodeToGlyphId[0] = numGlyphs - 1;
  44674. }
  44675. } else {
  44676. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  44677. var cmapPlatformId = cmapTable.platformId;
  44678. var cmapEncodingId = cmapTable.encodingId;
  44679. var cmapMappings = cmapTable.mappings;
  44680. var cmapMappingsLength = cmapMappings.length;
  44681. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  44682. var baseEncoding = [];
  44683. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  44684. baseEncoding = getEncoding(properties.baseEncodingName);
  44685. }
  44686. var glyphsUnicodeMap = getGlyphsUnicode();
  44687. for (charCode = 0; charCode < 256; charCode++) {
  44688. var glyphName, standardGlyphName;
  44689. if (this.differences && charCode in this.differences) {
  44690. glyphName = this.differences[charCode];
  44691. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  44692. glyphName = baseEncoding[charCode];
  44693. } else {
  44694. glyphName = StandardEncoding[charCode];
  44695. }
  44696. if (!glyphName) {
  44697. continue;
  44698. }
  44699. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  44700. var unicodeOrCharCode, isUnicode = false;
  44701. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  44702. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  44703. isUnicode = true;
  44704. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  44705. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  44706. }
  44707. var found = false;
  44708. for (i = 0; i < cmapMappingsLength; ++i) {
  44709. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  44710. continue;
  44711. }
  44712. var code = isUnicode ? charCode : unicodeOrCharCode;
  44713. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  44714. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  44715. found = true;
  44716. break;
  44717. }
  44718. }
  44719. if (!found && properties.glyphNames) {
  44720. var glyphId = properties.glyphNames.indexOf(glyphName);
  44721. if (glyphId === -1 && standardGlyphName !== glyphName) {
  44722. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  44723. }
  44724. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  44725. charCodeToGlyphId[charCode] = glyphId;
  44726. found = true;
  44727. }
  44728. }
  44729. if (!found) {
  44730. charCodeToGlyphId[charCode] = 0;
  44731. }
  44732. }
  44733. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  44734. for (i = 0; i < cmapMappingsLength; ++i) {
  44735. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  44736. }
  44737. } else {
  44738. for (i = 0; i < cmapMappingsLength; ++i) {
  44739. charCode = cmapMappings[i].charCode & 0xFF;
  44740. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  44741. }
  44742. }
  44743. }
  44744. if (charCodeToGlyphId.length === 0) {
  44745. charCodeToGlyphId[0] = 0;
  44746. }
  44747. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  44748. this.toFontChar = newMapping.toFontChar;
  44749. tables['cmap'] = {
  44750. tag: 'cmap',
  44751. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  44752. };
  44753. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  44754. tables['OS/2'] = {
  44755. tag: 'OS/2',
  44756. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  44757. };
  44758. }
  44759. if (!tables['post']) {
  44760. tables['post'] = {
  44761. tag: 'post',
  44762. data: createPostTable(properties)
  44763. };
  44764. }
  44765. if (!isTrueType) {
  44766. try {
  44767. cffFile = new Stream(tables['CFF '].data);
  44768. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  44769. cff = parser.parse();
  44770. var compiler = new CFFCompiler(cff);
  44771. tables['CFF '].data = compiler.compile();
  44772. } catch (e) {
  44773. warn('Failed to compile font ' + properties.loadedName);
  44774. }
  44775. }
  44776. if (!tables['name']) {
  44777. tables['name'] = {
  44778. tag: 'name',
  44779. data: createNameTable(this.name)
  44780. };
  44781. } else {
  44782. var namePrototype = readNameTable(tables['name']);
  44783. tables['name'].data = createNameTable(name, namePrototype);
  44784. }
  44785. var builder = new OpenTypeFileBuilder(header.version);
  44786. for (var tableTag in tables) {
  44787. builder.addTable(tableTag, tables[tableTag].data);
  44788. }
  44789. return builder.toArray();
  44790. },
  44791. convert: function Font_convert(fontName, font, properties) {
  44792. properties.fixedPitch = false;
  44793. if (properties.builtInEncoding) {
  44794. adjustToUnicode(properties, properties.builtInEncoding);
  44795. }
  44796. var mapping = font.getGlyphMapping(properties);
  44797. var newMapping = adjustMapping(mapping, properties);
  44798. this.toFontChar = newMapping.toFontChar;
  44799. var numGlyphs = font.numGlyphs;
  44800. function getCharCodes(charCodeToGlyphId, glyphId) {
  44801. var charCodes = null;
  44802. for (var charCode in charCodeToGlyphId) {
  44803. if (glyphId === charCodeToGlyphId[charCode]) {
  44804. if (!charCodes) {
  44805. charCodes = [];
  44806. }
  44807. charCodes.push(charCode | 0);
  44808. }
  44809. }
  44810. return charCodes;
  44811. }
  44812. function createCharCode(charCodeToGlyphId, glyphId) {
  44813. for (var charCode in charCodeToGlyphId) {
  44814. if (glyphId === charCodeToGlyphId[charCode]) {
  44815. return charCode | 0;
  44816. }
  44817. }
  44818. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  44819. return newMapping.nextAvailableFontCharCode++;
  44820. }
  44821. var seacs = font.seacs;
  44822. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  44823. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  44824. var charset = font.getCharset();
  44825. var seacMap = Object.create(null);
  44826. for (var glyphId in seacs) {
  44827. glyphId |= 0;
  44828. var seac = seacs[glyphId];
  44829. var baseGlyphName = StandardEncoding[seac[2]];
  44830. var accentGlyphName = StandardEncoding[seac[3]];
  44831. var baseGlyphId = charset.indexOf(baseGlyphName);
  44832. var accentGlyphId = charset.indexOf(accentGlyphName);
  44833. if (baseGlyphId < 0 || accentGlyphId < 0) {
  44834. continue;
  44835. }
  44836. var accentOffset = {
  44837. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  44838. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  44839. };
  44840. var charCodes = getCharCodes(mapping, glyphId);
  44841. if (!charCodes) {
  44842. continue;
  44843. }
  44844. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  44845. var charCode = charCodes[i];
  44846. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  44847. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  44848. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  44849. seacMap[charCode] = {
  44850. baseFontCharCode: baseFontCharCode,
  44851. accentFontCharCode: accentFontCharCode,
  44852. accentOffset: accentOffset
  44853. };
  44854. }
  44855. }
  44856. properties.seacMap = seacMap;
  44857. }
  44858. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  44859. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  44860. builder.addTable('CFF ', font.data);
  44861. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  44862. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  44863. builder.addTable('head', '\x00\x01\x00\x00' + '\x00\x00\x10\x00' + '\x00\x00\x00\x00' + '\x5F\x0F\x3C\xF5' + '\x00\x00' + safeString16(unitsPerEm) + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00\x00\x00\x9e\x0b\x7e\x27' + '\x00\x00' + safeString16(properties.descent) + '\x0F\xFF' + safeString16(properties.ascent) + string16(properties.italicAngle ? 2 : 0) + '\x00\x11' + '\x00\x00' + '\x00\x00' + '\x00\x00');
  44864. builder.addTable('hhea', '\x00\x01\x00\x00' + safeString16(properties.ascent) + safeString16(properties.descent) + '\x00\x00' + '\xFF\xFF' + '\x00\x00' + '\x00\x00' + '\x00\x00' + safeString16(properties.capHeight) + safeString16(Math.tan(properties.italicAngle) * properties.xHeight) + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + '\x00\x00' + string16(numGlyphs));
  44865. builder.addTable('hmtx', function fontFieldsHmtx() {
  44866. var charstrings = font.charstrings;
  44867. var cffWidths = font.cff ? font.cff.widths : null;
  44868. var hmtx = '\x00\x00\x00\x00';
  44869. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  44870. var width = 0;
  44871. if (charstrings) {
  44872. var charstring = charstrings[i - 1];
  44873. width = 'width' in charstring ? charstring.width : 0;
  44874. } else if (cffWidths) {
  44875. width = Math.ceil(cffWidths[i] || 0);
  44876. }
  44877. hmtx += string16(width) + string16(0);
  44878. }
  44879. return hmtx;
  44880. }());
  44881. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  44882. builder.addTable('name', createNameTable(fontName));
  44883. builder.addTable('post', createPostTable(properties));
  44884. return builder.toArray();
  44885. },
  44886. get spaceWidth() {
  44887. if ('_shadowWidth' in this) {
  44888. return this._shadowWidth;
  44889. }
  44890. var possibleSpaceReplacements = [
  44891. 'space',
  44892. 'minus',
  44893. 'one',
  44894. 'i',
  44895. 'I'
  44896. ];
  44897. var width;
  44898. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  44899. var glyphName = possibleSpaceReplacements[i];
  44900. if (glyphName in this.widths) {
  44901. width = this.widths[glyphName];
  44902. break;
  44903. }
  44904. var glyphsUnicodeMap = getGlyphsUnicode();
  44905. var glyphUnicode = glyphsUnicodeMap[glyphName];
  44906. var charcode = 0;
  44907. if (this.composite) {
  44908. if (this.cMap.contains(glyphUnicode)) {
  44909. charcode = this.cMap.lookup(glyphUnicode);
  44910. }
  44911. }
  44912. if (!charcode && this.toUnicode) {
  44913. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  44914. }
  44915. if (charcode <= 0) {
  44916. charcode = glyphUnicode;
  44917. }
  44918. width = this.widths[charcode];
  44919. if (width) {
  44920. break;
  44921. }
  44922. }
  44923. width = width || this.defaultWidth;
  44924. this._shadowWidth = width;
  44925. return width;
  44926. },
  44927. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  44928. var fontCharCode, width, operatorListId;
  44929. var widthCode = charcode;
  44930. if (this.cMap && this.cMap.contains(charcode)) {
  44931. widthCode = this.cMap.lookup(charcode);
  44932. }
  44933. width = this.widths[widthCode];
  44934. width = isNum(width) ? width : this.defaultWidth;
  44935. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  44936. var unicode = this.toUnicode.get(charcode) || charcode;
  44937. if (typeof unicode === 'number') {
  44938. unicode = String.fromCharCode(unicode);
  44939. }
  44940. var isInFont = charcode in this.toFontChar;
  44941. fontCharCode = this.toFontChar[charcode] || charcode;
  44942. if (this.missingFile) {
  44943. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  44944. }
  44945. if (this.isType3Font) {
  44946. operatorListId = fontCharCode;
  44947. }
  44948. var accent = null;
  44949. if (this.seacMap && this.seacMap[charcode]) {
  44950. isInFont = true;
  44951. var seac = this.seacMap[charcode];
  44952. fontCharCode = seac.baseFontCharCode;
  44953. accent = {
  44954. fontChar: String.fromCharCode(seac.accentFontCharCode),
  44955. offset: seac.accentOffset
  44956. };
  44957. }
  44958. var fontChar = String.fromCharCode(fontCharCode);
  44959. var glyph = this.glyphCache[charcode];
  44960. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  44961. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  44962. this.glyphCache[charcode] = glyph;
  44963. }
  44964. return glyph;
  44965. },
  44966. charsToGlyphs: function Font_charsToGlyphs(chars) {
  44967. var charsCache = this.charsCache;
  44968. var glyphs, glyph, charcode;
  44969. if (charsCache) {
  44970. glyphs = charsCache[chars];
  44971. if (glyphs) {
  44972. return glyphs;
  44973. }
  44974. }
  44975. if (!charsCache) {
  44976. charsCache = this.charsCache = Object.create(null);
  44977. }
  44978. glyphs = [];
  44979. var charsCacheKey = chars;
  44980. var i = 0, ii;
  44981. if (this.cMap) {
  44982. var c = Object.create(null);
  44983. while (i < chars.length) {
  44984. this.cMap.readCharCode(chars, i, c);
  44985. charcode = c.charcode;
  44986. var length = c.length;
  44987. i += length;
  44988. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  44989. glyph = this.charToGlyph(charcode, isSpace);
  44990. glyphs.push(glyph);
  44991. }
  44992. } else {
  44993. for (i = 0, ii = chars.length; i < ii; ++i) {
  44994. charcode = chars.charCodeAt(i);
  44995. glyph = this.charToGlyph(charcode, charcode === 0x20);
  44996. glyphs.push(glyph);
  44997. }
  44998. }
  44999. return charsCache[charsCacheKey] = glyphs;
  45000. }
  45001. };
  45002. return Font;
  45003. }();
  45004. var ErrorFont = function ErrorFontClosure() {
  45005. function ErrorFont(error) {
  45006. this.error = error;
  45007. this.loadedName = 'g_font_error';
  45008. this.loading = false;
  45009. }
  45010. ErrorFont.prototype = {
  45011. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  45012. return [];
  45013. },
  45014. exportData: function ErrorFont_exportData() {
  45015. return { error: this.error };
  45016. }
  45017. };
  45018. return ErrorFont;
  45019. }();
  45020. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  45021. var charCodeToGlyphId = Object.create(null);
  45022. var glyphId, charCode, baseEncoding;
  45023. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  45024. if (properties.baseEncodingName) {
  45025. baseEncoding = getEncoding(properties.baseEncodingName);
  45026. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45027. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45028. if (glyphId >= 0) {
  45029. charCodeToGlyphId[charCode] = glyphId;
  45030. } else {
  45031. charCodeToGlyphId[charCode] = 0;
  45032. }
  45033. }
  45034. } else if (isSymbolicFont) {
  45035. for (charCode in builtInEncoding) {
  45036. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  45037. }
  45038. } else {
  45039. baseEncoding = StandardEncoding;
  45040. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  45041. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  45042. if (glyphId >= 0) {
  45043. charCodeToGlyphId[charCode] = glyphId;
  45044. } else {
  45045. charCodeToGlyphId[charCode] = 0;
  45046. }
  45047. }
  45048. }
  45049. var differences = properties.differences, glyphsUnicodeMap;
  45050. if (differences) {
  45051. for (charCode in differences) {
  45052. var glyphName = differences[charCode];
  45053. glyphId = glyphNames.indexOf(glyphName);
  45054. if (glyphId === -1) {
  45055. if (!glyphsUnicodeMap) {
  45056. glyphsUnicodeMap = getGlyphsUnicode();
  45057. }
  45058. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  45059. if (standardGlyphName !== glyphName) {
  45060. glyphId = glyphNames.indexOf(standardGlyphName);
  45061. }
  45062. }
  45063. if (glyphId >= 0) {
  45064. charCodeToGlyphId[charCode] = glyphId;
  45065. } else {
  45066. charCodeToGlyphId[charCode] = 0;
  45067. }
  45068. }
  45069. }
  45070. return charCodeToGlyphId;
  45071. }
  45072. var Type1Font = function Type1FontClosure() {
  45073. function findBlock(streamBytes, signature, startIndex) {
  45074. var streamBytesLength = streamBytes.length;
  45075. var signatureLength = signature.length;
  45076. var scanLength = streamBytesLength - signatureLength;
  45077. var i = startIndex, j, found = false;
  45078. while (i < scanLength) {
  45079. j = 0;
  45080. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  45081. j++;
  45082. }
  45083. if (j >= signatureLength) {
  45084. i += j;
  45085. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  45086. i++;
  45087. }
  45088. found = true;
  45089. break;
  45090. }
  45091. i++;
  45092. }
  45093. return {
  45094. found: found,
  45095. length: i
  45096. };
  45097. }
  45098. function getHeaderBlock(stream, suggestedLength) {
  45099. var EEXEC_SIGNATURE = [
  45100. 0x65,
  45101. 0x65,
  45102. 0x78,
  45103. 0x65,
  45104. 0x63
  45105. ];
  45106. var streamStartPos = stream.pos;
  45107. var headerBytes, headerBytesLength, block;
  45108. try {
  45109. headerBytes = stream.getBytes(suggestedLength);
  45110. headerBytesLength = headerBytes.length;
  45111. } catch (ex) {
  45112. if (ex instanceof MissingDataException) {
  45113. throw ex;
  45114. }
  45115. }
  45116. if (headerBytesLength === suggestedLength) {
  45117. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  45118. if (block.found && block.length === suggestedLength) {
  45119. return {
  45120. stream: new Stream(headerBytes),
  45121. length: suggestedLength
  45122. };
  45123. }
  45124. }
  45125. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  45126. stream.pos = streamStartPos;
  45127. var SCAN_BLOCK_LENGTH = 2048;
  45128. var actualLength;
  45129. while (true) {
  45130. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  45131. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  45132. if (block.length === 0) {
  45133. break;
  45134. }
  45135. stream.pos += block.length;
  45136. if (block.found) {
  45137. actualLength = stream.pos - streamStartPos;
  45138. break;
  45139. }
  45140. }
  45141. stream.pos = streamStartPos;
  45142. if (actualLength) {
  45143. return {
  45144. stream: new Stream(stream.getBytes(actualLength)),
  45145. length: actualLength
  45146. };
  45147. }
  45148. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  45149. return {
  45150. stream: new Stream(stream.getBytes(suggestedLength)),
  45151. length: suggestedLength
  45152. };
  45153. }
  45154. function getEexecBlock(stream, suggestedLength) {
  45155. var eexecBytes = stream.getBytes();
  45156. return {
  45157. stream: new Stream(eexecBytes),
  45158. length: eexecBytes.length
  45159. };
  45160. }
  45161. function Type1Font(name, file, properties) {
  45162. var PFB_HEADER_SIZE = 6;
  45163. var headerBlockLength = properties.length1;
  45164. var eexecBlockLength = properties.length2;
  45165. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  45166. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  45167. if (pfbHeaderPresent) {
  45168. file.skip(PFB_HEADER_SIZE);
  45169. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45170. }
  45171. var headerBlock = getHeaderBlock(file, headerBlockLength);
  45172. headerBlockLength = headerBlock.length;
  45173. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  45174. headerBlockParser.extractFontHeader(properties);
  45175. if (pfbHeaderPresent) {
  45176. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  45177. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  45178. }
  45179. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  45180. eexecBlockLength = eexecBlock.length;
  45181. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  45182. var data = eexecBlockParser.extractFontProgram();
  45183. for (var info in data.properties) {
  45184. properties[info] = data.properties[info];
  45185. }
  45186. var charstrings = data.charstrings;
  45187. var type2Charstrings = this.getType2Charstrings(charstrings);
  45188. var subrs = this.getType2Subrs(data.subrs);
  45189. this.charstrings = charstrings;
  45190. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  45191. this.seacs = this.getSeacs(data.charstrings);
  45192. }
  45193. Type1Font.prototype = {
  45194. get numGlyphs() {
  45195. return this.charstrings.length + 1;
  45196. },
  45197. getCharset: function Type1Font_getCharset() {
  45198. var charset = ['.notdef'];
  45199. var charstrings = this.charstrings;
  45200. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45201. charset.push(charstrings[glyphId].glyphName);
  45202. }
  45203. return charset;
  45204. },
  45205. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  45206. var charstrings = this.charstrings;
  45207. var glyphNames = ['.notdef'], glyphId;
  45208. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  45209. glyphNames.push(charstrings[glyphId].glyphName);
  45210. }
  45211. var encoding = properties.builtInEncoding;
  45212. if (encoding) {
  45213. var builtInEncoding = Object.create(null);
  45214. for (var charCode in encoding) {
  45215. glyphId = glyphNames.indexOf(encoding[charCode]);
  45216. if (glyphId >= 0) {
  45217. builtInEncoding[charCode] = glyphId;
  45218. }
  45219. }
  45220. }
  45221. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  45222. },
  45223. getSeacs: function Type1Font_getSeacs(charstrings) {
  45224. var i, ii;
  45225. var seacMap = [];
  45226. for (i = 0, ii = charstrings.length; i < ii; i++) {
  45227. var charstring = charstrings[i];
  45228. if (charstring.seac) {
  45229. seacMap[i + 1] = charstring.seac;
  45230. }
  45231. }
  45232. return seacMap;
  45233. },
  45234. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  45235. var type2Charstrings = [];
  45236. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  45237. type2Charstrings.push(type1Charstrings[i].charstring);
  45238. }
  45239. return type2Charstrings;
  45240. },
  45241. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  45242. var bias = 0;
  45243. var count = type1Subrs.length;
  45244. if (count < 1133) {
  45245. bias = 107;
  45246. } else if (count < 33769) {
  45247. bias = 1131;
  45248. } else {
  45249. bias = 32768;
  45250. }
  45251. var type2Subrs = [];
  45252. var i;
  45253. for (i = 0; i < bias; i++) {
  45254. type2Subrs.push([0x0B]);
  45255. }
  45256. for (i = 0; i < count; i++) {
  45257. type2Subrs.push(type1Subrs[i]);
  45258. }
  45259. return type2Subrs;
  45260. },
  45261. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  45262. var cff = new CFF();
  45263. cff.header = new CFFHeader(1, 0, 4, 4);
  45264. cff.names = [name];
  45265. var topDict = new CFFTopDict();
  45266. topDict.setByName('version', 391);
  45267. topDict.setByName('Notice', 392);
  45268. topDict.setByName('FullName', 393);
  45269. topDict.setByName('FamilyName', 394);
  45270. topDict.setByName('Weight', 395);
  45271. topDict.setByName('Encoding', null);
  45272. topDict.setByName('FontMatrix', properties.fontMatrix);
  45273. topDict.setByName('FontBBox', properties.bbox);
  45274. topDict.setByName('charset', null);
  45275. topDict.setByName('CharStrings', null);
  45276. topDict.setByName('Private', null);
  45277. cff.topDict = topDict;
  45278. var strings = new CFFStrings();
  45279. strings.add('Version 0.11');
  45280. strings.add('See original notice');
  45281. strings.add(name);
  45282. strings.add(name);
  45283. strings.add('Medium');
  45284. cff.strings = strings;
  45285. cff.globalSubrIndex = new CFFIndex();
  45286. var count = glyphs.length;
  45287. var charsetArray = [0];
  45288. var i, ii;
  45289. for (i = 0; i < count; i++) {
  45290. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  45291. if (index === -1) {
  45292. index = 0;
  45293. }
  45294. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  45295. }
  45296. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  45297. var charStringsIndex = new CFFIndex();
  45298. charStringsIndex.add([
  45299. 0x8B,
  45300. 0x0E
  45301. ]);
  45302. for (i = 0; i < count; i++) {
  45303. var glyph = glyphs[i];
  45304. if (glyph.length === 0) {
  45305. charStringsIndex.add([
  45306. 0x8B,
  45307. 0x0E
  45308. ]);
  45309. continue;
  45310. }
  45311. charStringsIndex.add(glyph);
  45312. }
  45313. cff.charStrings = charStringsIndex;
  45314. var privateDict = new CFFPrivateDict();
  45315. privateDict.setByName('Subrs', null);
  45316. var fields = [
  45317. 'BlueValues',
  45318. 'OtherBlues',
  45319. 'FamilyBlues',
  45320. 'FamilyOtherBlues',
  45321. 'StemSnapH',
  45322. 'StemSnapV',
  45323. 'BlueShift',
  45324. 'BlueFuzz',
  45325. 'BlueScale',
  45326. 'LanguageGroup',
  45327. 'ExpansionFactor',
  45328. 'ForceBold',
  45329. 'StdHW',
  45330. 'StdVW'
  45331. ];
  45332. for (i = 0, ii = fields.length; i < ii; i++) {
  45333. var field = fields[i];
  45334. if (!(field in properties.privateData)) {
  45335. continue;
  45336. }
  45337. var value = properties.privateData[field];
  45338. if (isArray(value)) {
  45339. for (var j = value.length - 1; j > 0; j--) {
  45340. value[j] -= value[j - 1];
  45341. }
  45342. }
  45343. privateDict.setByName(field, value);
  45344. }
  45345. cff.topDict.privateDict = privateDict;
  45346. var subrIndex = new CFFIndex();
  45347. for (i = 0, ii = subrs.length; i < ii; i++) {
  45348. subrIndex.add(subrs[i]);
  45349. }
  45350. privateDict.subrsIndex = subrIndex;
  45351. var compiler = new CFFCompiler(cff);
  45352. return compiler.compile();
  45353. }
  45354. };
  45355. return Type1Font;
  45356. }();
  45357. var CFFFont = function CFFFontClosure() {
  45358. function CFFFont(file, properties) {
  45359. this.properties = properties;
  45360. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  45361. this.cff = parser.parse();
  45362. var compiler = new CFFCompiler(this.cff);
  45363. this.seacs = this.cff.seacs;
  45364. try {
  45365. this.data = compiler.compile();
  45366. } catch (e) {
  45367. warn('Failed to compile font ' + properties.loadedName);
  45368. this.data = file;
  45369. }
  45370. }
  45371. CFFFont.prototype = {
  45372. get numGlyphs() {
  45373. return this.cff.charStrings.count;
  45374. },
  45375. getCharset: function CFFFont_getCharset() {
  45376. return this.cff.charset.charset;
  45377. },
  45378. getGlyphMapping: function CFFFont_getGlyphMapping() {
  45379. var cff = this.cff;
  45380. var properties = this.properties;
  45381. var charsets = cff.charset.charset;
  45382. var charCodeToGlyphId;
  45383. var glyphId;
  45384. if (properties.composite) {
  45385. charCodeToGlyphId = Object.create(null);
  45386. if (cff.isCIDFont) {
  45387. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  45388. var cid = charsets[glyphId];
  45389. var charCode = properties.cMap.charCodeOf(cid);
  45390. charCodeToGlyphId[charCode] = glyphId;
  45391. }
  45392. } else {
  45393. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  45394. charCodeToGlyphId[glyphId] = glyphId;
  45395. }
  45396. }
  45397. return charCodeToGlyphId;
  45398. }
  45399. var encoding = cff.encoding ? cff.encoding.encoding : null;
  45400. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  45401. return charCodeToGlyphId;
  45402. }
  45403. };
  45404. return CFFFont;
  45405. }();
  45406. (function checkSeacSupport() {
  45407. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  45408. SEAC_ANALYSIS_ENABLED = true;
  45409. }
  45410. }());
  45411. (function checkChromeWindows() {
  45412. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  45413. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  45414. }
  45415. }());
  45416. exports.ErrorFont = ErrorFont;
  45417. exports.Font = Font;
  45418. exports.FontFlags = FontFlags;
  45419. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  45420. exports.ToUnicodeMap = ToUnicodeMap;
  45421. exports.getFontType = getFontType;
  45422. }));
  45423. (function (root, factory) {
  45424. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  45425. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  45426. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  45427. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  45428. var ImageKind = sharedUtil.ImageKind;
  45429. var OPS = sharedUtil.OPS;
  45430. var TextRenderingMode = sharedUtil.TextRenderingMode;
  45431. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  45432. var Util = sharedUtil.Util;
  45433. var assert = sharedUtil.assert;
  45434. var info = sharedUtil.info;
  45435. var isNum = sharedUtil.isNum;
  45436. var isArray = sharedUtil.isArray;
  45437. var isLittleEndian = sharedUtil.isLittleEndian;
  45438. var error = sharedUtil.error;
  45439. var shadow = sharedUtil.shadow;
  45440. var warn = sharedUtil.warn;
  45441. var TilingPattern = displayPatternHelper.TilingPattern;
  45442. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  45443. var WebGLUtils = displayWebGL.WebGLUtils;
  45444. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  45445. var MIN_FONT_SIZE = 16;
  45446. var MAX_FONT_SIZE = 100;
  45447. var MAX_GROUP_SIZE = 4096;
  45448. var MIN_WIDTH_FACTOR = 0.65;
  45449. var COMPILE_TYPE3_GLYPHS = true;
  45450. var MAX_SIZE_TO_COMPILE = 1000;
  45451. var FULL_CHUNK_HEIGHT = 16;
  45452. var HasCanvasTypedArraysCached = {
  45453. get value() {
  45454. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  45455. }
  45456. };
  45457. var IsLittleEndianCached = {
  45458. get value() {
  45459. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  45460. }
  45461. };
  45462. function addContextCurrentTransform(ctx) {
  45463. if (!ctx.mozCurrentTransform) {
  45464. ctx._originalSave = ctx.save;
  45465. ctx._originalRestore = ctx.restore;
  45466. ctx._originalRotate = ctx.rotate;
  45467. ctx._originalScale = ctx.scale;
  45468. ctx._originalTranslate = ctx.translate;
  45469. ctx._originalTransform = ctx.transform;
  45470. ctx._originalSetTransform = ctx.setTransform;
  45471. ctx._transformMatrix = ctx._transformMatrix || [
  45472. 1,
  45473. 0,
  45474. 0,
  45475. 1,
  45476. 0,
  45477. 0
  45478. ];
  45479. ctx._transformStack = [];
  45480. Object.defineProperty(ctx, 'mozCurrentTransform', {
  45481. get: function getCurrentTransform() {
  45482. return this._transformMatrix;
  45483. }
  45484. });
  45485. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  45486. get: function getCurrentTransformInverse() {
  45487. var m = this._transformMatrix;
  45488. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  45489. var ad_bc = a * d - b * c;
  45490. var bc_ad = b * c - a * d;
  45491. return [
  45492. d / ad_bc,
  45493. b / bc_ad,
  45494. c / bc_ad,
  45495. a / ad_bc,
  45496. (d * e - c * f) / bc_ad,
  45497. (b * e - a * f) / ad_bc
  45498. ];
  45499. }
  45500. });
  45501. ctx.save = function ctxSave() {
  45502. var old = this._transformMatrix;
  45503. this._transformStack.push(old);
  45504. this._transformMatrix = old.slice(0, 6);
  45505. this._originalSave();
  45506. };
  45507. ctx.restore = function ctxRestore() {
  45508. var prev = this._transformStack.pop();
  45509. if (prev) {
  45510. this._transformMatrix = prev;
  45511. this._originalRestore();
  45512. }
  45513. };
  45514. ctx.translate = function ctxTranslate(x, y) {
  45515. var m = this._transformMatrix;
  45516. m[4] = m[0] * x + m[2] * y + m[4];
  45517. m[5] = m[1] * x + m[3] * y + m[5];
  45518. this._originalTranslate(x, y);
  45519. };
  45520. ctx.scale = function ctxScale(x, y) {
  45521. var m = this._transformMatrix;
  45522. m[0] = m[0] * x;
  45523. m[1] = m[1] * x;
  45524. m[2] = m[2] * y;
  45525. m[3] = m[3] * y;
  45526. this._originalScale(x, y);
  45527. };
  45528. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  45529. var m = this._transformMatrix;
  45530. this._transformMatrix = [
  45531. m[0] * a + m[2] * b,
  45532. m[1] * a + m[3] * b,
  45533. m[0] * c + m[2] * d,
  45534. m[1] * c + m[3] * d,
  45535. m[0] * e + m[2] * f + m[4],
  45536. m[1] * e + m[3] * f + m[5]
  45537. ];
  45538. ctx._originalTransform(a, b, c, d, e, f);
  45539. };
  45540. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  45541. this._transformMatrix = [
  45542. a,
  45543. b,
  45544. c,
  45545. d,
  45546. e,
  45547. f
  45548. ];
  45549. ctx._originalSetTransform(a, b, c, d, e, f);
  45550. };
  45551. ctx.rotate = function ctxRotate(angle) {
  45552. var cosValue = Math.cos(angle);
  45553. var sinValue = Math.sin(angle);
  45554. var m = this._transformMatrix;
  45555. this._transformMatrix = [
  45556. m[0] * cosValue + m[2] * sinValue,
  45557. m[1] * cosValue + m[3] * sinValue,
  45558. m[0] * -sinValue + m[2] * cosValue,
  45559. m[1] * -sinValue + m[3] * cosValue,
  45560. m[4],
  45561. m[5]
  45562. ];
  45563. this._originalRotate(angle);
  45564. };
  45565. }
  45566. }
  45567. var CachedCanvases = function CachedCanvasesClosure() {
  45568. function CachedCanvases(canvasFactory) {
  45569. this.canvasFactory = canvasFactory;
  45570. this.cache = Object.create(null);
  45571. }
  45572. CachedCanvases.prototype = {
  45573. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  45574. var canvasEntry;
  45575. if (this.cache[id] !== undefined) {
  45576. canvasEntry = this.cache[id];
  45577. this.canvasFactory.reset(canvasEntry.canvas, width, height);
  45578. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  45579. } else {
  45580. var canvas = this.canvasFactory.create(width, height);
  45581. var ctx = canvas.getContext('2d');
  45582. if (trackTransform) {
  45583. addContextCurrentTransform(ctx);
  45584. }
  45585. this.cache[id] = canvasEntry = {
  45586. canvas: canvas,
  45587. context: ctx
  45588. };
  45589. }
  45590. return canvasEntry;
  45591. },
  45592. clear: function () {
  45593. for (var id in this.cache) {
  45594. var canvasEntry = this.cache[id];
  45595. this.canvasFactory.destroy(canvasEntry.canvas);
  45596. delete this.cache[id];
  45597. }
  45598. }
  45599. };
  45600. return CachedCanvases;
  45601. }();
  45602. function compileType3Glyph(imgData) {
  45603. var POINT_TO_PROCESS_LIMIT = 1000;
  45604. var width = imgData.width, height = imgData.height;
  45605. var i, j, j0, width1 = width + 1;
  45606. var points = new Uint8Array(width1 * (height + 1));
  45607. var POINT_TYPES = new Uint8Array([
  45608. 0,
  45609. 2,
  45610. 4,
  45611. 0,
  45612. 1,
  45613. 0,
  45614. 5,
  45615. 4,
  45616. 8,
  45617. 10,
  45618. 0,
  45619. 8,
  45620. 0,
  45621. 2,
  45622. 1,
  45623. 0
  45624. ]);
  45625. var lineSize = width + 7 & ~7, data0 = imgData.data;
  45626. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  45627. for (i = 0, ii = data0.length; i < ii; i++) {
  45628. var mask = 128, elem = data0[i];
  45629. while (mask > 0) {
  45630. data[pos++] = elem & mask ? 0 : 255;
  45631. mask >>= 1;
  45632. }
  45633. }
  45634. var count = 0;
  45635. pos = 0;
  45636. if (data[pos] !== 0) {
  45637. points[0] = 1;
  45638. ++count;
  45639. }
  45640. for (j = 1; j < width; j++) {
  45641. if (data[pos] !== data[pos + 1]) {
  45642. points[j] = data[pos] ? 2 : 1;
  45643. ++count;
  45644. }
  45645. pos++;
  45646. }
  45647. if (data[pos] !== 0) {
  45648. points[j] = 2;
  45649. ++count;
  45650. }
  45651. for (i = 1; i < height; i++) {
  45652. pos = i * lineSize;
  45653. j0 = i * width1;
  45654. if (data[pos - lineSize] !== data[pos]) {
  45655. points[j0] = data[pos] ? 1 : 8;
  45656. ++count;
  45657. }
  45658. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  45659. for (j = 1; j < width; j++) {
  45660. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  45661. if (POINT_TYPES[sum]) {
  45662. points[j0 + j] = POINT_TYPES[sum];
  45663. ++count;
  45664. }
  45665. pos++;
  45666. }
  45667. if (data[pos - lineSize] !== data[pos]) {
  45668. points[j0 + j] = data[pos] ? 2 : 4;
  45669. ++count;
  45670. }
  45671. if (count > POINT_TO_PROCESS_LIMIT) {
  45672. return null;
  45673. }
  45674. }
  45675. pos = lineSize * (height - 1);
  45676. j0 = i * width1;
  45677. if (data[pos] !== 0) {
  45678. points[j0] = 8;
  45679. ++count;
  45680. }
  45681. for (j = 1; j < width; j++) {
  45682. if (data[pos] !== data[pos + 1]) {
  45683. points[j0 + j] = data[pos] ? 4 : 8;
  45684. ++count;
  45685. }
  45686. pos++;
  45687. }
  45688. if (data[pos] !== 0) {
  45689. points[j0 + j] = 4;
  45690. ++count;
  45691. }
  45692. if (count > POINT_TO_PROCESS_LIMIT) {
  45693. return null;
  45694. }
  45695. var steps = new Int32Array([
  45696. 0,
  45697. width1,
  45698. -1,
  45699. 0,
  45700. -width1,
  45701. 0,
  45702. 0,
  45703. 0,
  45704. 1
  45705. ]);
  45706. var outlines = [];
  45707. for (i = 0; count && i <= height; i++) {
  45708. var p = i * width1;
  45709. var end = p + width;
  45710. while (p < end && !points[p]) {
  45711. p++;
  45712. }
  45713. if (p === end) {
  45714. continue;
  45715. }
  45716. var coords = [
  45717. p % width1,
  45718. i
  45719. ];
  45720. var type = points[p], p0 = p, pp;
  45721. do {
  45722. var step = steps[type];
  45723. do {
  45724. p += step;
  45725. } while (!points[p]);
  45726. pp = points[p];
  45727. if (pp !== 5 && pp !== 10) {
  45728. type = pp;
  45729. points[p] = 0;
  45730. } else {
  45731. type = pp & 0x33 * type >> 4;
  45732. points[p] &= type >> 2 | type << 2;
  45733. }
  45734. coords.push(p % width1);
  45735. coords.push(p / width1 | 0);
  45736. --count;
  45737. } while (p0 !== p);
  45738. outlines.push(coords);
  45739. --i;
  45740. }
  45741. var drawOutline = function (c) {
  45742. c.save();
  45743. c.scale(1 / width, -1 / height);
  45744. c.translate(0, -height);
  45745. c.beginPath();
  45746. for (var i = 0, ii = outlines.length; i < ii; i++) {
  45747. var o = outlines[i];
  45748. c.moveTo(o[0], o[1]);
  45749. for (var j = 2, jj = o.length; j < jj; j += 2) {
  45750. c.lineTo(o[j], o[j + 1]);
  45751. }
  45752. }
  45753. c.fill();
  45754. c.beginPath();
  45755. c.restore();
  45756. };
  45757. return drawOutline;
  45758. }
  45759. var CanvasExtraState = function CanvasExtraStateClosure() {
  45760. function CanvasExtraState(old) {
  45761. this.alphaIsShape = false;
  45762. this.fontSize = 0;
  45763. this.fontSizeScale = 1;
  45764. this.textMatrix = IDENTITY_MATRIX;
  45765. this.textMatrixScale = 1;
  45766. this.fontMatrix = FONT_IDENTITY_MATRIX;
  45767. this.leading = 0;
  45768. this.x = 0;
  45769. this.y = 0;
  45770. this.lineX = 0;
  45771. this.lineY = 0;
  45772. this.charSpacing = 0;
  45773. this.wordSpacing = 0;
  45774. this.textHScale = 1;
  45775. this.textRenderingMode = TextRenderingMode.FILL;
  45776. this.textRise = 0;
  45777. this.fillColor = '#000000';
  45778. this.strokeColor = '#000000';
  45779. this.patternFill = false;
  45780. this.fillAlpha = 1;
  45781. this.strokeAlpha = 1;
  45782. this.lineWidth = 1;
  45783. this.activeSMask = null;
  45784. this.resumeSMaskCtx = null;
  45785. this.old = old;
  45786. }
  45787. CanvasExtraState.prototype = {
  45788. clone: function CanvasExtraState_clone() {
  45789. return Object.create(this);
  45790. },
  45791. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  45792. this.x = x;
  45793. this.y = y;
  45794. }
  45795. };
  45796. return CanvasExtraState;
  45797. }();
  45798. var CanvasGraphics = function CanvasGraphicsClosure() {
  45799. var EXECUTION_TIME = 15;
  45800. var EXECUTION_STEPS = 10;
  45801. function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, imageLayer) {
  45802. this.ctx = canvasCtx;
  45803. this.current = new CanvasExtraState();
  45804. this.stateStack = [];
  45805. this.pendingClip = null;
  45806. this.pendingEOFill = false;
  45807. this.res = null;
  45808. this.xobjs = null;
  45809. this.commonObjs = commonObjs;
  45810. this.objs = objs;
  45811. this.canvasFactory = canvasFactory;
  45812. this.imageLayer = imageLayer;
  45813. this.groupStack = [];
  45814. this.processingType3 = null;
  45815. this.baseTransform = null;
  45816. this.baseTransformStack = [];
  45817. this.groupLevel = 0;
  45818. this.smaskStack = [];
  45819. this.smaskCounter = 0;
  45820. this.tempSMask = null;
  45821. this.cachedCanvases = new CachedCanvases(this.canvasFactory);
  45822. if (canvasCtx) {
  45823. addContextCurrentTransform(canvasCtx);
  45824. }
  45825. this.cachedGetSinglePixelWidth = null;
  45826. }
  45827. function putBinaryImageData(ctx, imgData) {
  45828. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  45829. ctx.putImageData(imgData, 0, 0);
  45830. return;
  45831. }
  45832. var height = imgData.height, width = imgData.width;
  45833. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  45834. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  45835. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  45836. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  45837. var srcPos = 0, destPos;
  45838. var src = imgData.data;
  45839. var dest = chunkImgData.data;
  45840. var i, j, thisChunkHeight, elemsInThisChunk;
  45841. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  45842. var srcLength = src.byteLength;
  45843. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  45844. var dest32DataLength = dest32.length;
  45845. var fullSrcDiff = width + 7 >> 3;
  45846. var white = 0xFFFFFFFF;
  45847. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  45848. for (i = 0; i < totalChunks; i++) {
  45849. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  45850. destPos = 0;
  45851. for (j = 0; j < thisChunkHeight; j++) {
  45852. var srcDiff = srcLength - srcPos;
  45853. var k = 0;
  45854. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  45855. var kEndUnrolled = kEnd & ~7;
  45856. var mask = 0;
  45857. var srcByte = 0;
  45858. for (; k < kEndUnrolled; k += 8) {
  45859. srcByte = src[srcPos++];
  45860. dest32[destPos++] = srcByte & 128 ? white : black;
  45861. dest32[destPos++] = srcByte & 64 ? white : black;
  45862. dest32[destPos++] = srcByte & 32 ? white : black;
  45863. dest32[destPos++] = srcByte & 16 ? white : black;
  45864. dest32[destPos++] = srcByte & 8 ? white : black;
  45865. dest32[destPos++] = srcByte & 4 ? white : black;
  45866. dest32[destPos++] = srcByte & 2 ? white : black;
  45867. dest32[destPos++] = srcByte & 1 ? white : black;
  45868. }
  45869. for (; k < kEnd; k++) {
  45870. if (mask === 0) {
  45871. srcByte = src[srcPos++];
  45872. mask = 128;
  45873. }
  45874. dest32[destPos++] = srcByte & mask ? white : black;
  45875. mask >>= 1;
  45876. }
  45877. }
  45878. while (destPos < dest32DataLength) {
  45879. dest32[destPos++] = 0;
  45880. }
  45881. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  45882. }
  45883. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  45884. j = 0;
  45885. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  45886. for (i = 0; i < fullChunks; i++) {
  45887. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  45888. srcPos += elemsInThisChunk;
  45889. ctx.putImageData(chunkImgData, 0, j);
  45890. j += FULL_CHUNK_HEIGHT;
  45891. }
  45892. if (i < totalChunks) {
  45893. elemsInThisChunk = width * partialChunkHeight * 4;
  45894. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  45895. ctx.putImageData(chunkImgData, 0, j);
  45896. }
  45897. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  45898. thisChunkHeight = FULL_CHUNK_HEIGHT;
  45899. elemsInThisChunk = width * thisChunkHeight;
  45900. for (i = 0; i < totalChunks; i++) {
  45901. if (i >= fullChunks) {
  45902. thisChunkHeight = partialChunkHeight;
  45903. elemsInThisChunk = width * thisChunkHeight;
  45904. }
  45905. destPos = 0;
  45906. for (j = elemsInThisChunk; j--;) {
  45907. dest[destPos++] = src[srcPos++];
  45908. dest[destPos++] = src[srcPos++];
  45909. dest[destPos++] = src[srcPos++];
  45910. dest[destPos++] = 255;
  45911. }
  45912. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  45913. }
  45914. } else {
  45915. error('bad image kind: ' + imgData.kind);
  45916. }
  45917. }
  45918. function putBinaryImageMask(ctx, imgData) {
  45919. var height = imgData.height, width = imgData.width;
  45920. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  45921. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  45922. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  45923. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  45924. var srcPos = 0;
  45925. var src = imgData.data;
  45926. var dest = chunkImgData.data;
  45927. for (var i = 0; i < totalChunks; i++) {
  45928. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  45929. var destPos = 3;
  45930. for (var j = 0; j < thisChunkHeight; j++) {
  45931. var mask = 0;
  45932. for (var k = 0; k < width; k++) {
  45933. if (!mask) {
  45934. var elem = src[srcPos++];
  45935. mask = 128;
  45936. }
  45937. dest[destPos] = elem & mask ? 0 : 255;
  45938. destPos += 4;
  45939. mask >>= 1;
  45940. }
  45941. }
  45942. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  45943. }
  45944. }
  45945. function copyCtxState(sourceCtx, destCtx) {
  45946. var properties = [
  45947. 'strokeStyle',
  45948. 'fillStyle',
  45949. 'fillRule',
  45950. 'globalAlpha',
  45951. 'lineWidth',
  45952. 'lineCap',
  45953. 'lineJoin',
  45954. 'miterLimit',
  45955. 'globalCompositeOperation',
  45956. 'font'
  45957. ];
  45958. for (var i = 0, ii = properties.length; i < ii; i++) {
  45959. var property = properties[i];
  45960. if (sourceCtx[property] !== undefined) {
  45961. destCtx[property] = sourceCtx[property];
  45962. }
  45963. }
  45964. if (sourceCtx.setLineDash !== undefined) {
  45965. destCtx.setLineDash(sourceCtx.getLineDash());
  45966. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  45967. }
  45968. }
  45969. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  45970. var length = bytes.length;
  45971. for (var i = 3; i < length; i += 4) {
  45972. var alpha = bytes[i];
  45973. if (alpha === 0) {
  45974. bytes[i - 3] = r0;
  45975. bytes[i - 2] = g0;
  45976. bytes[i - 1] = b0;
  45977. } else if (alpha < 255) {
  45978. var alpha_ = 255 - alpha;
  45979. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  45980. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  45981. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  45982. }
  45983. }
  45984. }
  45985. function composeSMaskAlpha(maskData, layerData, transferMap) {
  45986. var length = maskData.length;
  45987. var scale = 1 / 255;
  45988. for (var i = 3; i < length; i += 4) {
  45989. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  45990. layerData[i] = layerData[i] * alpha * scale | 0;
  45991. }
  45992. }
  45993. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  45994. var length = maskData.length;
  45995. for (var i = 3; i < length; i += 4) {
  45996. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  45997. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  45998. }
  45999. }
  46000. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  46001. var hasBackdrop = !!backdrop;
  46002. var r0 = hasBackdrop ? backdrop[0] : 0;
  46003. var g0 = hasBackdrop ? backdrop[1] : 0;
  46004. var b0 = hasBackdrop ? backdrop[2] : 0;
  46005. var composeFn;
  46006. if (subtype === 'Luminosity') {
  46007. composeFn = composeSMaskLuminosity;
  46008. } else {
  46009. composeFn = composeSMaskAlpha;
  46010. }
  46011. var PIXELS_TO_PROCESS = 1048576;
  46012. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  46013. for (var row = 0; row < height; row += chunkSize) {
  46014. var chunkHeight = Math.min(chunkSize, height - row);
  46015. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  46016. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  46017. if (hasBackdrop) {
  46018. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  46019. }
  46020. composeFn(maskData.data, layerData.data, transferMap);
  46021. maskCtx.putImageData(layerData, 0, row);
  46022. }
  46023. }
  46024. function composeSMask(ctx, smask, layerCtx) {
  46025. var mask = smask.canvas;
  46026. var maskCtx = smask.context;
  46027. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  46028. var backdrop = smask.backdrop || null;
  46029. if (!smask.transferMap && WebGLUtils.isEnabled) {
  46030. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  46031. subtype: smask.subtype,
  46032. backdrop: backdrop
  46033. });
  46034. ctx.setTransform(1, 0, 0, 1, 0, 0);
  46035. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  46036. return;
  46037. }
  46038. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  46039. ctx.drawImage(mask, 0, 0);
  46040. }
  46041. var LINE_CAP_STYLES = [
  46042. 'butt',
  46043. 'round',
  46044. 'square'
  46045. ];
  46046. var LINE_JOIN_STYLES = [
  46047. 'miter',
  46048. 'round',
  46049. 'bevel'
  46050. ];
  46051. var NORMAL_CLIP = {};
  46052. var EO_CLIP = {};
  46053. CanvasGraphics.prototype = {
  46054. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  46055. var width = this.ctx.canvas.width;
  46056. var height = this.ctx.canvas.height;
  46057. this.ctx.save();
  46058. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  46059. this.ctx.fillRect(0, 0, width, height);
  46060. this.ctx.restore();
  46061. if (transparency) {
  46062. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  46063. this.compositeCtx = this.ctx;
  46064. this.transparentCanvas = transparentCanvas.canvas;
  46065. this.ctx = transparentCanvas.context;
  46066. this.ctx.save();
  46067. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  46068. }
  46069. this.ctx.save();
  46070. if (transform) {
  46071. this.ctx.transform.apply(this.ctx, transform);
  46072. }
  46073. this.ctx.transform.apply(this.ctx, viewport.transform);
  46074. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  46075. if (this.imageLayer) {
  46076. this.imageLayer.beginLayout();
  46077. }
  46078. },
  46079. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  46080. var argsArray = operatorList.argsArray;
  46081. var fnArray = operatorList.fnArray;
  46082. var i = executionStartIdx || 0;
  46083. var argsArrayLen = argsArray.length;
  46084. if (argsArrayLen === i) {
  46085. return i;
  46086. }
  46087. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  46088. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  46089. var steps = 0;
  46090. var commonObjs = this.commonObjs;
  46091. var objs = this.objs;
  46092. var fnId;
  46093. while (true) {
  46094. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  46095. stepper.breakIt(i, continueCallback);
  46096. return i;
  46097. }
  46098. fnId = fnArray[i];
  46099. if (fnId !== OPS.dependency) {
  46100. this[fnId].apply(this, argsArray[i]);
  46101. } else {
  46102. var deps = argsArray[i];
  46103. for (var n = 0, nn = deps.length; n < nn; n++) {
  46104. var depObjId = deps[n];
  46105. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  46106. var objsPool = common ? commonObjs : objs;
  46107. if (!objsPool.isResolved(depObjId)) {
  46108. objsPool.get(depObjId, continueCallback);
  46109. return i;
  46110. }
  46111. }
  46112. }
  46113. i++;
  46114. if (i === argsArrayLen) {
  46115. return i;
  46116. }
  46117. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  46118. if (Date.now() > endTime) {
  46119. continueCallback();
  46120. return i;
  46121. }
  46122. steps = 0;
  46123. }
  46124. }
  46125. },
  46126. endDrawing: function CanvasGraphics_endDrawing() {
  46127. if (this.current.activeSMask !== null) {
  46128. this.endSMaskGroup();
  46129. }
  46130. this.ctx.restore();
  46131. if (this.transparentCanvas) {
  46132. this.ctx = this.compositeCtx;
  46133. this.ctx.save();
  46134. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  46135. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  46136. this.ctx.restore();
  46137. this.transparentCanvas = null;
  46138. }
  46139. this.cachedCanvases.clear();
  46140. WebGLUtils.clear();
  46141. if (this.imageLayer) {
  46142. this.imageLayer.endLayout();
  46143. }
  46144. },
  46145. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  46146. this.current.lineWidth = width;
  46147. this.ctx.lineWidth = width;
  46148. },
  46149. setLineCap: function CanvasGraphics_setLineCap(style) {
  46150. this.ctx.lineCap = LINE_CAP_STYLES[style];
  46151. },
  46152. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  46153. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  46154. },
  46155. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  46156. this.ctx.miterLimit = limit;
  46157. },
  46158. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  46159. var ctx = this.ctx;
  46160. if (ctx.setLineDash !== undefined) {
  46161. ctx.setLineDash(dashArray);
  46162. ctx.lineDashOffset = dashPhase;
  46163. }
  46164. },
  46165. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  46166. },
  46167. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  46168. },
  46169. setGState: function CanvasGraphics_setGState(states) {
  46170. for (var i = 0, ii = states.length; i < ii; i++) {
  46171. var state = states[i];
  46172. var key = state[0];
  46173. var value = state[1];
  46174. switch (key) {
  46175. case 'LW':
  46176. this.setLineWidth(value);
  46177. break;
  46178. case 'LC':
  46179. this.setLineCap(value);
  46180. break;
  46181. case 'LJ':
  46182. this.setLineJoin(value);
  46183. break;
  46184. case 'ML':
  46185. this.setMiterLimit(value);
  46186. break;
  46187. case 'D':
  46188. this.setDash(value[0], value[1]);
  46189. break;
  46190. case 'RI':
  46191. this.setRenderingIntent(value);
  46192. break;
  46193. case 'FL':
  46194. this.setFlatness(value);
  46195. break;
  46196. case 'Font':
  46197. this.setFont(value[0], value[1]);
  46198. break;
  46199. case 'CA':
  46200. this.current.strokeAlpha = state[1];
  46201. break;
  46202. case 'ca':
  46203. this.current.fillAlpha = state[1];
  46204. this.ctx.globalAlpha = state[1];
  46205. break;
  46206. case 'BM':
  46207. if (value && value.name && value.name !== 'Normal') {
  46208. var mode = value.name.replace(/([A-Z])/g, function (c) {
  46209. return '-' + c.toLowerCase();
  46210. }).substring(1);
  46211. this.ctx.globalCompositeOperation = mode;
  46212. if (this.ctx.globalCompositeOperation !== mode) {
  46213. warn('globalCompositeOperation "' + mode + '" is not supported');
  46214. }
  46215. } else {
  46216. this.ctx.globalCompositeOperation = 'source-over';
  46217. }
  46218. break;
  46219. case 'SMask':
  46220. if (this.current.activeSMask) {
  46221. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  46222. this.suspendSMaskGroup();
  46223. } else {
  46224. this.endSMaskGroup();
  46225. }
  46226. }
  46227. this.current.activeSMask = value ? this.tempSMask : null;
  46228. if (this.current.activeSMask) {
  46229. this.beginSMaskGroup();
  46230. }
  46231. this.tempSMask = null;
  46232. break;
  46233. }
  46234. }
  46235. },
  46236. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  46237. var activeSMask = this.current.activeSMask;
  46238. var drawnWidth = activeSMask.canvas.width;
  46239. var drawnHeight = activeSMask.canvas.height;
  46240. var cacheId = 'smaskGroupAt' + this.groupLevel;
  46241. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  46242. var currentCtx = this.ctx;
  46243. var currentTransform = currentCtx.mozCurrentTransform;
  46244. this.ctx.save();
  46245. var groupCtx = scratchCanvas.context;
  46246. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  46247. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  46248. groupCtx.transform.apply(groupCtx, currentTransform);
  46249. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  46250. copyCtxState(currentCtx, groupCtx);
  46251. this.ctx = groupCtx;
  46252. this.setGState([
  46253. [
  46254. 'BM',
  46255. 'Normal'
  46256. ],
  46257. [
  46258. 'ca',
  46259. 1
  46260. ],
  46261. [
  46262. 'CA',
  46263. 1
  46264. ]
  46265. ]);
  46266. this.groupStack.push(currentCtx);
  46267. this.groupLevel++;
  46268. },
  46269. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  46270. var groupCtx = this.ctx;
  46271. this.groupLevel--;
  46272. this.ctx = this.groupStack.pop();
  46273. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  46274. this.ctx.restore();
  46275. this.ctx.save();
  46276. copyCtxState(groupCtx, this.ctx);
  46277. this.current.resumeSMaskCtx = groupCtx;
  46278. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  46279. this.ctx.transform.apply(this.ctx, deltaTransform);
  46280. groupCtx.save();
  46281. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  46282. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  46283. groupCtx.restore();
  46284. },
  46285. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  46286. var groupCtx = this.current.resumeSMaskCtx;
  46287. var currentCtx = this.ctx;
  46288. this.ctx = groupCtx;
  46289. this.groupStack.push(currentCtx);
  46290. this.groupLevel++;
  46291. },
  46292. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  46293. var groupCtx = this.ctx;
  46294. this.groupLevel--;
  46295. this.ctx = this.groupStack.pop();
  46296. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  46297. this.ctx.restore();
  46298. copyCtxState(groupCtx, this.ctx);
  46299. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  46300. this.ctx.transform.apply(this.ctx, deltaTransform);
  46301. },
  46302. save: function CanvasGraphics_save() {
  46303. this.ctx.save();
  46304. var old = this.current;
  46305. this.stateStack.push(old);
  46306. this.current = old.clone();
  46307. this.current.resumeSMaskCtx = null;
  46308. },
  46309. restore: function CanvasGraphics_restore() {
  46310. if (this.current.resumeSMaskCtx) {
  46311. this.resumeSMaskGroup();
  46312. }
  46313. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  46314. this.endSMaskGroup();
  46315. }
  46316. if (this.stateStack.length !== 0) {
  46317. this.current = this.stateStack.pop();
  46318. this.ctx.restore();
  46319. this.pendingClip = null;
  46320. this.cachedGetSinglePixelWidth = null;
  46321. }
  46322. },
  46323. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  46324. this.ctx.transform(a, b, c, d, e, f);
  46325. this.cachedGetSinglePixelWidth = null;
  46326. },
  46327. constructPath: function CanvasGraphics_constructPath(ops, args) {
  46328. var ctx = this.ctx;
  46329. var current = this.current;
  46330. var x = current.x, y = current.y;
  46331. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  46332. switch (ops[i] | 0) {
  46333. case OPS.rectangle:
  46334. x = args[j++];
  46335. y = args[j++];
  46336. var width = args[j++];
  46337. var height = args[j++];
  46338. if (width === 0) {
  46339. width = this.getSinglePixelWidth();
  46340. }
  46341. if (height === 0) {
  46342. height = this.getSinglePixelWidth();
  46343. }
  46344. var xw = x + width;
  46345. var yh = y + height;
  46346. this.ctx.moveTo(x, y);
  46347. this.ctx.lineTo(xw, y);
  46348. this.ctx.lineTo(xw, yh);
  46349. this.ctx.lineTo(x, yh);
  46350. this.ctx.lineTo(x, y);
  46351. this.ctx.closePath();
  46352. break;
  46353. case OPS.moveTo:
  46354. x = args[j++];
  46355. y = args[j++];
  46356. ctx.moveTo(x, y);
  46357. break;
  46358. case OPS.lineTo:
  46359. x = args[j++];
  46360. y = args[j++];
  46361. ctx.lineTo(x, y);
  46362. break;
  46363. case OPS.curveTo:
  46364. x = args[j + 4];
  46365. y = args[j + 5];
  46366. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  46367. j += 6;
  46368. break;
  46369. case OPS.curveTo2:
  46370. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  46371. x = args[j + 2];
  46372. y = args[j + 3];
  46373. j += 4;
  46374. break;
  46375. case OPS.curveTo3:
  46376. x = args[j + 2];
  46377. y = args[j + 3];
  46378. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  46379. j += 4;
  46380. break;
  46381. case OPS.closePath:
  46382. ctx.closePath();
  46383. break;
  46384. }
  46385. }
  46386. current.setCurrentPoint(x, y);
  46387. },
  46388. closePath: function CanvasGraphics_closePath() {
  46389. this.ctx.closePath();
  46390. },
  46391. stroke: function CanvasGraphics_stroke(consumePath) {
  46392. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  46393. var ctx = this.ctx;
  46394. var strokeColor = this.current.strokeColor;
  46395. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  46396. ctx.globalAlpha = this.current.strokeAlpha;
  46397. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  46398. ctx.save();
  46399. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  46400. ctx.stroke();
  46401. ctx.restore();
  46402. } else {
  46403. ctx.stroke();
  46404. }
  46405. if (consumePath) {
  46406. this.consumePath();
  46407. }
  46408. ctx.globalAlpha = this.current.fillAlpha;
  46409. },
  46410. closeStroke: function CanvasGraphics_closeStroke() {
  46411. this.closePath();
  46412. this.stroke();
  46413. },
  46414. fill: function CanvasGraphics_fill(consumePath) {
  46415. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  46416. var ctx = this.ctx;
  46417. var fillColor = this.current.fillColor;
  46418. var isPatternFill = this.current.patternFill;
  46419. var needRestore = false;
  46420. if (isPatternFill) {
  46421. ctx.save();
  46422. if (this.baseTransform) {
  46423. ctx.setTransform.apply(ctx, this.baseTransform);
  46424. }
  46425. ctx.fillStyle = fillColor.getPattern(ctx, this);
  46426. needRestore = true;
  46427. }
  46428. if (this.pendingEOFill) {
  46429. ctx.fill('evenodd');
  46430. this.pendingEOFill = false;
  46431. } else {
  46432. ctx.fill();
  46433. }
  46434. if (needRestore) {
  46435. ctx.restore();
  46436. }
  46437. if (consumePath) {
  46438. this.consumePath();
  46439. }
  46440. },
  46441. eoFill: function CanvasGraphics_eoFill() {
  46442. this.pendingEOFill = true;
  46443. this.fill();
  46444. },
  46445. fillStroke: function CanvasGraphics_fillStroke() {
  46446. this.fill(false);
  46447. this.stroke(false);
  46448. this.consumePath();
  46449. },
  46450. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  46451. this.pendingEOFill = true;
  46452. this.fillStroke();
  46453. },
  46454. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  46455. this.closePath();
  46456. this.fillStroke();
  46457. },
  46458. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  46459. this.pendingEOFill = true;
  46460. this.closePath();
  46461. this.fillStroke();
  46462. },
  46463. endPath: function CanvasGraphics_endPath() {
  46464. this.consumePath();
  46465. },
  46466. clip: function CanvasGraphics_clip() {
  46467. this.pendingClip = NORMAL_CLIP;
  46468. },
  46469. eoClip: function CanvasGraphics_eoClip() {
  46470. this.pendingClip = EO_CLIP;
  46471. },
  46472. beginText: function CanvasGraphics_beginText() {
  46473. this.current.textMatrix = IDENTITY_MATRIX;
  46474. this.current.textMatrixScale = 1;
  46475. this.current.x = this.current.lineX = 0;
  46476. this.current.y = this.current.lineY = 0;
  46477. },
  46478. endText: function CanvasGraphics_endText() {
  46479. var paths = this.pendingTextPaths;
  46480. var ctx = this.ctx;
  46481. if (paths === undefined) {
  46482. ctx.beginPath();
  46483. return;
  46484. }
  46485. ctx.save();
  46486. ctx.beginPath();
  46487. for (var i = 0; i < paths.length; i++) {
  46488. var path = paths[i];
  46489. ctx.setTransform.apply(ctx, path.transform);
  46490. ctx.translate(path.x, path.y);
  46491. path.addToPath(ctx, path.fontSize);
  46492. }
  46493. ctx.restore();
  46494. ctx.clip();
  46495. ctx.beginPath();
  46496. delete this.pendingTextPaths;
  46497. },
  46498. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  46499. this.current.charSpacing = spacing;
  46500. },
  46501. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  46502. this.current.wordSpacing = spacing;
  46503. },
  46504. setHScale: function CanvasGraphics_setHScale(scale) {
  46505. this.current.textHScale = scale / 100;
  46506. },
  46507. setLeading: function CanvasGraphics_setLeading(leading) {
  46508. this.current.leading = -leading;
  46509. },
  46510. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  46511. var fontObj = this.commonObjs.get(fontRefName);
  46512. var current = this.current;
  46513. if (!fontObj) {
  46514. error('Can\'t find font for ' + fontRefName);
  46515. }
  46516. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  46517. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  46518. warn('Invalid font matrix for font ' + fontRefName);
  46519. }
  46520. if (size < 0) {
  46521. size = -size;
  46522. current.fontDirection = -1;
  46523. } else {
  46524. current.fontDirection = 1;
  46525. }
  46526. this.current.font = fontObj;
  46527. this.current.fontSize = size;
  46528. if (fontObj.isType3Font) {
  46529. return;
  46530. }
  46531. var name = fontObj.loadedName || 'sans-serif';
  46532. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  46533. var italic = fontObj.italic ? 'italic' : 'normal';
  46534. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  46535. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  46536. this.current.fontSizeScale = size / browserFontSize;
  46537. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  46538. this.ctx.font = rule;
  46539. },
  46540. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  46541. this.current.textRenderingMode = mode;
  46542. },
  46543. setTextRise: function CanvasGraphics_setTextRise(rise) {
  46544. this.current.textRise = rise;
  46545. },
  46546. moveText: function CanvasGraphics_moveText(x, y) {
  46547. this.current.x = this.current.lineX += x;
  46548. this.current.y = this.current.lineY += y;
  46549. },
  46550. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  46551. this.setLeading(-y);
  46552. this.moveText(x, y);
  46553. },
  46554. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  46555. this.current.textMatrix = [
  46556. a,
  46557. b,
  46558. c,
  46559. d,
  46560. e,
  46561. f
  46562. ];
  46563. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  46564. this.current.x = this.current.lineX = 0;
  46565. this.current.y = this.current.lineY = 0;
  46566. },
  46567. nextLine: function CanvasGraphics_nextLine() {
  46568. this.moveText(0, this.current.leading);
  46569. },
  46570. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  46571. var ctx = this.ctx;
  46572. var current = this.current;
  46573. var font = current.font;
  46574. var textRenderingMode = current.textRenderingMode;
  46575. var fontSize = current.fontSize / current.fontSizeScale;
  46576. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  46577. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  46578. var addToPath;
  46579. if (font.disableFontFace || isAddToPathSet) {
  46580. addToPath = font.getPathGenerator(this.commonObjs, character);
  46581. }
  46582. if (font.disableFontFace) {
  46583. ctx.save();
  46584. ctx.translate(x, y);
  46585. ctx.beginPath();
  46586. addToPath(ctx, fontSize);
  46587. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  46588. ctx.fill();
  46589. }
  46590. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  46591. ctx.stroke();
  46592. }
  46593. ctx.restore();
  46594. } else {
  46595. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  46596. ctx.fillText(character, x, y);
  46597. }
  46598. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  46599. ctx.strokeText(character, x, y);
  46600. }
  46601. }
  46602. if (isAddToPathSet) {
  46603. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  46604. paths.push({
  46605. transform: ctx.mozCurrentTransform,
  46606. x: x,
  46607. y: y,
  46608. fontSize: fontSize,
  46609. addToPath: addToPath
  46610. });
  46611. }
  46612. },
  46613. get isFontSubpixelAAEnabled() {
  46614. var ctx = this.canvasFactory.create(10, 10).getContext('2d');
  46615. ctx.scale(1.5, 1);
  46616. ctx.fillText('I', 0, 10);
  46617. var data = ctx.getImageData(0, 0, 10, 10).data;
  46618. var enabled = false;
  46619. for (var i = 3; i < data.length; i += 4) {
  46620. if (data[i] > 0 && data[i] < 255) {
  46621. enabled = true;
  46622. break;
  46623. }
  46624. }
  46625. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  46626. },
  46627. showText: function CanvasGraphics_showText(glyphs) {
  46628. var current = this.current;
  46629. var font = current.font;
  46630. if (font.isType3Font) {
  46631. return this.showType3Text(glyphs);
  46632. }
  46633. var fontSize = current.fontSize;
  46634. if (fontSize === 0) {
  46635. return;
  46636. }
  46637. var ctx = this.ctx;
  46638. var fontSizeScale = current.fontSizeScale;
  46639. var charSpacing = current.charSpacing;
  46640. var wordSpacing = current.wordSpacing;
  46641. var fontDirection = current.fontDirection;
  46642. var textHScale = current.textHScale * fontDirection;
  46643. var glyphsLength = glyphs.length;
  46644. var vertical = font.vertical;
  46645. var spacingDir = vertical ? 1 : -1;
  46646. var defaultVMetrics = font.defaultVMetrics;
  46647. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  46648. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  46649. ctx.save();
  46650. ctx.transform.apply(ctx, current.textMatrix);
  46651. ctx.translate(current.x, current.y + current.textRise);
  46652. if (current.patternFill) {
  46653. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  46654. }
  46655. if (fontDirection > 0) {
  46656. ctx.scale(textHScale, -1);
  46657. } else {
  46658. ctx.scale(textHScale, 1);
  46659. }
  46660. var lineWidth = current.lineWidth;
  46661. var scale = current.textMatrixScale;
  46662. if (scale === 0 || lineWidth === 0) {
  46663. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  46664. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  46665. this.cachedGetSinglePixelWidth = null;
  46666. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  46667. }
  46668. } else {
  46669. lineWidth /= scale;
  46670. }
  46671. if (fontSizeScale !== 1.0) {
  46672. ctx.scale(fontSizeScale, fontSizeScale);
  46673. lineWidth /= fontSizeScale;
  46674. }
  46675. ctx.lineWidth = lineWidth;
  46676. var x = 0, i;
  46677. for (i = 0; i < glyphsLength; ++i) {
  46678. var glyph = glyphs[i];
  46679. if (isNum(glyph)) {
  46680. x += spacingDir * glyph * fontSize / 1000;
  46681. continue;
  46682. }
  46683. var restoreNeeded = false;
  46684. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  46685. var character = glyph.fontChar;
  46686. var accent = glyph.accent;
  46687. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  46688. var width = glyph.width;
  46689. if (vertical) {
  46690. var vmetric, vx, vy;
  46691. vmetric = glyph.vmetric || defaultVMetrics;
  46692. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  46693. vx = -vx * widthAdvanceScale;
  46694. vy = vmetric[2] * widthAdvanceScale;
  46695. width = vmetric ? -vmetric[0] : width;
  46696. scaledX = vx / fontSizeScale;
  46697. scaledY = (x + vy) / fontSizeScale;
  46698. } else {
  46699. scaledX = x / fontSizeScale;
  46700. scaledY = 0;
  46701. }
  46702. if (font.remeasure && width > 0) {
  46703. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  46704. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  46705. var characterScaleX = width / measuredWidth;
  46706. restoreNeeded = true;
  46707. ctx.save();
  46708. ctx.scale(characterScaleX, 1);
  46709. scaledX /= characterScaleX;
  46710. } else if (width !== measuredWidth) {
  46711. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  46712. }
  46713. }
  46714. if (glyph.isInFont || font.missingFile) {
  46715. if (simpleFillText && !accent) {
  46716. ctx.fillText(character, scaledX, scaledY);
  46717. } else {
  46718. this.paintChar(character, scaledX, scaledY);
  46719. if (accent) {
  46720. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  46721. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  46722. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  46723. }
  46724. }
  46725. }
  46726. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  46727. x += charWidth;
  46728. if (restoreNeeded) {
  46729. ctx.restore();
  46730. }
  46731. }
  46732. if (vertical) {
  46733. current.y -= x * textHScale;
  46734. } else {
  46735. current.x += x * textHScale;
  46736. }
  46737. ctx.restore();
  46738. },
  46739. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  46740. var ctx = this.ctx;
  46741. var current = this.current;
  46742. var font = current.font;
  46743. var fontSize = current.fontSize;
  46744. var fontDirection = current.fontDirection;
  46745. var spacingDir = font.vertical ? 1 : -1;
  46746. var charSpacing = current.charSpacing;
  46747. var wordSpacing = current.wordSpacing;
  46748. var textHScale = current.textHScale * fontDirection;
  46749. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  46750. var glyphsLength = glyphs.length;
  46751. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  46752. var i, glyph, width, spacingLength;
  46753. if (isTextInvisible || fontSize === 0) {
  46754. return;
  46755. }
  46756. this.cachedGetSinglePixelWidth = null;
  46757. ctx.save();
  46758. ctx.transform.apply(ctx, current.textMatrix);
  46759. ctx.translate(current.x, current.y);
  46760. ctx.scale(textHScale, fontDirection);
  46761. for (i = 0; i < glyphsLength; ++i) {
  46762. glyph = glyphs[i];
  46763. if (isNum(glyph)) {
  46764. spacingLength = spacingDir * glyph * fontSize / 1000;
  46765. this.ctx.translate(spacingLength, 0);
  46766. current.x += spacingLength * textHScale;
  46767. continue;
  46768. }
  46769. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  46770. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  46771. if (!operatorList) {
  46772. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  46773. continue;
  46774. }
  46775. this.processingType3 = glyph;
  46776. this.save();
  46777. ctx.scale(fontSize, fontSize);
  46778. ctx.transform.apply(ctx, fontMatrix);
  46779. this.executeOperatorList(operatorList);
  46780. this.restore();
  46781. var transformed = Util.applyTransform([
  46782. glyph.width,
  46783. 0
  46784. ], fontMatrix);
  46785. width = transformed[0] * fontSize + spacing;
  46786. ctx.translate(width, 0);
  46787. current.x += width * textHScale;
  46788. }
  46789. ctx.restore();
  46790. this.processingType3 = null;
  46791. },
  46792. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  46793. },
  46794. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  46795. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  46796. this.clip();
  46797. this.endPath();
  46798. },
  46799. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  46800. var pattern;
  46801. if (IR[0] === 'TilingPattern') {
  46802. var color = IR[1];
  46803. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  46804. var self = this;
  46805. var canvasGraphicsFactory = {
  46806. createCanvasGraphics: function (ctx) {
  46807. return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
  46808. }
  46809. };
  46810. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  46811. } else {
  46812. pattern = getShadingPatternFromIR(IR);
  46813. }
  46814. return pattern;
  46815. },
  46816. setStrokeColorN: function CanvasGraphics_setStrokeColorN() {
  46817. this.current.strokeColor = this.getColorN_Pattern(arguments);
  46818. },
  46819. setFillColorN: function CanvasGraphics_setFillColorN() {
  46820. this.current.fillColor = this.getColorN_Pattern(arguments);
  46821. this.current.patternFill = true;
  46822. },
  46823. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  46824. var color = Util.makeCssRgb(r, g, b);
  46825. this.ctx.strokeStyle = color;
  46826. this.current.strokeColor = color;
  46827. },
  46828. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  46829. var color = Util.makeCssRgb(r, g, b);
  46830. this.ctx.fillStyle = color;
  46831. this.current.fillColor = color;
  46832. this.current.patternFill = false;
  46833. },
  46834. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  46835. var ctx = this.ctx;
  46836. this.save();
  46837. var pattern = getShadingPatternFromIR(patternIR);
  46838. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  46839. var inv = ctx.mozCurrentTransformInverse;
  46840. if (inv) {
  46841. var canvas = ctx.canvas;
  46842. var width = canvas.width;
  46843. var height = canvas.height;
  46844. var bl = Util.applyTransform([
  46845. 0,
  46846. 0
  46847. ], inv);
  46848. var br = Util.applyTransform([
  46849. 0,
  46850. height
  46851. ], inv);
  46852. var ul = Util.applyTransform([
  46853. width,
  46854. 0
  46855. ], inv);
  46856. var ur = Util.applyTransform([
  46857. width,
  46858. height
  46859. ], inv);
  46860. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  46861. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  46862. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  46863. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  46864. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  46865. } else {
  46866. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  46867. }
  46868. this.restore();
  46869. },
  46870. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  46871. error('Should not call beginInlineImage');
  46872. },
  46873. beginImageData: function CanvasGraphics_beginImageData() {
  46874. error('Should not call beginImageData');
  46875. },
  46876. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  46877. this.save();
  46878. this.baseTransformStack.push(this.baseTransform);
  46879. if (isArray(matrix) && matrix.length === 6) {
  46880. this.transform.apply(this, matrix);
  46881. }
  46882. this.baseTransform = this.ctx.mozCurrentTransform;
  46883. if (isArray(bbox) && bbox.length === 4) {
  46884. var width = bbox[2] - bbox[0];
  46885. var height = bbox[3] - bbox[1];
  46886. this.ctx.rect(bbox[0], bbox[1], width, height);
  46887. this.clip();
  46888. this.endPath();
  46889. }
  46890. },
  46891. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  46892. this.restore();
  46893. this.baseTransform = this.baseTransformStack.pop();
  46894. },
  46895. beginGroup: function CanvasGraphics_beginGroup(group) {
  46896. this.save();
  46897. var currentCtx = this.ctx;
  46898. if (!group.isolated) {
  46899. info('TODO: Support non-isolated groups.');
  46900. }
  46901. if (group.knockout) {
  46902. warn('Knockout groups not supported.');
  46903. }
  46904. var currentTransform = currentCtx.mozCurrentTransform;
  46905. if (group.matrix) {
  46906. currentCtx.transform.apply(currentCtx, group.matrix);
  46907. }
  46908. assert(group.bbox, 'Bounding box is required.');
  46909. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  46910. var canvasBounds = [
  46911. 0,
  46912. 0,
  46913. currentCtx.canvas.width,
  46914. currentCtx.canvas.height
  46915. ];
  46916. bounds = Util.intersect(bounds, canvasBounds) || [
  46917. 0,
  46918. 0,
  46919. 0,
  46920. 0
  46921. ];
  46922. var offsetX = Math.floor(bounds[0]);
  46923. var offsetY = Math.floor(bounds[1]);
  46924. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  46925. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  46926. var scaleX = 1, scaleY = 1;
  46927. if (drawnWidth > MAX_GROUP_SIZE) {
  46928. scaleX = drawnWidth / MAX_GROUP_SIZE;
  46929. drawnWidth = MAX_GROUP_SIZE;
  46930. }
  46931. if (drawnHeight > MAX_GROUP_SIZE) {
  46932. scaleY = drawnHeight / MAX_GROUP_SIZE;
  46933. drawnHeight = MAX_GROUP_SIZE;
  46934. }
  46935. var cacheId = 'groupAt' + this.groupLevel;
  46936. if (group.smask) {
  46937. cacheId += '_smask_' + this.smaskCounter++ % 2;
  46938. }
  46939. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  46940. var groupCtx = scratchCanvas.context;
  46941. groupCtx.scale(1 / scaleX, 1 / scaleY);
  46942. groupCtx.translate(-offsetX, -offsetY);
  46943. groupCtx.transform.apply(groupCtx, currentTransform);
  46944. if (group.smask) {
  46945. this.smaskStack.push({
  46946. canvas: scratchCanvas.canvas,
  46947. context: groupCtx,
  46948. offsetX: offsetX,
  46949. offsetY: offsetY,
  46950. scaleX: scaleX,
  46951. scaleY: scaleY,
  46952. subtype: group.smask.subtype,
  46953. backdrop: group.smask.backdrop,
  46954. transferMap: group.smask.transferMap || null,
  46955. startTransformInverse: null
  46956. });
  46957. } else
  46958. {
  46959. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  46960. currentCtx.translate(offsetX, offsetY);
  46961. currentCtx.scale(scaleX, scaleY);
  46962. }
  46963. copyCtxState(currentCtx, groupCtx);
  46964. this.ctx = groupCtx;
  46965. this.setGState([
  46966. [
  46967. 'BM',
  46968. 'Normal'
  46969. ],
  46970. [
  46971. 'ca',
  46972. 1
  46973. ],
  46974. [
  46975. 'CA',
  46976. 1
  46977. ]
  46978. ]);
  46979. this.groupStack.push(currentCtx);
  46980. this.groupLevel++;
  46981. this.current.activeSMask = null;
  46982. },
  46983. endGroup: function CanvasGraphics_endGroup(group) {
  46984. this.groupLevel--;
  46985. var groupCtx = this.ctx;
  46986. this.ctx = this.groupStack.pop();
  46987. if (this.ctx.imageSmoothingEnabled !== undefined) {
  46988. this.ctx.imageSmoothingEnabled = false;
  46989. } else {
  46990. this.ctx.mozImageSmoothingEnabled = false;
  46991. }
  46992. if (group.smask) {
  46993. this.tempSMask = this.smaskStack.pop();
  46994. } else {
  46995. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  46996. }
  46997. this.restore();
  46998. },
  46999. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  47000. this.save();
  47001. this.current = new CanvasExtraState();
  47002. if (this.baseTransform) {
  47003. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  47004. }
  47005. },
  47006. endAnnotations: function CanvasGraphics_endAnnotations() {
  47007. this.restore();
  47008. },
  47009. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  47010. this.save();
  47011. if (isArray(rect) && rect.length === 4) {
  47012. var width = rect[2] - rect[0];
  47013. var height = rect[3] - rect[1];
  47014. this.ctx.rect(rect[0], rect[1], width, height);
  47015. this.clip();
  47016. this.endPath();
  47017. }
  47018. this.transform.apply(this, transform);
  47019. this.transform.apply(this, matrix);
  47020. },
  47021. endAnnotation: function CanvasGraphics_endAnnotation() {
  47022. this.restore();
  47023. },
  47024. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  47025. var domImage = this.objs.get(objId);
  47026. if (!domImage) {
  47027. warn('Dependent image isn\'t ready yet');
  47028. return;
  47029. }
  47030. this.save();
  47031. var ctx = this.ctx;
  47032. ctx.scale(1 / w, -1 / h);
  47033. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  47034. if (this.imageLayer) {
  47035. var currentTransform = ctx.mozCurrentTransformInverse;
  47036. var position = this.getCanvasPosition(0, 0);
  47037. this.imageLayer.appendImage({
  47038. objId: objId,
  47039. left: position[0],
  47040. top: position[1],
  47041. width: w / currentTransform[0],
  47042. height: h / currentTransform[3]
  47043. });
  47044. }
  47045. this.restore();
  47046. },
  47047. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  47048. var ctx = this.ctx;
  47049. var width = img.width, height = img.height;
  47050. var fillColor = this.current.fillColor;
  47051. var isPatternFill = this.current.patternFill;
  47052. var glyph = this.processingType3;
  47053. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  47054. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  47055. glyph.compiled = compileType3Glyph({
  47056. data: img.data,
  47057. width: width,
  47058. height: height
  47059. });
  47060. } else {
  47061. glyph.compiled = null;
  47062. }
  47063. }
  47064. if (glyph && glyph.compiled) {
  47065. glyph.compiled(ctx);
  47066. return;
  47067. }
  47068. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  47069. var maskCtx = maskCanvas.context;
  47070. maskCtx.save();
  47071. putBinaryImageMask(maskCtx, img);
  47072. maskCtx.globalCompositeOperation = 'source-in';
  47073. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  47074. maskCtx.fillRect(0, 0, width, height);
  47075. maskCtx.restore();
  47076. this.paintInlineImageXObject(maskCanvas.canvas);
  47077. },
  47078. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  47079. var width = imgData.width;
  47080. var height = imgData.height;
  47081. var fillColor = this.current.fillColor;
  47082. var isPatternFill = this.current.patternFill;
  47083. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  47084. var maskCtx = maskCanvas.context;
  47085. maskCtx.save();
  47086. putBinaryImageMask(maskCtx, imgData);
  47087. maskCtx.globalCompositeOperation = 'source-in';
  47088. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  47089. maskCtx.fillRect(0, 0, width, height);
  47090. maskCtx.restore();
  47091. var ctx = this.ctx;
  47092. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  47093. ctx.save();
  47094. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  47095. ctx.scale(1, -1);
  47096. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  47097. ctx.restore();
  47098. }
  47099. },
  47100. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  47101. var ctx = this.ctx;
  47102. var fillColor = this.current.fillColor;
  47103. var isPatternFill = this.current.patternFill;
  47104. for (var i = 0, ii = images.length; i < ii; i++) {
  47105. var image = images[i];
  47106. var width = image.width, height = image.height;
  47107. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  47108. var maskCtx = maskCanvas.context;
  47109. maskCtx.save();
  47110. putBinaryImageMask(maskCtx, image);
  47111. maskCtx.globalCompositeOperation = 'source-in';
  47112. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  47113. maskCtx.fillRect(0, 0, width, height);
  47114. maskCtx.restore();
  47115. ctx.save();
  47116. ctx.transform.apply(ctx, image.transform);
  47117. ctx.scale(1, -1);
  47118. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  47119. ctx.restore();
  47120. }
  47121. },
  47122. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  47123. var imgData = this.objs.get(objId);
  47124. if (!imgData) {
  47125. warn('Dependent image isn\'t ready yet');
  47126. return;
  47127. }
  47128. this.paintInlineImageXObject(imgData);
  47129. },
  47130. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  47131. var imgData = this.objs.get(objId);
  47132. if (!imgData) {
  47133. warn('Dependent image isn\'t ready yet');
  47134. return;
  47135. }
  47136. var width = imgData.width;
  47137. var height = imgData.height;
  47138. var map = [];
  47139. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  47140. map.push({
  47141. transform: [
  47142. scaleX,
  47143. 0,
  47144. 0,
  47145. scaleY,
  47146. positions[i],
  47147. positions[i + 1]
  47148. ],
  47149. x: 0,
  47150. y: 0,
  47151. w: width,
  47152. h: height
  47153. });
  47154. }
  47155. this.paintInlineImageXObjectGroup(imgData, map);
  47156. },
  47157. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  47158. var width = imgData.width;
  47159. var height = imgData.height;
  47160. var ctx = this.ctx;
  47161. this.save();
  47162. ctx.scale(1 / width, -1 / height);
  47163. var currentTransform = ctx.mozCurrentTransformInverse;
  47164. var a = currentTransform[0], b = currentTransform[1];
  47165. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  47166. var c = currentTransform[2], d = currentTransform[3];
  47167. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  47168. var imgToPaint, tmpCanvas;
  47169. if (imgData instanceof HTMLElement || !imgData.data) {
  47170. imgToPaint = imgData;
  47171. } else {
  47172. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  47173. var tmpCtx = tmpCanvas.context;
  47174. putBinaryImageData(tmpCtx, imgData);
  47175. imgToPaint = tmpCanvas.canvas;
  47176. }
  47177. var paintWidth = width, paintHeight = height;
  47178. var tmpCanvasId = 'prescale1';
  47179. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  47180. var newWidth = paintWidth, newHeight = paintHeight;
  47181. if (widthScale > 2 && paintWidth > 1) {
  47182. newWidth = Math.ceil(paintWidth / 2);
  47183. widthScale /= paintWidth / newWidth;
  47184. }
  47185. if (heightScale > 2 && paintHeight > 1) {
  47186. newHeight = Math.ceil(paintHeight / 2);
  47187. heightScale /= paintHeight / newHeight;
  47188. }
  47189. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  47190. tmpCtx = tmpCanvas.context;
  47191. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  47192. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  47193. imgToPaint = tmpCanvas.canvas;
  47194. paintWidth = newWidth;
  47195. paintHeight = newHeight;
  47196. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  47197. }
  47198. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  47199. if (this.imageLayer) {
  47200. var position = this.getCanvasPosition(0, -height);
  47201. this.imageLayer.appendImage({
  47202. imgData: imgData,
  47203. left: position[0],
  47204. top: position[1],
  47205. width: width / currentTransform[0],
  47206. height: height / currentTransform[3]
  47207. });
  47208. }
  47209. this.restore();
  47210. },
  47211. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  47212. var ctx = this.ctx;
  47213. var w = imgData.width;
  47214. var h = imgData.height;
  47215. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  47216. var tmpCtx = tmpCanvas.context;
  47217. putBinaryImageData(tmpCtx, imgData);
  47218. for (var i = 0, ii = map.length; i < ii; i++) {
  47219. var entry = map[i];
  47220. ctx.save();
  47221. ctx.transform.apply(ctx, entry.transform);
  47222. ctx.scale(1, -1);
  47223. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  47224. if (this.imageLayer) {
  47225. var position = this.getCanvasPosition(entry.x, entry.y);
  47226. this.imageLayer.appendImage({
  47227. imgData: imgData,
  47228. left: position[0],
  47229. top: position[1],
  47230. width: w,
  47231. height: h
  47232. });
  47233. }
  47234. ctx.restore();
  47235. }
  47236. },
  47237. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  47238. this.ctx.fillRect(0, 0, 1, 1);
  47239. },
  47240. paintXObject: function CanvasGraphics_paintXObject() {
  47241. warn('Unsupported \'paintXObject\' command.');
  47242. },
  47243. markPoint: function CanvasGraphics_markPoint(tag) {
  47244. },
  47245. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  47246. },
  47247. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  47248. },
  47249. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  47250. },
  47251. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  47252. },
  47253. beginCompat: function CanvasGraphics_beginCompat() {
  47254. },
  47255. endCompat: function CanvasGraphics_endCompat() {
  47256. },
  47257. consumePath: function CanvasGraphics_consumePath() {
  47258. var ctx = this.ctx;
  47259. if (this.pendingClip) {
  47260. if (this.pendingClip === EO_CLIP) {
  47261. ctx.clip('evenodd');
  47262. } else {
  47263. ctx.clip();
  47264. }
  47265. this.pendingClip = null;
  47266. }
  47267. ctx.beginPath();
  47268. },
  47269. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  47270. if (this.cachedGetSinglePixelWidth === null) {
  47271. this.ctx.save();
  47272. var inverse = this.ctx.mozCurrentTransformInverse;
  47273. this.ctx.restore();
  47274. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  47275. }
  47276. return this.cachedGetSinglePixelWidth;
  47277. },
  47278. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  47279. var transform = this.ctx.mozCurrentTransform;
  47280. return [
  47281. transform[0] * x + transform[2] * y + transform[4],
  47282. transform[1] * x + transform[3] * y + transform[5]
  47283. ];
  47284. }
  47285. };
  47286. for (var op in OPS) {
  47287. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  47288. }
  47289. return CanvasGraphics;
  47290. }();
  47291. exports.CanvasGraphics = CanvasGraphics;
  47292. }));
  47293. (function (root, factory) {
  47294. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  47295. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  47296. var ImageKind = sharedUtil.ImageKind;
  47297. var assert = sharedUtil.assert;
  47298. var error = sharedUtil.error;
  47299. var info = sharedUtil.info;
  47300. var isArray = sharedUtil.isArray;
  47301. var warn = sharedUtil.warn;
  47302. var Name = corePrimitives.Name;
  47303. var isStream = corePrimitives.isStream;
  47304. var ColorSpace = coreColorSpace.ColorSpace;
  47305. var DecodeStream = coreStream.DecodeStream;
  47306. var JpegStream = coreStream.JpegStream;
  47307. var JpxImage = coreJpx.JpxImage;
  47308. var PDFImage = function PDFImageClosure() {
  47309. function handleImageData(image, nativeDecoder) {
  47310. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  47311. return nativeDecoder.decode(image);
  47312. }
  47313. return Promise.resolve(image);
  47314. }
  47315. function decodeAndClamp(value, addend, coefficient, max) {
  47316. value = addend + value * coefficient;
  47317. return value < 0 ? 0 : value > max ? max : value;
  47318. }
  47319. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  47320. var length = w2 * h2;
  47321. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  47322. var xRatio = w1 / w2;
  47323. var yRatio = h1 / h2;
  47324. var i, j, py, newIndex = 0, oldIndex;
  47325. var xScaled = new Uint16Array(w2);
  47326. var w1Scanline = w1;
  47327. for (i = 0; i < w2; i++) {
  47328. xScaled[i] = Math.floor(i * xRatio);
  47329. }
  47330. for (i = 0; i < h2; i++) {
  47331. py = Math.floor(i * yRatio) * w1Scanline;
  47332. for (j = 0; j < w2; j++) {
  47333. oldIndex = py + xScaled[j];
  47334. dest[newIndex++] = src[oldIndex];
  47335. }
  47336. }
  47337. return dest;
  47338. }
  47339. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  47340. this.image = image;
  47341. var dict = image.dict;
  47342. if (dict.has('Filter')) {
  47343. var filter = dict.get('Filter').name;
  47344. if (filter === 'JPXDecode') {
  47345. var jpxImage = new JpxImage();
  47346. jpxImage.parseImageProperties(image.stream);
  47347. image.stream.reset();
  47348. image.bitsPerComponent = jpxImage.bitsPerComponent;
  47349. image.numComps = jpxImage.componentsCount;
  47350. } else if (filter === 'JBIG2Decode') {
  47351. image.bitsPerComponent = 1;
  47352. image.numComps = 1;
  47353. }
  47354. }
  47355. this.width = dict.get('Width', 'W');
  47356. this.height = dict.get('Height', 'H');
  47357. if (this.width < 1 || this.height < 1) {
  47358. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  47359. }
  47360. this.interpolate = dict.get('Interpolate', 'I') || false;
  47361. this.imageMask = dict.get('ImageMask', 'IM') || false;
  47362. this.matte = dict.get('Matte') || false;
  47363. var bitsPerComponent = image.bitsPerComponent;
  47364. if (!bitsPerComponent) {
  47365. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  47366. if (!bitsPerComponent) {
  47367. if (this.imageMask) {
  47368. bitsPerComponent = 1;
  47369. } else {
  47370. error('Bits per component missing in image: ' + this.imageMask);
  47371. }
  47372. }
  47373. }
  47374. this.bpc = bitsPerComponent;
  47375. if (!this.imageMask) {
  47376. var colorSpace = dict.get('ColorSpace', 'CS');
  47377. if (!colorSpace) {
  47378. info('JPX images (which do not require color spaces)');
  47379. switch (image.numComps) {
  47380. case 1:
  47381. colorSpace = Name.get('DeviceGray');
  47382. break;
  47383. case 3:
  47384. colorSpace = Name.get('DeviceRGB');
  47385. break;
  47386. case 4:
  47387. colorSpace = Name.get('DeviceCMYK');
  47388. break;
  47389. default:
  47390. error('JPX images with ' + this.numComps + ' color components not supported.');
  47391. }
  47392. }
  47393. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  47394. this.numComps = this.colorSpace.numComps;
  47395. }
  47396. this.decode = dict.getArray('Decode', 'D');
  47397. this.needsDecode = false;
  47398. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  47399. this.needsDecode = true;
  47400. var max = (1 << bitsPerComponent) - 1;
  47401. this.decodeCoefficients = [];
  47402. this.decodeAddends = [];
  47403. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  47404. var dmin = this.decode[i];
  47405. var dmax = this.decode[i + 1];
  47406. this.decodeCoefficients[j] = dmax - dmin;
  47407. this.decodeAddends[j] = max * dmin;
  47408. }
  47409. }
  47410. if (smask) {
  47411. this.smask = new PDFImage(xref, res, smask, false);
  47412. } else if (mask) {
  47413. if (isStream(mask)) {
  47414. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  47415. if (!imageMask) {
  47416. warn('Ignoring /Mask in image without /ImageMask.');
  47417. } else {
  47418. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  47419. }
  47420. } else {
  47421. this.mask = mask;
  47422. }
  47423. }
  47424. }
  47425. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  47426. var imagePromise = handleImageData(image, nativeDecoder);
  47427. var smaskPromise;
  47428. var maskPromise;
  47429. var smask = image.dict.get('SMask');
  47430. var mask = image.dict.get('Mask');
  47431. if (smask) {
  47432. smaskPromise = handleImageData(smask, nativeDecoder);
  47433. maskPromise = Promise.resolve(null);
  47434. } else {
  47435. smaskPromise = Promise.resolve(null);
  47436. if (mask) {
  47437. if (isStream(mask)) {
  47438. maskPromise = handleImageData(mask, nativeDecoder);
  47439. } else if (isArray(mask)) {
  47440. maskPromise = Promise.resolve(mask);
  47441. } else {
  47442. warn('Unsupported mask format.');
  47443. maskPromise = Promise.resolve(null);
  47444. }
  47445. } else {
  47446. maskPromise = Promise.resolve(null);
  47447. }
  47448. }
  47449. return Promise.all([
  47450. imagePromise,
  47451. smaskPromise,
  47452. maskPromise
  47453. ]).then(function (results) {
  47454. var imageData = results[0];
  47455. var smaskData = results[1];
  47456. var maskData = results[2];
  47457. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  47458. });
  47459. };
  47460. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  47461. var computedLength = (width + 7 >> 3) * height;
  47462. var actualLength = imgArray.byteLength;
  47463. var haveFullData = computedLength === actualLength;
  47464. var data, i;
  47465. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  47466. data = imgArray;
  47467. } else if (!inverseDecode) {
  47468. data = new Uint8Array(actualLength);
  47469. data.set(imgArray);
  47470. } else {
  47471. data = new Uint8Array(computedLength);
  47472. data.set(imgArray);
  47473. for (i = actualLength; i < computedLength; i++) {
  47474. data[i] = 0xff;
  47475. }
  47476. }
  47477. if (inverseDecode) {
  47478. for (i = 0; i < actualLength; i++) {
  47479. data[i] = ~data[i];
  47480. }
  47481. }
  47482. return {
  47483. data: data,
  47484. width: width,
  47485. height: height
  47486. };
  47487. };
  47488. PDFImage.prototype = {
  47489. get drawWidth() {
  47490. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  47491. },
  47492. get drawHeight() {
  47493. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  47494. },
  47495. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  47496. var bpc = this.bpc;
  47497. var numComps = this.numComps;
  47498. var decodeAddends = this.decodeAddends;
  47499. var decodeCoefficients = this.decodeCoefficients;
  47500. var max = (1 << bpc) - 1;
  47501. var i, ii;
  47502. if (bpc === 1) {
  47503. for (i = 0, ii = buffer.length; i < ii; i++) {
  47504. buffer[i] = +!buffer[i];
  47505. }
  47506. return;
  47507. }
  47508. var index = 0;
  47509. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  47510. for (var j = 0; j < numComps; j++) {
  47511. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  47512. index++;
  47513. }
  47514. }
  47515. },
  47516. getComponents: function PDFImage_getComponents(buffer) {
  47517. var bpc = this.bpc;
  47518. if (bpc === 8) {
  47519. return buffer;
  47520. }
  47521. var width = this.width;
  47522. var height = this.height;
  47523. var numComps = this.numComps;
  47524. var length = width * height * numComps;
  47525. var bufferPos = 0;
  47526. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  47527. var rowComps = width * numComps;
  47528. var max = (1 << bpc) - 1;
  47529. var i = 0, ii, buf;
  47530. if (bpc === 1) {
  47531. var mask, loop1End, loop2End;
  47532. for (var j = 0; j < height; j++) {
  47533. loop1End = i + (rowComps & ~7);
  47534. loop2End = i + rowComps;
  47535. while (i < loop1End) {
  47536. buf = buffer[bufferPos++];
  47537. output[i] = buf >> 7 & 1;
  47538. output[i + 1] = buf >> 6 & 1;
  47539. output[i + 2] = buf >> 5 & 1;
  47540. output[i + 3] = buf >> 4 & 1;
  47541. output[i + 4] = buf >> 3 & 1;
  47542. output[i + 5] = buf >> 2 & 1;
  47543. output[i + 6] = buf >> 1 & 1;
  47544. output[i + 7] = buf & 1;
  47545. i += 8;
  47546. }
  47547. if (i < loop2End) {
  47548. buf = buffer[bufferPos++];
  47549. mask = 128;
  47550. while (i < loop2End) {
  47551. output[i++] = +!!(buf & mask);
  47552. mask >>= 1;
  47553. }
  47554. }
  47555. }
  47556. } else {
  47557. var bits = 0;
  47558. buf = 0;
  47559. for (i = 0, ii = length; i < ii; ++i) {
  47560. if (i % rowComps === 0) {
  47561. buf = 0;
  47562. bits = 0;
  47563. }
  47564. while (bits < bpc) {
  47565. buf = buf << 8 | buffer[bufferPos++];
  47566. bits += 8;
  47567. }
  47568. var remainingBits = bits - bpc;
  47569. var value = buf >> remainingBits;
  47570. output[i] = value < 0 ? 0 : value > max ? max : value;
  47571. buf = buf & (1 << remainingBits) - 1;
  47572. bits = remainingBits;
  47573. }
  47574. }
  47575. return output;
  47576. },
  47577. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  47578. var smask = this.smask;
  47579. var mask = this.mask;
  47580. var alphaBuf, sw, sh, i, ii, j;
  47581. if (smask) {
  47582. sw = smask.width;
  47583. sh = smask.height;
  47584. alphaBuf = new Uint8Array(sw * sh);
  47585. smask.fillGrayBuffer(alphaBuf);
  47586. if (sw !== width || sh !== height) {
  47587. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  47588. }
  47589. } else if (mask) {
  47590. if (mask instanceof PDFImage) {
  47591. sw = mask.width;
  47592. sh = mask.height;
  47593. alphaBuf = new Uint8Array(sw * sh);
  47594. mask.numComps = 1;
  47595. mask.fillGrayBuffer(alphaBuf);
  47596. for (i = 0, ii = sw * sh; i < ii; ++i) {
  47597. alphaBuf[i] = 255 - alphaBuf[i];
  47598. }
  47599. if (sw !== width || sh !== height) {
  47600. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  47601. }
  47602. } else if (isArray(mask)) {
  47603. alphaBuf = new Uint8Array(width * height);
  47604. var numComps = this.numComps;
  47605. for (i = 0, ii = width * height; i < ii; ++i) {
  47606. var opacity = 0;
  47607. var imageOffset = i * numComps;
  47608. for (j = 0; j < numComps; ++j) {
  47609. var color = image[imageOffset + j];
  47610. var maskOffset = j * 2;
  47611. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  47612. opacity = 255;
  47613. break;
  47614. }
  47615. }
  47616. alphaBuf[i] = opacity;
  47617. }
  47618. } else {
  47619. error('Unknown mask format.');
  47620. }
  47621. }
  47622. if (alphaBuf) {
  47623. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47624. rgbaBuf[j] = alphaBuf[i];
  47625. }
  47626. } else {
  47627. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  47628. rgbaBuf[j] = 255;
  47629. }
  47630. }
  47631. },
  47632. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  47633. var matte = this.smask && this.smask.matte;
  47634. if (!matte) {
  47635. return;
  47636. }
  47637. var matteRgb = this.colorSpace.getRgb(matte, 0);
  47638. var matteR = matteRgb[0];
  47639. var matteG = matteRgb[1];
  47640. var matteB = matteRgb[2];
  47641. var length = width * height * 4;
  47642. var r, g, b;
  47643. for (var i = 0; i < length; i += 4) {
  47644. var alpha = buffer[i + 3];
  47645. if (alpha === 0) {
  47646. buffer[i] = 255;
  47647. buffer[i + 1] = 255;
  47648. buffer[i + 2] = 255;
  47649. continue;
  47650. }
  47651. var k = 255 / alpha;
  47652. r = (buffer[i] - matteR) * k + matteR;
  47653. g = (buffer[i + 1] - matteG) * k + matteG;
  47654. b = (buffer[i + 2] - matteB) * k + matteB;
  47655. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  47656. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  47657. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  47658. }
  47659. },
  47660. createImageData: function PDFImage_createImageData(forceRGBA) {
  47661. var drawWidth = this.drawWidth;
  47662. var drawHeight = this.drawHeight;
  47663. var imgData = {
  47664. width: drawWidth,
  47665. height: drawHeight
  47666. };
  47667. var numComps = this.numComps;
  47668. var originalWidth = this.width;
  47669. var originalHeight = this.height;
  47670. var bpc = this.bpc;
  47671. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  47672. var imgArray;
  47673. if (!forceRGBA) {
  47674. var kind;
  47675. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  47676. kind = ImageKind.GRAYSCALE_1BPP;
  47677. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  47678. kind = ImageKind.RGB_24BPP;
  47679. }
  47680. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  47681. imgData.kind = kind;
  47682. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47683. if (this.image instanceof DecodeStream) {
  47684. imgData.data = imgArray;
  47685. } else {
  47686. var newArray = new Uint8Array(imgArray.length);
  47687. newArray.set(imgArray);
  47688. imgData.data = newArray;
  47689. }
  47690. if (this.needsDecode) {
  47691. assert(kind === ImageKind.GRAYSCALE_1BPP);
  47692. var buffer = imgData.data;
  47693. for (var i = 0, ii = buffer.length; i < ii; i++) {
  47694. buffer[i] ^= 0xff;
  47695. }
  47696. }
  47697. return imgData;
  47698. }
  47699. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  47700. imgData.kind = ImageKind.RGB_24BPP;
  47701. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  47702. return imgData;
  47703. }
  47704. }
  47705. imgArray = this.getImageBytes(originalHeight * rowBytes);
  47706. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  47707. var comps = this.getComponents(imgArray);
  47708. var alpha01, maybeUndoPreblend;
  47709. if (!forceRGBA && !this.smask && !this.mask) {
  47710. imgData.kind = ImageKind.RGB_24BPP;
  47711. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  47712. alpha01 = 0;
  47713. maybeUndoPreblend = false;
  47714. } else {
  47715. imgData.kind = ImageKind.RGBA_32BPP;
  47716. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  47717. alpha01 = 1;
  47718. maybeUndoPreblend = true;
  47719. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  47720. }
  47721. if (this.needsDecode) {
  47722. this.decodeBuffer(comps);
  47723. }
  47724. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  47725. if (maybeUndoPreblend) {
  47726. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  47727. }
  47728. return imgData;
  47729. },
  47730. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  47731. var numComps = this.numComps;
  47732. if (numComps !== 1) {
  47733. error('Reading gray scale from a color image: ' + numComps);
  47734. }
  47735. var width = this.width;
  47736. var height = this.height;
  47737. var bpc = this.bpc;
  47738. var rowBytes = width * numComps * bpc + 7 >> 3;
  47739. var imgArray = this.getImageBytes(height * rowBytes);
  47740. var comps = this.getComponents(imgArray);
  47741. var i, length;
  47742. if (bpc === 1) {
  47743. length = width * height;
  47744. if (this.needsDecode) {
  47745. for (i = 0; i < length; ++i) {
  47746. buffer[i] = comps[i] - 1 & 255;
  47747. }
  47748. } else {
  47749. for (i = 0; i < length; ++i) {
  47750. buffer[i] = -comps[i] & 255;
  47751. }
  47752. }
  47753. return;
  47754. }
  47755. if (this.needsDecode) {
  47756. this.decodeBuffer(comps);
  47757. }
  47758. length = width * height;
  47759. var scale = 255 / ((1 << bpc) - 1);
  47760. for (i = 0; i < length; ++i) {
  47761. buffer[i] = scale * comps[i] | 0;
  47762. }
  47763. },
  47764. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  47765. this.image.reset();
  47766. this.image.drawWidth = drawWidth || this.width;
  47767. this.image.drawHeight = drawHeight || this.height;
  47768. this.image.forceRGB = !!forceRGB;
  47769. return this.image.getBytes(length);
  47770. }
  47771. };
  47772. return PDFImage;
  47773. }();
  47774. exports.PDFImage = PDFImage;
  47775. }));
  47776. (function (root, factory) {
  47777. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  47778. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  47779. var InvalidPDFException = sharedUtil.InvalidPDFException;
  47780. var MissingDataException = sharedUtil.MissingDataException;
  47781. var XRefParseException = sharedUtil.XRefParseException;
  47782. var assert = sharedUtil.assert;
  47783. var bytesToString = sharedUtil.bytesToString;
  47784. var createPromiseCapability = sharedUtil.createPromiseCapability;
  47785. var error = sharedUtil.error;
  47786. var info = sharedUtil.info;
  47787. var isArray = sharedUtil.isArray;
  47788. var isBool = sharedUtil.isBool;
  47789. var isInt = sharedUtil.isInt;
  47790. var isString = sharedUtil.isString;
  47791. var shadow = sharedUtil.shadow;
  47792. var stringToPDFString = sharedUtil.stringToPDFString;
  47793. var stringToUTF8String = sharedUtil.stringToUTF8String;
  47794. var warn = sharedUtil.warn;
  47795. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  47796. var Util = sharedUtil.Util;
  47797. var Ref = corePrimitives.Ref;
  47798. var RefSet = corePrimitives.RefSet;
  47799. var RefSetCache = corePrimitives.RefSetCache;
  47800. var isName = corePrimitives.isName;
  47801. var isCmd = corePrimitives.isCmd;
  47802. var isDict = corePrimitives.isDict;
  47803. var isRef = corePrimitives.isRef;
  47804. var isRefsEqual = corePrimitives.isRefsEqual;
  47805. var isStream = corePrimitives.isStream;
  47806. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  47807. var Lexer = coreParser.Lexer;
  47808. var Parser = coreParser.Parser;
  47809. var ChunkedStream = coreChunkedStream.ChunkedStream;
  47810. var ColorSpace = coreColorSpace.ColorSpace;
  47811. var Catalog = function CatalogClosure() {
  47812. function Catalog(pdfManager, xref, pageFactory) {
  47813. this.pdfManager = pdfManager;
  47814. this.xref = xref;
  47815. this.catDict = xref.getCatalogObj();
  47816. this.fontCache = new RefSetCache();
  47817. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  47818. this.pageFactory = pageFactory;
  47819. this.pagePromises = [];
  47820. }
  47821. Catalog.prototype = {
  47822. get metadata() {
  47823. var streamRef = this.catDict.getRaw('Metadata');
  47824. if (!isRef(streamRef)) {
  47825. return shadow(this, 'metadata', null);
  47826. }
  47827. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  47828. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  47829. var metadata;
  47830. if (stream && isDict(stream.dict)) {
  47831. var type = stream.dict.get('Type');
  47832. var subtype = stream.dict.get('Subtype');
  47833. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  47834. try {
  47835. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  47836. } catch (e) {
  47837. info('Skipping invalid metadata.');
  47838. }
  47839. }
  47840. }
  47841. return shadow(this, 'metadata', metadata);
  47842. },
  47843. get toplevelPagesDict() {
  47844. var pagesObj = this.catDict.get('Pages');
  47845. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  47846. return shadow(this, 'toplevelPagesDict', pagesObj);
  47847. },
  47848. get documentOutline() {
  47849. var obj = null;
  47850. try {
  47851. obj = this.readDocumentOutline();
  47852. } catch (ex) {
  47853. if (ex instanceof MissingDataException) {
  47854. throw ex;
  47855. }
  47856. warn('Unable to read document outline');
  47857. }
  47858. return shadow(this, 'documentOutline', obj);
  47859. },
  47860. readDocumentOutline: function Catalog_readDocumentOutline() {
  47861. var obj = this.catDict.get('Outlines');
  47862. if (!isDict(obj)) {
  47863. return null;
  47864. }
  47865. obj = obj.getRaw('First');
  47866. if (!isRef(obj)) {
  47867. return null;
  47868. }
  47869. var root = { items: [] };
  47870. var queue = [{
  47871. obj: obj,
  47872. parent: root
  47873. }];
  47874. var processed = new RefSet();
  47875. processed.put(obj);
  47876. var xref = this.xref, blackColor = new Uint8Array(3);
  47877. while (queue.length > 0) {
  47878. var i = queue.shift();
  47879. var outlineDict = xref.fetchIfRef(i.obj);
  47880. if (outlineDict === null) {
  47881. continue;
  47882. }
  47883. assert(outlineDict.has('Title'), 'Invalid outline item');
  47884. var data = {
  47885. url: null,
  47886. dest: null
  47887. };
  47888. Catalog.parseDestDictionary({
  47889. destDict: outlineDict,
  47890. resultObj: data,
  47891. docBaseUrl: this.pdfManager.docBaseUrl
  47892. });
  47893. var title = outlineDict.get('Title');
  47894. var flags = outlineDict.get('F') || 0;
  47895. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  47896. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  47897. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  47898. }
  47899. var outlineItem = {
  47900. dest: data.dest,
  47901. url: data.url,
  47902. unsafeUrl: data.unsafeUrl,
  47903. newWindow: data.newWindow,
  47904. title: stringToPDFString(title),
  47905. color: rgbColor,
  47906. count: outlineDict.get('Count'),
  47907. bold: !!(flags & 2),
  47908. italic: !!(flags & 1),
  47909. items: []
  47910. };
  47911. i.parent.items.push(outlineItem);
  47912. obj = outlineDict.getRaw('First');
  47913. if (isRef(obj) && !processed.has(obj)) {
  47914. queue.push({
  47915. obj: obj,
  47916. parent: outlineItem
  47917. });
  47918. processed.put(obj);
  47919. }
  47920. obj = outlineDict.getRaw('Next');
  47921. if (isRef(obj) && !processed.has(obj)) {
  47922. queue.push({
  47923. obj: obj,
  47924. parent: i.parent
  47925. });
  47926. processed.put(obj);
  47927. }
  47928. }
  47929. return root.items.length > 0 ? root.items : null;
  47930. },
  47931. get numPages() {
  47932. var obj = this.toplevelPagesDict.get('Count');
  47933. assert(isInt(obj), 'page count in top level pages object is not an integer');
  47934. return shadow(this, 'num', obj);
  47935. },
  47936. get destinations() {
  47937. function fetchDestination(dest) {
  47938. return isDict(dest) ? dest.get('D') : dest;
  47939. }
  47940. var xref = this.xref;
  47941. var dests = {}, nameTreeRef, nameDictionaryRef;
  47942. var obj = this.catDict.get('Names');
  47943. if (obj && obj.has('Dests')) {
  47944. nameTreeRef = obj.getRaw('Dests');
  47945. } else if (this.catDict.has('Dests')) {
  47946. nameDictionaryRef = this.catDict.get('Dests');
  47947. }
  47948. if (nameDictionaryRef) {
  47949. obj = nameDictionaryRef;
  47950. obj.forEach(function catalogForEach(key, value) {
  47951. if (!value) {
  47952. return;
  47953. }
  47954. dests[key] = fetchDestination(value);
  47955. });
  47956. }
  47957. if (nameTreeRef) {
  47958. var nameTree = new NameTree(nameTreeRef, xref);
  47959. var names = nameTree.getAll();
  47960. for (var name in names) {
  47961. dests[name] = fetchDestination(names[name]);
  47962. }
  47963. }
  47964. return shadow(this, 'destinations', dests);
  47965. },
  47966. getDestination: function Catalog_getDestination(destinationId) {
  47967. function fetchDestination(dest) {
  47968. return isDict(dest) ? dest.get('D') : dest;
  47969. }
  47970. var xref = this.xref;
  47971. var dest = null, nameTreeRef, nameDictionaryRef;
  47972. var obj = this.catDict.get('Names');
  47973. if (obj && obj.has('Dests')) {
  47974. nameTreeRef = obj.getRaw('Dests');
  47975. } else if (this.catDict.has('Dests')) {
  47976. nameDictionaryRef = this.catDict.get('Dests');
  47977. }
  47978. if (nameDictionaryRef) {
  47979. var value = nameDictionaryRef.get(destinationId);
  47980. if (value) {
  47981. dest = fetchDestination(value);
  47982. }
  47983. }
  47984. if (nameTreeRef) {
  47985. var nameTree = new NameTree(nameTreeRef, xref);
  47986. dest = fetchDestination(nameTree.get(destinationId));
  47987. }
  47988. return dest;
  47989. },
  47990. get pageLabels() {
  47991. var obj = null;
  47992. try {
  47993. obj = this.readPageLabels();
  47994. } catch (ex) {
  47995. if (ex instanceof MissingDataException) {
  47996. throw ex;
  47997. }
  47998. warn('Unable to read page labels.');
  47999. }
  48000. return shadow(this, 'pageLabels', obj);
  48001. },
  48002. readPageLabels: function Catalog_readPageLabels() {
  48003. var obj = this.catDict.getRaw('PageLabels');
  48004. if (!obj) {
  48005. return null;
  48006. }
  48007. var pageLabels = new Array(this.numPages);
  48008. var style = null;
  48009. var prefix = '';
  48010. var numberTree = new NumberTree(obj, this.xref);
  48011. var nums = numberTree.getAll();
  48012. var currentLabel = '', currentIndex = 1;
  48013. for (var i = 0, ii = this.numPages; i < ii; i++) {
  48014. if (i in nums) {
  48015. var labelDict = nums[i];
  48016. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  48017. var type = labelDict.get('Type');
  48018. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  48019. var s = labelDict.get('S');
  48020. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  48021. style = s ? s.name : null;
  48022. var p = labelDict.get('P');
  48023. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  48024. prefix = p ? stringToPDFString(p) : '';
  48025. var st = labelDict.get('St');
  48026. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  48027. currentIndex = st || 1;
  48028. }
  48029. switch (style) {
  48030. case 'D':
  48031. currentLabel = currentIndex;
  48032. break;
  48033. case 'R':
  48034. case 'r':
  48035. currentLabel = Util.toRoman(currentIndex, style === 'r');
  48036. break;
  48037. case 'A':
  48038. case 'a':
  48039. var LIMIT = 26;
  48040. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  48041. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  48042. var letterIndex = currentIndex - 1;
  48043. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  48044. var charBuf = [];
  48045. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  48046. charBuf.push(character);
  48047. }
  48048. currentLabel = charBuf.join('');
  48049. break;
  48050. default:
  48051. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  48052. }
  48053. pageLabels[i] = prefix + currentLabel;
  48054. currentLabel = '';
  48055. currentIndex++;
  48056. }
  48057. return pageLabels;
  48058. },
  48059. get attachments() {
  48060. var xref = this.xref;
  48061. var attachments = null, nameTreeRef;
  48062. var obj = this.catDict.get('Names');
  48063. if (obj) {
  48064. nameTreeRef = obj.getRaw('EmbeddedFiles');
  48065. }
  48066. if (nameTreeRef) {
  48067. var nameTree = new NameTree(nameTreeRef, xref);
  48068. var names = nameTree.getAll();
  48069. for (var name in names) {
  48070. var fs = new FileSpec(names[name], xref);
  48071. if (!attachments) {
  48072. attachments = Object.create(null);
  48073. }
  48074. attachments[stringToPDFString(name)] = fs.serializable;
  48075. }
  48076. }
  48077. return shadow(this, 'attachments', attachments);
  48078. },
  48079. get javaScript() {
  48080. var xref = this.xref;
  48081. var obj = this.catDict.get('Names');
  48082. var javaScript = [];
  48083. function appendIfJavaScriptDict(jsDict) {
  48084. var type = jsDict.get('S');
  48085. if (!isName(type, 'JavaScript')) {
  48086. return;
  48087. }
  48088. var js = jsDict.get('JS');
  48089. if (isStream(js)) {
  48090. js = bytesToString(js.getBytes());
  48091. } else if (!isString(js)) {
  48092. return;
  48093. }
  48094. javaScript.push(stringToPDFString(js));
  48095. }
  48096. if (obj && obj.has('JavaScript')) {
  48097. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  48098. var names = nameTree.getAll();
  48099. for (var name in names) {
  48100. var jsDict = names[name];
  48101. if (isDict(jsDict)) {
  48102. appendIfJavaScriptDict(jsDict);
  48103. }
  48104. }
  48105. }
  48106. var openactionDict = this.catDict.get('OpenAction');
  48107. if (isDict(openactionDict, 'Action')) {
  48108. var actionType = openactionDict.get('S');
  48109. if (isName(actionType, 'Named')) {
  48110. var action = openactionDict.get('N');
  48111. if (isName(action, 'Print')) {
  48112. javaScript.push('print({});');
  48113. }
  48114. } else {
  48115. appendIfJavaScriptDict(openactionDict);
  48116. }
  48117. }
  48118. return shadow(this, 'javaScript', javaScript);
  48119. },
  48120. cleanup: function Catalog_cleanup() {
  48121. var promises = [];
  48122. this.fontCache.forEach(function (promise) {
  48123. promises.push(promise);
  48124. });
  48125. return Promise.all(promises).then(function (translatedFonts) {
  48126. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  48127. var font = translatedFonts[i].dict;
  48128. delete font.translated;
  48129. }
  48130. this.fontCache.clear();
  48131. }.bind(this));
  48132. },
  48133. getPage: function Catalog_getPage(pageIndex) {
  48134. if (!(pageIndex in this.pagePromises)) {
  48135. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  48136. var dict = a[0];
  48137. var ref = a[1];
  48138. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  48139. }.bind(this));
  48140. }
  48141. return this.pagePromises[pageIndex];
  48142. },
  48143. getPageDict: function Catalog_getPageDict(pageIndex) {
  48144. var capability = createPromiseCapability();
  48145. var nodesToVisit = [this.catDict.getRaw('Pages')];
  48146. var currentPageIndex = 0;
  48147. var xref = this.xref;
  48148. var checkAllKids = false;
  48149. function next() {
  48150. while (nodesToVisit.length) {
  48151. var currentNode = nodesToVisit.pop();
  48152. if (isRef(currentNode)) {
  48153. xref.fetchAsync(currentNode).then(function (obj) {
  48154. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  48155. if (pageIndex === currentPageIndex) {
  48156. capability.resolve([
  48157. obj,
  48158. currentNode
  48159. ]);
  48160. } else {
  48161. currentPageIndex++;
  48162. next();
  48163. }
  48164. return;
  48165. }
  48166. nodesToVisit.push(obj);
  48167. next();
  48168. }, capability.reject);
  48169. return;
  48170. }
  48171. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  48172. var count = currentNode.get('Count');
  48173. if (count === 0) {
  48174. checkAllKids = true;
  48175. }
  48176. if (currentPageIndex + count <= pageIndex) {
  48177. currentPageIndex += count;
  48178. continue;
  48179. }
  48180. var kids = currentNode.get('Kids');
  48181. assert(isArray(kids), 'page dictionary kids object is not an array');
  48182. if (!checkAllKids && count === kids.length) {
  48183. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  48184. currentPageIndex = pageIndex;
  48185. continue;
  48186. } else {
  48187. for (var last = kids.length - 1; last >= 0; last--) {
  48188. nodesToVisit.push(kids[last]);
  48189. }
  48190. }
  48191. }
  48192. capability.reject('Page index ' + pageIndex + ' not found.');
  48193. }
  48194. next();
  48195. return capability.promise;
  48196. },
  48197. getPageIndex: function Catalog_getPageIndex(pageRef) {
  48198. var xref = this.xref;
  48199. function pagesBeforeRef(kidRef) {
  48200. var total = 0;
  48201. var parentRef;
  48202. return xref.fetchAsync(kidRef).then(function (node) {
  48203. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  48204. throw new Error('The reference does not point to a /Page Dict.');
  48205. }
  48206. if (!node) {
  48207. return null;
  48208. }
  48209. assert(isDict(node), 'node must be a Dict.');
  48210. parentRef = node.getRaw('Parent');
  48211. return node.getAsync('Parent');
  48212. }).then(function (parent) {
  48213. if (!parent) {
  48214. return null;
  48215. }
  48216. assert(isDict(parent), 'parent must be a Dict.');
  48217. return parent.getAsync('Kids');
  48218. }).then(function (kids) {
  48219. if (!kids) {
  48220. return null;
  48221. }
  48222. var kidPromises = [];
  48223. var found = false;
  48224. for (var i = 0; i < kids.length; i++) {
  48225. var kid = kids[i];
  48226. assert(isRef(kid), 'kid must be a Ref.');
  48227. if (kid.num === kidRef.num) {
  48228. found = true;
  48229. break;
  48230. }
  48231. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  48232. if (kid.has('Count')) {
  48233. var count = kid.get('Count');
  48234. total += count;
  48235. } else {
  48236. total++;
  48237. }
  48238. }));
  48239. }
  48240. if (!found) {
  48241. error('kid ref not found in parents kids');
  48242. }
  48243. return Promise.all(kidPromises).then(function () {
  48244. return [
  48245. total,
  48246. parentRef
  48247. ];
  48248. });
  48249. });
  48250. }
  48251. var total = 0;
  48252. function next(ref) {
  48253. return pagesBeforeRef(ref).then(function (args) {
  48254. if (!args) {
  48255. return total;
  48256. }
  48257. var count = args[0];
  48258. var parentRef = args[1];
  48259. total += count;
  48260. return next(parentRef);
  48261. });
  48262. }
  48263. return next(pageRef);
  48264. }
  48265. };
  48266. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  48267. function addDefaultProtocolToUrl(url) {
  48268. if (url.indexOf('www.') === 0) {
  48269. return 'http://' + url;
  48270. }
  48271. return url;
  48272. }
  48273. function tryConvertUrlEncoding(url) {
  48274. try {
  48275. return stringToUTF8String(url);
  48276. } catch (e) {
  48277. return url;
  48278. }
  48279. }
  48280. var destDict = params.destDict;
  48281. if (!isDict(destDict)) {
  48282. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  48283. return;
  48284. }
  48285. var resultObj = params.resultObj;
  48286. if (typeof resultObj !== 'object') {
  48287. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  48288. return;
  48289. }
  48290. var docBaseUrl = params.docBaseUrl || null;
  48291. var action = destDict.get('A'), url, dest;
  48292. if (isDict(action)) {
  48293. var linkType = action.get('S').name;
  48294. switch (linkType) {
  48295. case 'URI':
  48296. url = action.get('URI');
  48297. if (isName(url)) {
  48298. url = '/' + url.name;
  48299. } else if (isString(url)) {
  48300. url = addDefaultProtocolToUrl(url);
  48301. }
  48302. break;
  48303. case 'GoTo':
  48304. dest = action.get('D');
  48305. break;
  48306. case 'Launch':
  48307. case 'GoToR':
  48308. var urlDict = action.get('F');
  48309. if (isDict(urlDict)) {
  48310. url = urlDict.get('F') || null;
  48311. } else if (isString(urlDict)) {
  48312. url = urlDict;
  48313. }
  48314. var remoteDest = action.get('D');
  48315. if (remoteDest) {
  48316. if (isName(remoteDest)) {
  48317. remoteDest = remoteDest.name;
  48318. }
  48319. if (isString(url)) {
  48320. var baseUrl = url.split('#')[0];
  48321. if (isString(remoteDest)) {
  48322. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  48323. } else if (isArray(remoteDest)) {
  48324. url = baseUrl + '#' + JSON.stringify(remoteDest);
  48325. }
  48326. }
  48327. }
  48328. var newWindow = action.get('NewWindow');
  48329. if (isBool(newWindow)) {
  48330. resultObj.newWindow = newWindow;
  48331. }
  48332. break;
  48333. case 'Named':
  48334. var namedAction = action.get('N');
  48335. if (isName(namedAction)) {
  48336. resultObj.action = namedAction.name;
  48337. }
  48338. break;
  48339. case 'JavaScript':
  48340. var jsAction = action.get('JS'), js;
  48341. if (isStream(jsAction)) {
  48342. js = bytesToString(jsAction.getBytes());
  48343. } else if (isString(jsAction)) {
  48344. js = jsAction;
  48345. }
  48346. if (js) {
  48347. var URL_OPEN_METHODS = [
  48348. 'app.launchURL',
  48349. 'window.open'
  48350. ];
  48351. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  48352. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  48353. if (jsUrl && jsUrl[1]) {
  48354. url = jsUrl[1];
  48355. break;
  48356. }
  48357. }
  48358. default:
  48359. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  48360. break;
  48361. }
  48362. } else if (destDict.has('Dest')) {
  48363. dest = destDict.get('Dest');
  48364. }
  48365. if (isString(url)) {
  48366. url = tryConvertUrlEncoding(url);
  48367. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  48368. if (absoluteUrl) {
  48369. resultObj.url = absoluteUrl.href;
  48370. }
  48371. resultObj.unsafeUrl = url;
  48372. }
  48373. if (dest) {
  48374. if (isName(dest)) {
  48375. dest = dest.name;
  48376. }
  48377. if (isString(dest) || isArray(dest)) {
  48378. resultObj.dest = dest;
  48379. }
  48380. }
  48381. };
  48382. return Catalog;
  48383. }();
  48384. var XRef = function XRefClosure() {
  48385. function XRef(stream, pdfManager) {
  48386. this.stream = stream;
  48387. this.pdfManager = pdfManager;
  48388. this.entries = [];
  48389. this.xrefstms = Object.create(null);
  48390. this.cache = [];
  48391. this.stats = {
  48392. streamTypes: [],
  48393. fontTypes: []
  48394. };
  48395. }
  48396. XRef.prototype = {
  48397. setStartXRef: function XRef_setStartXRef(startXRef) {
  48398. this.startXRefQueue = [startXRef];
  48399. },
  48400. parse: function XRef_parse(recoveryMode) {
  48401. var trailerDict;
  48402. if (!recoveryMode) {
  48403. trailerDict = this.readXRef();
  48404. } else {
  48405. warn('Indexing all PDF objects');
  48406. trailerDict = this.indexObjects();
  48407. }
  48408. trailerDict.assignXref(this);
  48409. this.trailer = trailerDict;
  48410. var encrypt = trailerDict.get('Encrypt');
  48411. if (isDict(encrypt)) {
  48412. var ids = trailerDict.get('ID');
  48413. var fileId = ids && ids.length ? ids[0] : '';
  48414. encrypt.suppressEncryption = true;
  48415. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  48416. }
  48417. if (!(this.root = trailerDict.get('Root'))) {
  48418. error('Invalid root reference');
  48419. }
  48420. },
  48421. processXRefTable: function XRef_processXRefTable(parser) {
  48422. if (!('tableState' in this)) {
  48423. this.tableState = {
  48424. entryNum: 0,
  48425. streamPos: parser.lexer.stream.pos,
  48426. parserBuf1: parser.buf1,
  48427. parserBuf2: parser.buf2
  48428. };
  48429. }
  48430. var obj = this.readXRefTable(parser);
  48431. if (!isCmd(obj, 'trailer')) {
  48432. error('Invalid XRef table: could not find trailer dictionary');
  48433. }
  48434. var dict = parser.getObj();
  48435. if (!isDict(dict) && dict.dict) {
  48436. dict = dict.dict;
  48437. }
  48438. if (!isDict(dict)) {
  48439. error('Invalid XRef table: could not parse trailer dictionary');
  48440. }
  48441. delete this.tableState;
  48442. return dict;
  48443. },
  48444. readXRefTable: function XRef_readXRefTable(parser) {
  48445. var stream = parser.lexer.stream;
  48446. var tableState = this.tableState;
  48447. stream.pos = tableState.streamPos;
  48448. parser.buf1 = tableState.parserBuf1;
  48449. parser.buf2 = tableState.parserBuf2;
  48450. var obj;
  48451. while (true) {
  48452. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  48453. if (isCmd(obj = parser.getObj(), 'trailer')) {
  48454. break;
  48455. }
  48456. tableState.firstEntryNum = obj;
  48457. tableState.entryCount = parser.getObj();
  48458. }
  48459. var first = tableState.firstEntryNum;
  48460. var count = tableState.entryCount;
  48461. if (!isInt(first) || !isInt(count)) {
  48462. error('Invalid XRef table: wrong types in subsection header');
  48463. }
  48464. for (var i = tableState.entryNum; i < count; i++) {
  48465. tableState.streamPos = stream.pos;
  48466. tableState.entryNum = i;
  48467. tableState.parserBuf1 = parser.buf1;
  48468. tableState.parserBuf2 = parser.buf2;
  48469. var entry = {};
  48470. entry.offset = parser.getObj();
  48471. entry.gen = parser.getObj();
  48472. var type = parser.getObj();
  48473. if (isCmd(type, 'f')) {
  48474. entry.free = true;
  48475. } else if (isCmd(type, 'n')) {
  48476. entry.uncompressed = true;
  48477. }
  48478. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  48479. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  48480. }
  48481. if (i === 0 && entry.free && first === 1) {
  48482. first = 0;
  48483. }
  48484. if (!this.entries[i + first]) {
  48485. this.entries[i + first] = entry;
  48486. }
  48487. }
  48488. tableState.entryNum = 0;
  48489. tableState.streamPos = stream.pos;
  48490. tableState.parserBuf1 = parser.buf1;
  48491. tableState.parserBuf2 = parser.buf2;
  48492. delete tableState.firstEntryNum;
  48493. delete tableState.entryCount;
  48494. }
  48495. if (this.entries[0] && !this.entries[0].free) {
  48496. error('Invalid XRef table: unexpected first object');
  48497. }
  48498. return obj;
  48499. },
  48500. processXRefStream: function XRef_processXRefStream(stream) {
  48501. if (!('streamState' in this)) {
  48502. var streamParameters = stream.dict;
  48503. var byteWidths = streamParameters.get('W');
  48504. var range = streamParameters.get('Index');
  48505. if (!range) {
  48506. range = [
  48507. 0,
  48508. streamParameters.get('Size')
  48509. ];
  48510. }
  48511. this.streamState = {
  48512. entryRanges: range,
  48513. byteWidths: byteWidths,
  48514. entryNum: 0,
  48515. streamPos: stream.pos
  48516. };
  48517. }
  48518. this.readXRefStream(stream);
  48519. delete this.streamState;
  48520. return stream.dict;
  48521. },
  48522. readXRefStream: function XRef_readXRefStream(stream) {
  48523. var i, j;
  48524. var streamState = this.streamState;
  48525. stream.pos = streamState.streamPos;
  48526. var byteWidths = streamState.byteWidths;
  48527. var typeFieldWidth = byteWidths[0];
  48528. var offsetFieldWidth = byteWidths[1];
  48529. var generationFieldWidth = byteWidths[2];
  48530. var entryRanges = streamState.entryRanges;
  48531. while (entryRanges.length > 0) {
  48532. var first = entryRanges[0];
  48533. var n = entryRanges[1];
  48534. if (!isInt(first) || !isInt(n)) {
  48535. error('Invalid XRef range fields: ' + first + ', ' + n);
  48536. }
  48537. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  48538. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  48539. }
  48540. for (i = streamState.entryNum; i < n; ++i) {
  48541. streamState.entryNum = i;
  48542. streamState.streamPos = stream.pos;
  48543. var type = 0, offset = 0, generation = 0;
  48544. for (j = 0; j < typeFieldWidth; ++j) {
  48545. type = type << 8 | stream.getByte();
  48546. }
  48547. if (typeFieldWidth === 0) {
  48548. type = 1;
  48549. }
  48550. for (j = 0; j < offsetFieldWidth; ++j) {
  48551. offset = offset << 8 | stream.getByte();
  48552. }
  48553. for (j = 0; j < generationFieldWidth; ++j) {
  48554. generation = generation << 8 | stream.getByte();
  48555. }
  48556. var entry = {};
  48557. entry.offset = offset;
  48558. entry.gen = generation;
  48559. switch (type) {
  48560. case 0:
  48561. entry.free = true;
  48562. break;
  48563. case 1:
  48564. entry.uncompressed = true;
  48565. break;
  48566. case 2:
  48567. break;
  48568. default:
  48569. error('Invalid XRef entry type: ' + type);
  48570. }
  48571. if (!this.entries[first + i]) {
  48572. this.entries[first + i] = entry;
  48573. }
  48574. }
  48575. streamState.entryNum = 0;
  48576. streamState.streamPos = stream.pos;
  48577. entryRanges.splice(0, 2);
  48578. }
  48579. },
  48580. indexObjects: function XRef_indexObjects() {
  48581. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  48582. var PERCENT = 0x25, LT = 0x3C;
  48583. function readToken(data, offset) {
  48584. var token = '', ch = data[offset];
  48585. while (ch !== LF && ch !== CR && ch !== LT) {
  48586. if (++offset >= data.length) {
  48587. break;
  48588. }
  48589. token += String.fromCharCode(ch);
  48590. ch = data[offset];
  48591. }
  48592. return token;
  48593. }
  48594. function skipUntil(data, offset, what) {
  48595. var length = what.length, dataLength = data.length;
  48596. var skipped = 0;
  48597. while (offset < dataLength) {
  48598. var i = 0;
  48599. while (i < length && data[offset + i] === what[i]) {
  48600. ++i;
  48601. }
  48602. if (i >= length) {
  48603. break;
  48604. }
  48605. offset++;
  48606. skipped++;
  48607. }
  48608. return skipped;
  48609. }
  48610. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  48611. var trailerBytes = new Uint8Array([
  48612. 116,
  48613. 114,
  48614. 97,
  48615. 105,
  48616. 108,
  48617. 101,
  48618. 114
  48619. ]);
  48620. var startxrefBytes = new Uint8Array([
  48621. 115,
  48622. 116,
  48623. 97,
  48624. 114,
  48625. 116,
  48626. 120,
  48627. 114,
  48628. 101,
  48629. 102
  48630. ]);
  48631. var endobjBytes = new Uint8Array([
  48632. 101,
  48633. 110,
  48634. 100,
  48635. 111,
  48636. 98,
  48637. 106
  48638. ]);
  48639. var xrefBytes = new Uint8Array([
  48640. 47,
  48641. 88,
  48642. 82,
  48643. 101,
  48644. 102
  48645. ]);
  48646. this.entries.length = 0;
  48647. var stream = this.stream;
  48648. stream.pos = 0;
  48649. var buffer = stream.getBytes();
  48650. var position = stream.start, length = buffer.length;
  48651. var trailers = [], xrefStms = [];
  48652. while (position < length) {
  48653. var ch = buffer[position];
  48654. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  48655. ++position;
  48656. continue;
  48657. }
  48658. if (ch === PERCENT) {
  48659. do {
  48660. ++position;
  48661. if (position >= length) {
  48662. break;
  48663. }
  48664. ch = buffer[position];
  48665. } while (ch !== LF && ch !== CR);
  48666. continue;
  48667. }
  48668. var token = readToken(buffer, position);
  48669. var m;
  48670. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  48671. position += skipUntil(buffer, position, trailerBytes);
  48672. trailers.push(position);
  48673. position += skipUntil(buffer, position, startxrefBytes);
  48674. } else if (m = objRegExp.exec(token)) {
  48675. if (typeof this.entries[m[1]] === 'undefined') {
  48676. this.entries[m[1]] = {
  48677. offset: position - stream.start,
  48678. gen: m[2] | 0,
  48679. uncompressed: true
  48680. };
  48681. }
  48682. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  48683. var content = buffer.subarray(position, position + contentLength);
  48684. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  48685. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  48686. xrefStms.push(position - stream.start);
  48687. this.xrefstms[position - stream.start] = 1;
  48688. }
  48689. position += contentLength;
  48690. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  48691. trailers.push(position);
  48692. position += skipUntil(buffer, position, startxrefBytes);
  48693. } else {
  48694. position += token.length + 1;
  48695. }
  48696. }
  48697. var i, ii;
  48698. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  48699. this.startXRefQueue.push(xrefStms[i]);
  48700. this.readXRef(true);
  48701. }
  48702. var dict;
  48703. for (i = 0, ii = trailers.length; i < ii; ++i) {
  48704. stream.pos = trailers[i];
  48705. var parser = new Parser(new Lexer(stream), true, this, true);
  48706. var obj = parser.getObj();
  48707. if (!isCmd(obj, 'trailer')) {
  48708. continue;
  48709. }
  48710. dict = parser.getObj();
  48711. if (!isDict(dict)) {
  48712. continue;
  48713. }
  48714. if (dict.has('ID')) {
  48715. return dict;
  48716. }
  48717. }
  48718. if (dict) {
  48719. return dict;
  48720. }
  48721. throw new InvalidPDFException('Invalid PDF structure');
  48722. },
  48723. readXRef: function XRef_readXRef(recoveryMode) {
  48724. var stream = this.stream;
  48725. try {
  48726. while (this.startXRefQueue.length) {
  48727. var startXRef = this.startXRefQueue[0];
  48728. stream.pos = startXRef + stream.start;
  48729. var parser = new Parser(new Lexer(stream), true, this);
  48730. var obj = parser.getObj();
  48731. var dict;
  48732. if (isCmd(obj, 'xref')) {
  48733. dict = this.processXRefTable(parser);
  48734. if (!this.topDict) {
  48735. this.topDict = dict;
  48736. }
  48737. obj = dict.get('XRefStm');
  48738. if (isInt(obj)) {
  48739. var pos = obj;
  48740. if (!(pos in this.xrefstms)) {
  48741. this.xrefstms[pos] = 1;
  48742. this.startXRefQueue.push(pos);
  48743. }
  48744. }
  48745. } else if (isInt(obj)) {
  48746. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  48747. error('Invalid XRef stream');
  48748. }
  48749. dict = this.processXRefStream(obj);
  48750. if (!this.topDict) {
  48751. this.topDict = dict;
  48752. }
  48753. if (!dict) {
  48754. error('Failed to read XRef stream');
  48755. }
  48756. } else {
  48757. error('Invalid XRef stream header');
  48758. }
  48759. obj = dict.get('Prev');
  48760. if (isInt(obj)) {
  48761. this.startXRefQueue.push(obj);
  48762. } else if (isRef(obj)) {
  48763. this.startXRefQueue.push(obj.num);
  48764. }
  48765. this.startXRefQueue.shift();
  48766. }
  48767. return this.topDict;
  48768. } catch (e) {
  48769. if (e instanceof MissingDataException) {
  48770. throw e;
  48771. }
  48772. info('(while reading XRef): ' + e);
  48773. }
  48774. if (recoveryMode) {
  48775. return;
  48776. }
  48777. throw new XRefParseException();
  48778. },
  48779. getEntry: function XRef_getEntry(i) {
  48780. var xrefEntry = this.entries[i];
  48781. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  48782. return xrefEntry;
  48783. }
  48784. return null;
  48785. },
  48786. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  48787. if (!isRef(obj)) {
  48788. return obj;
  48789. }
  48790. return this.fetch(obj, suppressEncryption);
  48791. },
  48792. fetch: function XRef_fetch(ref, suppressEncryption) {
  48793. assert(isRef(ref), 'ref object is not a reference');
  48794. var num = ref.num;
  48795. if (num in this.cache) {
  48796. var cacheEntry = this.cache[num];
  48797. return cacheEntry;
  48798. }
  48799. var xrefEntry = this.getEntry(num);
  48800. if (xrefEntry === null) {
  48801. return this.cache[num] = null;
  48802. }
  48803. if (xrefEntry.uncompressed) {
  48804. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  48805. } else {
  48806. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  48807. }
  48808. if (isDict(xrefEntry)) {
  48809. xrefEntry.objId = ref.toString();
  48810. } else if (isStream(xrefEntry)) {
  48811. xrefEntry.dict.objId = ref.toString();
  48812. }
  48813. return xrefEntry;
  48814. },
  48815. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  48816. var gen = ref.gen;
  48817. var num = ref.num;
  48818. if (xrefEntry.gen !== gen) {
  48819. error('inconsistent generation in XRef');
  48820. }
  48821. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  48822. var parser = new Parser(new Lexer(stream), true, this);
  48823. var obj1 = parser.getObj();
  48824. var obj2 = parser.getObj();
  48825. var obj3 = parser.getObj();
  48826. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  48827. error('bad XRef entry');
  48828. }
  48829. if (!isCmd(obj3, 'obj')) {
  48830. if (obj3.cmd.indexOf('obj') === 0) {
  48831. num = parseInt(obj3.cmd.substring(3), 10);
  48832. if (!isNaN(num)) {
  48833. return num;
  48834. }
  48835. }
  48836. error('bad XRef entry');
  48837. }
  48838. if (this.encrypt && !suppressEncryption) {
  48839. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  48840. } else {
  48841. xrefEntry = parser.getObj();
  48842. }
  48843. if (!isStream(xrefEntry)) {
  48844. this.cache[num] = xrefEntry;
  48845. }
  48846. return xrefEntry;
  48847. },
  48848. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  48849. var tableOffset = xrefEntry.offset;
  48850. var stream = this.fetch(new Ref(tableOffset, 0));
  48851. if (!isStream(stream)) {
  48852. error('bad ObjStm stream');
  48853. }
  48854. var first = stream.dict.get('First');
  48855. var n = stream.dict.get('N');
  48856. if (!isInt(first) || !isInt(n)) {
  48857. error('invalid first and n parameters for ObjStm stream');
  48858. }
  48859. var parser = new Parser(new Lexer(stream), false, this);
  48860. parser.allowStreams = true;
  48861. var i, entries = [], num, nums = [];
  48862. for (i = 0; i < n; ++i) {
  48863. num = parser.getObj();
  48864. if (!isInt(num)) {
  48865. error('invalid object number in the ObjStm stream: ' + num);
  48866. }
  48867. nums.push(num);
  48868. var offset = parser.getObj();
  48869. if (!isInt(offset)) {
  48870. error('invalid object offset in the ObjStm stream: ' + offset);
  48871. }
  48872. }
  48873. for (i = 0; i < n; ++i) {
  48874. entries.push(parser.getObj());
  48875. if (isCmd(parser.buf1, 'endobj')) {
  48876. parser.shift();
  48877. }
  48878. num = nums[i];
  48879. var entry = this.entries[num];
  48880. if (entry && entry.offset === tableOffset && entry.gen === i) {
  48881. this.cache[num] = entries[i];
  48882. }
  48883. }
  48884. xrefEntry = entries[xrefEntry.gen];
  48885. if (xrefEntry === undefined) {
  48886. error('bad XRef entry for compressed object');
  48887. }
  48888. return xrefEntry;
  48889. },
  48890. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  48891. if (!isRef(obj)) {
  48892. return Promise.resolve(obj);
  48893. }
  48894. return this.fetchAsync(obj, suppressEncryption);
  48895. },
  48896. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  48897. var streamManager = this.stream.manager;
  48898. var xref = this;
  48899. return new Promise(function tryFetch(resolve, reject) {
  48900. try {
  48901. resolve(xref.fetch(ref, suppressEncryption));
  48902. } catch (e) {
  48903. if (e instanceof MissingDataException) {
  48904. streamManager.requestRange(e.begin, e.end).then(function () {
  48905. tryFetch(resolve, reject);
  48906. }, reject);
  48907. return;
  48908. }
  48909. reject(e);
  48910. }
  48911. });
  48912. },
  48913. getCatalogObj: function XRef_getCatalogObj() {
  48914. return this.root;
  48915. }
  48916. };
  48917. return XRef;
  48918. }();
  48919. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  48920. function NameOrNumberTree(root, xref) {
  48921. throw new Error('Cannot initialize NameOrNumberTree.');
  48922. }
  48923. NameOrNumberTree.prototype = {
  48924. getAll: function NameOrNumberTree_getAll() {
  48925. var dict = Object.create(null);
  48926. if (!this.root) {
  48927. return dict;
  48928. }
  48929. var xref = this.xref;
  48930. var processed = new RefSet();
  48931. processed.put(this.root);
  48932. var queue = [this.root];
  48933. while (queue.length > 0) {
  48934. var i, n;
  48935. var obj = xref.fetchIfRef(queue.shift());
  48936. if (!isDict(obj)) {
  48937. continue;
  48938. }
  48939. if (obj.has('Kids')) {
  48940. var kids = obj.get('Kids');
  48941. for (i = 0, n = kids.length; i < n; i++) {
  48942. var kid = kids[i];
  48943. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  48944. queue.push(kid);
  48945. processed.put(kid);
  48946. }
  48947. continue;
  48948. }
  48949. var entries = obj.get(this._type);
  48950. if (isArray(entries)) {
  48951. for (i = 0, n = entries.length; i < n; i += 2) {
  48952. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  48953. }
  48954. }
  48955. }
  48956. return dict;
  48957. },
  48958. get: function NameOrNumberTree_get(key) {
  48959. if (!this.root) {
  48960. return null;
  48961. }
  48962. var xref = this.xref;
  48963. var kidsOrEntries = xref.fetchIfRef(this.root);
  48964. var loopCount = 0;
  48965. var MAX_LEVELS = 10;
  48966. var l, r, m;
  48967. while (kidsOrEntries.has('Kids')) {
  48968. if (++loopCount > MAX_LEVELS) {
  48969. warn('Search depth limit reached for "' + this._type + '" tree.');
  48970. return null;
  48971. }
  48972. var kids = kidsOrEntries.get('Kids');
  48973. if (!isArray(kids)) {
  48974. return null;
  48975. }
  48976. l = 0;
  48977. r = kids.length - 1;
  48978. while (l <= r) {
  48979. m = l + r >> 1;
  48980. var kid = xref.fetchIfRef(kids[m]);
  48981. var limits = kid.get('Limits');
  48982. if (key < xref.fetchIfRef(limits[0])) {
  48983. r = m - 1;
  48984. } else if (key > xref.fetchIfRef(limits[1])) {
  48985. l = m + 1;
  48986. } else {
  48987. kidsOrEntries = xref.fetchIfRef(kids[m]);
  48988. break;
  48989. }
  48990. }
  48991. if (l > r) {
  48992. return null;
  48993. }
  48994. }
  48995. var entries = kidsOrEntries.get(this._type);
  48996. if (isArray(entries)) {
  48997. l = 0;
  48998. r = entries.length - 2;
  48999. while (l <= r) {
  49000. m = l + r & ~1;
  49001. var currentKey = xref.fetchIfRef(entries[m]);
  49002. if (key < currentKey) {
  49003. r = m - 2;
  49004. } else if (key > currentKey) {
  49005. l = m + 2;
  49006. } else {
  49007. return xref.fetchIfRef(entries[m + 1]);
  49008. }
  49009. }
  49010. }
  49011. return null;
  49012. }
  49013. };
  49014. return NameOrNumberTree;
  49015. }();
  49016. var NameTree = function NameTreeClosure() {
  49017. function NameTree(root, xref) {
  49018. this.root = root;
  49019. this.xref = xref;
  49020. this._type = 'Names';
  49021. }
  49022. Util.inherit(NameTree, NameOrNumberTree, {});
  49023. return NameTree;
  49024. }();
  49025. var NumberTree = function NumberTreeClosure() {
  49026. function NumberTree(root, xref) {
  49027. this.root = root;
  49028. this.xref = xref;
  49029. this._type = 'Nums';
  49030. }
  49031. Util.inherit(NumberTree, NameOrNumberTree, {});
  49032. return NumberTree;
  49033. }();
  49034. var FileSpec = function FileSpecClosure() {
  49035. function FileSpec(root, xref) {
  49036. if (!root || !isDict(root)) {
  49037. return;
  49038. }
  49039. this.xref = xref;
  49040. this.root = root;
  49041. if (root.has('FS')) {
  49042. this.fs = root.get('FS');
  49043. }
  49044. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  49045. if (root.has('RF')) {
  49046. warn('Related file specifications are not supported');
  49047. }
  49048. this.contentAvailable = true;
  49049. if (!root.has('EF')) {
  49050. this.contentAvailable = false;
  49051. warn('Non-embedded file specifications are not supported');
  49052. }
  49053. }
  49054. function pickPlatformItem(dict) {
  49055. if (dict.has('UF')) {
  49056. return dict.get('UF');
  49057. } else if (dict.has('F')) {
  49058. return dict.get('F');
  49059. } else if (dict.has('Unix')) {
  49060. return dict.get('Unix');
  49061. } else if (dict.has('Mac')) {
  49062. return dict.get('Mac');
  49063. } else if (dict.has('DOS')) {
  49064. return dict.get('DOS');
  49065. }
  49066. return null;
  49067. }
  49068. FileSpec.prototype = {
  49069. get filename() {
  49070. if (!this._filename && this.root) {
  49071. var filename = pickPlatformItem(this.root) || 'unnamed';
  49072. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  49073. }
  49074. return this._filename;
  49075. },
  49076. get content() {
  49077. if (!this.contentAvailable) {
  49078. return null;
  49079. }
  49080. if (!this.contentRef && this.root) {
  49081. this.contentRef = pickPlatformItem(this.root.get('EF'));
  49082. }
  49083. var content = null;
  49084. if (this.contentRef) {
  49085. var xref = this.xref;
  49086. var fileObj = xref.fetchIfRef(this.contentRef);
  49087. if (fileObj && isStream(fileObj)) {
  49088. content = fileObj.getBytes();
  49089. } else {
  49090. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  49091. }
  49092. } else {
  49093. warn('Embedded file specification does not have a content');
  49094. }
  49095. return content;
  49096. },
  49097. get serializable() {
  49098. return {
  49099. filename: this.filename,
  49100. content: this.content
  49101. };
  49102. }
  49103. };
  49104. return FileSpec;
  49105. }();
  49106. var ObjectLoader = function () {
  49107. function mayHaveChildren(value) {
  49108. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  49109. }
  49110. function addChildren(node, nodesToVisit) {
  49111. var value;
  49112. if (isDict(node) || isStream(node)) {
  49113. var map;
  49114. if (isDict(node)) {
  49115. map = node.map;
  49116. } else {
  49117. map = node.dict.map;
  49118. }
  49119. for (var key in map) {
  49120. value = map[key];
  49121. if (mayHaveChildren(value)) {
  49122. nodesToVisit.push(value);
  49123. }
  49124. }
  49125. } else if (isArray(node)) {
  49126. for (var i = 0, ii = node.length; i < ii; i++) {
  49127. value = node[i];
  49128. if (mayHaveChildren(value)) {
  49129. nodesToVisit.push(value);
  49130. }
  49131. }
  49132. }
  49133. }
  49134. function ObjectLoader(obj, keys, xref) {
  49135. this.obj = obj;
  49136. this.keys = keys;
  49137. this.xref = xref;
  49138. this.refSet = null;
  49139. this.capability = null;
  49140. }
  49141. ObjectLoader.prototype = {
  49142. load: function ObjectLoader_load() {
  49143. var keys = this.keys;
  49144. this.capability = createPromiseCapability();
  49145. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  49146. this.capability.resolve();
  49147. return this.capability.promise;
  49148. }
  49149. this.refSet = new RefSet();
  49150. var nodesToVisit = [];
  49151. for (var i = 0; i < keys.length; i++) {
  49152. nodesToVisit.push(this.obj[keys[i]]);
  49153. }
  49154. this._walk(nodesToVisit);
  49155. return this.capability.promise;
  49156. },
  49157. _walk: function ObjectLoader_walk(nodesToVisit) {
  49158. var nodesToRevisit = [];
  49159. var pendingRequests = [];
  49160. while (nodesToVisit.length) {
  49161. var currentNode = nodesToVisit.pop();
  49162. if (isRef(currentNode)) {
  49163. if (this.refSet.has(currentNode)) {
  49164. continue;
  49165. }
  49166. try {
  49167. var ref = currentNode;
  49168. this.refSet.put(ref);
  49169. currentNode = this.xref.fetch(currentNode);
  49170. } catch (e) {
  49171. if (!(e instanceof MissingDataException)) {
  49172. throw e;
  49173. }
  49174. nodesToRevisit.push(currentNode);
  49175. pendingRequests.push({
  49176. begin: e.begin,
  49177. end: e.end
  49178. });
  49179. }
  49180. }
  49181. if (currentNode && currentNode.getBaseStreams) {
  49182. var baseStreams = currentNode.getBaseStreams();
  49183. var foundMissingData = false;
  49184. for (var i = 0; i < baseStreams.length; i++) {
  49185. var stream = baseStreams[i];
  49186. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  49187. foundMissingData = true;
  49188. pendingRequests.push({
  49189. begin: stream.start,
  49190. end: stream.end
  49191. });
  49192. }
  49193. }
  49194. if (foundMissingData) {
  49195. nodesToRevisit.push(currentNode);
  49196. }
  49197. }
  49198. addChildren(currentNode, nodesToVisit);
  49199. }
  49200. if (pendingRequests.length) {
  49201. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  49202. nodesToVisit = nodesToRevisit;
  49203. for (var i = 0; i < nodesToRevisit.length; i++) {
  49204. var node = nodesToRevisit[i];
  49205. if (isRef(node)) {
  49206. this.refSet.remove(node);
  49207. }
  49208. }
  49209. this._walk(nodesToVisit);
  49210. }.bind(this), this.capability.reject);
  49211. return;
  49212. }
  49213. this.refSet = null;
  49214. this.capability.resolve();
  49215. }
  49216. };
  49217. return ObjectLoader;
  49218. }();
  49219. exports.Catalog = Catalog;
  49220. exports.ObjectLoader = ObjectLoader;
  49221. exports.XRef = XRef;
  49222. exports.FileSpec = FileSpec;
  49223. }));
  49224. (function (root, factory) {
  49225. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  49226. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  49227. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  49228. var MissingDataException = sharedUtil.MissingDataException;
  49229. var Util = sharedUtil.Util;
  49230. var assert = sharedUtil.assert;
  49231. var error = sharedUtil.error;
  49232. var info = sharedUtil.info;
  49233. var warn = sharedUtil.warn;
  49234. var isStream = corePrimitives.isStream;
  49235. var PDFFunction = coreFunction.PDFFunction;
  49236. var ColorSpace = coreColorSpace.ColorSpace;
  49237. var ShadingType = {
  49238. FUNCTION_BASED: 1,
  49239. AXIAL: 2,
  49240. RADIAL: 3,
  49241. FREE_FORM_MESH: 4,
  49242. LATTICE_FORM_MESH: 5,
  49243. COONS_PATCH_MESH: 6,
  49244. TENSOR_PATCH_MESH: 7
  49245. };
  49246. var Pattern = function PatternClosure() {
  49247. function Pattern() {
  49248. error('should not call Pattern constructor');
  49249. }
  49250. Pattern.prototype = {
  49251. getPattern: function Pattern_getPattern(ctx) {
  49252. error('Should not call Pattern.getStyle: ' + ctx);
  49253. }
  49254. };
  49255. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  49256. var dict = isStream(shading) ? shading.dict : shading;
  49257. var type = dict.get('ShadingType');
  49258. try {
  49259. switch (type) {
  49260. case ShadingType.AXIAL:
  49261. case ShadingType.RADIAL:
  49262. return new Shadings.RadialAxial(dict, matrix, xref, res);
  49263. case ShadingType.FREE_FORM_MESH:
  49264. case ShadingType.LATTICE_FORM_MESH:
  49265. case ShadingType.COONS_PATCH_MESH:
  49266. case ShadingType.TENSOR_PATCH_MESH:
  49267. return new Shadings.Mesh(shading, matrix, xref, res);
  49268. default:
  49269. throw new Error('Unsupported ShadingType: ' + type);
  49270. }
  49271. } catch (ex) {
  49272. if (ex instanceof MissingDataException) {
  49273. throw ex;
  49274. }
  49275. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  49276. warn(ex);
  49277. return new Shadings.Dummy();
  49278. }
  49279. };
  49280. return Pattern;
  49281. }();
  49282. var Shadings = {};
  49283. Shadings.SMALL_NUMBER = 1e-6;
  49284. Shadings.RadialAxial = function RadialAxialClosure() {
  49285. function RadialAxial(dict, matrix, xref, res) {
  49286. this.matrix = matrix;
  49287. this.coordsArr = dict.getArray('Coords');
  49288. this.shadingType = dict.get('ShadingType');
  49289. this.type = 'Pattern';
  49290. var cs = dict.get('ColorSpace', 'CS');
  49291. cs = ColorSpace.parse(cs, xref, res);
  49292. this.cs = cs;
  49293. var t0 = 0.0, t1 = 1.0;
  49294. if (dict.has('Domain')) {
  49295. var domainArr = dict.getArray('Domain');
  49296. t0 = domainArr[0];
  49297. t1 = domainArr[1];
  49298. }
  49299. var extendStart = false, extendEnd = false;
  49300. if (dict.has('Extend')) {
  49301. var extendArr = dict.getArray('Extend');
  49302. extendStart = extendArr[0];
  49303. extendEnd = extendArr[1];
  49304. }
  49305. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  49306. var x1 = this.coordsArr[0];
  49307. var y1 = this.coordsArr[1];
  49308. var r1 = this.coordsArr[2];
  49309. var x2 = this.coordsArr[3];
  49310. var y2 = this.coordsArr[4];
  49311. var r2 = this.coordsArr[5];
  49312. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  49313. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  49314. warn('Unsupported radial gradient.');
  49315. }
  49316. }
  49317. this.extendStart = extendStart;
  49318. this.extendEnd = extendEnd;
  49319. var fnObj = dict.get('Function');
  49320. var fn = PDFFunction.parseArray(xref, fnObj);
  49321. var diff = t1 - t0;
  49322. var step = diff / 10;
  49323. var colorStops = this.colorStops = [];
  49324. if (t0 >= t1 || step <= 0) {
  49325. info('Bad shading domain.');
  49326. return;
  49327. }
  49328. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  49329. var rgbColor;
  49330. for (var i = t0; i <= t1; i += step) {
  49331. ratio[0] = i;
  49332. fn(ratio, 0, color, 0);
  49333. rgbColor = cs.getRgb(color, 0);
  49334. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  49335. colorStops.push([
  49336. (i - t0) / diff,
  49337. cssColor
  49338. ]);
  49339. }
  49340. var background = 'transparent';
  49341. if (dict.has('Background')) {
  49342. rgbColor = cs.getRgb(dict.get('Background'), 0);
  49343. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  49344. }
  49345. if (!extendStart) {
  49346. colorStops.unshift([
  49347. 0,
  49348. background
  49349. ]);
  49350. colorStops[1][0] += Shadings.SMALL_NUMBER;
  49351. }
  49352. if (!extendEnd) {
  49353. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  49354. colorStops.push([
  49355. 1,
  49356. background
  49357. ]);
  49358. }
  49359. this.colorStops = colorStops;
  49360. }
  49361. RadialAxial.prototype = {
  49362. getIR: function RadialAxial_getIR() {
  49363. var coordsArr = this.coordsArr;
  49364. var shadingType = this.shadingType;
  49365. var type, p0, p1, r0, r1;
  49366. if (shadingType === ShadingType.AXIAL) {
  49367. p0 = [
  49368. coordsArr[0],
  49369. coordsArr[1]
  49370. ];
  49371. p1 = [
  49372. coordsArr[2],
  49373. coordsArr[3]
  49374. ];
  49375. r0 = null;
  49376. r1 = null;
  49377. type = 'axial';
  49378. } else if (shadingType === ShadingType.RADIAL) {
  49379. p0 = [
  49380. coordsArr[0],
  49381. coordsArr[1]
  49382. ];
  49383. p1 = [
  49384. coordsArr[3],
  49385. coordsArr[4]
  49386. ];
  49387. r0 = coordsArr[2];
  49388. r1 = coordsArr[5];
  49389. type = 'radial';
  49390. } else {
  49391. error('getPattern type unknown: ' + shadingType);
  49392. }
  49393. var matrix = this.matrix;
  49394. if (matrix) {
  49395. p0 = Util.applyTransform(p0, matrix);
  49396. p1 = Util.applyTransform(p1, matrix);
  49397. if (shadingType === ShadingType.RADIAL) {
  49398. var scale = Util.singularValueDecompose2dScale(matrix);
  49399. r0 *= scale[0];
  49400. r1 *= scale[1];
  49401. }
  49402. }
  49403. return [
  49404. 'RadialAxial',
  49405. type,
  49406. this.colorStops,
  49407. p0,
  49408. p1,
  49409. r0,
  49410. r1
  49411. ];
  49412. }
  49413. };
  49414. return RadialAxial;
  49415. }();
  49416. Shadings.Mesh = function MeshClosure() {
  49417. function MeshStreamReader(stream, context) {
  49418. this.stream = stream;
  49419. this.context = context;
  49420. this.buffer = 0;
  49421. this.bufferLength = 0;
  49422. var numComps = context.numComps;
  49423. this.tmpCompsBuf = new Float32Array(numComps);
  49424. var csNumComps = context.colorSpace.numComps;
  49425. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  49426. }
  49427. MeshStreamReader.prototype = {
  49428. get hasData() {
  49429. if (this.stream.end) {
  49430. return this.stream.pos < this.stream.end;
  49431. }
  49432. if (this.bufferLength > 0) {
  49433. return true;
  49434. }
  49435. var nextByte = this.stream.getByte();
  49436. if (nextByte < 0) {
  49437. return false;
  49438. }
  49439. this.buffer = nextByte;
  49440. this.bufferLength = 8;
  49441. return true;
  49442. },
  49443. readBits: function MeshStreamReader_readBits(n) {
  49444. var buffer = this.buffer;
  49445. var bufferLength = this.bufferLength;
  49446. if (n === 32) {
  49447. if (bufferLength === 0) {
  49448. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  49449. }
  49450. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  49451. var nextByte = this.stream.getByte();
  49452. this.buffer = nextByte & (1 << bufferLength) - 1;
  49453. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  49454. }
  49455. if (n === 8 && bufferLength === 0) {
  49456. return this.stream.getByte();
  49457. }
  49458. while (bufferLength < n) {
  49459. buffer = buffer << 8 | this.stream.getByte();
  49460. bufferLength += 8;
  49461. }
  49462. bufferLength -= n;
  49463. this.bufferLength = bufferLength;
  49464. this.buffer = buffer & (1 << bufferLength) - 1;
  49465. return buffer >> bufferLength;
  49466. },
  49467. align: function MeshStreamReader_align() {
  49468. this.buffer = 0;
  49469. this.bufferLength = 0;
  49470. },
  49471. readFlag: function MeshStreamReader_readFlag() {
  49472. return this.readBits(this.context.bitsPerFlag);
  49473. },
  49474. readCoordinate: function MeshStreamReader_readCoordinate() {
  49475. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  49476. var xi = this.readBits(bitsPerCoordinate);
  49477. var yi = this.readBits(bitsPerCoordinate);
  49478. var decode = this.context.decode;
  49479. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  49480. return [
  49481. xi * scale * (decode[1] - decode[0]) + decode[0],
  49482. yi * scale * (decode[3] - decode[2]) + decode[2]
  49483. ];
  49484. },
  49485. readComponents: function MeshStreamReader_readComponents() {
  49486. var numComps = this.context.numComps;
  49487. var bitsPerComponent = this.context.bitsPerComponent;
  49488. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  49489. var decode = this.context.decode;
  49490. var components = this.tmpCompsBuf;
  49491. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  49492. var ci = this.readBits(bitsPerComponent);
  49493. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  49494. }
  49495. var color = this.tmpCsCompsBuf;
  49496. if (this.context.colorFn) {
  49497. this.context.colorFn(components, 0, color, 0);
  49498. }
  49499. return this.context.colorSpace.getRgb(color, 0);
  49500. }
  49501. };
  49502. function decodeType4Shading(mesh, reader) {
  49503. var coords = mesh.coords;
  49504. var colors = mesh.colors;
  49505. var operators = [];
  49506. var ps = [];
  49507. var verticesLeft = 0;
  49508. while (reader.hasData) {
  49509. var f = reader.readFlag();
  49510. var coord = reader.readCoordinate();
  49511. var color = reader.readComponents();
  49512. if (verticesLeft === 0) {
  49513. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  49514. switch (f) {
  49515. case 0:
  49516. verticesLeft = 3;
  49517. break;
  49518. case 1:
  49519. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  49520. verticesLeft = 1;
  49521. break;
  49522. case 2:
  49523. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  49524. verticesLeft = 1;
  49525. break;
  49526. }
  49527. operators.push(f);
  49528. }
  49529. ps.push(coords.length);
  49530. coords.push(coord);
  49531. colors.push(color);
  49532. verticesLeft--;
  49533. reader.align();
  49534. }
  49535. mesh.figures.push({
  49536. type: 'triangles',
  49537. coords: new Int32Array(ps),
  49538. colors: new Int32Array(ps)
  49539. });
  49540. }
  49541. function decodeType5Shading(mesh, reader, verticesPerRow) {
  49542. var coords = mesh.coords;
  49543. var colors = mesh.colors;
  49544. var ps = [];
  49545. while (reader.hasData) {
  49546. var coord = reader.readCoordinate();
  49547. var color = reader.readComponents();
  49548. ps.push(coords.length);
  49549. coords.push(coord);
  49550. colors.push(color);
  49551. }
  49552. mesh.figures.push({
  49553. type: 'lattice',
  49554. coords: new Int32Array(ps),
  49555. colors: new Int32Array(ps),
  49556. verticesPerRow: verticesPerRow
  49557. });
  49558. }
  49559. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  49560. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  49561. var TRIANGLE_DENSITY = 20;
  49562. var getB = function getBClosure() {
  49563. function buildB(count) {
  49564. var lut = [];
  49565. for (var i = 0; i <= count; i++) {
  49566. var t = i / count, t_ = 1 - t;
  49567. lut.push(new Float32Array([
  49568. t_ * t_ * t_,
  49569. 3 * t * t_ * t_,
  49570. 3 * t * t * t_,
  49571. t * t * t
  49572. ]));
  49573. }
  49574. return lut;
  49575. }
  49576. var cache = [];
  49577. return function getB(count) {
  49578. if (!cache[count]) {
  49579. cache[count] = buildB(count);
  49580. }
  49581. return cache[count];
  49582. };
  49583. }();
  49584. function buildFigureFromPatch(mesh, index) {
  49585. var figure = mesh.figures[index];
  49586. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  49587. var coords = mesh.coords, colors = mesh.colors;
  49588. var pi = figure.coords;
  49589. var ci = figure.colors;
  49590. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  49591. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  49592. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  49593. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  49594. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  49595. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  49596. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  49597. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  49598. var verticesPerRow = splitXBy + 1;
  49599. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  49600. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  49601. var k = 0;
  49602. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  49603. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  49604. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  49605. for (var row = 0; row <= splitYBy; row++) {
  49606. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  49607. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  49608. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  49609. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  49610. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  49611. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  49612. for (var col = 0; col <= splitXBy; col++, k++) {
  49613. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  49614. continue;
  49615. }
  49616. var x = 0, y = 0;
  49617. var q = 0;
  49618. for (var i = 0; i <= 3; i++) {
  49619. for (var j = 0; j <= 3; j++, q++) {
  49620. var m = bRow[row][i] * bCol[col][j];
  49621. x += coords[pi[q]][0] * m;
  49622. y += coords[pi[q]][1] * m;
  49623. }
  49624. }
  49625. figureCoords[k] = coords.length;
  49626. coords.push([
  49627. x,
  49628. y
  49629. ]);
  49630. figureColors[k] = colors.length;
  49631. var newColor = new Uint8Array(3);
  49632. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  49633. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  49634. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  49635. colors.push(newColor);
  49636. }
  49637. }
  49638. figureCoords[0] = pi[0];
  49639. figureColors[0] = ci[0];
  49640. figureCoords[splitXBy] = pi[3];
  49641. figureColors[splitXBy] = ci[1];
  49642. figureCoords[verticesPerRow * splitYBy] = pi[12];
  49643. figureColors[verticesPerRow * splitYBy] = ci[2];
  49644. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  49645. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  49646. mesh.figures[index] = {
  49647. type: 'lattice',
  49648. coords: figureCoords,
  49649. colors: figureColors,
  49650. verticesPerRow: verticesPerRow
  49651. };
  49652. }
  49653. function decodeType6Shading(mesh, reader) {
  49654. var coords = mesh.coords;
  49655. var colors = mesh.colors;
  49656. var ps = new Int32Array(16);
  49657. var cs = new Int32Array(4);
  49658. while (reader.hasData) {
  49659. var f = reader.readFlag();
  49660. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  49661. var i, ii;
  49662. var pi = coords.length;
  49663. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  49664. coords.push(reader.readCoordinate());
  49665. }
  49666. var ci = colors.length;
  49667. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  49668. colors.push(reader.readComponents());
  49669. }
  49670. var tmp1, tmp2, tmp3, tmp4;
  49671. switch (f) {
  49672. case 0:
  49673. ps[12] = pi + 3;
  49674. ps[13] = pi + 4;
  49675. ps[14] = pi + 5;
  49676. ps[15] = pi + 6;
  49677. ps[8] = pi + 2;
  49678. ps[11] = pi + 7;
  49679. ps[4] = pi + 1;
  49680. ps[7] = pi + 8;
  49681. ps[0] = pi;
  49682. ps[1] = pi + 11;
  49683. ps[2] = pi + 10;
  49684. ps[3] = pi + 9;
  49685. cs[2] = ci + 1;
  49686. cs[3] = ci + 2;
  49687. cs[0] = ci;
  49688. cs[1] = ci + 3;
  49689. break;
  49690. case 1:
  49691. tmp1 = ps[12];
  49692. tmp2 = ps[13];
  49693. tmp3 = ps[14];
  49694. tmp4 = ps[15];
  49695. ps[12] = tmp4;
  49696. ps[13] = pi + 0;
  49697. ps[14] = pi + 1;
  49698. ps[15] = pi + 2;
  49699. ps[8] = tmp3;
  49700. ps[11] = pi + 3;
  49701. ps[4] = tmp2;
  49702. ps[7] = pi + 4;
  49703. ps[0] = tmp1;
  49704. ps[1] = pi + 7;
  49705. ps[2] = pi + 6;
  49706. ps[3] = pi + 5;
  49707. tmp1 = cs[2];
  49708. tmp2 = cs[3];
  49709. cs[2] = tmp2;
  49710. cs[3] = ci;
  49711. cs[0] = tmp1;
  49712. cs[1] = ci + 1;
  49713. break;
  49714. case 2:
  49715. tmp1 = ps[15];
  49716. tmp2 = ps[11];
  49717. ps[12] = ps[3];
  49718. ps[13] = pi + 0;
  49719. ps[14] = pi + 1;
  49720. ps[15] = pi + 2;
  49721. ps[8] = ps[7];
  49722. ps[11] = pi + 3;
  49723. ps[4] = tmp2;
  49724. ps[7] = pi + 4;
  49725. ps[0] = tmp1;
  49726. ps[1] = pi + 7;
  49727. ps[2] = pi + 6;
  49728. ps[3] = pi + 5;
  49729. tmp1 = cs[3];
  49730. cs[2] = cs[1];
  49731. cs[3] = ci;
  49732. cs[0] = tmp1;
  49733. cs[1] = ci + 1;
  49734. break;
  49735. case 3:
  49736. ps[12] = ps[0];
  49737. ps[13] = pi + 0;
  49738. ps[14] = pi + 1;
  49739. ps[15] = pi + 2;
  49740. ps[8] = ps[1];
  49741. ps[11] = pi + 3;
  49742. ps[4] = ps[2];
  49743. ps[7] = pi + 4;
  49744. ps[0] = ps[3];
  49745. ps[1] = pi + 7;
  49746. ps[2] = pi + 6;
  49747. ps[3] = pi + 5;
  49748. cs[2] = cs[0];
  49749. cs[3] = ci;
  49750. cs[0] = cs[1];
  49751. cs[1] = ci + 1;
  49752. break;
  49753. }
  49754. ps[5] = coords.length;
  49755. coords.push([
  49756. (-4 * coords[ps[0]][0] - coords[ps[15]][0] + 6 * (coords[ps[4]][0] + coords[ps[1]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[13]][0] + coords[ps[7]][0])) / 9,
  49757. (-4 * coords[ps[0]][1] - coords[ps[15]][1] + 6 * (coords[ps[4]][1] + coords[ps[1]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[13]][1] + coords[ps[7]][1])) / 9
  49758. ]);
  49759. ps[6] = coords.length;
  49760. coords.push([
  49761. (-4 * coords[ps[3]][0] - coords[ps[12]][0] + 6 * (coords[ps[2]][0] + coords[ps[7]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[4]][0] + coords[ps[14]][0])) / 9,
  49762. (-4 * coords[ps[3]][1] - coords[ps[12]][1] + 6 * (coords[ps[2]][1] + coords[ps[7]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[4]][1] + coords[ps[14]][1])) / 9
  49763. ]);
  49764. ps[9] = coords.length;
  49765. coords.push([
  49766. (-4 * coords[ps[12]][0] - coords[ps[3]][0] + 6 * (coords[ps[8]][0] + coords[ps[13]][0]) - 2 * (coords[ps[0]][0] + coords[ps[15]][0]) + 3 * (coords[ps[11]][0] + coords[ps[1]][0])) / 9,
  49767. (-4 * coords[ps[12]][1] - coords[ps[3]][1] + 6 * (coords[ps[8]][1] + coords[ps[13]][1]) - 2 * (coords[ps[0]][1] + coords[ps[15]][1]) + 3 * (coords[ps[11]][1] + coords[ps[1]][1])) / 9
  49768. ]);
  49769. ps[10] = coords.length;
  49770. coords.push([
  49771. (-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9,
  49772. (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9
  49773. ]);
  49774. mesh.figures.push({
  49775. type: 'patch',
  49776. coords: new Int32Array(ps),
  49777. colors: new Int32Array(cs)
  49778. });
  49779. }
  49780. }
  49781. function decodeType7Shading(mesh, reader) {
  49782. var coords = mesh.coords;
  49783. var colors = mesh.colors;
  49784. var ps = new Int32Array(16);
  49785. var cs = new Int32Array(4);
  49786. while (reader.hasData) {
  49787. var f = reader.readFlag();
  49788. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  49789. var i, ii;
  49790. var pi = coords.length;
  49791. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  49792. coords.push(reader.readCoordinate());
  49793. }
  49794. var ci = colors.length;
  49795. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  49796. colors.push(reader.readComponents());
  49797. }
  49798. var tmp1, tmp2, tmp3, tmp4;
  49799. switch (f) {
  49800. case 0:
  49801. ps[12] = pi + 3;
  49802. ps[13] = pi + 4;
  49803. ps[14] = pi + 5;
  49804. ps[15] = pi + 6;
  49805. ps[8] = pi + 2;
  49806. ps[9] = pi + 13;
  49807. ps[10] = pi + 14;
  49808. ps[11] = pi + 7;
  49809. ps[4] = pi + 1;
  49810. ps[5] = pi + 12;
  49811. ps[6] = pi + 15;
  49812. ps[7] = pi + 8;
  49813. ps[0] = pi;
  49814. ps[1] = pi + 11;
  49815. ps[2] = pi + 10;
  49816. ps[3] = pi + 9;
  49817. cs[2] = ci + 1;
  49818. cs[3] = ci + 2;
  49819. cs[0] = ci;
  49820. cs[1] = ci + 3;
  49821. break;
  49822. case 1:
  49823. tmp1 = ps[12];
  49824. tmp2 = ps[13];
  49825. tmp3 = ps[14];
  49826. tmp4 = ps[15];
  49827. ps[12] = tmp4;
  49828. ps[13] = pi + 0;
  49829. ps[14] = pi + 1;
  49830. ps[15] = pi + 2;
  49831. ps[8] = tmp3;
  49832. ps[9] = pi + 9;
  49833. ps[10] = pi + 10;
  49834. ps[11] = pi + 3;
  49835. ps[4] = tmp2;
  49836. ps[5] = pi + 8;
  49837. ps[6] = pi + 11;
  49838. ps[7] = pi + 4;
  49839. ps[0] = tmp1;
  49840. ps[1] = pi + 7;
  49841. ps[2] = pi + 6;
  49842. ps[3] = pi + 5;
  49843. tmp1 = cs[2];
  49844. tmp2 = cs[3];
  49845. cs[2] = tmp2;
  49846. cs[3] = ci;
  49847. cs[0] = tmp1;
  49848. cs[1] = ci + 1;
  49849. break;
  49850. case 2:
  49851. tmp1 = ps[15];
  49852. tmp2 = ps[11];
  49853. ps[12] = ps[3];
  49854. ps[13] = pi + 0;
  49855. ps[14] = pi + 1;
  49856. ps[15] = pi + 2;
  49857. ps[8] = ps[7];
  49858. ps[9] = pi + 9;
  49859. ps[10] = pi + 10;
  49860. ps[11] = pi + 3;
  49861. ps[4] = tmp2;
  49862. ps[5] = pi + 8;
  49863. ps[6] = pi + 11;
  49864. ps[7] = pi + 4;
  49865. ps[0] = tmp1;
  49866. ps[1] = pi + 7;
  49867. ps[2] = pi + 6;
  49868. ps[3] = pi + 5;
  49869. tmp1 = cs[3];
  49870. cs[2] = cs[1];
  49871. cs[3] = ci;
  49872. cs[0] = tmp1;
  49873. cs[1] = ci + 1;
  49874. break;
  49875. case 3:
  49876. ps[12] = ps[0];
  49877. ps[13] = pi + 0;
  49878. ps[14] = pi + 1;
  49879. ps[15] = pi + 2;
  49880. ps[8] = ps[1];
  49881. ps[9] = pi + 9;
  49882. ps[10] = pi + 10;
  49883. ps[11] = pi + 3;
  49884. ps[4] = ps[2];
  49885. ps[5] = pi + 8;
  49886. ps[6] = pi + 11;
  49887. ps[7] = pi + 4;
  49888. ps[0] = ps[3];
  49889. ps[1] = pi + 7;
  49890. ps[2] = pi + 6;
  49891. ps[3] = pi + 5;
  49892. cs[2] = cs[0];
  49893. cs[3] = ci;
  49894. cs[0] = cs[1];
  49895. cs[1] = ci + 1;
  49896. break;
  49897. }
  49898. mesh.figures.push({
  49899. type: 'patch',
  49900. coords: new Int32Array(ps),
  49901. colors: new Int32Array(cs)
  49902. });
  49903. }
  49904. }
  49905. function updateBounds(mesh) {
  49906. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  49907. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  49908. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  49909. minX = minX > x ? x : minX;
  49910. minY = minY > y ? y : minY;
  49911. maxX = maxX < x ? x : maxX;
  49912. maxY = maxY < y ? y : maxY;
  49913. }
  49914. mesh.bounds = [
  49915. minX,
  49916. minY,
  49917. maxX,
  49918. maxY
  49919. ];
  49920. }
  49921. function packData(mesh) {
  49922. var i, ii, j, jj;
  49923. var coords = mesh.coords;
  49924. var coordsPacked = new Float32Array(coords.length * 2);
  49925. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  49926. var xy = coords[i];
  49927. coordsPacked[j++] = xy[0];
  49928. coordsPacked[j++] = xy[1];
  49929. }
  49930. mesh.coords = coordsPacked;
  49931. var colors = mesh.colors;
  49932. var colorsPacked = new Uint8Array(colors.length * 3);
  49933. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  49934. var c = colors[i];
  49935. colorsPacked[j++] = c[0];
  49936. colorsPacked[j++] = c[1];
  49937. colorsPacked[j++] = c[2];
  49938. }
  49939. mesh.colors = colorsPacked;
  49940. var figures = mesh.figures;
  49941. for (i = 0, ii = figures.length; i < ii; i++) {
  49942. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  49943. for (j = 0, jj = ps.length; j < jj; j++) {
  49944. ps[j] *= 2;
  49945. cs[j] *= 3;
  49946. }
  49947. }
  49948. }
  49949. function Mesh(stream, matrix, xref, res) {
  49950. assert(isStream(stream), 'Mesh data is not a stream');
  49951. var dict = stream.dict;
  49952. this.matrix = matrix;
  49953. this.shadingType = dict.get('ShadingType');
  49954. this.type = 'Pattern';
  49955. this.bbox = dict.getArray('BBox');
  49956. var cs = dict.get('ColorSpace', 'CS');
  49957. cs = ColorSpace.parse(cs, xref, res);
  49958. this.cs = cs;
  49959. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  49960. var fnObj = dict.get('Function');
  49961. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  49962. this.coords = [];
  49963. this.colors = [];
  49964. this.figures = [];
  49965. var decodeContext = {
  49966. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  49967. bitsPerComponent: dict.get('BitsPerComponent'),
  49968. bitsPerFlag: dict.get('BitsPerFlag'),
  49969. decode: dict.getArray('Decode'),
  49970. colorFn: fn,
  49971. colorSpace: cs,
  49972. numComps: fn ? 1 : cs.numComps
  49973. };
  49974. var reader = new MeshStreamReader(stream, decodeContext);
  49975. var patchMesh = false;
  49976. switch (this.shadingType) {
  49977. case ShadingType.FREE_FORM_MESH:
  49978. decodeType4Shading(this, reader);
  49979. break;
  49980. case ShadingType.LATTICE_FORM_MESH:
  49981. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  49982. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  49983. decodeType5Shading(this, reader, verticesPerRow);
  49984. break;
  49985. case ShadingType.COONS_PATCH_MESH:
  49986. decodeType6Shading(this, reader);
  49987. patchMesh = true;
  49988. break;
  49989. case ShadingType.TENSOR_PATCH_MESH:
  49990. decodeType7Shading(this, reader);
  49991. patchMesh = true;
  49992. break;
  49993. default:
  49994. error('Unsupported mesh type.');
  49995. break;
  49996. }
  49997. if (patchMesh) {
  49998. updateBounds(this);
  49999. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  50000. buildFigureFromPatch(this, i);
  50001. }
  50002. }
  50003. updateBounds(this);
  50004. packData(this);
  50005. }
  50006. Mesh.prototype = {
  50007. getIR: function Mesh_getIR() {
  50008. return [
  50009. 'Mesh',
  50010. this.shadingType,
  50011. this.coords,
  50012. this.colors,
  50013. this.figures,
  50014. this.bounds,
  50015. this.matrix,
  50016. this.bbox,
  50017. this.background
  50018. ];
  50019. }
  50020. };
  50021. return Mesh;
  50022. }();
  50023. Shadings.Dummy = function DummyClosure() {
  50024. function Dummy() {
  50025. this.type = 'Pattern';
  50026. }
  50027. Dummy.prototype = {
  50028. getIR: function Dummy_getIR() {
  50029. return ['Dummy'];
  50030. }
  50031. };
  50032. return Dummy;
  50033. }();
  50034. function getTilingPatternIR(operatorList, dict, args) {
  50035. var matrix = dict.getArray('Matrix');
  50036. var bbox = dict.getArray('BBox');
  50037. var xstep = dict.get('XStep');
  50038. var ystep = dict.get('YStep');
  50039. var paintType = dict.get('PaintType');
  50040. var tilingType = dict.get('TilingType');
  50041. return [
  50042. 'TilingPattern',
  50043. args,
  50044. operatorList,
  50045. matrix,
  50046. bbox,
  50047. xstep,
  50048. ystep,
  50049. paintType,
  50050. tilingType
  50051. ];
  50052. }
  50053. exports.Pattern = Pattern;
  50054. exports.getTilingPatternIR = getTilingPatternIR;
  50055. }));
  50056. (function (root, factory) {
  50057. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  50058. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  50059. var InvalidPDFException = sharedUtil.InvalidPDFException;
  50060. var MessageHandler = sharedUtil.MessageHandler;
  50061. var MissingPDFException = sharedUtil.MissingPDFException;
  50062. var PageViewport = sharedUtil.PageViewport;
  50063. var PasswordException = sharedUtil.PasswordException;
  50064. var StatTimer = sharedUtil.StatTimer;
  50065. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  50066. var UnknownErrorException = sharedUtil.UnknownErrorException;
  50067. var Util = sharedUtil.Util;
  50068. var createPromiseCapability = sharedUtil.createPromiseCapability;
  50069. var error = sharedUtil.error;
  50070. var deprecated = sharedUtil.deprecated;
  50071. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  50072. var info = sharedUtil.info;
  50073. var isInt = sharedUtil.isInt;
  50074. var isArray = sharedUtil.isArray;
  50075. var isArrayBuffer = sharedUtil.isArrayBuffer;
  50076. var isSameOrigin = sharedUtil.isSameOrigin;
  50077. var loadJpegStream = sharedUtil.loadJpegStream;
  50078. var stringToBytes = sharedUtil.stringToBytes;
  50079. var globalScope = sharedUtil.globalScope;
  50080. var warn = sharedUtil.warn;
  50081. var FontFaceObject = displayFontLoader.FontFaceObject;
  50082. var FontLoader = displayFontLoader.FontLoader;
  50083. var CanvasGraphics = displayCanvas.CanvasGraphics;
  50084. var Metadata = displayMetadata.Metadata;
  50085. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  50086. var DOMCanvasFactory = displayDOMUtils.DOMCanvasFactory;
  50087. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  50088. var isWorkerDisabled = false;
  50089. var workerSrc;
  50090. var isPostMessageTransfersDisabled = false;
  50091. var fakeWorkerFilesLoader = null;
  50092. var useRequireEnsure = false;
  50093. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  50094. var task = new PDFDocumentLoadingTask();
  50095. if (arguments.length > 1) {
  50096. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  50097. }
  50098. if (pdfDataRangeTransport) {
  50099. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  50100. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  50101. pdfDataRangeTransport.length = src.length;
  50102. pdfDataRangeTransport.initialData = src.initialData;
  50103. if (!pdfDataRangeTransport.abort) {
  50104. pdfDataRangeTransport.abort = function () {
  50105. };
  50106. }
  50107. }
  50108. src = Object.create(src);
  50109. src.range = pdfDataRangeTransport;
  50110. }
  50111. task.onPassword = passwordCallback || null;
  50112. task.onProgress = progressCallback || null;
  50113. var source;
  50114. if (typeof src === 'string') {
  50115. source = { url: src };
  50116. } else if (isArrayBuffer(src)) {
  50117. source = { data: src };
  50118. } else if (src instanceof PDFDataRangeTransport) {
  50119. source = { range: src };
  50120. } else {
  50121. if (typeof src !== 'object') {
  50122. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  50123. }
  50124. if (!src.url && !src.data && !src.range) {
  50125. error('Invalid parameter object: need either .data, .range or .url');
  50126. }
  50127. source = src;
  50128. }
  50129. var params = {};
  50130. var rangeTransport = null;
  50131. var worker = null;
  50132. for (var key in source) {
  50133. if (key === 'url' && typeof window !== 'undefined') {
  50134. params[key] = new URL(source[key], window.location).href;
  50135. continue;
  50136. } else if (key === 'range') {
  50137. rangeTransport = source[key];
  50138. continue;
  50139. } else if (key === 'worker') {
  50140. worker = source[key];
  50141. continue;
  50142. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  50143. var pdfBytes = source[key];
  50144. if (typeof pdfBytes === 'string') {
  50145. params[key] = stringToBytes(pdfBytes);
  50146. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  50147. params[key] = new Uint8Array(pdfBytes);
  50148. } else if (isArrayBuffer(pdfBytes)) {
  50149. params[key] = new Uint8Array(pdfBytes);
  50150. } else {
  50151. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  50152. }
  50153. continue;
  50154. }
  50155. params[key] = source[key];
  50156. }
  50157. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  50158. params.disableNativeImageDecoder = params.disableNativeImageDecoder === true;
  50159. if (!worker) {
  50160. worker = new PDFWorker();
  50161. task._worker = worker;
  50162. }
  50163. var docId = task.docId;
  50164. worker.promise.then(function () {
  50165. if (task.destroyed) {
  50166. throw new Error('Loading aborted');
  50167. }
  50168. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  50169. if (task.destroyed) {
  50170. throw new Error('Loading aborted');
  50171. }
  50172. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  50173. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  50174. task._transport = transport;
  50175. messageHandler.send('Ready', null);
  50176. });
  50177. }).catch(task._capability.reject);
  50178. return task;
  50179. }
  50180. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  50181. if (worker.destroyed) {
  50182. return Promise.reject(new Error('Worker was destroyed'));
  50183. }
  50184. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  50185. source.disableStream = getDefaultSetting('disableStream');
  50186. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  50187. if (pdfDataRangeTransport) {
  50188. source.length = pdfDataRangeTransport.length;
  50189. source.initialData = pdfDataRangeTransport.initialData;
  50190. }
  50191. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  50192. docId: docId,
  50193. source: source,
  50194. disableRange: getDefaultSetting('disableRange'),
  50195. maxImageSize: getDefaultSetting('maxImageSize'),
  50196. cMapUrl: getDefaultSetting('cMapUrl'),
  50197. cMapPacked: getDefaultSetting('cMapPacked'),
  50198. disableFontFace: getDefaultSetting('disableFontFace'),
  50199. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  50200. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  50201. docBaseUrl: source.docBaseUrl,
  50202. disableNativeImageDecoder: source.disableNativeImageDecoder
  50203. }).then(function (workerId) {
  50204. if (worker.destroyed) {
  50205. throw new Error('Worker was destroyed');
  50206. }
  50207. return workerId;
  50208. });
  50209. }
  50210. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  50211. var nextDocumentId = 0;
  50212. function PDFDocumentLoadingTask() {
  50213. this._capability = createPromiseCapability();
  50214. this._transport = null;
  50215. this._worker = null;
  50216. this.docId = 'd' + nextDocumentId++;
  50217. this.destroyed = false;
  50218. this.onPassword = null;
  50219. this.onProgress = null;
  50220. this.onUnsupportedFeature = null;
  50221. }
  50222. PDFDocumentLoadingTask.prototype = {
  50223. get promise() {
  50224. return this._capability.promise;
  50225. },
  50226. destroy: function () {
  50227. this.destroyed = true;
  50228. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  50229. return transportDestroyed.then(function () {
  50230. this._transport = null;
  50231. if (this._worker) {
  50232. this._worker.destroy();
  50233. this._worker = null;
  50234. }
  50235. }.bind(this));
  50236. },
  50237. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  50238. return this.promise.then.apply(this.promise, arguments);
  50239. }
  50240. };
  50241. return PDFDocumentLoadingTask;
  50242. }();
  50243. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  50244. function PDFDataRangeTransport(length, initialData) {
  50245. this.length = length;
  50246. this.initialData = initialData;
  50247. this._rangeListeners = [];
  50248. this._progressListeners = [];
  50249. this._progressiveReadListeners = [];
  50250. this._readyCapability = createPromiseCapability();
  50251. }
  50252. PDFDataRangeTransport.prototype = {
  50253. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  50254. this._rangeListeners.push(listener);
  50255. },
  50256. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  50257. this._progressListeners.push(listener);
  50258. },
  50259. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  50260. this._progressiveReadListeners.push(listener);
  50261. },
  50262. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  50263. var listeners = this._rangeListeners;
  50264. for (var i = 0, n = listeners.length; i < n; ++i) {
  50265. listeners[i](begin, chunk);
  50266. }
  50267. },
  50268. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  50269. this._readyCapability.promise.then(function () {
  50270. var listeners = this._progressListeners;
  50271. for (var i = 0, n = listeners.length; i < n; ++i) {
  50272. listeners[i](loaded);
  50273. }
  50274. }.bind(this));
  50275. },
  50276. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  50277. this._readyCapability.promise.then(function () {
  50278. var listeners = this._progressiveReadListeners;
  50279. for (var i = 0, n = listeners.length; i < n; ++i) {
  50280. listeners[i](chunk);
  50281. }
  50282. }.bind(this));
  50283. },
  50284. transportReady: function PDFDataRangeTransport_transportReady() {
  50285. this._readyCapability.resolve();
  50286. },
  50287. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  50288. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  50289. },
  50290. abort: function PDFDataRangeTransport_abort() {
  50291. }
  50292. };
  50293. return PDFDataRangeTransport;
  50294. }();
  50295. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  50296. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  50297. this.pdfInfo = pdfInfo;
  50298. this.transport = transport;
  50299. this.loadingTask = loadingTask;
  50300. }
  50301. PDFDocumentProxy.prototype = {
  50302. get numPages() {
  50303. return this.pdfInfo.numPages;
  50304. },
  50305. get fingerprint() {
  50306. return this.pdfInfo.fingerprint;
  50307. },
  50308. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  50309. return this.transport.getPage(pageNumber);
  50310. },
  50311. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  50312. return this.transport.getPageIndex(ref);
  50313. },
  50314. getDestinations: function PDFDocumentProxy_getDestinations() {
  50315. return this.transport.getDestinations();
  50316. },
  50317. getDestination: function PDFDocumentProxy_getDestination(id) {
  50318. return this.transport.getDestination(id);
  50319. },
  50320. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  50321. return this.transport.getPageLabels();
  50322. },
  50323. getAttachments: function PDFDocumentProxy_getAttachments() {
  50324. return this.transport.getAttachments();
  50325. },
  50326. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  50327. return this.transport.getJavaScript();
  50328. },
  50329. getOutline: function PDFDocumentProxy_getOutline() {
  50330. return this.transport.getOutline();
  50331. },
  50332. getMetadata: function PDFDocumentProxy_getMetadata() {
  50333. return this.transport.getMetadata();
  50334. },
  50335. getData: function PDFDocumentProxy_getData() {
  50336. return this.transport.getData();
  50337. },
  50338. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  50339. return this.transport.downloadInfoCapability.promise;
  50340. },
  50341. getStats: function PDFDocumentProxy_getStats() {
  50342. return this.transport.getStats();
  50343. },
  50344. cleanup: function PDFDocumentProxy_cleanup() {
  50345. this.transport.startCleanup();
  50346. },
  50347. destroy: function PDFDocumentProxy_destroy() {
  50348. return this.loadingTask.destroy();
  50349. }
  50350. };
  50351. return PDFDocumentProxy;
  50352. }();
  50353. var PDFPageProxy = function PDFPageProxyClosure() {
  50354. function PDFPageProxy(pageIndex, pageInfo, transport) {
  50355. this.pageIndex = pageIndex;
  50356. this.pageInfo = pageInfo;
  50357. this.transport = transport;
  50358. this.stats = new StatTimer();
  50359. this.stats.enabled = getDefaultSetting('enableStats');
  50360. this.commonObjs = transport.commonObjs;
  50361. this.objs = new PDFObjects();
  50362. this.cleanupAfterRender = false;
  50363. this.pendingCleanup = false;
  50364. this.intentStates = Object.create(null);
  50365. this.destroyed = false;
  50366. }
  50367. PDFPageProxy.prototype = {
  50368. get pageNumber() {
  50369. return this.pageIndex + 1;
  50370. },
  50371. get rotate() {
  50372. return this.pageInfo.rotate;
  50373. },
  50374. get ref() {
  50375. return this.pageInfo.ref;
  50376. },
  50377. get userUnit() {
  50378. return this.pageInfo.userUnit;
  50379. },
  50380. get view() {
  50381. return this.pageInfo.view;
  50382. },
  50383. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  50384. if (arguments.length < 2) {
  50385. rotate = this.rotate;
  50386. }
  50387. return new PageViewport(this.view, scale, rotate, 0, 0);
  50388. },
  50389. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  50390. var intent = params && params.intent || null;
  50391. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  50392. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  50393. this.annotationsIntent = intent;
  50394. }
  50395. return this.annotationsPromise;
  50396. },
  50397. render: function PDFPageProxy_render(params) {
  50398. var stats = this.stats;
  50399. stats.time('Overall');
  50400. this.pendingCleanup = false;
  50401. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  50402. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  50403. var canvasFactory = params.canvasFactory || new DOMCanvasFactory();
  50404. if (!this.intentStates[renderingIntent]) {
  50405. this.intentStates[renderingIntent] = Object.create(null);
  50406. }
  50407. var intentState = this.intentStates[renderingIntent];
  50408. if (!intentState.displayReadyCapability) {
  50409. intentState.receivingOperatorList = true;
  50410. intentState.displayReadyCapability = createPromiseCapability();
  50411. intentState.operatorList = {
  50412. fnArray: [],
  50413. argsArray: [],
  50414. lastChunk: false
  50415. };
  50416. this.stats.time('Page Request');
  50417. this.transport.messageHandler.send('RenderPageRequest', {
  50418. pageIndex: this.pageNumber - 1,
  50419. intent: renderingIntent,
  50420. renderInteractiveForms: renderInteractiveForms
  50421. });
  50422. }
  50423. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory);
  50424. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  50425. if (!intentState.renderTasks) {
  50426. intentState.renderTasks = [];
  50427. }
  50428. intentState.renderTasks.push(internalRenderTask);
  50429. var renderTask = internalRenderTask.task;
  50430. if (params.continueCallback) {
  50431. deprecated('render is used with continueCallback parameter');
  50432. renderTask.onContinue = params.continueCallback;
  50433. }
  50434. var self = this;
  50435. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  50436. if (self.pendingCleanup) {
  50437. complete();
  50438. return;
  50439. }
  50440. stats.time('Rendering');
  50441. internalRenderTask.initializeGraphics(transparency);
  50442. internalRenderTask.operatorListChanged();
  50443. }, function pageDisplayReadPromiseError(reason) {
  50444. complete(reason);
  50445. });
  50446. function complete(error) {
  50447. var i = intentState.renderTasks.indexOf(internalRenderTask);
  50448. if (i >= 0) {
  50449. intentState.renderTasks.splice(i, 1);
  50450. }
  50451. if (self.cleanupAfterRender) {
  50452. self.pendingCleanup = true;
  50453. }
  50454. self._tryCleanup();
  50455. if (error) {
  50456. internalRenderTask.capability.reject(error);
  50457. } else {
  50458. internalRenderTask.capability.resolve();
  50459. }
  50460. stats.timeEnd('Rendering');
  50461. stats.timeEnd('Overall');
  50462. }
  50463. return renderTask;
  50464. },
  50465. getOperatorList: function PDFPageProxy_getOperatorList() {
  50466. function operatorListChanged() {
  50467. if (intentState.operatorList.lastChunk) {
  50468. intentState.opListReadCapability.resolve(intentState.operatorList);
  50469. var i = intentState.renderTasks.indexOf(opListTask);
  50470. if (i >= 0) {
  50471. intentState.renderTasks.splice(i, 1);
  50472. }
  50473. }
  50474. }
  50475. var renderingIntent = 'oplist';
  50476. if (!this.intentStates[renderingIntent]) {
  50477. this.intentStates[renderingIntent] = Object.create(null);
  50478. }
  50479. var intentState = this.intentStates[renderingIntent];
  50480. var opListTask;
  50481. if (!intentState.opListReadCapability) {
  50482. opListTask = {};
  50483. opListTask.operatorListChanged = operatorListChanged;
  50484. intentState.receivingOperatorList = true;
  50485. intentState.opListReadCapability = createPromiseCapability();
  50486. intentState.renderTasks = [];
  50487. intentState.renderTasks.push(opListTask);
  50488. intentState.operatorList = {
  50489. fnArray: [],
  50490. argsArray: [],
  50491. lastChunk: false
  50492. };
  50493. this.transport.messageHandler.send('RenderPageRequest', {
  50494. pageIndex: this.pageIndex,
  50495. intent: renderingIntent
  50496. });
  50497. }
  50498. return intentState.opListReadCapability.promise;
  50499. },
  50500. getTextContent: function PDFPageProxy_getTextContent(params) {
  50501. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  50502. pageIndex: this.pageNumber - 1,
  50503. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  50504. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  50505. });
  50506. },
  50507. _destroy: function PDFPageProxy_destroy() {
  50508. this.destroyed = true;
  50509. this.transport.pageCache[this.pageIndex] = null;
  50510. var waitOn = [];
  50511. Object.keys(this.intentStates).forEach(function (intent) {
  50512. if (intent === 'oplist') {
  50513. return;
  50514. }
  50515. var intentState = this.intentStates[intent];
  50516. intentState.renderTasks.forEach(function (renderTask) {
  50517. var renderCompleted = renderTask.capability.promise.catch(function () {
  50518. });
  50519. waitOn.push(renderCompleted);
  50520. renderTask.cancel();
  50521. });
  50522. }, this);
  50523. this.objs.clear();
  50524. this.annotationsPromise = null;
  50525. this.pendingCleanup = false;
  50526. return Promise.all(waitOn);
  50527. },
  50528. destroy: function () {
  50529. deprecated('page destroy method, use cleanup() instead');
  50530. this.cleanup();
  50531. },
  50532. cleanup: function PDFPageProxy_cleanup() {
  50533. this.pendingCleanup = true;
  50534. this._tryCleanup();
  50535. },
  50536. _tryCleanup: function PDFPageProxy_tryCleanup() {
  50537. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  50538. var intentState = this.intentStates[intent];
  50539. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  50540. }, this)) {
  50541. return;
  50542. }
  50543. Object.keys(this.intentStates).forEach(function (intent) {
  50544. delete this.intentStates[intent];
  50545. }, this);
  50546. this.objs.clear();
  50547. this.annotationsPromise = null;
  50548. this.pendingCleanup = false;
  50549. },
  50550. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  50551. var intentState = this.intentStates[intent];
  50552. if (intentState.displayReadyCapability) {
  50553. intentState.displayReadyCapability.resolve(transparency);
  50554. }
  50555. },
  50556. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  50557. var intentState = this.intentStates[intent];
  50558. var i, ii;
  50559. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  50560. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  50561. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  50562. }
  50563. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  50564. for (i = 0; i < intentState.renderTasks.length; i++) {
  50565. intentState.renderTasks[i].operatorListChanged();
  50566. }
  50567. if (operatorListChunk.lastChunk) {
  50568. intentState.receivingOperatorList = false;
  50569. this._tryCleanup();
  50570. }
  50571. }
  50572. };
  50573. return PDFPageProxy;
  50574. }();
  50575. var PDFWorker = function PDFWorkerClosure() {
  50576. var nextFakeWorkerId = 0;
  50577. function getWorkerSrc() {
  50578. if (typeof workerSrc !== 'undefined') {
  50579. return workerSrc;
  50580. }
  50581. if (getDefaultSetting('workerSrc')) {
  50582. return getDefaultSetting('workerSrc');
  50583. }
  50584. if (pdfjsFilePath) {
  50585. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  50586. }
  50587. error('No PDFJS.workerSrc specified');
  50588. }
  50589. var fakeWorkerFilesLoadedCapability;
  50590. function setupFakeWorkerGlobal() {
  50591. var WorkerMessageHandler;
  50592. if (fakeWorkerFilesLoadedCapability) {
  50593. return fakeWorkerFilesLoadedCapability.promise;
  50594. }
  50595. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  50596. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  50597. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  50598. return fakeWorkerFilesLoadedCapability.promise;
  50599. }
  50600. function FakeWorkerPort(defer) {
  50601. this._listeners = [];
  50602. this._defer = defer;
  50603. this._deferred = Promise.resolve(undefined);
  50604. }
  50605. FakeWorkerPort.prototype = {
  50606. postMessage: function (obj, transfers) {
  50607. function cloneValue(value) {
  50608. if (typeof value !== 'object' || value === null) {
  50609. return value;
  50610. }
  50611. if (cloned.has(value)) {
  50612. return cloned.get(value);
  50613. }
  50614. var result;
  50615. var buffer;
  50616. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  50617. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  50618. if (value === buffer) {
  50619. result = value;
  50620. } else if (transferable) {
  50621. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  50622. } else {
  50623. result = new value.constructor(value);
  50624. }
  50625. cloned.set(value, result);
  50626. return result;
  50627. }
  50628. result = isArray(value) ? [] : {};
  50629. cloned.set(value, result);
  50630. for (var i in value) {
  50631. var desc, p = value;
  50632. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  50633. p = Object.getPrototypeOf(p);
  50634. }
  50635. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  50636. continue;
  50637. }
  50638. result[i] = cloneValue(desc.value);
  50639. }
  50640. return result;
  50641. }
  50642. if (!this._defer) {
  50643. this._listeners.forEach(function (listener) {
  50644. listener.call(this, { data: obj });
  50645. }, this);
  50646. return;
  50647. }
  50648. var cloned = new WeakMap();
  50649. var e = { data: cloneValue(obj) };
  50650. this._deferred.then(function () {
  50651. this._listeners.forEach(function (listener) {
  50652. listener.call(this, e);
  50653. }, this);
  50654. }.bind(this));
  50655. },
  50656. addEventListener: function (name, listener) {
  50657. this._listeners.push(listener);
  50658. },
  50659. removeEventListener: function (name, listener) {
  50660. var i = this._listeners.indexOf(listener);
  50661. this._listeners.splice(i, 1);
  50662. },
  50663. terminate: function () {
  50664. this._listeners = [];
  50665. }
  50666. };
  50667. function createCDNWrapper(url) {
  50668. var wrapper = 'importScripts(\'' + url + '\');';
  50669. return URL.createObjectURL(new Blob([wrapper]));
  50670. }
  50671. function PDFWorker(name) {
  50672. this.name = name;
  50673. this.destroyed = false;
  50674. this._readyCapability = createPromiseCapability();
  50675. this._port = null;
  50676. this._webWorker = null;
  50677. this._messageHandler = null;
  50678. this._initialize();
  50679. }
  50680. PDFWorker.prototype = {
  50681. get promise() {
  50682. return this._readyCapability.promise;
  50683. },
  50684. get port() {
  50685. return this._port;
  50686. },
  50687. get messageHandler() {
  50688. return this._messageHandler;
  50689. },
  50690. _initialize: function PDFWorker_initialize() {
  50691. this._setupFakeWorker();
  50692. },
  50693. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  50694. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  50695. warn('Setting up fake worker.');
  50696. isWorkerDisabled = true;
  50697. }
  50698. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  50699. if (this.destroyed) {
  50700. this._readyCapability.reject(new Error('Worker was destroyed'));
  50701. return;
  50702. }
  50703. var isTypedArraysPresent = Uint8Array !== Float32Array;
  50704. var port = new FakeWorkerPort(isTypedArraysPresent);
  50705. this._port = port;
  50706. var id = 'fake' + nextFakeWorkerId++;
  50707. var workerHandler = new MessageHandler(id + '_worker', id, port);
  50708. WorkerMessageHandler.setup(workerHandler, port);
  50709. var messageHandler = new MessageHandler(id, id + '_worker', port);
  50710. this._messageHandler = messageHandler;
  50711. this._readyCapability.resolve();
  50712. }.bind(this));
  50713. },
  50714. destroy: function PDFWorker_destroy() {
  50715. this.destroyed = true;
  50716. if (this._webWorker) {
  50717. this._webWorker.terminate();
  50718. this._webWorker = null;
  50719. }
  50720. this._port = null;
  50721. if (this._messageHandler) {
  50722. this._messageHandler.destroy();
  50723. this._messageHandler = null;
  50724. }
  50725. }
  50726. };
  50727. return PDFWorker;
  50728. }();
  50729. var WorkerTransport = function WorkerTransportClosure() {
  50730. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  50731. this.messageHandler = messageHandler;
  50732. this.loadingTask = loadingTask;
  50733. this.pdfDataRangeTransport = pdfDataRangeTransport;
  50734. this.commonObjs = new PDFObjects();
  50735. this.fontLoader = new FontLoader(loadingTask.docId);
  50736. this.destroyed = false;
  50737. this.destroyCapability = null;
  50738. this._passwordCapability = null;
  50739. this.pageCache = [];
  50740. this.pagePromises = [];
  50741. this.downloadInfoCapability = createPromiseCapability();
  50742. this.setupMessageHandler();
  50743. }
  50744. WorkerTransport.prototype = {
  50745. destroy: function WorkerTransport_destroy() {
  50746. if (this.destroyCapability) {
  50747. return this.destroyCapability.promise;
  50748. }
  50749. this.destroyed = true;
  50750. this.destroyCapability = createPromiseCapability();
  50751. if (this._passwordCapability) {
  50752. this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback'));
  50753. }
  50754. var waitOn = [];
  50755. this.pageCache.forEach(function (page) {
  50756. if (page) {
  50757. waitOn.push(page._destroy());
  50758. }
  50759. });
  50760. this.pageCache = [];
  50761. this.pagePromises = [];
  50762. var self = this;
  50763. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  50764. waitOn.push(terminated);
  50765. Promise.all(waitOn).then(function () {
  50766. self.fontLoader.clear();
  50767. if (self.pdfDataRangeTransport) {
  50768. self.pdfDataRangeTransport.abort();
  50769. self.pdfDataRangeTransport = null;
  50770. }
  50771. if (self.messageHandler) {
  50772. self.messageHandler.destroy();
  50773. self.messageHandler = null;
  50774. }
  50775. self.destroyCapability.resolve();
  50776. }, this.destroyCapability.reject);
  50777. return this.destroyCapability.promise;
  50778. },
  50779. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  50780. var messageHandler = this.messageHandler;
  50781. var loadingTask = this.loadingTask;
  50782. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  50783. if (pdfDataRangeTransport) {
  50784. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  50785. messageHandler.send('OnDataRange', {
  50786. begin: begin,
  50787. chunk: chunk
  50788. });
  50789. });
  50790. pdfDataRangeTransport.addProgressListener(function (loaded) {
  50791. messageHandler.send('OnDataProgress', { loaded: loaded });
  50792. });
  50793. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  50794. messageHandler.send('OnDataRange', { chunk: chunk });
  50795. });
  50796. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  50797. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  50798. }, this);
  50799. }
  50800. messageHandler.on('GetDoc', function transportDoc(data) {
  50801. var pdfInfo = data.pdfInfo;
  50802. this.numPages = data.pdfInfo.numPages;
  50803. var loadingTask = this.loadingTask;
  50804. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  50805. this.pdfDocument = pdfDocument;
  50806. loadingTask._capability.resolve(pdfDocument);
  50807. }, this);
  50808. messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
  50809. this._passwordCapability = createPromiseCapability();
  50810. if (loadingTask.onPassword) {
  50811. var updatePassword = function (password) {
  50812. this._passwordCapability.resolve({ password: password });
  50813. }.bind(this);
  50814. loadingTask.onPassword(updatePassword, exception.code);
  50815. } else {
  50816. this._passwordCapability.reject(new PasswordException(exception.message, exception.code));
  50817. }
  50818. return this._passwordCapability.promise;
  50819. }, this);
  50820. messageHandler.on('PasswordException', function transportPasswordException(exception) {
  50821. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  50822. }, this);
  50823. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  50824. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  50825. }, this);
  50826. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  50827. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  50828. }, this);
  50829. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  50830. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  50831. }, this);
  50832. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  50833. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  50834. }, this);
  50835. messageHandler.on('DataLoaded', function transportPage(data) {
  50836. this.downloadInfoCapability.resolve(data);
  50837. }, this);
  50838. messageHandler.on('PDFManagerReady', function transportPage(data) {
  50839. if (this.pdfDataRangeTransport) {
  50840. this.pdfDataRangeTransport.transportReady();
  50841. }
  50842. }, this);
  50843. messageHandler.on('StartRenderPage', function transportRender(data) {
  50844. if (this.destroyed) {
  50845. return;
  50846. }
  50847. var page = this.pageCache[data.pageIndex];
  50848. page.stats.timeEnd('Page Request');
  50849. page._startRenderPage(data.transparency, data.intent);
  50850. }, this);
  50851. messageHandler.on('RenderPageChunk', function transportRender(data) {
  50852. if (this.destroyed) {
  50853. return;
  50854. }
  50855. var page = this.pageCache[data.pageIndex];
  50856. page._renderPageChunk(data.operatorList, data.intent);
  50857. }, this);
  50858. messageHandler.on('commonobj', function transportObj(data) {
  50859. if (this.destroyed) {
  50860. return;
  50861. }
  50862. var id = data[0];
  50863. var type = data[1];
  50864. if (this.commonObjs.hasData(id)) {
  50865. return;
  50866. }
  50867. switch (type) {
  50868. case 'Font':
  50869. var exportedData = data[2];
  50870. if ('error' in exportedData) {
  50871. var exportedError = exportedData.error;
  50872. warn('Error during font loading: ' + exportedError);
  50873. this.commonObjs.resolve(id, exportedError);
  50874. break;
  50875. }
  50876. var fontRegistry = null;
  50877. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  50878. fontRegistry = {
  50879. registerFont: function (font, url) {
  50880. globalScope['FontInspector'].fontAdded(font, url);
  50881. }
  50882. };
  50883. }
  50884. var font = new FontFaceObject(exportedData, {
  50885. isEvalSuported: getDefaultSetting('isEvalSupported'),
  50886. disableFontFace: getDefaultSetting('disableFontFace'),
  50887. fontRegistry: fontRegistry
  50888. });
  50889. this.fontLoader.bind([font], function fontReady(fontObjs) {
  50890. this.commonObjs.resolve(id, font);
  50891. }.bind(this));
  50892. break;
  50893. case 'FontPath':
  50894. this.commonObjs.resolve(id, data[2]);
  50895. break;
  50896. default:
  50897. error('Got unknown common object type ' + type);
  50898. }
  50899. }, this);
  50900. messageHandler.on('obj', function transportObj(data) {
  50901. if (this.destroyed) {
  50902. return;
  50903. }
  50904. var id = data[0];
  50905. var pageIndex = data[1];
  50906. var type = data[2];
  50907. var pageProxy = this.pageCache[pageIndex];
  50908. var imageData;
  50909. if (pageProxy.objs.hasData(id)) {
  50910. return;
  50911. }
  50912. switch (type) {
  50913. case 'JpegStream':
  50914. imageData = data[3];
  50915. loadJpegStream(id, imageData, pageProxy.objs);
  50916. break;
  50917. case 'Image':
  50918. imageData = data[3];
  50919. pageProxy.objs.resolve(id, imageData);
  50920. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  50921. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  50922. pageProxy.cleanupAfterRender = true;
  50923. }
  50924. break;
  50925. default:
  50926. error('Got unknown object type ' + type);
  50927. }
  50928. }, this);
  50929. messageHandler.on('DocProgress', function transportDocProgress(data) {
  50930. if (this.destroyed) {
  50931. return;
  50932. }
  50933. var loadingTask = this.loadingTask;
  50934. if (loadingTask.onProgress) {
  50935. loadingTask.onProgress({
  50936. loaded: data.loaded,
  50937. total: data.total
  50938. });
  50939. }
  50940. }, this);
  50941. messageHandler.on('PageError', function transportError(data) {
  50942. if (this.destroyed) {
  50943. return;
  50944. }
  50945. var page = this.pageCache[data.pageNum - 1];
  50946. var intentState = page.intentStates[data.intent];
  50947. if (intentState.displayReadyCapability) {
  50948. intentState.displayReadyCapability.reject(data.error);
  50949. } else {
  50950. error(data.error);
  50951. }
  50952. if (intentState.operatorList) {
  50953. intentState.operatorList.lastChunk = true;
  50954. for (var i = 0; i < intentState.renderTasks.length; i++) {
  50955. intentState.renderTasks[i].operatorListChanged();
  50956. }
  50957. }
  50958. }, this);
  50959. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  50960. if (this.destroyed) {
  50961. return;
  50962. }
  50963. var featureId = data.featureId;
  50964. var loadingTask = this.loadingTask;
  50965. if (loadingTask.onUnsupportedFeature) {
  50966. loadingTask.onUnsupportedFeature(featureId);
  50967. }
  50968. _UnsupportedManager.notify(featureId);
  50969. }, this);
  50970. messageHandler.on('JpegDecode', function (data) {
  50971. if (this.destroyed) {
  50972. return Promise.reject(new Error('Worker was destroyed'));
  50973. }
  50974. if (typeof document === 'undefined') {
  50975. return Promise.reject(new Error('"document" is not defined.'));
  50976. }
  50977. var imageUrl = data[0];
  50978. var components = data[1];
  50979. if (components !== 3 && components !== 1) {
  50980. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  50981. }
  50982. return new Promise(function (resolve, reject) {
  50983. var img = new Image();
  50984. img.onload = function () {
  50985. var width = img.width;
  50986. var height = img.height;
  50987. var size = width * height;
  50988. var rgbaLength = size * 4;
  50989. var buf = new Uint8Array(size * components);
  50990. var tmpCanvas = document.createElement('canvas');
  50991. tmpCanvas.width = width;
  50992. tmpCanvas.height = height;
  50993. var tmpCtx = tmpCanvas.getContext('2d');
  50994. tmpCtx.drawImage(img, 0, 0);
  50995. var data = tmpCtx.getImageData(0, 0, width, height).data;
  50996. var i, j;
  50997. if (components === 3) {
  50998. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  50999. buf[j] = data[i];
  51000. buf[j + 1] = data[i + 1];
  51001. buf[j + 2] = data[i + 2];
  51002. }
  51003. } else if (components === 1) {
  51004. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  51005. buf[j] = data[i];
  51006. }
  51007. }
  51008. resolve({
  51009. data: buf,
  51010. width: width,
  51011. height: height
  51012. });
  51013. };
  51014. img.onerror = function () {
  51015. reject(new Error('JpegDecode failed to load image'));
  51016. };
  51017. img.src = imageUrl;
  51018. });
  51019. }, this);
  51020. },
  51021. getData: function WorkerTransport_getData() {
  51022. return this.messageHandler.sendWithPromise('GetData', null);
  51023. },
  51024. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  51025. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  51026. return Promise.reject(new Error('Invalid page request'));
  51027. }
  51028. var pageIndex = pageNumber - 1;
  51029. if (pageIndex in this.pagePromises) {
  51030. return this.pagePromises[pageIndex];
  51031. }
  51032. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  51033. if (this.destroyed) {
  51034. throw new Error('Transport destroyed');
  51035. }
  51036. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  51037. this.pageCache[pageIndex] = page;
  51038. return page;
  51039. }.bind(this));
  51040. this.pagePromises[pageIndex] = promise;
  51041. return promise;
  51042. },
  51043. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  51044. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  51045. return Promise.reject(new Error(reason));
  51046. });
  51047. },
  51048. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  51049. return this.messageHandler.sendWithPromise('GetAnnotations', {
  51050. pageIndex: pageIndex,
  51051. intent: intent
  51052. });
  51053. },
  51054. getDestinations: function WorkerTransport_getDestinations() {
  51055. return this.messageHandler.sendWithPromise('GetDestinations', null);
  51056. },
  51057. getDestination: function WorkerTransport_getDestination(id) {
  51058. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  51059. },
  51060. getPageLabels: function WorkerTransport_getPageLabels() {
  51061. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  51062. },
  51063. getAttachments: function WorkerTransport_getAttachments() {
  51064. return this.messageHandler.sendWithPromise('GetAttachments', null);
  51065. },
  51066. getJavaScript: function WorkerTransport_getJavaScript() {
  51067. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  51068. },
  51069. getOutline: function WorkerTransport_getOutline() {
  51070. return this.messageHandler.sendWithPromise('GetOutline', null);
  51071. },
  51072. getMetadata: function WorkerTransport_getMetadata() {
  51073. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  51074. return {
  51075. info: results[0],
  51076. metadata: results[1] ? new Metadata(results[1]) : null
  51077. };
  51078. });
  51079. },
  51080. getStats: function WorkerTransport_getStats() {
  51081. return this.messageHandler.sendWithPromise('GetStats', null);
  51082. },
  51083. startCleanup: function WorkerTransport_startCleanup() {
  51084. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  51085. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  51086. var page = this.pageCache[i];
  51087. if (page) {
  51088. page.cleanup();
  51089. }
  51090. }
  51091. this.commonObjs.clear();
  51092. this.fontLoader.clear();
  51093. }.bind(this));
  51094. }
  51095. };
  51096. return WorkerTransport;
  51097. }();
  51098. var PDFObjects = function PDFObjectsClosure() {
  51099. function PDFObjects() {
  51100. this.objs = Object.create(null);
  51101. }
  51102. PDFObjects.prototype = {
  51103. ensureObj: function PDFObjects_ensureObj(objId) {
  51104. if (this.objs[objId]) {
  51105. return this.objs[objId];
  51106. }
  51107. var obj = {
  51108. capability: createPromiseCapability(),
  51109. data: null,
  51110. resolved: false
  51111. };
  51112. this.objs[objId] = obj;
  51113. return obj;
  51114. },
  51115. get: function PDFObjects_get(objId, callback) {
  51116. if (callback) {
  51117. this.ensureObj(objId).capability.promise.then(callback);
  51118. return null;
  51119. }
  51120. var obj = this.objs[objId];
  51121. if (!obj || !obj.resolved) {
  51122. error('Requesting object that isn\'t resolved yet ' + objId);
  51123. }
  51124. return obj.data;
  51125. },
  51126. resolve: function PDFObjects_resolve(objId, data) {
  51127. var obj = this.ensureObj(objId);
  51128. obj.resolved = true;
  51129. obj.data = data;
  51130. obj.capability.resolve(data);
  51131. },
  51132. isResolved: function PDFObjects_isResolved(objId) {
  51133. var objs = this.objs;
  51134. if (!objs[objId]) {
  51135. return false;
  51136. }
  51137. return objs[objId].resolved;
  51138. },
  51139. hasData: function PDFObjects_hasData(objId) {
  51140. return this.isResolved(objId);
  51141. },
  51142. getData: function PDFObjects_getData(objId) {
  51143. var objs = this.objs;
  51144. if (!objs[objId] || !objs[objId].resolved) {
  51145. return null;
  51146. }
  51147. return objs[objId].data;
  51148. },
  51149. clear: function PDFObjects_clear() {
  51150. this.objs = Object.create(null);
  51151. }
  51152. };
  51153. return PDFObjects;
  51154. }();
  51155. var RenderTask = function RenderTaskClosure() {
  51156. function RenderTask(internalRenderTask) {
  51157. this._internalRenderTask = internalRenderTask;
  51158. this.onContinue = null;
  51159. }
  51160. RenderTask.prototype = {
  51161. get promise() {
  51162. return this._internalRenderTask.capability.promise;
  51163. },
  51164. cancel: function RenderTask_cancel() {
  51165. this._internalRenderTask.cancel();
  51166. },
  51167. then: function RenderTask_then(onFulfilled, onRejected) {
  51168. return this.promise.then.apply(this.promise, arguments);
  51169. }
  51170. };
  51171. return RenderTask;
  51172. }();
  51173. var InternalRenderTask = function InternalRenderTaskClosure() {
  51174. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory) {
  51175. this.callback = callback;
  51176. this.params = params;
  51177. this.objs = objs;
  51178. this.commonObjs = commonObjs;
  51179. this.operatorListIdx = null;
  51180. this.operatorList = operatorList;
  51181. this.pageNumber = pageNumber;
  51182. this.canvasFactory = canvasFactory;
  51183. this.running = false;
  51184. this.graphicsReadyCallback = null;
  51185. this.graphicsReady = false;
  51186. this.useRequestAnimationFrame = false;
  51187. this.cancelled = false;
  51188. this.capability = createPromiseCapability();
  51189. this.task = new RenderTask(this);
  51190. this._continueBound = this._continue.bind(this);
  51191. this._scheduleNextBound = this._scheduleNext.bind(this);
  51192. this._nextBound = this._next.bind(this);
  51193. }
  51194. InternalRenderTask.prototype = {
  51195. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  51196. if (this.cancelled) {
  51197. return;
  51198. }
  51199. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  51200. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  51201. this.stepper.init(this.operatorList);
  51202. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  51203. }
  51204. var params = this.params;
  51205. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, params.imageLayer);
  51206. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  51207. this.operatorListIdx = 0;
  51208. this.graphicsReady = true;
  51209. if (this.graphicsReadyCallback) {
  51210. this.graphicsReadyCallback();
  51211. }
  51212. },
  51213. cancel: function InternalRenderTask_cancel() {
  51214. this.running = false;
  51215. this.cancelled = true;
  51216. this.callback('cancelled');
  51217. },
  51218. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  51219. if (!this.graphicsReady) {
  51220. if (!this.graphicsReadyCallback) {
  51221. this.graphicsReadyCallback = this._continueBound;
  51222. }
  51223. return;
  51224. }
  51225. if (this.stepper) {
  51226. this.stepper.updateOperatorList(this.operatorList);
  51227. }
  51228. if (this.running) {
  51229. return;
  51230. }
  51231. this._continue();
  51232. },
  51233. _continue: function InternalRenderTask__continue() {
  51234. this.running = true;
  51235. if (this.cancelled) {
  51236. return;
  51237. }
  51238. if (this.task.onContinue) {
  51239. this.task.onContinue(this._scheduleNextBound);
  51240. } else {
  51241. this._scheduleNext();
  51242. }
  51243. },
  51244. _scheduleNext: function InternalRenderTask__scheduleNext() {
  51245. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  51246. window.requestAnimationFrame(this._nextBound);
  51247. } else {
  51248. Promise.resolve(undefined).then(this._nextBound);
  51249. }
  51250. },
  51251. _next: function InternalRenderTask__next() {
  51252. if (this.cancelled) {
  51253. return;
  51254. }
  51255. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  51256. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  51257. this.running = false;
  51258. if (this.operatorList.lastChunk) {
  51259. this.gfx.endDrawing();
  51260. this.callback();
  51261. }
  51262. }
  51263. }
  51264. };
  51265. return InternalRenderTask;
  51266. }();
  51267. var _UnsupportedManager = function UnsupportedManagerClosure() {
  51268. var listeners = [];
  51269. return {
  51270. listen: function (cb) {
  51271. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  51272. listeners.push(cb);
  51273. },
  51274. notify: function (featureId) {
  51275. for (var i = 0, ii = listeners.length; i < ii; i++) {
  51276. listeners[i](featureId);
  51277. }
  51278. }
  51279. };
  51280. }();
  51281. if (typeof pdfjsVersion !== 'undefined') {
  51282. exports.version = pdfjsVersion;
  51283. }
  51284. if (typeof pdfjsBuild !== 'undefined') {
  51285. exports.build = pdfjsBuild;
  51286. }
  51287. exports.getDocument = getDocument;
  51288. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  51289. exports.PDFWorker = PDFWorker;
  51290. exports.PDFDocumentProxy = PDFDocumentProxy;
  51291. exports.PDFPageProxy = PDFPageProxy;
  51292. exports._UnsupportedManager = _UnsupportedManager;
  51293. }));
  51294. (function (root, factory) {
  51295. factory(root.pdfjsCoreEvaluator = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser, root.pdfjsCoreImage, root.pdfjsCoreColorSpace, root.pdfjsCoreMurmurHash3, root.pdfjsCoreFonts, root.pdfjsCoreFunction, root.pdfjsCorePattern, root.pdfjsCoreCMap, root.pdfjsCoreMetrics, root.pdfjsCoreBidi, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreGlyphList);
  51296. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51297. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51298. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51299. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51300. var ImageKind = sharedUtil.ImageKind;
  51301. var OPS = sharedUtil.OPS;
  51302. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51303. var Util = sharedUtil.Util;
  51304. var assert = sharedUtil.assert;
  51305. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51306. var error = sharedUtil.error;
  51307. var info = sharedUtil.info;
  51308. var isArray = sharedUtil.isArray;
  51309. var isNum = sharedUtil.isNum;
  51310. var isString = sharedUtil.isString;
  51311. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51312. var warn = sharedUtil.warn;
  51313. var Dict = corePrimitives.Dict;
  51314. var Name = corePrimitives.Name;
  51315. var isEOF = corePrimitives.isEOF;
  51316. var isCmd = corePrimitives.isCmd;
  51317. var isDict = corePrimitives.isDict;
  51318. var isName = corePrimitives.isName;
  51319. var isRef = corePrimitives.isRef;
  51320. var isStream = corePrimitives.isStream;
  51321. var DecodeStream = coreStream.DecodeStream;
  51322. var JpegStream = coreStream.JpegStream;
  51323. var Stream = coreStream.Stream;
  51324. var Lexer = coreParser.Lexer;
  51325. var Parser = coreParser.Parser;
  51326. var PDFImage = coreImage.PDFImage;
  51327. var ColorSpace = coreColorSpace.ColorSpace;
  51328. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51329. var ErrorFont = coreFonts.ErrorFont;
  51330. var FontFlags = coreFonts.FontFlags;
  51331. var Font = coreFonts.Font;
  51332. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51333. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51334. var getFontType = coreFonts.getFontType;
  51335. var isPDFFunction = coreFunction.isPDFFunction;
  51336. var PDFFunction = coreFunction.PDFFunction;
  51337. var Pattern = corePattern.Pattern;
  51338. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51339. var CMapFactory = coreCMap.CMapFactory;
  51340. var IdentityCMap = coreCMap.IdentityCMap;
  51341. var getMetrics = coreMetrics.getMetrics;
  51342. var bidi = coreBidi.bidi;
  51343. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51344. var StandardEncoding = coreEncodings.StandardEncoding;
  51345. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51346. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51347. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51348. var getEncoding = coreEncodings.getEncoding;
  51349. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51350. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51351. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51352. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51353. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51354. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51355. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51356. var PartialEvaluator = function PartialEvaluatorClosure() {
  51357. var DefaultPartialEvaluatorOptions = {
  51358. forceDataSchema: false,
  51359. maxImageSize: -1,
  51360. disableFontFace: false,
  51361. cMapOptions: {
  51362. url: null,
  51363. packed: false
  51364. },
  51365. disableNativeImageDecoder: false
  51366. };
  51367. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51368. this.xref = xref;
  51369. this.resources = resources;
  51370. this.handler = handler;
  51371. this.forceDataSchema = forceDataSchema;
  51372. }
  51373. NativeImageDecoder.prototype = {
  51374. canDecode: function (image) {
  51375. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51376. },
  51377. decode: function (image) {
  51378. var dict = image.dict;
  51379. var colorSpace = dict.get('ColorSpace', 'CS');
  51380. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51381. var numComps = colorSpace.numComps;
  51382. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51383. image.getIR(this.forceDataSchema),
  51384. numComps
  51385. ]);
  51386. return decodePromise.then(function (message) {
  51387. var data = message.data;
  51388. return new Stream(data, 0, data.length, image.dict);
  51389. });
  51390. }
  51391. };
  51392. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51393. var dict = image.dict;
  51394. if (dict.has('DecodeParms') || dict.has('DP')) {
  51395. return false;
  51396. }
  51397. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51398. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51399. };
  51400. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51401. var dict = image.dict;
  51402. if (dict.has('DecodeParms') || dict.has('DP')) {
  51403. return false;
  51404. }
  51405. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51406. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51407. };
  51408. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  51409. this.pdfManager = pdfManager;
  51410. this.xref = xref;
  51411. this.handler = handler;
  51412. this.pageIndex = pageIndex;
  51413. this.idFactory = idFactory;
  51414. this.fontCache = fontCache;
  51415. this.options = options || DefaultPartialEvaluatorOptions;
  51416. }
  51417. var TIME_SLOT_DURATION_MS = 20;
  51418. var CHECK_TIME_EVERY = 100;
  51419. function TimeSlotManager() {
  51420. this.reset();
  51421. }
  51422. TimeSlotManager.prototype = {
  51423. check: function TimeSlotManager_check() {
  51424. if (++this.checked < CHECK_TIME_EVERY) {
  51425. return false;
  51426. }
  51427. this.checked = 0;
  51428. return this.endTime <= Date.now();
  51429. },
  51430. reset: function TimeSlotManager_reset() {
  51431. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51432. this.checked = 0;
  51433. }
  51434. };
  51435. var deferred = Promise.resolve();
  51436. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51437. PartialEvaluator.prototype = {
  51438. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51439. if (!isDict(resources)) {
  51440. return false;
  51441. }
  51442. var processed = Object.create(null);
  51443. if (resources.objId) {
  51444. processed[resources.objId] = true;
  51445. }
  51446. var nodes = [resources], xref = this.xref;
  51447. while (nodes.length) {
  51448. var key, i, ii;
  51449. var node = nodes.shift();
  51450. var graphicStates = node.get('ExtGState');
  51451. if (isDict(graphicStates)) {
  51452. var graphicStatesKeys = graphicStates.getKeys();
  51453. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51454. key = graphicStatesKeys[i];
  51455. var graphicState = graphicStates.get(key);
  51456. var bm = graphicState.get('BM');
  51457. if (isName(bm) && bm.name !== 'Normal') {
  51458. return true;
  51459. }
  51460. }
  51461. }
  51462. var xObjects = node.get('XObject');
  51463. if (!isDict(xObjects)) {
  51464. continue;
  51465. }
  51466. var xObjectsKeys = xObjects.getKeys();
  51467. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51468. key = xObjectsKeys[i];
  51469. var xObject = xObjects.getRaw(key);
  51470. if (isRef(xObject)) {
  51471. if (processed[xObject.toString()]) {
  51472. continue;
  51473. }
  51474. xObject = xref.fetch(xObject);
  51475. }
  51476. if (!isStream(xObject)) {
  51477. continue;
  51478. }
  51479. if (xObject.dict.objId) {
  51480. if (processed[xObject.dict.objId]) {
  51481. continue;
  51482. }
  51483. processed[xObject.dict.objId] = true;
  51484. }
  51485. var xResources = xObject.dict.get('Resources');
  51486. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51487. nodes.push(xResources);
  51488. if (xResources.objId) {
  51489. processed[xResources.objId] = true;
  51490. }
  51491. }
  51492. }
  51493. }
  51494. return false;
  51495. },
  51496. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51497. var matrix = xobj.dict.getArray('Matrix');
  51498. var bbox = xobj.dict.getArray('BBox');
  51499. var group = xobj.dict.get('Group');
  51500. if (group) {
  51501. var groupOptions = {
  51502. matrix: matrix,
  51503. bbox: bbox,
  51504. smask: smask,
  51505. isolated: false,
  51506. knockout: false
  51507. };
  51508. var groupSubtype = group.get('S');
  51509. var colorSpace;
  51510. if (isName(groupSubtype, 'Transparency')) {
  51511. groupOptions.isolated = group.get('I') || false;
  51512. groupOptions.knockout = group.get('K') || false;
  51513. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51514. }
  51515. if (smask && smask.backdrop) {
  51516. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51517. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51518. }
  51519. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51520. }
  51521. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51522. matrix,
  51523. bbox
  51524. ]);
  51525. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51526. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51527. if (group) {
  51528. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51529. }
  51530. });
  51531. },
  51532. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51533. var self = this;
  51534. var dict = image.dict;
  51535. var w = dict.get('Width', 'W');
  51536. var h = dict.get('Height', 'H');
  51537. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51538. warn('Image dimensions are missing, or not numbers.');
  51539. return;
  51540. }
  51541. var maxImageSize = this.options.maxImageSize;
  51542. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51543. warn('Image exceeded maximum allowed size and was removed.');
  51544. return;
  51545. }
  51546. var imageMask = dict.get('ImageMask', 'IM') || false;
  51547. var imgData, args;
  51548. if (imageMask) {
  51549. var width = dict.get('Width', 'W');
  51550. var height = dict.get('Height', 'H');
  51551. var bitStrideLength = width + 7 >> 3;
  51552. var imgArray = image.getBytes(bitStrideLength * height);
  51553. var decode = dict.getArray('Decode', 'D');
  51554. var inverseDecode = !!decode && decode[0] > 0;
  51555. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51556. imgData.cached = true;
  51557. args = [imgData];
  51558. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51559. if (cacheKey) {
  51560. imageCache[cacheKey] = {
  51561. fn: OPS.paintImageMaskXObject,
  51562. args: args
  51563. };
  51564. }
  51565. return;
  51566. }
  51567. var softMask = dict.get('SMask', 'SM') || false;
  51568. var mask = dict.get('Mask') || false;
  51569. var SMALL_IMAGE_DIMENSIONS = 200;
  51570. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51571. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51572. imgData = imageObj.createImageData(true);
  51573. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51574. return;
  51575. }
  51576. var useNativeImageDecoder = !this.options.disableNativeImageDecoder;
  51577. var objId = 'img_' + this.idFactory.createObjId();
  51578. operatorList.addDependency(objId);
  51579. args = [
  51580. objId,
  51581. w,
  51582. h
  51583. ];
  51584. if (useNativeImageDecoder && !softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51585. operatorList.addOp(OPS.paintJpegXObject, args);
  51586. this.handler.send('obj', [
  51587. objId,
  51588. this.pageIndex,
  51589. 'JpegStream',
  51590. image.getIR(this.options.forceDataSchema)
  51591. ]);
  51592. return;
  51593. }
  51594. var nativeImageDecoder = null;
  51595. if (useNativeImageDecoder && (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream)) {
  51596. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51597. }
  51598. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51599. var imgData = imageObj.createImageData(false);
  51600. self.handler.send('obj', [
  51601. objId,
  51602. self.pageIndex,
  51603. 'Image',
  51604. imgData
  51605. ], [imgData.data.buffer]);
  51606. }).then(undefined, function (reason) {
  51607. warn('Unable to decode image: ' + reason);
  51608. self.handler.send('obj', [
  51609. objId,
  51610. self.pageIndex,
  51611. 'Image',
  51612. null
  51613. ]);
  51614. });
  51615. operatorList.addOp(OPS.paintImageXObject, args);
  51616. if (cacheKey) {
  51617. imageCache[cacheKey] = {
  51618. fn: OPS.paintImageXObject,
  51619. args: args
  51620. };
  51621. }
  51622. },
  51623. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51624. var smaskContent = smask.get('G');
  51625. var smaskOptions = {
  51626. subtype: smask.get('S').name,
  51627. backdrop: smask.get('BC')
  51628. };
  51629. var transferObj = smask.get('TR');
  51630. if (isPDFFunction(transferObj)) {
  51631. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51632. var transferMap = new Uint8Array(256);
  51633. var tmp = new Float32Array(1);
  51634. for (var i = 0; i < 256; i++) {
  51635. tmp[0] = i / 255;
  51636. transferFn(tmp, 0, tmp, 0);
  51637. transferMap[i] = tmp[0] * 255 | 0;
  51638. }
  51639. smaskOptions.transferMap = transferMap;
  51640. }
  51641. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  51642. },
  51643. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  51644. var tilingOpList = new OperatorList();
  51645. var resourcesArray = [
  51646. patternDict.get('Resources'),
  51647. resources
  51648. ];
  51649. var patternResources = Dict.merge(this.xref, resourcesArray);
  51650. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  51651. operatorList.addDependencies(tilingOpList.dependencies);
  51652. operatorList.addOp(fn, getTilingPatternIR({
  51653. fnArray: tilingOpList.fnArray,
  51654. argsArray: tilingOpList.argsArray
  51655. }, patternDict, args));
  51656. });
  51657. },
  51658. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  51659. var fontName;
  51660. if (fontArgs) {
  51661. fontArgs = fontArgs.slice();
  51662. fontName = fontArgs[0].name;
  51663. }
  51664. var self = this;
  51665. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  51666. if (!translated.font.isType3Font) {
  51667. return translated;
  51668. }
  51669. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  51670. return translated;
  51671. }, function (reason) {
  51672. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51673. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  51674. });
  51675. }).then(function (translated) {
  51676. state.font = translated.font;
  51677. translated.send(self.handler);
  51678. return translated.loadedName;
  51679. });
  51680. },
  51681. handleText: function PartialEvaluator_handleText(chars, state) {
  51682. var font = state.font;
  51683. var glyphs = font.charsToGlyphs(chars);
  51684. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  51685. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  51686. var buildPath = function (fontChar) {
  51687. if (!font.renderer.hasBuiltPath(fontChar)) {
  51688. var path = font.renderer.getPathJs(fontChar);
  51689. this.handler.send('commonobj', [
  51690. font.loadedName + '_path_' + fontChar,
  51691. 'FontPath',
  51692. path
  51693. ]);
  51694. }
  51695. }.bind(this);
  51696. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  51697. var glyph = glyphs[i];
  51698. buildPath(glyph.fontChar);
  51699. var accent = glyph.accent;
  51700. if (accent && accent.fontChar) {
  51701. buildPath(accent.fontChar);
  51702. }
  51703. }
  51704. }
  51705. return glyphs;
  51706. },
  51707. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  51708. var gStateObj = [];
  51709. var gStateKeys = gState.getKeys();
  51710. var self = this;
  51711. var promise = Promise.resolve();
  51712. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  51713. var key = gStateKeys[i];
  51714. var value = gState.get(key);
  51715. switch (key) {
  51716. case 'Type':
  51717. break;
  51718. case 'LW':
  51719. case 'LC':
  51720. case 'LJ':
  51721. case 'ML':
  51722. case 'D':
  51723. case 'RI':
  51724. case 'FL':
  51725. case 'CA':
  51726. case 'ca':
  51727. gStateObj.push([
  51728. key,
  51729. value
  51730. ]);
  51731. break;
  51732. case 'Font':
  51733. promise = promise.then(function () {
  51734. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  51735. operatorList.addDependency(loadedName);
  51736. gStateObj.push([
  51737. key,
  51738. [
  51739. loadedName,
  51740. value[1]
  51741. ]
  51742. ]);
  51743. });
  51744. });
  51745. break;
  51746. case 'BM':
  51747. gStateObj.push([
  51748. key,
  51749. value
  51750. ]);
  51751. break;
  51752. case 'SMask':
  51753. if (isName(value, 'None')) {
  51754. gStateObj.push([
  51755. key,
  51756. false
  51757. ]);
  51758. break;
  51759. }
  51760. if (isDict(value)) {
  51761. promise = promise.then(function (dict) {
  51762. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  51763. }.bind(this, value));
  51764. gStateObj.push([
  51765. key,
  51766. true
  51767. ]);
  51768. } else {
  51769. warn('Unsupported SMask type');
  51770. }
  51771. break;
  51772. case 'OP':
  51773. case 'op':
  51774. case 'OPM':
  51775. case 'BG':
  51776. case 'BG2':
  51777. case 'UCR':
  51778. case 'UCR2':
  51779. case 'TR':
  51780. case 'TR2':
  51781. case 'HT':
  51782. case 'SM':
  51783. case 'SA':
  51784. case 'AIS':
  51785. case 'TK':
  51786. info('graphic state operator ' + key);
  51787. break;
  51788. default:
  51789. info('Unknown graphic state operator ' + key);
  51790. break;
  51791. }
  51792. }
  51793. return promise.then(function () {
  51794. if (gStateObj.length > 0) {
  51795. operatorList.addOp(OPS.setGState, [gStateObj]);
  51796. }
  51797. });
  51798. },
  51799. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  51800. function errorFont() {
  51801. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  51802. }
  51803. var fontRef;
  51804. if (font) {
  51805. assert(isRef(font));
  51806. fontRef = font;
  51807. } else {
  51808. var fontRes = resources.get('Font');
  51809. if (fontRes) {
  51810. fontRef = fontRes.getRaw(fontName);
  51811. } else {
  51812. warn('fontRes not available');
  51813. return errorFont();
  51814. }
  51815. }
  51816. if (!fontRef) {
  51817. warn('fontRef not available');
  51818. return errorFont();
  51819. }
  51820. if (this.fontCache.has(fontRef)) {
  51821. return this.fontCache.get(fontRef);
  51822. }
  51823. font = xref.fetchIfRef(fontRef);
  51824. if (!isDict(font)) {
  51825. return errorFont();
  51826. }
  51827. if (font.translated) {
  51828. return font.translated;
  51829. }
  51830. var fontCapability = createPromiseCapability();
  51831. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  51832. var descriptor = preEvaluatedFont.descriptor;
  51833. var fontRefIsRef = isRef(fontRef), fontID;
  51834. if (fontRefIsRef) {
  51835. fontID = fontRef.toString();
  51836. }
  51837. if (isDict(descriptor)) {
  51838. if (!descriptor.fontAliases) {
  51839. descriptor.fontAliases = Object.create(null);
  51840. }
  51841. var fontAliases = descriptor.fontAliases;
  51842. var hash = preEvaluatedFont.hash;
  51843. if (fontAliases[hash]) {
  51844. var aliasFontRef = fontAliases[hash].aliasRef;
  51845. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  51846. this.fontCache.putAlias(fontRef, aliasFontRef);
  51847. return this.fontCache.get(fontRef);
  51848. }
  51849. } else {
  51850. fontAliases[hash] = { fontID: Font.getFontID() };
  51851. }
  51852. if (fontRefIsRef) {
  51853. fontAliases[hash].aliasRef = fontRef;
  51854. }
  51855. fontID = fontAliases[hash].fontID;
  51856. }
  51857. if (fontRefIsRef) {
  51858. this.fontCache.put(fontRef, fontCapability.promise);
  51859. } else {
  51860. if (!fontID) {
  51861. fontID = this.idFactory.createObjId();
  51862. }
  51863. this.fontCache.put('id_' + fontID, fontCapability.promise);
  51864. }
  51865. assert(fontID, 'The "fontID" must be defined.');
  51866. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  51867. font.translated = fontCapability.promise;
  51868. var translatedPromise;
  51869. try {
  51870. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  51871. } catch (e) {
  51872. translatedPromise = Promise.reject(e);
  51873. }
  51874. var self = this;
  51875. translatedPromise.then(function (translatedFont) {
  51876. if (translatedFont.fontType !== undefined) {
  51877. var xrefFontStats = xref.stats.fontTypes;
  51878. xrefFontStats[translatedFont.fontType] = true;
  51879. }
  51880. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  51881. }, function (reason) {
  51882. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51883. try {
  51884. var descriptor = preEvaluatedFont.descriptor;
  51885. var fontFile3 = descriptor && descriptor.get('FontFile3');
  51886. var subtype = fontFile3 && fontFile3.get('Subtype');
  51887. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  51888. var xrefFontStats = xref.stats.fontTypes;
  51889. xrefFontStats[fontType] = true;
  51890. } catch (ex) {
  51891. }
  51892. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  51893. });
  51894. return fontCapability.promise;
  51895. },
  51896. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  51897. var lastIndex = operatorList.length - 1;
  51898. if (!args) {
  51899. args = [];
  51900. }
  51901. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  51902. operatorList.addOp(OPS.constructPath, [
  51903. [fn],
  51904. args
  51905. ]);
  51906. } else {
  51907. var opArgs = operatorList.argsArray[lastIndex];
  51908. opArgs[0].push(fn);
  51909. Array.prototype.push.apply(opArgs[1], args);
  51910. }
  51911. },
  51912. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  51913. var patternName = args[args.length - 1];
  51914. var pattern;
  51915. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  51916. var dict = isStream(pattern) ? pattern.dict : pattern;
  51917. var typeNum = dict.get('PatternType');
  51918. if (typeNum === TILING_PATTERN) {
  51919. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  51920. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  51921. } else if (typeNum === SHADING_PATTERN) {
  51922. var shading = dict.get('Shading');
  51923. var matrix = dict.getArray('Matrix');
  51924. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  51925. operatorList.addOp(fn, pattern.getIR());
  51926. return Promise.resolve();
  51927. }
  51928. return Promise.reject('Unknown PatternType: ' + typeNum);
  51929. }
  51930. operatorList.addOp(fn, args);
  51931. return Promise.resolve();
  51932. },
  51933. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  51934. var self = this;
  51935. var xref = this.xref;
  51936. var imageCache = Object.create(null);
  51937. assert(operatorList);
  51938. resources = resources || Dict.empty;
  51939. var xobjs = resources.get('XObject') || Dict.empty;
  51940. var patterns = resources.get('Pattern') || Dict.empty;
  51941. var stateManager = new StateManager(initialState || new EvalState());
  51942. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  51943. var timeSlotManager = new TimeSlotManager();
  51944. return new Promise(function promiseBody(resolve, reject) {
  51945. var next = function (promise) {
  51946. promise.then(function () {
  51947. try {
  51948. promiseBody(resolve, reject);
  51949. } catch (ex) {
  51950. reject(ex);
  51951. }
  51952. }, reject);
  51953. };
  51954. task.ensureNotTerminated();
  51955. timeSlotManager.reset();
  51956. var stop, operation = {}, i, ii, cs;
  51957. while (!(stop = timeSlotManager.check())) {
  51958. operation.args = null;
  51959. if (!preprocessor.read(operation)) {
  51960. break;
  51961. }
  51962. var args = operation.args;
  51963. var fn = operation.fn;
  51964. switch (fn | 0) {
  51965. case OPS.paintXObject:
  51966. if (args[0].code) {
  51967. break;
  51968. }
  51969. var name = args[0].name;
  51970. if (!name) {
  51971. warn('XObject must be referred to by name.');
  51972. continue;
  51973. }
  51974. if (imageCache[name] !== undefined) {
  51975. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  51976. args = null;
  51977. continue;
  51978. }
  51979. var xobj = xobjs.get(name);
  51980. if (xobj) {
  51981. assert(isStream(xobj), 'XObject should be a stream');
  51982. var type = xobj.dict.get('Subtype');
  51983. assert(isName(type), 'XObject should have a Name subtype');
  51984. if (type.name === 'Form') {
  51985. stateManager.save();
  51986. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  51987. stateManager.restore();
  51988. }));
  51989. return;
  51990. } else if (type.name === 'Image') {
  51991. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  51992. args = null;
  51993. continue;
  51994. } else if (type.name === 'PS') {
  51995. info('Ignored XObject subtype PS');
  51996. continue;
  51997. } else {
  51998. error('Unhandled XObject subtype ' + type.name);
  51999. }
  52000. }
  52001. break;
  52002. case OPS.setFont:
  52003. var fontSize = args[1];
  52004. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52005. operatorList.addDependency(loadedName);
  52006. operatorList.addOp(OPS.setFont, [
  52007. loadedName,
  52008. fontSize
  52009. ]);
  52010. }));
  52011. return;
  52012. case OPS.endInlineImage:
  52013. var cacheKey = args[0].cacheKey;
  52014. if (cacheKey) {
  52015. var cacheEntry = imageCache[cacheKey];
  52016. if (cacheEntry !== undefined) {
  52017. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52018. args = null;
  52019. continue;
  52020. }
  52021. }
  52022. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52023. args = null;
  52024. continue;
  52025. case OPS.showText:
  52026. args[0] = self.handleText(args[0], stateManager.state);
  52027. break;
  52028. case OPS.showSpacedText:
  52029. var arr = args[0];
  52030. var combinedGlyphs = [];
  52031. var arrLength = arr.length;
  52032. var state = stateManager.state;
  52033. for (i = 0; i < arrLength; ++i) {
  52034. var arrItem = arr[i];
  52035. if (isString(arrItem)) {
  52036. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52037. } else if (isNum(arrItem)) {
  52038. combinedGlyphs.push(arrItem);
  52039. }
  52040. }
  52041. args[0] = combinedGlyphs;
  52042. fn = OPS.showText;
  52043. break;
  52044. case OPS.nextLineShowText:
  52045. operatorList.addOp(OPS.nextLine);
  52046. args[0] = self.handleText(args[0], stateManager.state);
  52047. fn = OPS.showText;
  52048. break;
  52049. case OPS.nextLineSetSpacingShowText:
  52050. operatorList.addOp(OPS.nextLine);
  52051. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52052. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52053. args[0] = self.handleText(args[0], stateManager.state);
  52054. fn = OPS.showText;
  52055. break;
  52056. case OPS.setTextRenderingMode:
  52057. stateManager.state.textRenderingMode = args[0];
  52058. break;
  52059. case OPS.setFillColorSpace:
  52060. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52061. continue;
  52062. case OPS.setStrokeColorSpace:
  52063. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52064. continue;
  52065. case OPS.setFillColor:
  52066. cs = stateManager.state.fillColorSpace;
  52067. args = cs.getRgb(args, 0);
  52068. fn = OPS.setFillRGBColor;
  52069. break;
  52070. case OPS.setStrokeColor:
  52071. cs = stateManager.state.strokeColorSpace;
  52072. args = cs.getRgb(args, 0);
  52073. fn = OPS.setStrokeRGBColor;
  52074. break;
  52075. case OPS.setFillGray:
  52076. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52077. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52078. fn = OPS.setFillRGBColor;
  52079. break;
  52080. case OPS.setStrokeGray:
  52081. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52082. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52083. fn = OPS.setStrokeRGBColor;
  52084. break;
  52085. case OPS.setFillCMYKColor:
  52086. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52087. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52088. fn = OPS.setFillRGBColor;
  52089. break;
  52090. case OPS.setStrokeCMYKColor:
  52091. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52092. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52093. fn = OPS.setStrokeRGBColor;
  52094. break;
  52095. case OPS.setFillRGBColor:
  52096. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52097. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52098. break;
  52099. case OPS.setStrokeRGBColor:
  52100. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52101. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52102. break;
  52103. case OPS.setFillColorN:
  52104. cs = stateManager.state.fillColorSpace;
  52105. if (cs.name === 'Pattern') {
  52106. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52107. return;
  52108. }
  52109. args = cs.getRgb(args, 0);
  52110. fn = OPS.setFillRGBColor;
  52111. break;
  52112. case OPS.setStrokeColorN:
  52113. cs = stateManager.state.strokeColorSpace;
  52114. if (cs.name === 'Pattern') {
  52115. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52116. return;
  52117. }
  52118. args = cs.getRgb(args, 0);
  52119. fn = OPS.setStrokeRGBColor;
  52120. break;
  52121. case OPS.shadingFill:
  52122. var shadingRes = resources.get('Shading');
  52123. if (!shadingRes) {
  52124. error('No shading resource found');
  52125. }
  52126. var shading = shadingRes.get(args[0].name);
  52127. if (!shading) {
  52128. error('No shading object found');
  52129. }
  52130. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52131. var patternIR = shadingFill.getIR();
  52132. args = [patternIR];
  52133. fn = OPS.shadingFill;
  52134. break;
  52135. case OPS.setGState:
  52136. var dictName = args[0];
  52137. var extGState = resources.get('ExtGState');
  52138. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52139. break;
  52140. }
  52141. var gState = extGState.get(dictName.name);
  52142. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52143. return;
  52144. case OPS.moveTo:
  52145. case OPS.lineTo:
  52146. case OPS.curveTo:
  52147. case OPS.curveTo2:
  52148. case OPS.curveTo3:
  52149. case OPS.closePath:
  52150. self.buildPath(operatorList, fn, args);
  52151. continue;
  52152. case OPS.rectangle:
  52153. self.buildPath(operatorList, fn, args);
  52154. continue;
  52155. case OPS.markPoint:
  52156. case OPS.markPointProps:
  52157. case OPS.beginMarkedContent:
  52158. case OPS.beginMarkedContentProps:
  52159. case OPS.endMarkedContent:
  52160. case OPS.beginCompat:
  52161. case OPS.endCompat:
  52162. continue;
  52163. default:
  52164. if (args !== null) {
  52165. for (i = 0, ii = args.length; i < ii; i++) {
  52166. if (args[i] instanceof Dict) {
  52167. break;
  52168. }
  52169. }
  52170. if (i < ii) {
  52171. warn('getOperatorList - ignoring operator: ' + fn);
  52172. continue;
  52173. }
  52174. }
  52175. }
  52176. operatorList.addOp(fn, args);
  52177. }
  52178. if (stop) {
  52179. next(deferred);
  52180. return;
  52181. }
  52182. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52183. operatorList.addOp(OPS.restore, []);
  52184. }
  52185. resolve();
  52186. });
  52187. },
  52188. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52189. stateManager = stateManager || new StateManager(new TextState());
  52190. var WhitespaceRegexp = /\s/g;
  52191. var textContent = {
  52192. items: [],
  52193. styles: Object.create(null)
  52194. };
  52195. var textContentItem = {
  52196. initialized: false,
  52197. str: [],
  52198. width: 0,
  52199. height: 0,
  52200. vertical: false,
  52201. lastAdvanceWidth: 0,
  52202. lastAdvanceHeight: 0,
  52203. textAdvanceScale: 0,
  52204. spaceWidth: 0,
  52205. fakeSpaceMin: Infinity,
  52206. fakeMultiSpaceMin: Infinity,
  52207. fakeMultiSpaceMax: -0,
  52208. textRunBreakAllowed: false,
  52209. transform: null,
  52210. fontName: null
  52211. };
  52212. var SPACE_FACTOR = 0.3;
  52213. var MULTI_SPACE_FACTOR = 1.5;
  52214. var MULTI_SPACE_FACTOR_MAX = 4;
  52215. var self = this;
  52216. var xref = this.xref;
  52217. resources = xref.fetchIfRef(resources) || Dict.empty;
  52218. var xobjs = null;
  52219. var xobjsCache = Object.create(null);
  52220. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52221. var textState;
  52222. function ensureTextContentItem() {
  52223. if (textContentItem.initialized) {
  52224. return textContentItem;
  52225. }
  52226. var font = textState.font;
  52227. if (!(font.loadedName in textContent.styles)) {
  52228. textContent.styles[font.loadedName] = {
  52229. fontFamily: font.fallbackName,
  52230. ascent: font.ascent,
  52231. descent: font.descent,
  52232. vertical: font.vertical
  52233. };
  52234. }
  52235. textContentItem.fontName = font.loadedName;
  52236. var tsm = [
  52237. textState.fontSize * textState.textHScale,
  52238. 0,
  52239. 0,
  52240. textState.fontSize,
  52241. 0,
  52242. textState.textRise
  52243. ];
  52244. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52245. var glyphHeight = font.bbox[3] - font.bbox[1];
  52246. if (glyphHeight > 0) {
  52247. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52248. tsm[3] *= glyphHeight;
  52249. }
  52250. }
  52251. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52252. textContentItem.transform = trm;
  52253. if (!font.vertical) {
  52254. textContentItem.width = 0;
  52255. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52256. textContentItem.vertical = false;
  52257. } else {
  52258. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52259. textContentItem.height = 0;
  52260. textContentItem.vertical = true;
  52261. }
  52262. var a = textState.textLineMatrix[0];
  52263. var b = textState.textLineMatrix[1];
  52264. var scaleLineX = Math.sqrt(a * a + b * b);
  52265. a = textState.ctm[0];
  52266. b = textState.ctm[1];
  52267. var scaleCtmX = Math.sqrt(a * a + b * b);
  52268. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52269. textContentItem.lastAdvanceWidth = 0;
  52270. textContentItem.lastAdvanceHeight = 0;
  52271. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52272. if (spaceWidth) {
  52273. textContentItem.spaceWidth = spaceWidth;
  52274. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52275. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52276. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52277. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52278. } else {
  52279. textContentItem.spaceWidth = 0;
  52280. textContentItem.fakeSpaceMin = Infinity;
  52281. textContentItem.fakeMultiSpaceMin = Infinity;
  52282. textContentItem.fakeMultiSpaceMax = 0;
  52283. textContentItem.textRunBreakAllowed = false;
  52284. }
  52285. textContentItem.initialized = true;
  52286. return textContentItem;
  52287. }
  52288. function replaceWhitespace(str) {
  52289. var i = 0, ii = str.length, code;
  52290. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52291. i++;
  52292. }
  52293. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52294. }
  52295. function runBidiTransform(textChunk) {
  52296. var str = textChunk.str.join('');
  52297. var bidiResult = bidi(str, -1, textChunk.vertical);
  52298. return {
  52299. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52300. dir: bidiResult.dir,
  52301. width: textChunk.width,
  52302. height: textChunk.height,
  52303. transform: textChunk.transform,
  52304. fontName: textChunk.fontName
  52305. };
  52306. }
  52307. function handleSetFont(fontName, fontRef) {
  52308. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52309. textState.font = translated.font;
  52310. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52311. });
  52312. }
  52313. function buildTextContentItem(chars) {
  52314. var font = textState.font;
  52315. var textChunk = ensureTextContentItem();
  52316. var width = 0;
  52317. var height = 0;
  52318. var glyphs = font.charsToGlyphs(chars);
  52319. for (var i = 0; i < glyphs.length; i++) {
  52320. var glyph = glyphs[i];
  52321. var glyphWidth = null;
  52322. if (font.vertical && glyph.vmetric) {
  52323. glyphWidth = glyph.vmetric[0];
  52324. } else {
  52325. glyphWidth = glyph.width;
  52326. }
  52327. var glyphUnicode = glyph.unicode;
  52328. var NormalizedUnicodes = getNormalizedUnicodes();
  52329. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52330. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52331. }
  52332. glyphUnicode = reverseIfRtl(glyphUnicode);
  52333. var charSpacing = textState.charSpacing;
  52334. if (glyph.isSpace) {
  52335. var wordSpacing = textState.wordSpacing;
  52336. charSpacing += wordSpacing;
  52337. if (wordSpacing > 0) {
  52338. addFakeSpaces(wordSpacing, textChunk.str);
  52339. }
  52340. }
  52341. var tx = 0;
  52342. var ty = 0;
  52343. if (!font.vertical) {
  52344. var w0 = glyphWidth * textState.fontMatrix[0];
  52345. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52346. width += tx;
  52347. } else {
  52348. var w1 = glyphWidth * textState.fontMatrix[0];
  52349. ty = w1 * textState.fontSize + charSpacing;
  52350. height += ty;
  52351. }
  52352. textState.translateTextMatrix(tx, ty);
  52353. textChunk.str.push(glyphUnicode);
  52354. }
  52355. if (!font.vertical) {
  52356. textChunk.lastAdvanceWidth = width;
  52357. textChunk.width += width;
  52358. } else {
  52359. textChunk.lastAdvanceHeight = height;
  52360. textChunk.height += Math.abs(height);
  52361. }
  52362. return textChunk;
  52363. }
  52364. function addFakeSpaces(width, strBuf) {
  52365. if (width < textContentItem.fakeSpaceMin) {
  52366. return;
  52367. }
  52368. if (width < textContentItem.fakeMultiSpaceMin) {
  52369. strBuf.push(' ');
  52370. return;
  52371. }
  52372. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52373. while (fakeSpaces-- > 0) {
  52374. strBuf.push(' ');
  52375. }
  52376. }
  52377. function flushTextContentItem() {
  52378. if (!textContentItem.initialized) {
  52379. return;
  52380. }
  52381. textContentItem.width *= textContentItem.textAdvanceScale;
  52382. textContentItem.height *= textContentItem.textAdvanceScale;
  52383. textContent.items.push(runBidiTransform(textContentItem));
  52384. textContentItem.initialized = false;
  52385. textContentItem.str.length = 0;
  52386. }
  52387. var timeSlotManager = new TimeSlotManager();
  52388. return new Promise(function promiseBody(resolve, reject) {
  52389. var next = function (promise) {
  52390. promise.then(function () {
  52391. try {
  52392. promiseBody(resolve, reject);
  52393. } catch (ex) {
  52394. reject(ex);
  52395. }
  52396. }, reject);
  52397. };
  52398. task.ensureNotTerminated();
  52399. timeSlotManager.reset();
  52400. var stop, operation = {}, args = [];
  52401. while (!(stop = timeSlotManager.check())) {
  52402. args.length = 0;
  52403. operation.args = args;
  52404. if (!preprocessor.read(operation)) {
  52405. break;
  52406. }
  52407. textState = stateManager.state;
  52408. var fn = operation.fn;
  52409. args = operation.args;
  52410. var advance, diff;
  52411. switch (fn | 0) {
  52412. case OPS.setFont:
  52413. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52414. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52415. break;
  52416. }
  52417. flushTextContentItem();
  52418. textState.fontName = fontNameArg;
  52419. textState.fontSize = fontSizeArg;
  52420. next(handleSetFont(fontNameArg, null));
  52421. return;
  52422. case OPS.setTextRise:
  52423. flushTextContentItem();
  52424. textState.textRise = args[0];
  52425. break;
  52426. case OPS.setHScale:
  52427. flushTextContentItem();
  52428. textState.textHScale = args[0] / 100;
  52429. break;
  52430. case OPS.setLeading:
  52431. flushTextContentItem();
  52432. textState.leading = args[0];
  52433. break;
  52434. case OPS.moveText:
  52435. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52436. advance = args[0] - args[1];
  52437. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52438. textState.translateTextLineMatrix(args[0], args[1]);
  52439. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52440. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52441. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52442. addFakeSpaces(diff, textContentItem.str);
  52443. break;
  52444. }
  52445. flushTextContentItem();
  52446. textState.translateTextLineMatrix(args[0], args[1]);
  52447. textState.textMatrix = textState.textLineMatrix.slice();
  52448. break;
  52449. case OPS.setLeadingMoveText:
  52450. flushTextContentItem();
  52451. textState.leading = -args[1];
  52452. textState.translateTextLineMatrix(args[0], args[1]);
  52453. textState.textMatrix = textState.textLineMatrix.slice();
  52454. break;
  52455. case OPS.nextLine:
  52456. flushTextContentItem();
  52457. textState.carriageReturn();
  52458. break;
  52459. case OPS.setTextMatrix:
  52460. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52461. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52462. textState.translateTextLineMatrix(advance.width, advance.height);
  52463. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52464. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52465. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52466. addFakeSpaces(diff, textContentItem.str);
  52467. break;
  52468. }
  52469. flushTextContentItem();
  52470. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52471. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52472. break;
  52473. case OPS.setCharSpacing:
  52474. textState.charSpacing = args[0];
  52475. break;
  52476. case OPS.setWordSpacing:
  52477. textState.wordSpacing = args[0];
  52478. break;
  52479. case OPS.beginText:
  52480. flushTextContentItem();
  52481. textState.textMatrix = IDENTITY_MATRIX.slice();
  52482. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52483. break;
  52484. case OPS.showSpacedText:
  52485. var items = args[0];
  52486. var offset;
  52487. for (var j = 0, jj = items.length; j < jj; j++) {
  52488. if (typeof items[j] === 'string') {
  52489. buildTextContentItem(items[j]);
  52490. } else if (isNum(items[j])) {
  52491. ensureTextContentItem();
  52492. advance = items[j] * textState.fontSize / 1000;
  52493. var breakTextRun = false;
  52494. if (textState.font.vertical) {
  52495. offset = advance;
  52496. textState.translateTextMatrix(0, offset);
  52497. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52498. if (!breakTextRun) {
  52499. textContentItem.height += offset;
  52500. }
  52501. } else {
  52502. advance = -advance;
  52503. offset = advance * textState.textHScale;
  52504. textState.translateTextMatrix(offset, 0);
  52505. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52506. if (!breakTextRun) {
  52507. textContentItem.width += offset;
  52508. }
  52509. }
  52510. if (breakTextRun) {
  52511. flushTextContentItem();
  52512. } else if (advance > 0) {
  52513. addFakeSpaces(advance, textContentItem.str);
  52514. }
  52515. }
  52516. }
  52517. break;
  52518. case OPS.showText:
  52519. buildTextContentItem(args[0]);
  52520. break;
  52521. case OPS.nextLineShowText:
  52522. flushTextContentItem();
  52523. textState.carriageReturn();
  52524. buildTextContentItem(args[0]);
  52525. break;
  52526. case OPS.nextLineSetSpacingShowText:
  52527. flushTextContentItem();
  52528. textState.wordSpacing = args[0];
  52529. textState.charSpacing = args[1];
  52530. textState.carriageReturn();
  52531. buildTextContentItem(args[2]);
  52532. break;
  52533. case OPS.paintXObject:
  52534. flushTextContentItem();
  52535. if (args[0].code) {
  52536. break;
  52537. }
  52538. if (!xobjs) {
  52539. xobjs = resources.get('XObject') || Dict.empty;
  52540. }
  52541. var name = args[0].name;
  52542. if (xobjsCache.key === name) {
  52543. if (xobjsCache.texts) {
  52544. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52545. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52546. }
  52547. break;
  52548. }
  52549. var xobj = xobjs.get(name);
  52550. if (!xobj) {
  52551. break;
  52552. }
  52553. assert(isStream(xobj), 'XObject should be a stream');
  52554. var type = xobj.dict.get('Subtype');
  52555. assert(isName(type), 'XObject should have a Name subtype');
  52556. if ('Form' !== type.name) {
  52557. xobjsCache.key = name;
  52558. xobjsCache.texts = null;
  52559. break;
  52560. }
  52561. stateManager.save();
  52562. var matrix = xobj.dict.getArray('Matrix');
  52563. if (isArray(matrix) && matrix.length === 6) {
  52564. stateManager.transform(matrix);
  52565. }
  52566. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52567. Util.appendToArray(textContent.items, formTextContent.items);
  52568. Util.extendObj(textContent.styles, formTextContent.styles);
  52569. stateManager.restore();
  52570. xobjsCache.key = name;
  52571. xobjsCache.texts = formTextContent;
  52572. }));
  52573. return;
  52574. case OPS.setGState:
  52575. flushTextContentItem();
  52576. var dictName = args[0];
  52577. var extGState = resources.get('ExtGState');
  52578. if (!isDict(extGState) || !isName(dictName)) {
  52579. break;
  52580. }
  52581. var gState = extGState.get(dictName.name);
  52582. if (!isDict(gState)) {
  52583. break;
  52584. }
  52585. var gStateFont = gState.get('Font');
  52586. if (gStateFont) {
  52587. textState.fontName = null;
  52588. textState.fontSize = gStateFont[1];
  52589. next(handleSetFont(null, gStateFont[0]));
  52590. return;
  52591. }
  52592. break;
  52593. }
  52594. }
  52595. if (stop) {
  52596. next(deferred);
  52597. return;
  52598. }
  52599. flushTextContentItem();
  52600. resolve(textContent);
  52601. });
  52602. },
  52603. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52604. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52605. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52606. if (properties.composite) {
  52607. var cidSystemInfo = dict.get('CIDSystemInfo');
  52608. if (isDict(cidSystemInfo)) {
  52609. properties.cidSystemInfo = {
  52610. registry: cidSystemInfo.get('Registry'),
  52611. ordering: cidSystemInfo.get('Ordering'),
  52612. supplement: cidSystemInfo.get('Supplement')
  52613. };
  52614. }
  52615. var cidToGidMap = dict.get('CIDToGIDMap');
  52616. if (isStream(cidToGidMap)) {
  52617. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52618. }
  52619. }
  52620. var differences = [];
  52621. var baseEncodingName = null;
  52622. var encoding;
  52623. if (dict.has('Encoding')) {
  52624. encoding = dict.get('Encoding');
  52625. if (isDict(encoding)) {
  52626. baseEncodingName = encoding.get('BaseEncoding');
  52627. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  52628. if (encoding.has('Differences')) {
  52629. var diffEncoding = encoding.get('Differences');
  52630. var index = 0;
  52631. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  52632. var data = xref.fetchIfRef(diffEncoding[j]);
  52633. if (isNum(data)) {
  52634. index = data;
  52635. } else if (isName(data)) {
  52636. differences[index++] = data.name;
  52637. } else {
  52638. error('Invalid entry in \'Differences\' array: ' + data);
  52639. }
  52640. }
  52641. }
  52642. } else if (isName(encoding)) {
  52643. baseEncodingName = encoding.name;
  52644. } else {
  52645. error('Encoding is not a Name nor a Dict');
  52646. }
  52647. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  52648. baseEncodingName = null;
  52649. }
  52650. }
  52651. if (baseEncodingName) {
  52652. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  52653. } else {
  52654. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  52655. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  52656. encoding = StandardEncoding;
  52657. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  52658. encoding = WinAnsiEncoding;
  52659. }
  52660. if (isSymbolicFont) {
  52661. encoding = MacRomanEncoding;
  52662. if (!properties.file) {
  52663. if (/Symbol/i.test(properties.name)) {
  52664. encoding = SymbolSetEncoding;
  52665. } else if (/Dingbats/i.test(properties.name)) {
  52666. encoding = ZapfDingbatsEncoding;
  52667. }
  52668. }
  52669. }
  52670. properties.defaultEncoding = encoding;
  52671. }
  52672. properties.differences = differences;
  52673. properties.baseEncodingName = baseEncodingName;
  52674. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  52675. properties.dict = dict;
  52676. return toUnicodePromise.then(function (toUnicode) {
  52677. properties.toUnicode = toUnicode;
  52678. return this.buildToUnicode(properties);
  52679. }.bind(this)).then(function (toUnicode) {
  52680. properties.toUnicode = toUnicode;
  52681. return properties;
  52682. });
  52683. },
  52684. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  52685. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  52686. if (properties.hasIncludedToUnicodeMap) {
  52687. return Promise.resolve(properties.toUnicode);
  52688. }
  52689. var toUnicode, charcode, glyphName;
  52690. if (!properties.composite)
  52691. {
  52692. toUnicode = [];
  52693. var encoding = properties.defaultEncoding.slice();
  52694. var baseEncodingName = properties.baseEncodingName;
  52695. var differences = properties.differences;
  52696. for (charcode in differences) {
  52697. glyphName = differences[charcode];
  52698. if (glyphName === '.notdef') {
  52699. continue;
  52700. }
  52701. encoding[charcode] = glyphName;
  52702. }
  52703. var glyphsUnicodeMap = getGlyphsUnicode();
  52704. for (charcode in encoding) {
  52705. glyphName = encoding[charcode];
  52706. if (glyphName === '') {
  52707. continue;
  52708. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  52709. var code = 0;
  52710. switch (glyphName[0]) {
  52711. case 'G':
  52712. if (glyphName.length === 3) {
  52713. code = parseInt(glyphName.substr(1), 16);
  52714. }
  52715. break;
  52716. case 'g':
  52717. if (glyphName.length === 5) {
  52718. code = parseInt(glyphName.substr(1), 16);
  52719. }
  52720. break;
  52721. case 'C':
  52722. case 'c':
  52723. if (glyphName.length >= 3) {
  52724. code = +glyphName.substr(1);
  52725. }
  52726. break;
  52727. default:
  52728. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  52729. if (unicode !== -1) {
  52730. code = unicode;
  52731. }
  52732. }
  52733. if (code) {
  52734. if (baseEncodingName && code === +charcode) {
  52735. var baseEncoding = getEncoding(baseEncodingName);
  52736. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  52737. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52738. continue;
  52739. }
  52740. }
  52741. toUnicode[charcode] = String.fromCharCode(code);
  52742. }
  52743. continue;
  52744. }
  52745. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52746. }
  52747. return Promise.resolve(new ToUnicodeMap(toUnicode));
  52748. }
  52749. if (properties.composite && (properties.cMap.builtInCMap && !(properties.cMap instanceof IdentityCMap) || properties.cidSystemInfo.registry === 'Adobe' && (properties.cidSystemInfo.ordering === 'GB1' || properties.cidSystemInfo.ordering === 'CNS1' || properties.cidSystemInfo.ordering === 'Japan1' || properties.cidSystemInfo.ordering === 'Korea1'))) {
  52750. var registry = properties.cidSystemInfo.registry;
  52751. var ordering = properties.cidSystemInfo.ordering;
  52752. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  52753. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  52754. var cMap = properties.cMap;
  52755. toUnicode = [];
  52756. cMap.forEach(function (charcode, cid) {
  52757. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  52758. var ucs2 = ucs2CMap.lookup(cid);
  52759. if (ucs2) {
  52760. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  52761. }
  52762. });
  52763. return new ToUnicodeMap(toUnicode);
  52764. });
  52765. }
  52766. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  52767. },
  52768. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  52769. var cmapObj = toUnicode;
  52770. if (isName(cmapObj)) {
  52771. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  52772. if (cmap instanceof IdentityCMap) {
  52773. return new IdentityToUnicodeMap(0, 0xFFFF);
  52774. }
  52775. return new ToUnicodeMap(cmap.getMap());
  52776. });
  52777. } else if (isStream(cmapObj)) {
  52778. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  52779. if (cmap instanceof IdentityCMap) {
  52780. return new IdentityToUnicodeMap(0, 0xFFFF);
  52781. }
  52782. var map = new Array(cmap.length);
  52783. cmap.forEach(function (charCode, token) {
  52784. var str = [];
  52785. for (var k = 0; k < token.length; k += 2) {
  52786. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  52787. if ((w1 & 0xF800) !== 0xD800) {
  52788. str.push(w1);
  52789. continue;
  52790. }
  52791. k += 2;
  52792. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  52793. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  52794. }
  52795. map[charCode] = String.fromCharCode.apply(String, str);
  52796. });
  52797. return new ToUnicodeMap(map);
  52798. });
  52799. }
  52800. return Promise.resolve(null);
  52801. },
  52802. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  52803. var glyphsData = cidToGidStream.getBytes();
  52804. var result = [];
  52805. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  52806. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  52807. if (glyphID === 0) {
  52808. continue;
  52809. }
  52810. var code = j >> 1;
  52811. result[code] = glyphID;
  52812. }
  52813. return result;
  52814. },
  52815. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  52816. var glyphsWidths = [];
  52817. var defaultWidth = 0;
  52818. var glyphsVMetrics = [];
  52819. var defaultVMetrics;
  52820. var i, ii, j, jj, start, code, widths;
  52821. if (properties.composite) {
  52822. defaultWidth = dict.get('DW') || 1000;
  52823. widths = dict.get('W');
  52824. if (widths) {
  52825. for (i = 0, ii = widths.length; i < ii; i++) {
  52826. start = xref.fetchIfRef(widths[i++]);
  52827. code = xref.fetchIfRef(widths[i]);
  52828. if (isArray(code)) {
  52829. for (j = 0, jj = code.length; j < jj; j++) {
  52830. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  52831. }
  52832. } else {
  52833. var width = xref.fetchIfRef(widths[++i]);
  52834. for (j = start; j <= code; j++) {
  52835. glyphsWidths[j] = width;
  52836. }
  52837. }
  52838. }
  52839. }
  52840. if (properties.vertical) {
  52841. var vmetrics = dict.getArray('DW2') || [
  52842. 880,
  52843. -1000
  52844. ];
  52845. defaultVMetrics = [
  52846. vmetrics[1],
  52847. defaultWidth * 0.5,
  52848. vmetrics[0]
  52849. ];
  52850. vmetrics = dict.get('W2');
  52851. if (vmetrics) {
  52852. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  52853. start = xref.fetchIfRef(vmetrics[i++]);
  52854. code = xref.fetchIfRef(vmetrics[i]);
  52855. if (isArray(code)) {
  52856. for (j = 0, jj = code.length; j < jj; j++) {
  52857. glyphsVMetrics[start++] = [
  52858. xref.fetchIfRef(code[j++]),
  52859. xref.fetchIfRef(code[j++]),
  52860. xref.fetchIfRef(code[j])
  52861. ];
  52862. }
  52863. } else {
  52864. var vmetric = [
  52865. xref.fetchIfRef(vmetrics[++i]),
  52866. xref.fetchIfRef(vmetrics[++i]),
  52867. xref.fetchIfRef(vmetrics[++i])
  52868. ];
  52869. for (j = start; j <= code; j++) {
  52870. glyphsVMetrics[j] = vmetric;
  52871. }
  52872. }
  52873. }
  52874. }
  52875. }
  52876. } else {
  52877. var firstChar = properties.firstChar;
  52878. widths = dict.get('Widths');
  52879. if (widths) {
  52880. j = firstChar;
  52881. for (i = 0, ii = widths.length; i < ii; i++) {
  52882. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  52883. }
  52884. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  52885. } else {
  52886. var baseFontName = dict.get('BaseFont');
  52887. if (isName(baseFontName)) {
  52888. var metrics = this.getBaseFontMetrics(baseFontName.name);
  52889. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  52890. defaultWidth = metrics.defaultWidth;
  52891. }
  52892. }
  52893. }
  52894. var isMonospace = true;
  52895. var firstWidth = defaultWidth;
  52896. for (var glyph in glyphsWidths) {
  52897. var glyphWidth = glyphsWidths[glyph];
  52898. if (!glyphWidth) {
  52899. continue;
  52900. }
  52901. if (!firstWidth) {
  52902. firstWidth = glyphWidth;
  52903. continue;
  52904. }
  52905. if (firstWidth !== glyphWidth) {
  52906. isMonospace = false;
  52907. break;
  52908. }
  52909. }
  52910. if (isMonospace) {
  52911. properties.flags |= FontFlags.FixedPitch;
  52912. }
  52913. properties.defaultWidth = defaultWidth;
  52914. properties.widths = glyphsWidths;
  52915. properties.defaultVMetrics = defaultVMetrics;
  52916. properties.vmetrics = glyphsVMetrics;
  52917. },
  52918. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  52919. var fontNameWoStyle = baseFontName.split('-')[0];
  52920. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  52921. },
  52922. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  52923. var defaultWidth = 0;
  52924. var widths = [];
  52925. var monospace = false;
  52926. var stdFontMap = getStdFontMap();
  52927. var lookupName = stdFontMap[name] || name;
  52928. var Metrics = getMetrics();
  52929. if (!(lookupName in Metrics)) {
  52930. if (this.isSerifFont(name)) {
  52931. lookupName = 'Times-Roman';
  52932. } else {
  52933. lookupName = 'Helvetica';
  52934. }
  52935. }
  52936. var glyphWidths = Metrics[lookupName];
  52937. if (isNum(glyphWidths)) {
  52938. defaultWidth = glyphWidths;
  52939. monospace = true;
  52940. } else {
  52941. widths = glyphWidths();
  52942. }
  52943. return {
  52944. defaultWidth: defaultWidth,
  52945. monospace: monospace,
  52946. widths: widths
  52947. };
  52948. },
  52949. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  52950. var widths = Object.create(null);
  52951. var differences = properties.differences;
  52952. var encoding = properties.defaultEncoding;
  52953. for (var charCode = 0; charCode < 256; charCode++) {
  52954. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  52955. widths[charCode] = widthsByGlyphName[differences[charCode]];
  52956. continue;
  52957. }
  52958. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  52959. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  52960. continue;
  52961. }
  52962. }
  52963. return widths;
  52964. },
  52965. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  52966. var baseDict = dict;
  52967. var type = dict.get('Subtype');
  52968. assert(isName(type), 'invalid font Subtype');
  52969. var composite = false;
  52970. var uint8array;
  52971. if (type.name === 'Type0') {
  52972. var df = dict.get('DescendantFonts');
  52973. if (!df) {
  52974. error('Descendant fonts are not specified');
  52975. }
  52976. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  52977. type = dict.get('Subtype');
  52978. assert(isName(type), 'invalid font Subtype');
  52979. composite = true;
  52980. }
  52981. var descriptor = dict.get('FontDescriptor');
  52982. if (descriptor) {
  52983. var hash = new MurmurHash3_64();
  52984. var encoding = baseDict.getRaw('Encoding');
  52985. if (isName(encoding)) {
  52986. hash.update(encoding.name);
  52987. } else if (isRef(encoding)) {
  52988. hash.update(encoding.toString());
  52989. } else if (isDict(encoding)) {
  52990. var keys = encoding.getKeys();
  52991. for (var i = 0, ii = keys.length; i < ii; i++) {
  52992. var entry = encoding.getRaw(keys[i]);
  52993. if (isName(entry)) {
  52994. hash.update(entry.name);
  52995. } else if (isRef(entry)) {
  52996. hash.update(entry.toString());
  52997. } else if (isArray(entry)) {
  52998. var diffLength = entry.length, diffBuf = new Array(diffLength);
  52999. for (var j = 0; j < diffLength; j++) {
  53000. var diffEntry = entry[j];
  53001. if (isName(diffEntry)) {
  53002. diffBuf[j] = diffEntry.name;
  53003. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  53004. diffBuf[j] = diffEntry.toString();
  53005. }
  53006. }
  53007. hash.update(diffBuf.join());
  53008. }
  53009. }
  53010. }
  53011. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53012. if (isStream(toUnicode)) {
  53013. var stream = toUnicode.str || toUnicode;
  53014. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53015. hash.update(uint8array);
  53016. } else if (isName(toUnicode)) {
  53017. hash.update(toUnicode.name);
  53018. }
  53019. var widths = dict.get('Widths') || baseDict.get('Widths');
  53020. if (widths) {
  53021. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53022. hash.update(uint8array);
  53023. }
  53024. }
  53025. return {
  53026. descriptor: descriptor,
  53027. dict: dict,
  53028. baseDict: baseDict,
  53029. composite: composite,
  53030. type: type.name,
  53031. hash: hash ? hash.hexdigest() : ''
  53032. };
  53033. },
  53034. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53035. var baseDict = preEvaluatedFont.baseDict;
  53036. var dict = preEvaluatedFont.dict;
  53037. var composite = preEvaluatedFont.composite;
  53038. var descriptor = preEvaluatedFont.descriptor;
  53039. var type = preEvaluatedFont.type;
  53040. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53041. var cMapOptions = this.options.cMapOptions;
  53042. var properties;
  53043. if (!descriptor) {
  53044. if (type === 'Type3') {
  53045. descriptor = new Dict(null);
  53046. descriptor.set('FontName', Name.get(type));
  53047. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53048. } else {
  53049. var baseFontName = dict.get('BaseFont');
  53050. if (!isName(baseFontName)) {
  53051. error('Base font is not specified');
  53052. }
  53053. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53054. var metrics = this.getBaseFontMetrics(baseFontName);
  53055. var fontNameWoStyle = baseFontName.split('-')[0];
  53056. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53057. properties = {
  53058. type: type,
  53059. name: baseFontName,
  53060. widths: metrics.widths,
  53061. defaultWidth: metrics.defaultWidth,
  53062. flags: flags,
  53063. firstChar: 0,
  53064. lastChar: maxCharIndex
  53065. };
  53066. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53067. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53068. return new Font(baseFontName, null, properties);
  53069. }.bind(this));
  53070. }
  53071. }
  53072. var firstChar = dict.get('FirstChar') || 0;
  53073. var lastChar = dict.get('LastChar') || maxCharIndex;
  53074. var fontName = descriptor.get('FontName');
  53075. var baseFont = dict.get('BaseFont');
  53076. if (isString(fontName)) {
  53077. fontName = Name.get(fontName);
  53078. }
  53079. if (isString(baseFont)) {
  53080. baseFont = Name.get(baseFont);
  53081. }
  53082. if (type !== 'Type3') {
  53083. var fontNameStr = fontName && fontName.name;
  53084. var baseFontStr = baseFont && baseFont.name;
  53085. if (fontNameStr !== baseFontStr) {
  53086. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53087. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53088. fontName = baseFont;
  53089. }
  53090. }
  53091. }
  53092. fontName = fontName || baseFont;
  53093. assert(isName(fontName), 'invalid font name');
  53094. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53095. if (fontFile) {
  53096. if (fontFile.dict) {
  53097. var subtype = fontFile.dict.get('Subtype');
  53098. if (subtype) {
  53099. subtype = subtype.name;
  53100. }
  53101. var length1 = fontFile.dict.get('Length1');
  53102. var length2 = fontFile.dict.get('Length2');
  53103. var length3 = fontFile.dict.get('Length3');
  53104. }
  53105. }
  53106. properties = {
  53107. type: type,
  53108. name: fontName.name,
  53109. subtype: subtype,
  53110. file: fontFile,
  53111. length1: length1,
  53112. length2: length2,
  53113. length3: length3,
  53114. loadedName: baseDict.loadedName,
  53115. composite: composite,
  53116. wideChars: composite,
  53117. fixedPitch: false,
  53118. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53119. firstChar: firstChar || 0,
  53120. lastChar: lastChar || maxCharIndex,
  53121. bbox: descriptor.getArray('FontBBox'),
  53122. ascent: descriptor.get('Ascent'),
  53123. descent: descriptor.get('Descent'),
  53124. xHeight: descriptor.get('XHeight'),
  53125. capHeight: descriptor.get('CapHeight'),
  53126. flags: descriptor.get('Flags'),
  53127. italicAngle: descriptor.get('ItalicAngle'),
  53128. coded: false
  53129. };
  53130. var cMapPromise;
  53131. if (composite) {
  53132. var cidEncoding = baseDict.get('Encoding');
  53133. if (isName(cidEncoding)) {
  53134. properties.cidEncoding = cidEncoding.name;
  53135. }
  53136. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53137. properties.cMap = cMap;
  53138. properties.vertical = properties.cMap.vertical;
  53139. });
  53140. } else {
  53141. cMapPromise = Promise.resolve(undefined);
  53142. }
  53143. return cMapPromise.then(function () {
  53144. return this.extractDataStructures(dict, baseDict, xref, properties);
  53145. }.bind(this)).then(function (properties) {
  53146. this.extractWidths(dict, xref, descriptor, properties);
  53147. if (type === 'Type3') {
  53148. properties.isType3Font = true;
  53149. }
  53150. return new Font(fontName.name, fontFile, properties);
  53151. }.bind(this));
  53152. }
  53153. };
  53154. return PartialEvaluator;
  53155. }();
  53156. var TranslatedFont = function TranslatedFontClosure() {
  53157. function TranslatedFont(loadedName, font, dict) {
  53158. this.loadedName = loadedName;
  53159. this.font = font;
  53160. this.dict = dict;
  53161. this.type3Loaded = null;
  53162. this.sent = false;
  53163. }
  53164. TranslatedFont.prototype = {
  53165. send: function (handler) {
  53166. if (this.sent) {
  53167. return;
  53168. }
  53169. var fontData = this.font.exportData();
  53170. handler.send('commonobj', [
  53171. this.loadedName,
  53172. 'Font',
  53173. fontData
  53174. ]);
  53175. this.sent = true;
  53176. },
  53177. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53178. assert(this.font.isType3Font);
  53179. if (this.type3Loaded) {
  53180. return this.type3Loaded;
  53181. }
  53182. var translatedFont = this.font;
  53183. var loadCharProcsPromise = Promise.resolve();
  53184. var charProcs = this.dict.get('CharProcs');
  53185. var fontResources = this.dict.get('Resources') || resources;
  53186. var charProcKeys = charProcs.getKeys();
  53187. var charProcOperatorList = Object.create(null);
  53188. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53189. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53190. var glyphStream = charProcs.get(key);
  53191. var operatorList = new OperatorList();
  53192. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53193. charProcOperatorList[key] = operatorList.getIR();
  53194. parentOperatorList.addDependencies(operatorList.dependencies);
  53195. }, function (reason) {
  53196. warn('Type3 font resource \"' + key + '\" is not available');
  53197. var operatorList = new OperatorList();
  53198. charProcOperatorList[key] = operatorList.getIR();
  53199. });
  53200. }.bind(this, charProcKeys[i]));
  53201. }
  53202. this.type3Loaded = loadCharProcsPromise.then(function () {
  53203. translatedFont.charProcOperatorList = charProcOperatorList;
  53204. });
  53205. return this.type3Loaded;
  53206. }
  53207. };
  53208. return TranslatedFont;
  53209. }();
  53210. var OperatorList = function OperatorListClosure() {
  53211. var CHUNK_SIZE = 1000;
  53212. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53213. function getTransfers(queue) {
  53214. var transfers = [];
  53215. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53216. for (var i = 0, ii = queue.length; i < ii; i++) {
  53217. switch (fnArray[i]) {
  53218. case OPS.paintInlineImageXObject:
  53219. case OPS.paintInlineImageXObjectGroup:
  53220. case OPS.paintImageMaskXObject:
  53221. var arg = argsArray[i][0];
  53222. if (!arg.cached) {
  53223. transfers.push(arg.data.buffer);
  53224. }
  53225. break;
  53226. }
  53227. }
  53228. return transfers;
  53229. }
  53230. function OperatorList(intent, messageHandler, pageIndex) {
  53231. this.messageHandler = messageHandler;
  53232. this.fnArray = [];
  53233. this.argsArray = [];
  53234. this.dependencies = Object.create(null);
  53235. this._totalLength = 0;
  53236. this.pageIndex = pageIndex;
  53237. this.intent = intent;
  53238. }
  53239. OperatorList.prototype = {
  53240. get length() {
  53241. return this.argsArray.length;
  53242. },
  53243. get totalLength() {
  53244. return this._totalLength + this.length;
  53245. },
  53246. addOp: function (fn, args) {
  53247. this.fnArray.push(fn);
  53248. this.argsArray.push(args);
  53249. if (this.messageHandler) {
  53250. if (this.fnArray.length >= CHUNK_SIZE) {
  53251. this.flush();
  53252. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53253. this.flush();
  53254. }
  53255. }
  53256. },
  53257. addDependency: function (dependency) {
  53258. if (dependency in this.dependencies) {
  53259. return;
  53260. }
  53261. this.dependencies[dependency] = true;
  53262. this.addOp(OPS.dependency, [dependency]);
  53263. },
  53264. addDependencies: function (dependencies) {
  53265. for (var key in dependencies) {
  53266. this.addDependency(key);
  53267. }
  53268. },
  53269. addOpList: function (opList) {
  53270. Util.extendObj(this.dependencies, opList.dependencies);
  53271. for (var i = 0, ii = opList.length; i < ii; i++) {
  53272. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53273. }
  53274. },
  53275. getIR: function () {
  53276. return {
  53277. fnArray: this.fnArray,
  53278. argsArray: this.argsArray,
  53279. length: this.length
  53280. };
  53281. },
  53282. flush: function (lastChunk) {
  53283. if (this.intent !== 'oplist') {
  53284. new QueueOptimizer().optimize(this);
  53285. }
  53286. var transfers = getTransfers(this);
  53287. var length = this.length;
  53288. this._totalLength += length;
  53289. this.messageHandler.send('RenderPageChunk', {
  53290. operatorList: {
  53291. fnArray: this.fnArray,
  53292. argsArray: this.argsArray,
  53293. lastChunk: lastChunk,
  53294. length: length
  53295. },
  53296. pageIndex: this.pageIndex,
  53297. intent: this.intent
  53298. }, transfers);
  53299. this.dependencies = Object.create(null);
  53300. this.fnArray.length = 0;
  53301. this.argsArray.length = 0;
  53302. }
  53303. };
  53304. return OperatorList;
  53305. }();
  53306. var StateManager = function StateManagerClosure() {
  53307. function StateManager(initialState) {
  53308. this.state = initialState;
  53309. this.stateStack = [];
  53310. }
  53311. StateManager.prototype = {
  53312. save: function () {
  53313. var old = this.state;
  53314. this.stateStack.push(this.state);
  53315. this.state = old.clone();
  53316. },
  53317. restore: function () {
  53318. var prev = this.stateStack.pop();
  53319. if (prev) {
  53320. this.state = prev;
  53321. }
  53322. },
  53323. transform: function (args) {
  53324. this.state.ctm = Util.transform(this.state.ctm, args);
  53325. }
  53326. };
  53327. return StateManager;
  53328. }();
  53329. var TextState = function TextStateClosure() {
  53330. function TextState() {
  53331. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53332. this.fontName = null;
  53333. this.fontSize = 0;
  53334. this.font = null;
  53335. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53336. this.textMatrix = IDENTITY_MATRIX.slice();
  53337. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53338. this.charSpacing = 0;
  53339. this.wordSpacing = 0;
  53340. this.leading = 0;
  53341. this.textHScale = 1;
  53342. this.textRise = 0;
  53343. }
  53344. TextState.prototype = {
  53345. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53346. var m = this.textMatrix;
  53347. m[0] = a;
  53348. m[1] = b;
  53349. m[2] = c;
  53350. m[3] = d;
  53351. m[4] = e;
  53352. m[5] = f;
  53353. },
  53354. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53355. var m = this.textLineMatrix;
  53356. m[0] = a;
  53357. m[1] = b;
  53358. m[2] = c;
  53359. m[3] = d;
  53360. m[4] = e;
  53361. m[5] = f;
  53362. },
  53363. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53364. var m = this.textMatrix;
  53365. m[4] = m[0] * x + m[2] * y + m[4];
  53366. m[5] = m[1] * x + m[3] * y + m[5];
  53367. },
  53368. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53369. var m = this.textLineMatrix;
  53370. m[4] = m[0] * x + m[2] * y + m[4];
  53371. m[5] = m[1] * x + m[3] * y + m[5];
  53372. },
  53373. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53374. var font = this.font;
  53375. if (!font) {
  53376. return null;
  53377. }
  53378. var m = this.textLineMatrix;
  53379. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53380. return null;
  53381. }
  53382. var txDiff = e - m[4], tyDiff = f - m[5];
  53383. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53384. return null;
  53385. }
  53386. var tx, ty, denominator = a * d - b * c;
  53387. if (font.vertical) {
  53388. tx = -tyDiff * c / denominator;
  53389. ty = tyDiff * a / denominator;
  53390. } else {
  53391. tx = txDiff * d / denominator;
  53392. ty = -txDiff * b / denominator;
  53393. }
  53394. return {
  53395. width: tx,
  53396. height: ty,
  53397. value: font.vertical ? ty : tx
  53398. };
  53399. },
  53400. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53401. var tsm = [
  53402. this.fontSize * this.textHScale,
  53403. 0,
  53404. 0,
  53405. this.fontSize,
  53406. 0,
  53407. this.textRise
  53408. ];
  53409. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53410. },
  53411. carriageReturn: function TextState_carriageReturn() {
  53412. this.translateTextLineMatrix(0, -this.leading);
  53413. this.textMatrix = this.textLineMatrix.slice();
  53414. },
  53415. clone: function TextState_clone() {
  53416. var clone = Object.create(this);
  53417. clone.textMatrix = this.textMatrix.slice();
  53418. clone.textLineMatrix = this.textLineMatrix.slice();
  53419. clone.fontMatrix = this.fontMatrix.slice();
  53420. return clone;
  53421. }
  53422. };
  53423. return TextState;
  53424. }();
  53425. var EvalState = function EvalStateClosure() {
  53426. function EvalState() {
  53427. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53428. this.font = null;
  53429. this.textRenderingMode = TextRenderingMode.FILL;
  53430. this.fillColorSpace = ColorSpace.singletons.gray;
  53431. this.strokeColorSpace = ColorSpace.singletons.gray;
  53432. }
  53433. EvalState.prototype = {
  53434. clone: function CanvasExtraState_clone() {
  53435. return Object.create(this);
  53436. }
  53437. };
  53438. return EvalState;
  53439. }();
  53440. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53441. var getOPMap = getLookupTableFactory(function (t) {
  53442. t['w'] = {
  53443. id: OPS.setLineWidth,
  53444. numArgs: 1,
  53445. variableArgs: false
  53446. };
  53447. t['J'] = {
  53448. id: OPS.setLineCap,
  53449. numArgs: 1,
  53450. variableArgs: false
  53451. };
  53452. t['j'] = {
  53453. id: OPS.setLineJoin,
  53454. numArgs: 1,
  53455. variableArgs: false
  53456. };
  53457. t['M'] = {
  53458. id: OPS.setMiterLimit,
  53459. numArgs: 1,
  53460. variableArgs: false
  53461. };
  53462. t['d'] = {
  53463. id: OPS.setDash,
  53464. numArgs: 2,
  53465. variableArgs: false
  53466. };
  53467. t['ri'] = {
  53468. id: OPS.setRenderingIntent,
  53469. numArgs: 1,
  53470. variableArgs: false
  53471. };
  53472. t['i'] = {
  53473. id: OPS.setFlatness,
  53474. numArgs: 1,
  53475. variableArgs: false
  53476. };
  53477. t['gs'] = {
  53478. id: OPS.setGState,
  53479. numArgs: 1,
  53480. variableArgs: false
  53481. };
  53482. t['q'] = {
  53483. id: OPS.save,
  53484. numArgs: 0,
  53485. variableArgs: false
  53486. };
  53487. t['Q'] = {
  53488. id: OPS.restore,
  53489. numArgs: 0,
  53490. variableArgs: false
  53491. };
  53492. t['cm'] = {
  53493. id: OPS.transform,
  53494. numArgs: 6,
  53495. variableArgs: false
  53496. };
  53497. t['m'] = {
  53498. id: OPS.moveTo,
  53499. numArgs: 2,
  53500. variableArgs: false
  53501. };
  53502. t['l'] = {
  53503. id: OPS.lineTo,
  53504. numArgs: 2,
  53505. variableArgs: false
  53506. };
  53507. t['c'] = {
  53508. id: OPS.curveTo,
  53509. numArgs: 6,
  53510. variableArgs: false
  53511. };
  53512. t['v'] = {
  53513. id: OPS.curveTo2,
  53514. numArgs: 4,
  53515. variableArgs: false
  53516. };
  53517. t['y'] = {
  53518. id: OPS.curveTo3,
  53519. numArgs: 4,
  53520. variableArgs: false
  53521. };
  53522. t['h'] = {
  53523. id: OPS.closePath,
  53524. numArgs: 0,
  53525. variableArgs: false
  53526. };
  53527. t['re'] = {
  53528. id: OPS.rectangle,
  53529. numArgs: 4,
  53530. variableArgs: false
  53531. };
  53532. t['S'] = {
  53533. id: OPS.stroke,
  53534. numArgs: 0,
  53535. variableArgs: false
  53536. };
  53537. t['s'] = {
  53538. id: OPS.closeStroke,
  53539. numArgs: 0,
  53540. variableArgs: false
  53541. };
  53542. t['f'] = {
  53543. id: OPS.fill,
  53544. numArgs: 0,
  53545. variableArgs: false
  53546. };
  53547. t['F'] = {
  53548. id: OPS.fill,
  53549. numArgs: 0,
  53550. variableArgs: false
  53551. };
  53552. t['f*'] = {
  53553. id: OPS.eoFill,
  53554. numArgs: 0,
  53555. variableArgs: false
  53556. };
  53557. t['B'] = {
  53558. id: OPS.fillStroke,
  53559. numArgs: 0,
  53560. variableArgs: false
  53561. };
  53562. t['B*'] = {
  53563. id: OPS.eoFillStroke,
  53564. numArgs: 0,
  53565. variableArgs: false
  53566. };
  53567. t['b'] = {
  53568. id: OPS.closeFillStroke,
  53569. numArgs: 0,
  53570. variableArgs: false
  53571. };
  53572. t['b*'] = {
  53573. id: OPS.closeEOFillStroke,
  53574. numArgs: 0,
  53575. variableArgs: false
  53576. };
  53577. t['n'] = {
  53578. id: OPS.endPath,
  53579. numArgs: 0,
  53580. variableArgs: false
  53581. };
  53582. t['W'] = {
  53583. id: OPS.clip,
  53584. numArgs: 0,
  53585. variableArgs: false
  53586. };
  53587. t['W*'] = {
  53588. id: OPS.eoClip,
  53589. numArgs: 0,
  53590. variableArgs: false
  53591. };
  53592. t['BT'] = {
  53593. id: OPS.beginText,
  53594. numArgs: 0,
  53595. variableArgs: false
  53596. };
  53597. t['ET'] = {
  53598. id: OPS.endText,
  53599. numArgs: 0,
  53600. variableArgs: false
  53601. };
  53602. t['Tc'] = {
  53603. id: OPS.setCharSpacing,
  53604. numArgs: 1,
  53605. variableArgs: false
  53606. };
  53607. t['Tw'] = {
  53608. id: OPS.setWordSpacing,
  53609. numArgs: 1,
  53610. variableArgs: false
  53611. };
  53612. t['Tz'] = {
  53613. id: OPS.setHScale,
  53614. numArgs: 1,
  53615. variableArgs: false
  53616. };
  53617. t['TL'] = {
  53618. id: OPS.setLeading,
  53619. numArgs: 1,
  53620. variableArgs: false
  53621. };
  53622. t['Tf'] = {
  53623. id: OPS.setFont,
  53624. numArgs: 2,
  53625. variableArgs: false
  53626. };
  53627. t['Tr'] = {
  53628. id: OPS.setTextRenderingMode,
  53629. numArgs: 1,
  53630. variableArgs: false
  53631. };
  53632. t['Ts'] = {
  53633. id: OPS.setTextRise,
  53634. numArgs: 1,
  53635. variableArgs: false
  53636. };
  53637. t['Td'] = {
  53638. id: OPS.moveText,
  53639. numArgs: 2,
  53640. variableArgs: false
  53641. };
  53642. t['TD'] = {
  53643. id: OPS.setLeadingMoveText,
  53644. numArgs: 2,
  53645. variableArgs: false
  53646. };
  53647. t['Tm'] = {
  53648. id: OPS.setTextMatrix,
  53649. numArgs: 6,
  53650. variableArgs: false
  53651. };
  53652. t['T*'] = {
  53653. id: OPS.nextLine,
  53654. numArgs: 0,
  53655. variableArgs: false
  53656. };
  53657. t['Tj'] = {
  53658. id: OPS.showText,
  53659. numArgs: 1,
  53660. variableArgs: false
  53661. };
  53662. t['TJ'] = {
  53663. id: OPS.showSpacedText,
  53664. numArgs: 1,
  53665. variableArgs: false
  53666. };
  53667. t['\''] = {
  53668. id: OPS.nextLineShowText,
  53669. numArgs: 1,
  53670. variableArgs: false
  53671. };
  53672. t['"'] = {
  53673. id: OPS.nextLineSetSpacingShowText,
  53674. numArgs: 3,
  53675. variableArgs: false
  53676. };
  53677. t['d0'] = {
  53678. id: OPS.setCharWidth,
  53679. numArgs: 2,
  53680. variableArgs: false
  53681. };
  53682. t['d1'] = {
  53683. id: OPS.setCharWidthAndBounds,
  53684. numArgs: 6,
  53685. variableArgs: false
  53686. };
  53687. t['CS'] = {
  53688. id: OPS.setStrokeColorSpace,
  53689. numArgs: 1,
  53690. variableArgs: false
  53691. };
  53692. t['cs'] = {
  53693. id: OPS.setFillColorSpace,
  53694. numArgs: 1,
  53695. variableArgs: false
  53696. };
  53697. t['SC'] = {
  53698. id: OPS.setStrokeColor,
  53699. numArgs: 4,
  53700. variableArgs: true
  53701. };
  53702. t['SCN'] = {
  53703. id: OPS.setStrokeColorN,
  53704. numArgs: 33,
  53705. variableArgs: true
  53706. };
  53707. t['sc'] = {
  53708. id: OPS.setFillColor,
  53709. numArgs: 4,
  53710. variableArgs: true
  53711. };
  53712. t['scn'] = {
  53713. id: OPS.setFillColorN,
  53714. numArgs: 33,
  53715. variableArgs: true
  53716. };
  53717. t['G'] = {
  53718. id: OPS.setStrokeGray,
  53719. numArgs: 1,
  53720. variableArgs: false
  53721. };
  53722. t['g'] = {
  53723. id: OPS.setFillGray,
  53724. numArgs: 1,
  53725. variableArgs: false
  53726. };
  53727. t['RG'] = {
  53728. id: OPS.setStrokeRGBColor,
  53729. numArgs: 3,
  53730. variableArgs: false
  53731. };
  53732. t['rg'] = {
  53733. id: OPS.setFillRGBColor,
  53734. numArgs: 3,
  53735. variableArgs: false
  53736. };
  53737. t['K'] = {
  53738. id: OPS.setStrokeCMYKColor,
  53739. numArgs: 4,
  53740. variableArgs: false
  53741. };
  53742. t['k'] = {
  53743. id: OPS.setFillCMYKColor,
  53744. numArgs: 4,
  53745. variableArgs: false
  53746. };
  53747. t['sh'] = {
  53748. id: OPS.shadingFill,
  53749. numArgs: 1,
  53750. variableArgs: false
  53751. };
  53752. t['BI'] = {
  53753. id: OPS.beginInlineImage,
  53754. numArgs: 0,
  53755. variableArgs: false
  53756. };
  53757. t['ID'] = {
  53758. id: OPS.beginImageData,
  53759. numArgs: 0,
  53760. variableArgs: false
  53761. };
  53762. t['EI'] = {
  53763. id: OPS.endInlineImage,
  53764. numArgs: 1,
  53765. variableArgs: false
  53766. };
  53767. t['Do'] = {
  53768. id: OPS.paintXObject,
  53769. numArgs: 1,
  53770. variableArgs: false
  53771. };
  53772. t['MP'] = {
  53773. id: OPS.markPoint,
  53774. numArgs: 1,
  53775. variableArgs: false
  53776. };
  53777. t['DP'] = {
  53778. id: OPS.markPointProps,
  53779. numArgs: 2,
  53780. variableArgs: false
  53781. };
  53782. t['BMC'] = {
  53783. id: OPS.beginMarkedContent,
  53784. numArgs: 1,
  53785. variableArgs: false
  53786. };
  53787. t['BDC'] = {
  53788. id: OPS.beginMarkedContentProps,
  53789. numArgs: 2,
  53790. variableArgs: false
  53791. };
  53792. t['EMC'] = {
  53793. id: OPS.endMarkedContent,
  53794. numArgs: 0,
  53795. variableArgs: false
  53796. };
  53797. t['BX'] = {
  53798. id: OPS.beginCompat,
  53799. numArgs: 0,
  53800. variableArgs: false
  53801. };
  53802. t['EX'] = {
  53803. id: OPS.endCompat,
  53804. numArgs: 0,
  53805. variableArgs: false
  53806. };
  53807. t['BM'] = null;
  53808. t['BD'] = null;
  53809. t['true'] = null;
  53810. t['fa'] = null;
  53811. t['fal'] = null;
  53812. t['fals'] = null;
  53813. t['false'] = null;
  53814. t['nu'] = null;
  53815. t['nul'] = null;
  53816. t['null'] = null;
  53817. });
  53818. function EvaluatorPreprocessor(stream, xref, stateManager) {
  53819. this.opMap = getOPMap();
  53820. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  53821. this.stateManager = stateManager;
  53822. this.nonProcessedArgs = [];
  53823. }
  53824. EvaluatorPreprocessor.prototype = {
  53825. get savedStatesDepth() {
  53826. return this.stateManager.stateStack.length;
  53827. },
  53828. read: function EvaluatorPreprocessor_read(operation) {
  53829. var args = operation.args;
  53830. while (true) {
  53831. var obj = this.parser.getObj();
  53832. if (isCmd(obj)) {
  53833. var cmd = obj.cmd;
  53834. var opSpec = this.opMap[cmd];
  53835. if (!opSpec) {
  53836. warn('Unknown command "' + cmd + '"');
  53837. continue;
  53838. }
  53839. var fn = opSpec.id;
  53840. var numArgs = opSpec.numArgs;
  53841. var argsLength = args !== null ? args.length : 0;
  53842. if (!opSpec.variableArgs) {
  53843. if (argsLength !== numArgs) {
  53844. var nonProcessedArgs = this.nonProcessedArgs;
  53845. while (argsLength > numArgs) {
  53846. nonProcessedArgs.push(args.shift());
  53847. argsLength--;
  53848. }
  53849. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  53850. if (args === null) {
  53851. args = [];
  53852. }
  53853. args.unshift(nonProcessedArgs.pop());
  53854. argsLength++;
  53855. }
  53856. }
  53857. if (argsLength < numArgs) {
  53858. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  53859. if (args !== null) {
  53860. args.length = 0;
  53861. }
  53862. continue;
  53863. }
  53864. } else if (argsLength > numArgs) {
  53865. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  53866. }
  53867. this.preprocessCommand(fn, args);
  53868. operation.fn = fn;
  53869. operation.args = args;
  53870. return true;
  53871. }
  53872. if (isEOF(obj)) {
  53873. return false;
  53874. }
  53875. if (obj !== null) {
  53876. if (args === null) {
  53877. args = [];
  53878. }
  53879. args.push(obj);
  53880. assert(args.length <= 33, 'Too many arguments');
  53881. }
  53882. }
  53883. },
  53884. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  53885. switch (fn | 0) {
  53886. case OPS.save:
  53887. this.stateManager.save();
  53888. break;
  53889. case OPS.restore:
  53890. this.stateManager.restore();
  53891. break;
  53892. case OPS.transform:
  53893. this.stateManager.transform(args);
  53894. break;
  53895. }
  53896. }
  53897. };
  53898. return EvaluatorPreprocessor;
  53899. }();
  53900. var QueueOptimizer = function QueueOptimizerClosure() {
  53901. function addState(parentState, pattern, fn) {
  53902. var state = parentState;
  53903. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  53904. var item = pattern[i];
  53905. state = state[item] || (state[item] = []);
  53906. }
  53907. state[pattern[pattern.length - 1]] = fn;
  53908. }
  53909. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  53910. var iFirstPIMXO = iFirstSave + 2;
  53911. for (var i = 0; i < count; i++) {
  53912. var arg = argsArray[iFirstPIMXO + 4 * i];
  53913. var imageMask = arg.length === 1 && arg[0];
  53914. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  53915. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  53916. continue;
  53917. }
  53918. break;
  53919. }
  53920. return count - i;
  53921. }
  53922. var InitialState = [];
  53923. addState(InitialState, [
  53924. OPS.save,
  53925. OPS.transform,
  53926. OPS.paintInlineImageXObject,
  53927. OPS.restore
  53928. ], function foundInlineImageGroup(context) {
  53929. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  53930. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  53931. var MAX_WIDTH = 1000;
  53932. var IMAGE_PADDING = 1;
  53933. var fnArray = context.fnArray, argsArray = context.argsArray;
  53934. var curr = context.iCurr;
  53935. var iFirstSave = curr - 3;
  53936. var iFirstTransform = curr - 2;
  53937. var iFirstPIIXO = curr - 1;
  53938. var i = iFirstSave + 4;
  53939. var ii = fnArray.length;
  53940. while (i + 3 < ii) {
  53941. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  53942. break;
  53943. }
  53944. i += 4;
  53945. }
  53946. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  53947. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  53948. return i;
  53949. }
  53950. var maxX = 0;
  53951. var map = [], maxLineHeight = 0;
  53952. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  53953. var q;
  53954. for (q = 0; q < count; q++) {
  53955. var transform = argsArray[iFirstTransform + (q << 2)];
  53956. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  53957. if (currentX + img.width > MAX_WIDTH) {
  53958. maxX = Math.max(maxX, currentX);
  53959. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  53960. currentX = 0;
  53961. maxLineHeight = 0;
  53962. }
  53963. map.push({
  53964. transform: transform,
  53965. x: currentX,
  53966. y: currentY,
  53967. w: img.width,
  53968. h: img.height
  53969. });
  53970. currentX += img.width + 2 * IMAGE_PADDING;
  53971. maxLineHeight = Math.max(maxLineHeight, img.height);
  53972. }
  53973. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  53974. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  53975. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  53976. var imgRowSize = imgWidth << 2;
  53977. for (q = 0; q < count; q++) {
  53978. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  53979. var rowSize = map[q].w << 2;
  53980. var dataOffset = 0;
  53981. var offset = map[q].x + map[q].y * imgWidth << 2;
  53982. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  53983. for (var k = 0, kk = map[q].h; k < kk; k++) {
  53984. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  53985. dataOffset += rowSize;
  53986. offset += imgRowSize;
  53987. }
  53988. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  53989. while (offset >= 0) {
  53990. data[offset - 4] = data[offset];
  53991. data[offset - 3] = data[offset + 1];
  53992. data[offset - 2] = data[offset + 2];
  53993. data[offset - 1] = data[offset + 3];
  53994. data[offset + rowSize] = data[offset + rowSize - 4];
  53995. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  53996. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  53997. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  53998. offset -= imgRowSize;
  53999. }
  54000. }
  54001. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54002. argsArray.splice(iFirstSave, count * 4, [
  54003. {
  54004. width: imgWidth,
  54005. height: imgHeight,
  54006. kind: ImageKind.RGBA_32BPP,
  54007. data: imgData
  54008. },
  54009. map
  54010. ]);
  54011. return iFirstSave + 1;
  54012. });
  54013. addState(InitialState, [
  54014. OPS.save,
  54015. OPS.transform,
  54016. OPS.paintImageMaskXObject,
  54017. OPS.restore
  54018. ], function foundImageMaskGroup(context) {
  54019. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54020. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54021. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54022. var fnArray = context.fnArray, argsArray = context.argsArray;
  54023. var curr = context.iCurr;
  54024. var iFirstSave = curr - 3;
  54025. var iFirstTransform = curr - 2;
  54026. var iFirstPIMXO = curr - 1;
  54027. var i = iFirstSave + 4;
  54028. var ii = fnArray.length;
  54029. while (i + 3 < ii) {
  54030. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54031. break;
  54032. }
  54033. i += 4;
  54034. }
  54035. var count = (i - iFirstSave) / 4;
  54036. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54037. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54038. return i;
  54039. }
  54040. var q;
  54041. var isSameImage = false;
  54042. var iTransform, transformArgs;
  54043. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54044. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54045. isSameImage = true;
  54046. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54047. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54048. iTransform = iFirstTransform + 4;
  54049. var iPIMXO = iFirstPIMXO + 4;
  54050. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54051. transformArgs = argsArray[iTransform];
  54052. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54053. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54054. isSameImage = false;
  54055. } else {
  54056. count = q;
  54057. }
  54058. break;
  54059. }
  54060. }
  54061. }
  54062. if (isSameImage) {
  54063. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54064. var positions = new Float32Array(count * 2);
  54065. iTransform = iFirstTransform;
  54066. for (q = 0; q < count; q++, iTransform += 4) {
  54067. transformArgs = argsArray[iTransform];
  54068. positions[q << 1] = transformArgs[4];
  54069. positions[(q << 1) + 1] = transformArgs[5];
  54070. }
  54071. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54072. argsArray.splice(iFirstSave, count * 4, [
  54073. firstPIMXOArg0,
  54074. firstTransformArg0,
  54075. firstTransformArg3,
  54076. positions
  54077. ]);
  54078. } else {
  54079. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54080. var images = [];
  54081. for (q = 0; q < count; q++) {
  54082. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54083. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54084. images.push({
  54085. data: maskParams.data,
  54086. width: maskParams.width,
  54087. height: maskParams.height,
  54088. transform: transformArgs
  54089. });
  54090. }
  54091. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54092. argsArray.splice(iFirstSave, count * 4, [images]);
  54093. }
  54094. return iFirstSave + 1;
  54095. });
  54096. addState(InitialState, [
  54097. OPS.save,
  54098. OPS.transform,
  54099. OPS.paintImageXObject,
  54100. OPS.restore
  54101. ], function (context) {
  54102. var MIN_IMAGES_IN_BLOCK = 3;
  54103. var MAX_IMAGES_IN_BLOCK = 1000;
  54104. var fnArray = context.fnArray, argsArray = context.argsArray;
  54105. var curr = context.iCurr;
  54106. var iFirstSave = curr - 3;
  54107. var iFirstTransform = curr - 2;
  54108. var iFirstPIXO = curr - 1;
  54109. var iFirstRestore = curr;
  54110. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54111. return iFirstRestore + 1;
  54112. }
  54113. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54114. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54115. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54116. var i = iFirstSave + 4;
  54117. var ii = fnArray.length;
  54118. while (i + 3 < ii) {
  54119. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54120. break;
  54121. }
  54122. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54123. break;
  54124. }
  54125. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54126. break;
  54127. }
  54128. i += 4;
  54129. }
  54130. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54131. if (count < MIN_IMAGES_IN_BLOCK) {
  54132. return i;
  54133. }
  54134. var positions = new Float32Array(count * 2);
  54135. var iTransform = iFirstTransform;
  54136. for (var q = 0; q < count; q++, iTransform += 4) {
  54137. var transformArgs = argsArray[iTransform];
  54138. positions[q << 1] = transformArgs[4];
  54139. positions[(q << 1) + 1] = transformArgs[5];
  54140. }
  54141. var args = [
  54142. firstPIXOArg0,
  54143. firstTransformArg0,
  54144. firstTransformArg3,
  54145. positions
  54146. ];
  54147. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54148. argsArray.splice(iFirstSave, count * 4, args);
  54149. return iFirstSave + 1;
  54150. });
  54151. addState(InitialState, [
  54152. OPS.beginText,
  54153. OPS.setFont,
  54154. OPS.setTextMatrix,
  54155. OPS.showText,
  54156. OPS.endText
  54157. ], function (context) {
  54158. var MIN_CHARS_IN_BLOCK = 3;
  54159. var MAX_CHARS_IN_BLOCK = 1000;
  54160. var fnArray = context.fnArray, argsArray = context.argsArray;
  54161. var curr = context.iCurr;
  54162. var iFirstBeginText = curr - 4;
  54163. var iFirstSetFont = curr - 3;
  54164. var iFirstSetTextMatrix = curr - 2;
  54165. var iFirstShowText = curr - 1;
  54166. var iFirstEndText = curr;
  54167. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54168. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54169. var i = iFirstBeginText + 5;
  54170. var ii = fnArray.length;
  54171. while (i + 4 < ii) {
  54172. if (fnArray[i] !== OPS.beginText || fnArray[i + 1] !== OPS.setFont || fnArray[i + 2] !== OPS.setTextMatrix || fnArray[i + 3] !== OPS.showText || fnArray[i + 4] !== OPS.endText) {
  54173. break;
  54174. }
  54175. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54176. break;
  54177. }
  54178. i += 5;
  54179. }
  54180. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54181. if (count < MIN_CHARS_IN_BLOCK) {
  54182. return i;
  54183. }
  54184. var iFirst = iFirstBeginText;
  54185. if (iFirstBeginText >= 4 && fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] && fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] && fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] && fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] && argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 && argsArray[iFirstBeginText - 4][1] === firstSetFontArg1) {
  54186. count++;
  54187. iFirst -= 5;
  54188. }
  54189. var iEndText = iFirst + 4;
  54190. for (var q = 1; q < count; q++) {
  54191. fnArray.splice(iEndText, 3);
  54192. argsArray.splice(iEndText, 3);
  54193. iEndText += 2;
  54194. }
  54195. return iEndText + 1;
  54196. });
  54197. function QueueOptimizer() {
  54198. }
  54199. QueueOptimizer.prototype = {
  54200. optimize: function QueueOptimizer_optimize(queue) {
  54201. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54202. var context = {
  54203. iCurr: 0,
  54204. fnArray: fnArray,
  54205. argsArray: argsArray
  54206. };
  54207. var state;
  54208. var i = 0, ii = fnArray.length;
  54209. while (i < ii) {
  54210. state = (state || InitialState)[fnArray[i]];
  54211. if (typeof state === 'function') {
  54212. context.iCurr = i;
  54213. i = state(context);
  54214. state = undefined;
  54215. ii = context.fnArray.length;
  54216. } else {
  54217. i++;
  54218. }
  54219. }
  54220. }
  54221. };
  54222. return QueueOptimizer;
  54223. }();
  54224. exports.OperatorList = OperatorList;
  54225. exports.PartialEvaluator = PartialEvaluator;
  54226. }));
  54227. (function (root, factory) {
  54228. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  54229. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  54230. var globalScope = sharedUtil.globalScope;
  54231. var deprecated = sharedUtil.deprecated;
  54232. var warn = sharedUtil.warn;
  54233. var LinkTarget = displayDOMUtils.LinkTarget;
  54234. var DEFAULT_LINK_REL = displayDOMUtils.DEFAULT_LINK_REL;
  54235. var isWorker = typeof window === 'undefined';
  54236. if (!globalScope.PDFJS) {
  54237. globalScope.PDFJS = {};
  54238. }
  54239. var PDFJS = globalScope.PDFJS;
  54240. if (typeof pdfjsVersion !== 'undefined') {
  54241. PDFJS.version = pdfjsVersion;
  54242. }
  54243. if (typeof pdfjsBuild !== 'undefined') {
  54244. PDFJS.build = pdfjsBuild;
  54245. }
  54246. PDFJS.pdfBug = false;
  54247. if (PDFJS.verbosity !== undefined) {
  54248. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  54249. }
  54250. delete PDFJS.verbosity;
  54251. Object.defineProperty(PDFJS, 'verbosity', {
  54252. get: function () {
  54253. return sharedUtil.getVerbosityLevel();
  54254. },
  54255. set: function (level) {
  54256. sharedUtil.setVerbosityLevel(level);
  54257. },
  54258. enumerable: true,
  54259. configurable: true
  54260. });
  54261. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  54262. PDFJS.OPS = sharedUtil.OPS;
  54263. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  54264. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  54265. PDFJS.shadow = sharedUtil.shadow;
  54266. PDFJS.createBlob = sharedUtil.createBlob;
  54267. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  54268. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  54269. };
  54270. Object.defineProperty(PDFJS, 'isLittleEndian', {
  54271. configurable: true,
  54272. get: function PDFJS_isLittleEndian() {
  54273. var value = sharedUtil.isLittleEndian();
  54274. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  54275. }
  54276. });
  54277. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  54278. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  54279. PDFJS.PasswordException = sharedUtil.PasswordException;
  54280. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  54281. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  54282. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  54283. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  54284. PDFJS.Util = sharedUtil.Util;
  54285. PDFJS.PageViewport = sharedUtil.PageViewport;
  54286. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  54287. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  54288. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  54289. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  54290. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  54291. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  54292. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  54293. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  54294. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  54295. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  54296. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  54297. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  54298. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  54299. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  54300. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  54301. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  54302. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? DEFAULT_LINK_REL : PDFJS.externalLinkRel;
  54303. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  54304. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  54305. delete PDFJS.openExternalLinksInNewWindow;
  54306. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  54307. get: function () {
  54308. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  54309. },
  54310. set: function (value) {
  54311. if (value) {
  54312. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  54313. }
  54314. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  54315. warn('PDFJS.externalLinkTarget is already initialized');
  54316. return;
  54317. }
  54318. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  54319. },
  54320. enumerable: true,
  54321. configurable: true
  54322. });
  54323. if (savedOpenExternalLinksInNewWindow) {
  54324. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  54325. }
  54326. PDFJS.getDocument = displayAPI.getDocument;
  54327. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  54328. PDFJS.PDFWorker = displayAPI.PDFWorker;
  54329. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  54330. configurable: true,
  54331. get: function PDFJS_hasCanvasTypedArrays() {
  54332. var value = displayDOMUtils.hasCanvasTypedArrays();
  54333. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  54334. }
  54335. });
  54336. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  54337. PDFJS.LinkTarget = LinkTarget;
  54338. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  54339. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  54340. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  54341. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  54342. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  54343. PDFJS.Metadata = displayMetadata.Metadata;
  54344. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  54345. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  54346. exports.globalScope = globalScope;
  54347. exports.isWorker = isWorker;
  54348. exports.PDFJS = globalScope.PDFJS;
  54349. }));
  54350. (function (root, factory) {
  54351. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54352. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54353. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54354. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54355. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54356. var AnnotationType = sharedUtil.AnnotationType;
  54357. var OPS = sharedUtil.OPS;
  54358. var Util = sharedUtil.Util;
  54359. var isArray = sharedUtil.isArray;
  54360. var isInt = sharedUtil.isInt;
  54361. var stringToBytes = sharedUtil.stringToBytes;
  54362. var stringToPDFString = sharedUtil.stringToPDFString;
  54363. var warn = sharedUtil.warn;
  54364. var Dict = corePrimitives.Dict;
  54365. var isDict = corePrimitives.isDict;
  54366. var isName = corePrimitives.isName;
  54367. var isRef = corePrimitives.isRef;
  54368. var Stream = coreStream.Stream;
  54369. var ColorSpace = coreColorSpace.ColorSpace;
  54370. var Catalog = coreObj.Catalog;
  54371. var ObjectLoader = coreObj.ObjectLoader;
  54372. var FileSpec = coreObj.FileSpec;
  54373. var OperatorList = coreEvaluator.OperatorList;
  54374. function AnnotationFactory() {
  54375. }
  54376. AnnotationFactory.prototype = {
  54377. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  54378. var dict = xref.fetchIfRef(ref);
  54379. if (!isDict(dict)) {
  54380. return;
  54381. }
  54382. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  54383. var subtype = dict.get('Subtype');
  54384. subtype = isName(subtype) ? subtype.name : null;
  54385. var parameters = {
  54386. xref: xref,
  54387. dict: dict,
  54388. ref: isRef(ref) ? ref : null,
  54389. subtype: subtype,
  54390. id: id,
  54391. pdfManager: pdfManager
  54392. };
  54393. switch (subtype) {
  54394. case 'Link':
  54395. return new LinkAnnotation(parameters);
  54396. case 'Text':
  54397. return new TextAnnotation(parameters);
  54398. case 'Widget':
  54399. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54400. fieldType = isName(fieldType) ? fieldType.name : null;
  54401. switch (fieldType) {
  54402. case 'Tx':
  54403. return new TextWidgetAnnotation(parameters);
  54404. case 'Btn':
  54405. return new ButtonWidgetAnnotation(parameters);
  54406. case 'Ch':
  54407. return new ChoiceWidgetAnnotation(parameters);
  54408. }
  54409. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54410. return new WidgetAnnotation(parameters);
  54411. case 'Popup':
  54412. return new PopupAnnotation(parameters);
  54413. case 'Highlight':
  54414. return new HighlightAnnotation(parameters);
  54415. case 'Underline':
  54416. return new UnderlineAnnotation(parameters);
  54417. case 'Squiggly':
  54418. return new SquigglyAnnotation(parameters);
  54419. case 'StrikeOut':
  54420. return new StrikeOutAnnotation(parameters);
  54421. case 'FileAttachment':
  54422. return new FileAttachmentAnnotation(parameters);
  54423. default:
  54424. if (!subtype) {
  54425. warn('Annotation is missing the required /Subtype.');
  54426. } else {
  54427. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54428. }
  54429. return new Annotation(parameters);
  54430. }
  54431. }
  54432. };
  54433. var Annotation = function AnnotationClosure() {
  54434. function getTransformMatrix(rect, bbox, matrix) {
  54435. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54436. var minX = bounds[0];
  54437. var minY = bounds[1];
  54438. var maxX = bounds[2];
  54439. var maxY = bounds[3];
  54440. if (minX === maxX || minY === maxY) {
  54441. return [
  54442. 1,
  54443. 0,
  54444. 0,
  54445. 1,
  54446. rect[0],
  54447. rect[1]
  54448. ];
  54449. }
  54450. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54451. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54452. return [
  54453. xRatio,
  54454. 0,
  54455. 0,
  54456. yRatio,
  54457. rect[0] - minX * xRatio,
  54458. rect[1] - minY * yRatio
  54459. ];
  54460. }
  54461. function getDefaultAppearance(dict) {
  54462. var appearanceState = dict.get('AP');
  54463. if (!isDict(appearanceState)) {
  54464. return;
  54465. }
  54466. var appearance;
  54467. var appearances = appearanceState.get('N');
  54468. if (isDict(appearances)) {
  54469. var as = dict.get('AS');
  54470. if (as && appearances.has(as.name)) {
  54471. appearance = appearances.get(as.name);
  54472. }
  54473. } else {
  54474. appearance = appearances;
  54475. }
  54476. return appearance;
  54477. }
  54478. function Annotation(params) {
  54479. var dict = params.dict;
  54480. this.setFlags(dict.get('F'));
  54481. this.setRectangle(dict.getArray('Rect'));
  54482. this.setColor(dict.getArray('C'));
  54483. this.setBorderStyle(dict);
  54484. this.appearance = getDefaultAppearance(dict);
  54485. this.data = {};
  54486. this.data.id = params.id;
  54487. this.data.subtype = params.subtype;
  54488. this.data.annotationFlags = this.flags;
  54489. this.data.rect = this.rectangle;
  54490. this.data.color = this.color;
  54491. this.data.borderStyle = this.borderStyle;
  54492. this.data.hasAppearance = !!this.appearance;
  54493. }
  54494. Annotation.prototype = {
  54495. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54496. return !!(flags & flag);
  54497. },
  54498. _isViewable: function Annotation_isViewable(flags) {
  54499. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54500. },
  54501. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54502. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54503. },
  54504. get viewable() {
  54505. if (this.flags === 0) {
  54506. return true;
  54507. }
  54508. return this._isViewable(this.flags);
  54509. },
  54510. get printable() {
  54511. if (this.flags === 0) {
  54512. return false;
  54513. }
  54514. return this._isPrintable(this.flags);
  54515. },
  54516. setFlags: function Annotation_setFlags(flags) {
  54517. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54518. },
  54519. hasFlag: function Annotation_hasFlag(flag) {
  54520. return this._hasFlag(this.flags, flag);
  54521. },
  54522. setRectangle: function Annotation_setRectangle(rectangle) {
  54523. if (isArray(rectangle) && rectangle.length === 4) {
  54524. this.rectangle = Util.normalizeRect(rectangle);
  54525. } else {
  54526. this.rectangle = [
  54527. 0,
  54528. 0,
  54529. 0,
  54530. 0
  54531. ];
  54532. }
  54533. },
  54534. setColor: function Annotation_setColor(color) {
  54535. var rgbColor = new Uint8Array(3);
  54536. if (!isArray(color)) {
  54537. this.color = rgbColor;
  54538. return;
  54539. }
  54540. switch (color.length) {
  54541. case 0:
  54542. this.color = null;
  54543. break;
  54544. case 1:
  54545. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54546. this.color = rgbColor;
  54547. break;
  54548. case 3:
  54549. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54550. this.color = rgbColor;
  54551. break;
  54552. case 4:
  54553. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54554. this.color = rgbColor;
  54555. break;
  54556. default:
  54557. this.color = rgbColor;
  54558. break;
  54559. }
  54560. },
  54561. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54562. this.borderStyle = new AnnotationBorderStyle();
  54563. if (!isDict(borderStyle)) {
  54564. return;
  54565. }
  54566. if (borderStyle.has('BS')) {
  54567. var dict = borderStyle.get('BS');
  54568. var dictType = dict.get('Type');
  54569. if (!dictType || isName(dictType, 'Border')) {
  54570. this.borderStyle.setWidth(dict.get('W'));
  54571. this.borderStyle.setStyle(dict.get('S'));
  54572. this.borderStyle.setDashArray(dict.getArray('D'));
  54573. }
  54574. } else if (borderStyle.has('Border')) {
  54575. var array = borderStyle.getArray('Border');
  54576. if (isArray(array) && array.length >= 3) {
  54577. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54578. this.borderStyle.setVerticalCornerRadius(array[1]);
  54579. this.borderStyle.setWidth(array[2]);
  54580. if (array.length === 4) {
  54581. this.borderStyle.setDashArray(array[3]);
  54582. }
  54583. }
  54584. } else {
  54585. this.borderStyle.setWidth(0);
  54586. }
  54587. },
  54588. _preparePopup: function Annotation_preparePopup(dict) {
  54589. if (!dict.has('C')) {
  54590. this.data.color = null;
  54591. }
  54592. this.data.hasPopup = dict.has('Popup');
  54593. this.data.title = stringToPDFString(dict.get('T') || '');
  54594. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54595. },
  54596. loadResources: function Annotation_loadResources(keys) {
  54597. return new Promise(function (resolve, reject) {
  54598. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54599. if (!resources) {
  54600. resolve();
  54601. return;
  54602. }
  54603. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54604. objectLoader.load().then(function () {
  54605. resolve(resources);
  54606. }, reject);
  54607. }, reject);
  54608. }.bind(this));
  54609. },
  54610. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54611. if (!this.appearance) {
  54612. return Promise.resolve(new OperatorList());
  54613. }
  54614. var data = this.data;
  54615. var appearanceDict = this.appearance.dict;
  54616. var resourcesPromise = this.loadResources([
  54617. 'ExtGState',
  54618. 'ColorSpace',
  54619. 'Pattern',
  54620. 'Shading',
  54621. 'XObject',
  54622. 'Font'
  54623. ]);
  54624. var bbox = appearanceDict.getArray('BBox') || [
  54625. 0,
  54626. 0,
  54627. 1,
  54628. 1
  54629. ];
  54630. var matrix = appearanceDict.getArray('Matrix') || [
  54631. 1,
  54632. 0,
  54633. 0,
  54634. 1,
  54635. 0,
  54636. 0
  54637. ];
  54638. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54639. var self = this;
  54640. return resourcesPromise.then(function (resources) {
  54641. var opList = new OperatorList();
  54642. opList.addOp(OPS.beginAnnotation, [
  54643. data.rect,
  54644. transform,
  54645. matrix
  54646. ]);
  54647. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54648. opList.addOp(OPS.endAnnotation, []);
  54649. self.appearance.reset();
  54650. return opList;
  54651. });
  54652. });
  54653. }
  54654. };
  54655. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54656. var annotationPromises = [];
  54657. for (var i = 0, n = annotations.length; i < n; ++i) {
  54658. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54659. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54660. }
  54661. }
  54662. return Promise.all(annotationPromises).then(function (operatorLists) {
  54663. opList.addOp(OPS.beginAnnotations, []);
  54664. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54665. opList.addOpList(operatorLists[i]);
  54666. }
  54667. opList.addOp(OPS.endAnnotations, []);
  54668. });
  54669. };
  54670. return Annotation;
  54671. }();
  54672. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54673. function AnnotationBorderStyle() {
  54674. this.width = 1;
  54675. this.style = AnnotationBorderStyleType.SOLID;
  54676. this.dashArray = [3];
  54677. this.horizontalCornerRadius = 0;
  54678. this.verticalCornerRadius = 0;
  54679. }
  54680. AnnotationBorderStyle.prototype = {
  54681. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54682. if (width === (width | 0)) {
  54683. this.width = width;
  54684. }
  54685. },
  54686. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54687. if (!style) {
  54688. return;
  54689. }
  54690. switch (style.name) {
  54691. case 'S':
  54692. this.style = AnnotationBorderStyleType.SOLID;
  54693. break;
  54694. case 'D':
  54695. this.style = AnnotationBorderStyleType.DASHED;
  54696. break;
  54697. case 'B':
  54698. this.style = AnnotationBorderStyleType.BEVELED;
  54699. break;
  54700. case 'I':
  54701. this.style = AnnotationBorderStyleType.INSET;
  54702. break;
  54703. case 'U':
  54704. this.style = AnnotationBorderStyleType.UNDERLINE;
  54705. break;
  54706. default:
  54707. break;
  54708. }
  54709. },
  54710. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54711. if (isArray(dashArray) && dashArray.length > 0) {
  54712. var isValid = true;
  54713. var allZeros = true;
  54714. for (var i = 0, len = dashArray.length; i < len; i++) {
  54715. var element = dashArray[i];
  54716. var validNumber = +element >= 0;
  54717. if (!validNumber) {
  54718. isValid = false;
  54719. break;
  54720. } else if (element > 0) {
  54721. allZeros = false;
  54722. }
  54723. }
  54724. if (isValid && !allZeros) {
  54725. this.dashArray = dashArray;
  54726. } else {
  54727. this.width = 0;
  54728. }
  54729. } else if (dashArray) {
  54730. this.width = 0;
  54731. }
  54732. },
  54733. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54734. if (radius === (radius | 0)) {
  54735. this.horizontalCornerRadius = radius;
  54736. }
  54737. },
  54738. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54739. if (radius === (radius | 0)) {
  54740. this.verticalCornerRadius = radius;
  54741. }
  54742. }
  54743. };
  54744. return AnnotationBorderStyle;
  54745. }();
  54746. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54747. function WidgetAnnotation(params) {
  54748. Annotation.call(this, params);
  54749. var dict = params.dict;
  54750. var data = this.data;
  54751. data.annotationType = AnnotationType.WIDGET;
  54752. data.fieldName = this._constructFieldName(dict);
  54753. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  54754. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  54755. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  54756. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54757. data.fieldType = isName(fieldType) ? fieldType.name : null;
  54758. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  54759. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  54760. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  54761. data.fieldFlags = 0;
  54762. }
  54763. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  54764. if (data.fieldType === 'Sig') {
  54765. this.setFlags(AnnotationFlag.HIDDEN);
  54766. }
  54767. }
  54768. Util.inherit(WidgetAnnotation, Annotation, {
  54769. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  54770. if (!dict.has('T') && !dict.has('Parent')) {
  54771. warn('Unknown field name, falling back to empty field name.');
  54772. return '';
  54773. }
  54774. if (!dict.has('Parent')) {
  54775. return stringToPDFString(dict.get('T'));
  54776. }
  54777. var fieldName = [];
  54778. if (dict.has('T')) {
  54779. fieldName.unshift(stringToPDFString(dict.get('T')));
  54780. }
  54781. var loopDict = dict;
  54782. while (loopDict.has('Parent')) {
  54783. loopDict = loopDict.get('Parent');
  54784. if (loopDict.has('T')) {
  54785. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  54786. }
  54787. }
  54788. return fieldName.join('.');
  54789. },
  54790. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  54791. return !!(this.data.fieldFlags & flag);
  54792. }
  54793. });
  54794. return WidgetAnnotation;
  54795. }();
  54796. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  54797. function TextWidgetAnnotation(params) {
  54798. WidgetAnnotation.call(this, params);
  54799. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  54800. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  54801. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  54802. alignment = null;
  54803. }
  54804. this.data.textAlignment = alignment;
  54805. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  54806. if (!isInt(maximumLength) || maximumLength < 0) {
  54807. maximumLength = null;
  54808. }
  54809. this.data.maxLen = maximumLength;
  54810. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  54811. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  54812. }
  54813. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  54814. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54815. var operatorList = new OperatorList();
  54816. if (renderForms) {
  54817. return Promise.resolve(operatorList);
  54818. }
  54819. if (this.appearance) {
  54820. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54821. }
  54822. if (!this.data.defaultAppearance) {
  54823. return Promise.resolve(operatorList);
  54824. }
  54825. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  54826. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  54827. return operatorList;
  54828. });
  54829. }
  54830. });
  54831. return TextWidgetAnnotation;
  54832. }();
  54833. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  54834. function ButtonWidgetAnnotation(params) {
  54835. WidgetAnnotation.call(this, params);
  54836. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  54837. if (this.data.checkBox) {
  54838. if (!isName(this.data.fieldValue)) {
  54839. return;
  54840. }
  54841. this.data.fieldValue = this.data.fieldValue.name;
  54842. }
  54843. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  54844. if (this.data.radioButton) {
  54845. this.data.fieldValue = this.data.buttonValue = null;
  54846. var fieldParent = params.dict.get('Parent');
  54847. if (!isDict(fieldParent) || !fieldParent.has('V')) {
  54848. return;
  54849. }
  54850. var fieldParentValue = fieldParent.get('V');
  54851. if (!isName(fieldParentValue)) {
  54852. return;
  54853. }
  54854. this.data.fieldValue = fieldParentValue.name;
  54855. var appearanceStates = params.dict.get('AP');
  54856. if (!isDict(appearanceStates)) {
  54857. return;
  54858. }
  54859. var normalAppearanceState = appearanceStates.get('N');
  54860. if (!isDict(normalAppearanceState)) {
  54861. return;
  54862. }
  54863. var keys = normalAppearanceState.getKeys();
  54864. for (var i = 0, ii = keys.length; i < ii; i++) {
  54865. if (keys[i] !== 'Off') {
  54866. this.data.buttonValue = keys[i];
  54867. break;
  54868. }
  54869. }
  54870. }
  54871. }
  54872. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  54873. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54874. var operatorList = new OperatorList();
  54875. if (renderForms) {
  54876. return Promise.resolve(operatorList);
  54877. }
  54878. if (this.appearance) {
  54879. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54880. }
  54881. return Promise.resolve(operatorList);
  54882. }
  54883. });
  54884. return ButtonWidgetAnnotation;
  54885. }();
  54886. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  54887. function ChoiceWidgetAnnotation(params) {
  54888. WidgetAnnotation.call(this, params);
  54889. this.data.options = [];
  54890. var options = params.dict.get('Opt');
  54891. if (isArray(options)) {
  54892. var xref = params.xref;
  54893. for (var i = 0, ii = options.length; i < ii; i++) {
  54894. var option = xref.fetchIfRef(options[i]);
  54895. var isOptionArray = isArray(option);
  54896. this.data.options[i] = {
  54897. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  54898. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  54899. };
  54900. }
  54901. }
  54902. if (!isArray(this.data.fieldValue)) {
  54903. this.data.fieldValue = [this.data.fieldValue];
  54904. }
  54905. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  54906. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  54907. }
  54908. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  54909. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54910. var operatorList = new OperatorList();
  54911. if (renderForms) {
  54912. return Promise.resolve(operatorList);
  54913. }
  54914. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54915. }
  54916. });
  54917. return ChoiceWidgetAnnotation;
  54918. }();
  54919. var TextAnnotation = function TextAnnotationClosure() {
  54920. var DEFAULT_ICON_SIZE = 22;
  54921. function TextAnnotation(parameters) {
  54922. Annotation.call(this, parameters);
  54923. this.data.annotationType = AnnotationType.TEXT;
  54924. if (this.data.hasAppearance) {
  54925. this.data.name = 'NoIcon';
  54926. } else {
  54927. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  54928. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  54929. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  54930. }
  54931. this._preparePopup(parameters.dict);
  54932. }
  54933. Util.inherit(TextAnnotation, Annotation, {});
  54934. return TextAnnotation;
  54935. }();
  54936. var LinkAnnotation = function LinkAnnotationClosure() {
  54937. function LinkAnnotation(params) {
  54938. Annotation.call(this, params);
  54939. var data = this.data;
  54940. data.annotationType = AnnotationType.LINK;
  54941. Catalog.parseDestDictionary({
  54942. destDict: params.dict,
  54943. resultObj: data,
  54944. docBaseUrl: params.pdfManager.docBaseUrl
  54945. });
  54946. }
  54947. Util.inherit(LinkAnnotation, Annotation, {});
  54948. return LinkAnnotation;
  54949. }();
  54950. var PopupAnnotation = function PopupAnnotationClosure() {
  54951. function PopupAnnotation(parameters) {
  54952. Annotation.call(this, parameters);
  54953. this.data.annotationType = AnnotationType.POPUP;
  54954. var dict = parameters.dict;
  54955. var parentItem = dict.get('Parent');
  54956. if (!parentItem) {
  54957. warn('Popup annotation has a missing or invalid parent annotation.');
  54958. return;
  54959. }
  54960. this.data.parentId = dict.getRaw('Parent').toString();
  54961. this.data.title = stringToPDFString(parentItem.get('T') || '');
  54962. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  54963. if (!parentItem.has('C')) {
  54964. this.data.color = null;
  54965. } else {
  54966. this.setColor(parentItem.getArray('C'));
  54967. this.data.color = this.color;
  54968. }
  54969. if (!this.viewable) {
  54970. var parentFlags = parentItem.get('F');
  54971. if (this._isViewable(parentFlags)) {
  54972. this.setFlags(parentFlags);
  54973. }
  54974. }
  54975. }
  54976. Util.inherit(PopupAnnotation, Annotation, {});
  54977. return PopupAnnotation;
  54978. }();
  54979. var HighlightAnnotation = function HighlightAnnotationClosure() {
  54980. function HighlightAnnotation(parameters) {
  54981. Annotation.call(this, parameters);
  54982. this.data.annotationType = AnnotationType.HIGHLIGHT;
  54983. this._preparePopup(parameters.dict);
  54984. this.data.borderStyle.setWidth(0);
  54985. }
  54986. Util.inherit(HighlightAnnotation, Annotation, {});
  54987. return HighlightAnnotation;
  54988. }();
  54989. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  54990. function UnderlineAnnotation(parameters) {
  54991. Annotation.call(this, parameters);
  54992. this.data.annotationType = AnnotationType.UNDERLINE;
  54993. this._preparePopup(parameters.dict);
  54994. this.data.borderStyle.setWidth(0);
  54995. }
  54996. Util.inherit(UnderlineAnnotation, Annotation, {});
  54997. return UnderlineAnnotation;
  54998. }();
  54999. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55000. function SquigglyAnnotation(parameters) {
  55001. Annotation.call(this, parameters);
  55002. this.data.annotationType = AnnotationType.SQUIGGLY;
  55003. this._preparePopup(parameters.dict);
  55004. this.data.borderStyle.setWidth(0);
  55005. }
  55006. Util.inherit(SquigglyAnnotation, Annotation, {});
  55007. return SquigglyAnnotation;
  55008. }();
  55009. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55010. function StrikeOutAnnotation(parameters) {
  55011. Annotation.call(this, parameters);
  55012. this.data.annotationType = AnnotationType.STRIKEOUT;
  55013. this._preparePopup(parameters.dict);
  55014. this.data.borderStyle.setWidth(0);
  55015. }
  55016. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55017. return StrikeOutAnnotation;
  55018. }();
  55019. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55020. function FileAttachmentAnnotation(parameters) {
  55021. Annotation.call(this, parameters);
  55022. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55023. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55024. this.data.file = file.serializable;
  55025. this._preparePopup(parameters.dict);
  55026. }
  55027. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55028. return FileAttachmentAnnotation;
  55029. }();
  55030. exports.Annotation = Annotation;
  55031. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55032. exports.AnnotationFactory = AnnotationFactory;
  55033. }));
  55034. (function (root, factory) {
  55035. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55036. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55037. var MissingDataException = sharedUtil.MissingDataException;
  55038. var Util = sharedUtil.Util;
  55039. var assert = sharedUtil.assert;
  55040. var error = sharedUtil.error;
  55041. var info = sharedUtil.info;
  55042. var isArray = sharedUtil.isArray;
  55043. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55044. var isNum = sharedUtil.isNum;
  55045. var isString = sharedUtil.isString;
  55046. var shadow = sharedUtil.shadow;
  55047. var stringToBytes = sharedUtil.stringToBytes;
  55048. var stringToPDFString = sharedUtil.stringToPDFString;
  55049. var warn = sharedUtil.warn;
  55050. var isSpace = sharedUtil.isSpace;
  55051. var Dict = corePrimitives.Dict;
  55052. var isDict = corePrimitives.isDict;
  55053. var isName = corePrimitives.isName;
  55054. var isStream = corePrimitives.isStream;
  55055. var NullStream = coreStream.NullStream;
  55056. var Stream = coreStream.Stream;
  55057. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55058. var Catalog = coreObj.Catalog;
  55059. var ObjectLoader = coreObj.ObjectLoader;
  55060. var XRef = coreObj.XRef;
  55061. var Linearization = coreParser.Linearization;
  55062. var calculateMD5 = coreCrypto.calculateMD5;
  55063. var OperatorList = coreEvaluator.OperatorList;
  55064. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55065. var Annotation = coreAnnotation.Annotation;
  55066. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55067. var Page = function PageClosure() {
  55068. var DEFAULT_USER_UNIT = 1.0;
  55069. var LETTER_SIZE_MEDIABOX = [
  55070. 0,
  55071. 0,
  55072. 612,
  55073. 792
  55074. ];
  55075. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55076. this.pdfManager = pdfManager;
  55077. this.pageIndex = pageIndex;
  55078. this.pageDict = pageDict;
  55079. this.xref = xref;
  55080. this.ref = ref;
  55081. this.fontCache = fontCache;
  55082. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55083. this.resourcesPromise = null;
  55084. var uniquePrefix = 'p' + this.pageIndex + '_';
  55085. var idCounters = { obj: 0 };
  55086. this.idFactory = {
  55087. createObjId: function () {
  55088. return uniquePrefix + ++idCounters.obj;
  55089. }
  55090. };
  55091. }
  55092. Page.prototype = {
  55093. getPageProp: function Page_getPageProp(key) {
  55094. return this.pageDict.get(key);
  55095. },
  55096. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  55097. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55098. var MAX_LOOP_COUNT = 100;
  55099. getArray = getArray || false;
  55100. while (dict) {
  55101. var value = getArray ? dict.getArray(key) : dict.get(key);
  55102. if (value) {
  55103. if (!valueArray) {
  55104. valueArray = [];
  55105. }
  55106. valueArray.push(value);
  55107. }
  55108. if (++loopCount > MAX_LOOP_COUNT) {
  55109. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55110. break;
  55111. }
  55112. dict = dict.get('Parent');
  55113. }
  55114. if (!valueArray) {
  55115. return Dict.empty;
  55116. }
  55117. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55118. return valueArray[0];
  55119. }
  55120. return Dict.merge(this.xref, valueArray);
  55121. },
  55122. get content() {
  55123. return this.getPageProp('Contents');
  55124. },
  55125. get resources() {
  55126. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55127. },
  55128. get mediaBox() {
  55129. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  55130. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  55131. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  55132. }
  55133. return shadow(this, 'mediaBox', mediaBox);
  55134. },
  55135. get cropBox() {
  55136. var cropBox = this.getInheritedPageProp('CropBox', true);
  55137. if (!isArray(cropBox) || cropBox.length !== 4) {
  55138. return shadow(this, 'cropBox', this.mediaBox);
  55139. }
  55140. return shadow(this, 'cropBox', cropBox);
  55141. },
  55142. get userUnit() {
  55143. var obj = this.getPageProp('UserUnit');
  55144. if (!isNum(obj) || obj <= 0) {
  55145. obj = DEFAULT_USER_UNIT;
  55146. }
  55147. return shadow(this, 'userUnit', obj);
  55148. },
  55149. get view() {
  55150. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  55151. if (mediaBox === cropBox) {
  55152. return shadow(this, 'view', mediaBox);
  55153. }
  55154. var intersection = Util.intersect(cropBox, mediaBox);
  55155. return shadow(this, 'view', intersection || mediaBox);
  55156. },
  55157. get rotate() {
  55158. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55159. if (rotate % 90 !== 0) {
  55160. rotate = 0;
  55161. } else if (rotate >= 360) {
  55162. rotate = rotate % 360;
  55163. } else if (rotate < 0) {
  55164. rotate = (rotate % 360 + 360) % 360;
  55165. }
  55166. return shadow(this, 'rotate', rotate);
  55167. },
  55168. getContentStream: function Page_getContentStream() {
  55169. var content = this.content;
  55170. var stream;
  55171. if (isArray(content)) {
  55172. var xref = this.xref;
  55173. var i, n = content.length;
  55174. var streams = [];
  55175. for (i = 0; i < n; ++i) {
  55176. streams.push(xref.fetchIfRef(content[i]));
  55177. }
  55178. stream = new StreamsSequenceStream(streams);
  55179. } else if (isStream(content)) {
  55180. stream = content;
  55181. } else {
  55182. stream = new NullStream();
  55183. }
  55184. return stream;
  55185. },
  55186. loadResources: function Page_loadResources(keys) {
  55187. if (!this.resourcesPromise) {
  55188. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55189. }
  55190. return this.resourcesPromise.then(function resourceSuccess() {
  55191. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55192. return objectLoader.load();
  55193. }.bind(this));
  55194. },
  55195. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55196. var self = this;
  55197. var pdfManager = this.pdfManager;
  55198. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55199. var resourcesPromise = this.loadResources([
  55200. 'ExtGState',
  55201. 'ColorSpace',
  55202. 'Pattern',
  55203. 'Shading',
  55204. 'XObject',
  55205. 'Font'
  55206. ]);
  55207. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  55208. var dataPromises = Promise.all([
  55209. contentStreamPromise,
  55210. resourcesPromise
  55211. ]);
  55212. var pageListPromise = dataPromises.then(function (data) {
  55213. var contentStream = data[0];
  55214. var opList = new OperatorList(intent, handler, self.pageIndex);
  55215. handler.send('StartRenderPage', {
  55216. transparency: partialEvaluator.hasBlendModes(self.resources),
  55217. pageIndex: self.pageIndex,
  55218. intent: intent
  55219. });
  55220. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55221. return opList;
  55222. });
  55223. });
  55224. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55225. return Promise.all([
  55226. pageListPromise,
  55227. annotationsPromise
  55228. ]).then(function (datas) {
  55229. var pageOpList = datas[0];
  55230. var annotations = datas[1];
  55231. if (annotations.length === 0) {
  55232. pageOpList.flush(true);
  55233. return pageOpList;
  55234. }
  55235. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55236. return annotationsReadyPromise.then(function () {
  55237. pageOpList.flush(true);
  55238. return pageOpList;
  55239. });
  55240. });
  55241. },
  55242. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55243. var handler = {
  55244. on: function nullHandlerOn() {
  55245. },
  55246. send: function nullHandlerSend() {
  55247. }
  55248. };
  55249. var self = this;
  55250. var pdfManager = this.pdfManager;
  55251. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55252. var resourcesPromise = this.loadResources([
  55253. 'ExtGState',
  55254. 'XObject',
  55255. 'Font'
  55256. ]);
  55257. var dataPromises = Promise.all([
  55258. contentStreamPromise,
  55259. resourcesPromise
  55260. ]);
  55261. return dataPromises.then(function (data) {
  55262. var contentStream = data[0];
  55263. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  55264. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55265. });
  55266. },
  55267. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55268. var annotations = this.annotations;
  55269. var annotationsData = [];
  55270. for (var i = 0, n = annotations.length; i < n; ++i) {
  55271. if (intent) {
  55272. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55273. continue;
  55274. }
  55275. }
  55276. annotationsData.push(annotations[i].data);
  55277. }
  55278. return annotationsData;
  55279. },
  55280. get annotations() {
  55281. var annotations = [];
  55282. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55283. var annotationFactory = new AnnotationFactory();
  55284. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55285. var annotationRef = annotationRefs[i];
  55286. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  55287. if (annotation) {
  55288. annotations.push(annotation);
  55289. }
  55290. }
  55291. return shadow(this, 'annotations', annotations);
  55292. }
  55293. };
  55294. return Page;
  55295. }();
  55296. var PDFDocument = function PDFDocumentClosure() {
  55297. var FINGERPRINT_FIRST_BYTES = 1024;
  55298. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55299. function PDFDocument(pdfManager, arg) {
  55300. var stream;
  55301. if (isStream(arg)) {
  55302. stream = arg;
  55303. } else if (isArrayBuffer(arg)) {
  55304. stream = new Stream(arg);
  55305. } else {
  55306. error('PDFDocument: Unknown argument type');
  55307. }
  55308. assert(stream.length > 0, 'stream must have data');
  55309. this.pdfManager = pdfManager;
  55310. this.stream = stream;
  55311. this.xref = new XRef(stream, pdfManager);
  55312. }
  55313. function find(stream, needle, limit, backwards) {
  55314. var pos = stream.pos;
  55315. var end = stream.end;
  55316. var strBuf = [];
  55317. if (pos + limit > end) {
  55318. limit = end - pos;
  55319. }
  55320. for (var n = 0; n < limit; ++n) {
  55321. strBuf.push(String.fromCharCode(stream.getByte()));
  55322. }
  55323. var str = strBuf.join('');
  55324. stream.pos = pos;
  55325. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55326. if (index === -1) {
  55327. return false;
  55328. }
  55329. stream.pos += index;
  55330. return true;
  55331. }
  55332. var DocumentInfoValidators = {
  55333. get entries() {
  55334. return shadow(this, 'entries', {
  55335. Title: isString,
  55336. Author: isString,
  55337. Subject: isString,
  55338. Keywords: isString,
  55339. Creator: isString,
  55340. Producer: isString,
  55341. CreationDate: isString,
  55342. ModDate: isString,
  55343. Trapped: isName
  55344. });
  55345. }
  55346. };
  55347. PDFDocument.prototype = {
  55348. parse: function PDFDocument_parse(recoveryMode) {
  55349. this.setup(recoveryMode);
  55350. var version = this.catalog.catDict.get('Version');
  55351. if (isName(version)) {
  55352. this.pdfFormatVersion = version.name;
  55353. }
  55354. try {
  55355. this.acroForm = this.catalog.catDict.get('AcroForm');
  55356. if (this.acroForm) {
  55357. this.xfa = this.acroForm.get('XFA');
  55358. var fields = this.acroForm.get('Fields');
  55359. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55360. this.acroForm = null;
  55361. }
  55362. }
  55363. } catch (ex) {
  55364. info('Something wrong with AcroForm entry');
  55365. this.acroForm = null;
  55366. }
  55367. },
  55368. get linearization() {
  55369. var linearization = null;
  55370. if (this.stream.length) {
  55371. try {
  55372. linearization = Linearization.create(this.stream);
  55373. } catch (err) {
  55374. if (err instanceof MissingDataException) {
  55375. throw err;
  55376. }
  55377. info(err);
  55378. }
  55379. }
  55380. return shadow(this, 'linearization', linearization);
  55381. },
  55382. get startXRef() {
  55383. var stream = this.stream;
  55384. var startXRef = 0;
  55385. var linearization = this.linearization;
  55386. if (linearization) {
  55387. stream.reset();
  55388. if (find(stream, 'endobj', 1024)) {
  55389. startXRef = stream.pos + 6;
  55390. }
  55391. } else {
  55392. var step = 1024;
  55393. var found = false, pos = stream.end;
  55394. while (!found && pos > 0) {
  55395. pos -= step - 'startxref'.length;
  55396. if (pos < 0) {
  55397. pos = 0;
  55398. }
  55399. stream.pos = pos;
  55400. found = find(stream, 'startxref', step, true);
  55401. }
  55402. if (found) {
  55403. stream.skip(9);
  55404. var ch;
  55405. do {
  55406. ch = stream.getByte();
  55407. } while (isSpace(ch));
  55408. var str = '';
  55409. while (ch >= 0x20 && ch <= 0x39) {
  55410. str += String.fromCharCode(ch);
  55411. ch = stream.getByte();
  55412. }
  55413. startXRef = parseInt(str, 10);
  55414. if (isNaN(startXRef)) {
  55415. startXRef = 0;
  55416. }
  55417. }
  55418. }
  55419. return shadow(this, 'startXRef', startXRef);
  55420. },
  55421. get mainXRefEntriesOffset() {
  55422. var mainXRefEntriesOffset = 0;
  55423. var linearization = this.linearization;
  55424. if (linearization) {
  55425. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55426. }
  55427. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55428. },
  55429. checkHeader: function PDFDocument_checkHeader() {
  55430. var stream = this.stream;
  55431. stream.reset();
  55432. if (find(stream, '%PDF-', 1024)) {
  55433. stream.moveStart();
  55434. var MAX_VERSION_LENGTH = 12;
  55435. var version = '', ch;
  55436. while ((ch = stream.getByte()) > 0x20) {
  55437. if (version.length >= MAX_VERSION_LENGTH) {
  55438. break;
  55439. }
  55440. version += String.fromCharCode(ch);
  55441. }
  55442. if (!this.pdfFormatVersion) {
  55443. this.pdfFormatVersion = version.substring(5);
  55444. }
  55445. return;
  55446. }
  55447. },
  55448. parseStartXRef: function PDFDocument_parseStartXRef() {
  55449. var startXRef = this.startXRef;
  55450. this.xref.setStartXRef(startXRef);
  55451. },
  55452. setup: function PDFDocument_setup(recoveryMode) {
  55453. this.xref.parse(recoveryMode);
  55454. var self = this;
  55455. var pageFactory = {
  55456. createPage: function (pageIndex, dict, ref, fontCache) {
  55457. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55458. }
  55459. };
  55460. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55461. },
  55462. get numPages() {
  55463. var linearization = this.linearization;
  55464. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55465. return shadow(this, 'numPages', num);
  55466. },
  55467. get documentInfo() {
  55468. var docInfo = {
  55469. PDFFormatVersion: this.pdfFormatVersion,
  55470. IsAcroFormPresent: !!this.acroForm,
  55471. IsXFAPresent: !!this.xfa
  55472. };
  55473. var infoDict;
  55474. try {
  55475. infoDict = this.xref.trailer.get('Info');
  55476. } catch (err) {
  55477. info('The document information dictionary is invalid.');
  55478. }
  55479. if (infoDict) {
  55480. var validEntries = DocumentInfoValidators.entries;
  55481. for (var key in validEntries) {
  55482. if (infoDict.has(key)) {
  55483. var value = infoDict.get(key);
  55484. if (validEntries[key](value)) {
  55485. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55486. } else {
  55487. info('Bad value in document info for "' + key + '"');
  55488. }
  55489. }
  55490. }
  55491. }
  55492. return shadow(this, 'documentInfo', docInfo);
  55493. },
  55494. get fingerprint() {
  55495. var xref = this.xref, hash, fileID = '';
  55496. var idArray = xref.trailer.get('ID');
  55497. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55498. hash = stringToBytes(idArray[0]);
  55499. } else {
  55500. if (this.stream.ensureRange) {
  55501. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55502. }
  55503. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55504. }
  55505. for (var i = 0, n = hash.length; i < n; i++) {
  55506. var hex = hash[i].toString(16);
  55507. fileID += hex.length === 1 ? '0' + hex : hex;
  55508. }
  55509. return shadow(this, 'fingerprint', fileID);
  55510. },
  55511. getPage: function PDFDocument_getPage(pageIndex) {
  55512. return this.catalog.getPage(pageIndex);
  55513. },
  55514. cleanup: function PDFDocument_cleanup() {
  55515. return this.catalog.cleanup();
  55516. }
  55517. };
  55518. return PDFDocument;
  55519. }();
  55520. exports.Page = Page;
  55521. exports.PDFDocument = PDFDocument;
  55522. }));
  55523. (function (root, factory) {
  55524. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55525. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55526. var warn = sharedUtil.warn;
  55527. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55528. var shadow = sharedUtil.shadow;
  55529. var NotImplementedException = sharedUtil.NotImplementedException;
  55530. var MissingDataException = sharedUtil.MissingDataException;
  55531. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55532. var Util = sharedUtil.Util;
  55533. var Stream = coreStream.Stream;
  55534. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55535. var PDFDocument = coreDocument.PDFDocument;
  55536. var BasePdfManager = function BasePdfManagerClosure() {
  55537. function BasePdfManager() {
  55538. throw new Error('Cannot initialize BaseManagerManager');
  55539. }
  55540. BasePdfManager.prototype = {
  55541. get docId() {
  55542. return this._docId;
  55543. },
  55544. get password() {
  55545. return this._password;
  55546. },
  55547. get docBaseUrl() {
  55548. var docBaseUrl = null;
  55549. if (this._docBaseUrl) {
  55550. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55551. if (absoluteUrl) {
  55552. docBaseUrl = absoluteUrl.href;
  55553. } else {
  55554. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55555. }
  55556. }
  55557. return shadow(this, 'docBaseUrl', docBaseUrl);
  55558. },
  55559. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55560. throw new NotImplementedException();
  55561. },
  55562. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55563. return this.ensure(this.pdfDocument, prop, args);
  55564. },
  55565. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55566. return this.ensure(this.pdfDocument.xref, prop, args);
  55567. },
  55568. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55569. return this.ensure(this.pdfDocument.catalog, prop, args);
  55570. },
  55571. getPage: function BasePdfManager_getPage(pageIndex) {
  55572. return this.pdfDocument.getPage(pageIndex);
  55573. },
  55574. cleanup: function BasePdfManager_cleanup() {
  55575. return this.pdfDocument.cleanup();
  55576. },
  55577. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55578. return new NotImplementedException();
  55579. },
  55580. requestRange: function BasePdfManager_requestRange(begin, end) {
  55581. return new NotImplementedException();
  55582. },
  55583. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55584. return new NotImplementedException();
  55585. },
  55586. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55587. return new NotImplementedException();
  55588. },
  55589. updatePassword: function BasePdfManager_updatePassword(password) {
  55590. this._password = password;
  55591. },
  55592. terminate: function BasePdfManager_terminate() {
  55593. return new NotImplementedException();
  55594. }
  55595. };
  55596. return BasePdfManager;
  55597. }();
  55598. var LocalPdfManager = function LocalPdfManagerClosure() {
  55599. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55600. this._docId = docId;
  55601. this._password = password;
  55602. this._docBaseUrl = docBaseUrl;
  55603. this.evaluatorOptions = evaluatorOptions;
  55604. var stream = new Stream(data);
  55605. this.pdfDocument = new PDFDocument(this, stream);
  55606. this._loadedStreamCapability = createPromiseCapability();
  55607. this._loadedStreamCapability.resolve(stream);
  55608. }
  55609. Util.inherit(LocalPdfManager, BasePdfManager, {
  55610. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55611. return new Promise(function (resolve, reject) {
  55612. try {
  55613. var value = obj[prop];
  55614. var result;
  55615. if (typeof value === 'function') {
  55616. result = value.apply(obj, args);
  55617. } else {
  55618. result = value;
  55619. }
  55620. resolve(result);
  55621. } catch (e) {
  55622. reject(e);
  55623. }
  55624. });
  55625. },
  55626. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55627. return Promise.resolve();
  55628. },
  55629. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55630. },
  55631. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55632. return this._loadedStreamCapability.promise;
  55633. },
  55634. terminate: function LocalPdfManager_terminate() {
  55635. }
  55636. });
  55637. return LocalPdfManager;
  55638. }();
  55639. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55640. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55641. this._docId = docId;
  55642. this._password = args.password;
  55643. this._docBaseUrl = docBaseUrl;
  55644. this.msgHandler = args.msgHandler;
  55645. this.evaluatorOptions = evaluatorOptions;
  55646. var params = {
  55647. msgHandler: args.msgHandler,
  55648. url: args.url,
  55649. length: args.length,
  55650. disableAutoFetch: args.disableAutoFetch,
  55651. rangeChunkSize: args.rangeChunkSize
  55652. };
  55653. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55654. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  55655. }
  55656. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55657. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55658. var pdfManager = this;
  55659. return new Promise(function (resolve, reject) {
  55660. function ensureHelper() {
  55661. try {
  55662. var result;
  55663. var value = obj[prop];
  55664. if (typeof value === 'function') {
  55665. result = value.apply(obj, args);
  55666. } else {
  55667. result = value;
  55668. }
  55669. resolve(result);
  55670. } catch (e) {
  55671. if (!(e instanceof MissingDataException)) {
  55672. reject(e);
  55673. return;
  55674. }
  55675. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55676. }
  55677. }
  55678. ensureHelper();
  55679. });
  55680. },
  55681. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55682. return this.streamManager.requestRange(begin, end);
  55683. },
  55684. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55685. this.streamManager.requestAllChunks();
  55686. },
  55687. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55688. this.streamManager.onReceiveData({ chunk: chunk });
  55689. },
  55690. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55691. return this.streamManager.onLoadedStream();
  55692. },
  55693. terminate: function NetworkPdfManager_terminate() {
  55694. this.streamManager.abort();
  55695. }
  55696. });
  55697. return NetworkPdfManager;
  55698. }();
  55699. exports.LocalPdfManager = LocalPdfManager;
  55700. exports.NetworkPdfManager = NetworkPdfManager;
  55701. }));
  55702. (function (root, factory) {
  55703. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55704. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55705. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55706. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55707. var MessageHandler = sharedUtil.MessageHandler;
  55708. var MissingPDFException = sharedUtil.MissingPDFException;
  55709. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55710. var PasswordException = sharedUtil.PasswordException;
  55711. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55712. var XRefParseException = sharedUtil.XRefParseException;
  55713. var arrayByteLength = sharedUtil.arrayByteLength;
  55714. var arraysToBytes = sharedUtil.arraysToBytes;
  55715. var assert = sharedUtil.assert;
  55716. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55717. var error = sharedUtil.error;
  55718. var info = sharedUtil.info;
  55719. var warn = sharedUtil.warn;
  55720. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55721. var Ref = corePrimitives.Ref;
  55722. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55723. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55724. var globalScope = sharedUtil.globalScope;
  55725. var WorkerTask = function WorkerTaskClosure() {
  55726. function WorkerTask(name) {
  55727. this.name = name;
  55728. this.terminated = false;
  55729. this._capability = createPromiseCapability();
  55730. }
  55731. WorkerTask.prototype = {
  55732. get finished() {
  55733. return this._capability.promise;
  55734. },
  55735. finish: function () {
  55736. this._capability.resolve();
  55737. },
  55738. terminate: function () {
  55739. this.terminated = true;
  55740. },
  55741. ensureNotTerminated: function () {
  55742. if (this.terminated) {
  55743. throw new Error('Worker task was terminated');
  55744. }
  55745. }
  55746. };
  55747. return WorkerTask;
  55748. }();
  55749. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  55750. function PDFWorkerStream(params, msgHandler) {
  55751. this._queuedChunks = [];
  55752. var initialData = params.initialData;
  55753. if (initialData && initialData.length > 0) {
  55754. this._queuedChunks.push(initialData);
  55755. }
  55756. this._msgHandler = msgHandler;
  55757. this._isRangeSupported = !params.disableRange;
  55758. this._isStreamingSupported = !params.disableStream;
  55759. this._contentLength = params.length;
  55760. this._fullRequestReader = null;
  55761. this._rangeReaders = [];
  55762. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  55763. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  55764. }
  55765. PDFWorkerStream.prototype = {
  55766. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  55767. if (args.begin === undefined) {
  55768. if (this._fullRequestReader) {
  55769. this._fullRequestReader._enqueue(args.chunk);
  55770. } else {
  55771. this._queuedChunks.push(args.chunk);
  55772. }
  55773. } else {
  55774. var found = this._rangeReaders.some(function (rangeReader) {
  55775. if (rangeReader._begin !== args.begin) {
  55776. return false;
  55777. }
  55778. rangeReader._enqueue(args.chunk);
  55779. return true;
  55780. });
  55781. assert(found);
  55782. }
  55783. },
  55784. _onProgress: function PDFWorkerStream_onProgress(evt) {
  55785. if (this._rangeReaders.length > 0) {
  55786. var firstReader = this._rangeReaders[0];
  55787. if (firstReader.onProgress) {
  55788. firstReader.onProgress({ loaded: evt.loaded });
  55789. }
  55790. }
  55791. },
  55792. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  55793. var i = this._rangeReaders.indexOf(reader);
  55794. if (i >= 0) {
  55795. this._rangeReaders.splice(i, 1);
  55796. }
  55797. },
  55798. getFullReader: function PDFWorkerStream_getFullReader() {
  55799. assert(!this._fullRequestReader);
  55800. var queuedChunks = this._queuedChunks;
  55801. this._queuedChunks = null;
  55802. return new PDFWorkerStreamReader(this, queuedChunks);
  55803. },
  55804. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  55805. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  55806. this._msgHandler.send('RequestDataRange', {
  55807. begin: begin,
  55808. end: end
  55809. });
  55810. this._rangeReaders.push(reader);
  55811. return reader;
  55812. },
  55813. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  55814. if (this._fullRequestReader) {
  55815. this._fullRequestReader.cancel(reason);
  55816. }
  55817. var readers = this._rangeReaders.slice(0);
  55818. readers.forEach(function (rangeReader) {
  55819. rangeReader.cancel(reason);
  55820. });
  55821. }
  55822. };
  55823. function PDFWorkerStreamReader(stream, queuedChunks) {
  55824. this._stream = stream;
  55825. this._done = false;
  55826. this._queuedChunks = queuedChunks || [];
  55827. this._requests = [];
  55828. this._headersReady = Promise.resolve();
  55829. stream._fullRequestReader = this;
  55830. this.onProgress = null;
  55831. }
  55832. PDFWorkerStreamReader.prototype = {
  55833. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  55834. if (this._done) {
  55835. return;
  55836. }
  55837. if (this._requests.length > 0) {
  55838. var requestCapability = this._requests.shift();
  55839. requestCapability.resolve({
  55840. value: chunk,
  55841. done: false
  55842. });
  55843. return;
  55844. }
  55845. this._queuedChunks.push(chunk);
  55846. },
  55847. get headersReady() {
  55848. return this._headersReady;
  55849. },
  55850. get isRangeSupported() {
  55851. return this._stream._isRangeSupported;
  55852. },
  55853. get isStreamingSupported() {
  55854. return this._stream._isStreamingSupported;
  55855. },
  55856. get contentLength() {
  55857. return this._stream._contentLength;
  55858. },
  55859. read: function PDFWorkerStreamReader_read() {
  55860. if (this._queuedChunks.length > 0) {
  55861. var chunk = this._queuedChunks.shift();
  55862. return Promise.resolve({
  55863. value: chunk,
  55864. done: false
  55865. });
  55866. }
  55867. if (this._done) {
  55868. return Promise.resolve({
  55869. value: undefined,
  55870. done: true
  55871. });
  55872. }
  55873. var requestCapability = createPromiseCapability();
  55874. this._requests.push(requestCapability);
  55875. return requestCapability.promise;
  55876. },
  55877. cancel: function PDFWorkerStreamReader_cancel(reason) {
  55878. this._done = true;
  55879. this._requests.forEach(function (requestCapability) {
  55880. requestCapability.resolve({
  55881. value: undefined,
  55882. done: true
  55883. });
  55884. });
  55885. this._requests = [];
  55886. }
  55887. };
  55888. function PDFWorkerStreamRangeReader(stream, begin, end) {
  55889. this._stream = stream;
  55890. this._begin = begin;
  55891. this._end = end;
  55892. this._queuedChunk = null;
  55893. this._requests = [];
  55894. this._done = false;
  55895. this.onProgress = null;
  55896. }
  55897. PDFWorkerStreamRangeReader.prototype = {
  55898. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  55899. if (this._done) {
  55900. return;
  55901. }
  55902. if (this._requests.length === 0) {
  55903. this._queuedChunk = chunk;
  55904. } else {
  55905. var requestsCapability = this._requests.shift();
  55906. requestsCapability.resolve({
  55907. value: chunk,
  55908. done: false
  55909. });
  55910. this._requests.forEach(function (requestCapability) {
  55911. requestCapability.resolve({
  55912. value: undefined,
  55913. done: true
  55914. });
  55915. });
  55916. this._requests = [];
  55917. }
  55918. this._done = true;
  55919. this._stream._removeRangeReader(this);
  55920. },
  55921. get isStreamingSupported() {
  55922. return false;
  55923. },
  55924. read: function PDFWorkerStreamRangeReader_read() {
  55925. if (this._queuedChunk) {
  55926. return Promise.resolve({
  55927. value: this._queuedChunk,
  55928. done: false
  55929. });
  55930. }
  55931. if (this._done) {
  55932. return Promise.resolve({
  55933. value: undefined,
  55934. done: true
  55935. });
  55936. }
  55937. var requestCapability = createPromiseCapability();
  55938. this._requests.push(requestCapability);
  55939. return requestCapability.promise;
  55940. },
  55941. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  55942. this._done = true;
  55943. this._requests.forEach(function (requestCapability) {
  55944. requestCapability.resolve({
  55945. value: undefined,
  55946. done: true
  55947. });
  55948. });
  55949. this._requests = [];
  55950. this._stream._removeRangeReader(this);
  55951. }
  55952. };
  55953. return PDFWorkerStream;
  55954. }();
  55955. var PDFNetworkStream;
  55956. function setPDFNetworkStreamClass(cls) {
  55957. PDFNetworkStream = cls;
  55958. }
  55959. var WorkerMessageHandler = {
  55960. setup: function wphSetup(handler, port) {
  55961. var testMessageProcessed = false;
  55962. handler.on('test', function wphSetupTest(data) {
  55963. if (testMessageProcessed) {
  55964. return;
  55965. }
  55966. testMessageProcessed = true;
  55967. if (!(data instanceof Uint8Array)) {
  55968. handler.send('test', 'main', false);
  55969. return;
  55970. }
  55971. var supportTransfers = data[0] === 255;
  55972. handler.postMessageTransfers = supportTransfers;
  55973. var xhr = new XMLHttpRequest();
  55974. var responseExists = 'response' in xhr;
  55975. try {
  55976. xhr.responseType;
  55977. } catch (e) {
  55978. responseExists = false;
  55979. }
  55980. if (!responseExists) {
  55981. handler.send('test', false);
  55982. return;
  55983. }
  55984. handler.send('test', {
  55985. supportTypedArray: true,
  55986. supportTransfers: supportTransfers
  55987. });
  55988. });
  55989. handler.on('configure', function wphConfigure(data) {
  55990. setVerbosityLevel(data.verbosity);
  55991. });
  55992. handler.on('GetDocRequest', function wphSetupDoc(data) {
  55993. return WorkerMessageHandler.createDocumentHandler(data, port);
  55994. });
  55995. },
  55996. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  55997. var pdfManager;
  55998. var terminated = false;
  55999. var cancelXHRs = null;
  56000. var WorkerTasks = [];
  56001. var docId = docParams.docId;
  56002. var docBaseUrl = docParams.docBaseUrl;
  56003. var workerHandlerName = docParams.docId + '_worker';
  56004. var handler = new MessageHandler(workerHandlerName, docId, port);
  56005. handler.postMessageTransfers = docParams.postMessageTransfers;
  56006. function ensureNotTerminated() {
  56007. if (terminated) {
  56008. throw new Error('Worker was terminated');
  56009. }
  56010. }
  56011. function startWorkerTask(task) {
  56012. WorkerTasks.push(task);
  56013. }
  56014. function finishWorkerTask(task) {
  56015. task.finish();
  56016. var i = WorkerTasks.indexOf(task);
  56017. WorkerTasks.splice(i, 1);
  56018. }
  56019. function loadDocument(recoveryMode) {
  56020. var loadDocumentCapability = createPromiseCapability();
  56021. var parseSuccess = function parseSuccess() {
  56022. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56023. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56024. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56025. Promise.all([
  56026. numPagesPromise,
  56027. fingerprintPromise,
  56028. encryptedPromise
  56029. ]).then(function onDocReady(results) {
  56030. var doc = {
  56031. numPages: results[0],
  56032. fingerprint: results[1],
  56033. encrypted: !!results[2]
  56034. };
  56035. loadDocumentCapability.resolve(doc);
  56036. }, parseFailure);
  56037. };
  56038. var parseFailure = function parseFailure(e) {
  56039. loadDocumentCapability.reject(e);
  56040. };
  56041. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56042. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56043. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56044. }, parseFailure);
  56045. }, parseFailure);
  56046. return loadDocumentCapability.promise;
  56047. }
  56048. function getPdfManager(data, evaluatorOptions) {
  56049. var pdfManagerCapability = createPromiseCapability();
  56050. var pdfManager;
  56051. var source = data.source;
  56052. if (source.data) {
  56053. try {
  56054. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56055. pdfManagerCapability.resolve(pdfManager);
  56056. } catch (ex) {
  56057. pdfManagerCapability.reject(ex);
  56058. }
  56059. return pdfManagerCapability.promise;
  56060. }
  56061. var pdfStream;
  56062. try {
  56063. if (source.chunkedViewerLoading) {
  56064. pdfStream = new PDFWorkerStream(source, handler);
  56065. } else {
  56066. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56067. pdfStream = new PDFNetworkStream(data);
  56068. }
  56069. } catch (ex) {
  56070. pdfManagerCapability.reject(ex);
  56071. return pdfManagerCapability.promise;
  56072. }
  56073. var fullRequest = pdfStream.getFullReader();
  56074. fullRequest.headersReady.then(function () {
  56075. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56076. fullRequest.onProgress = function (evt) {
  56077. handler.send('DocProgress', {
  56078. loaded: evt.loaded,
  56079. total: evt.total
  56080. });
  56081. };
  56082. }
  56083. if (!fullRequest.isRangeSupported) {
  56084. return;
  56085. }
  56086. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56087. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56088. msgHandler: handler,
  56089. url: source.url,
  56090. password: source.password,
  56091. length: fullRequest.contentLength,
  56092. disableAutoFetch: disableAutoFetch,
  56093. rangeChunkSize: source.rangeChunkSize
  56094. }, evaluatorOptions, docBaseUrl);
  56095. pdfManagerCapability.resolve(pdfManager);
  56096. cancelXHRs = null;
  56097. }).catch(function (reason) {
  56098. pdfManagerCapability.reject(reason);
  56099. cancelXHRs = null;
  56100. });
  56101. var cachedChunks = [], loaded = 0;
  56102. var flushChunks = function () {
  56103. var pdfFile = arraysToBytes(cachedChunks);
  56104. if (source.length && pdfFile.length !== source.length) {
  56105. warn('reported HTTP length is different from actual');
  56106. }
  56107. try {
  56108. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56109. pdfManagerCapability.resolve(pdfManager);
  56110. } catch (ex) {
  56111. pdfManagerCapability.reject(ex);
  56112. }
  56113. cachedChunks = [];
  56114. };
  56115. var readPromise = new Promise(function (resolve, reject) {
  56116. var readChunk = function (chunk) {
  56117. try {
  56118. ensureNotTerminated();
  56119. if (chunk.done) {
  56120. if (!pdfManager) {
  56121. flushChunks();
  56122. }
  56123. cancelXHRs = null;
  56124. return;
  56125. }
  56126. var data = chunk.value;
  56127. loaded += arrayByteLength(data);
  56128. if (!fullRequest.isStreamingSupported) {
  56129. handler.send('DocProgress', {
  56130. loaded: loaded,
  56131. total: Math.max(loaded, fullRequest.contentLength || 0)
  56132. });
  56133. }
  56134. if (pdfManager) {
  56135. pdfManager.sendProgressiveData(data);
  56136. } else {
  56137. cachedChunks.push(data);
  56138. }
  56139. fullRequest.read().then(readChunk, reject);
  56140. } catch (e) {
  56141. reject(e);
  56142. }
  56143. };
  56144. fullRequest.read().then(readChunk, reject);
  56145. });
  56146. readPromise.catch(function (e) {
  56147. pdfManagerCapability.reject(e);
  56148. cancelXHRs = null;
  56149. });
  56150. cancelXHRs = function () {
  56151. pdfStream.cancelAllRequests('abort');
  56152. };
  56153. return pdfManagerCapability.promise;
  56154. }
  56155. function setupDoc(data) {
  56156. function onSuccess(doc) {
  56157. ensureNotTerminated();
  56158. handler.send('GetDoc', { pdfInfo: doc });
  56159. }
  56160. function onFailure(e) {
  56161. if (e instanceof PasswordException) {
  56162. var task = new WorkerTask('PasswordException: response ' + e.code);
  56163. startWorkerTask(task);
  56164. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  56165. finishWorkerTask(task);
  56166. pdfManager.updatePassword(data.password);
  56167. pdfManagerReady();
  56168. }).catch(function (ex) {
  56169. finishWorkerTask(task);
  56170. handler.send('PasswordException', ex);
  56171. }.bind(null, e));
  56172. } else if (e instanceof InvalidPDFException) {
  56173. handler.send('InvalidPDF', e);
  56174. } else if (e instanceof MissingPDFException) {
  56175. handler.send('MissingPDF', e);
  56176. } else if (e instanceof UnexpectedResponseException) {
  56177. handler.send('UnexpectedResponse', e);
  56178. } else {
  56179. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56180. }
  56181. }
  56182. function pdfManagerReady() {
  56183. ensureNotTerminated();
  56184. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56185. ensureNotTerminated();
  56186. if (!(ex instanceof XRefParseException)) {
  56187. onFailure(ex);
  56188. return;
  56189. }
  56190. pdfManager.requestLoadedStream();
  56191. pdfManager.onLoadedStream().then(function () {
  56192. ensureNotTerminated();
  56193. loadDocument(true).then(onSuccess, onFailure);
  56194. });
  56195. }, onFailure);
  56196. }
  56197. ensureNotTerminated();
  56198. var cMapOptions = {
  56199. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56200. packed: data.cMapPacked === true
  56201. };
  56202. var evaluatorOptions = {
  56203. forceDataSchema: data.disableCreateObjectURL,
  56204. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56205. disableFontFace: data.disableFontFace,
  56206. cMapOptions: cMapOptions,
  56207. disableNativeImageDecoder: data.disableNativeImageDecoder
  56208. };
  56209. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56210. if (terminated) {
  56211. newPdfManager.terminate();
  56212. throw new Error('Worker was terminated');
  56213. }
  56214. pdfManager = newPdfManager;
  56215. handler.send('PDFManagerReady', null);
  56216. pdfManager.onLoadedStream().then(function (stream) {
  56217. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56218. });
  56219. }).then(pdfManagerReady, onFailure);
  56220. }
  56221. handler.on('GetPage', function wphSetupGetPage(data) {
  56222. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56223. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56224. var refPromise = pdfManager.ensure(page, 'ref');
  56225. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  56226. var viewPromise = pdfManager.ensure(page, 'view');
  56227. return Promise.all([
  56228. rotatePromise,
  56229. refPromise,
  56230. userUnitPromise,
  56231. viewPromise
  56232. ]).then(function (results) {
  56233. return {
  56234. rotate: results[0],
  56235. ref: results[1],
  56236. userUnit: results[2],
  56237. view: results[3]
  56238. };
  56239. });
  56240. });
  56241. });
  56242. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56243. var ref = new Ref(data.ref.num, data.ref.gen);
  56244. var catalog = pdfManager.pdfDocument.catalog;
  56245. return catalog.getPageIndex(ref);
  56246. });
  56247. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56248. return pdfManager.ensureCatalog('destinations');
  56249. });
  56250. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56251. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56252. });
  56253. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56254. return pdfManager.ensureCatalog('pageLabels');
  56255. });
  56256. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56257. return pdfManager.ensureCatalog('attachments');
  56258. });
  56259. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56260. return pdfManager.ensureCatalog('javaScript');
  56261. });
  56262. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56263. return pdfManager.ensureCatalog('documentOutline');
  56264. });
  56265. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56266. return Promise.all([
  56267. pdfManager.ensureDoc('documentInfo'),
  56268. pdfManager.ensureCatalog('metadata')
  56269. ]);
  56270. });
  56271. handler.on('GetData', function wphSetupGetData(data) {
  56272. pdfManager.requestLoadedStream();
  56273. return pdfManager.onLoadedStream().then(function (stream) {
  56274. return stream.bytes;
  56275. });
  56276. });
  56277. handler.on('GetStats', function wphSetupGetStats(data) {
  56278. return pdfManager.pdfDocument.xref.stats;
  56279. });
  56280. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56281. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56282. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56283. });
  56284. });
  56285. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56286. var pageIndex = data.pageIndex;
  56287. pdfManager.getPage(pageIndex).then(function (page) {
  56288. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56289. startWorkerTask(task);
  56290. var pageNum = pageIndex + 1;
  56291. var start = Date.now();
  56292. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56293. finishWorkerTask(task);
  56294. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56295. }, function (e) {
  56296. finishWorkerTask(task);
  56297. if (task.terminated) {
  56298. return;
  56299. }
  56300. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56301. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56302. var wrappedException;
  56303. if (typeof e === 'string') {
  56304. wrappedException = {
  56305. message: e,
  56306. stack: minimumStackMessage
  56307. };
  56308. } else if (typeof e === 'object') {
  56309. wrappedException = {
  56310. message: e.message || e.toString(),
  56311. stack: e.stack || minimumStackMessage
  56312. };
  56313. } else {
  56314. wrappedException = {
  56315. message: 'Unknown exception type: ' + typeof e,
  56316. stack: minimumStackMessage
  56317. };
  56318. }
  56319. handler.send('PageError', {
  56320. pageNum: pageNum,
  56321. error: wrappedException,
  56322. intent: data.intent
  56323. });
  56324. });
  56325. });
  56326. }, this);
  56327. handler.on('GetTextContent', function wphExtractText(data) {
  56328. var pageIndex = data.pageIndex;
  56329. var normalizeWhitespace = data.normalizeWhitespace;
  56330. var combineTextItems = data.combineTextItems;
  56331. return pdfManager.getPage(pageIndex).then(function (page) {
  56332. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56333. startWorkerTask(task);
  56334. var pageNum = pageIndex + 1;
  56335. var start = Date.now();
  56336. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56337. finishWorkerTask(task);
  56338. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56339. return textContent;
  56340. }, function (reason) {
  56341. finishWorkerTask(task);
  56342. if (task.terminated) {
  56343. return;
  56344. }
  56345. throw reason;
  56346. });
  56347. });
  56348. });
  56349. handler.on('Cleanup', function wphCleanup(data) {
  56350. return pdfManager.cleanup();
  56351. });
  56352. handler.on('Terminate', function wphTerminate(data) {
  56353. terminated = true;
  56354. if (pdfManager) {
  56355. pdfManager.terminate();
  56356. pdfManager = null;
  56357. }
  56358. if (cancelXHRs) {
  56359. cancelXHRs();
  56360. }
  56361. var waitOn = [];
  56362. WorkerTasks.forEach(function (task) {
  56363. waitOn.push(task.finished);
  56364. task.terminate();
  56365. });
  56366. return Promise.all(waitOn).then(function () {
  56367. handler.destroy();
  56368. handler = null;
  56369. });
  56370. });
  56371. handler.on('Ready', function wphReady(data) {
  56372. setupDoc(docParams);
  56373. docParams = null;
  56374. });
  56375. return workerHandlerName;
  56376. }
  56377. };
  56378. function initializeWorker() {
  56379. if (!('console' in globalScope)) {
  56380. var consoleTimer = {};
  56381. var workerConsole = {
  56382. log: function log() {
  56383. var args = Array.prototype.slice.call(arguments);
  56384. globalScope.postMessage({
  56385. targetName: 'main',
  56386. action: 'console_log',
  56387. data: args
  56388. });
  56389. },
  56390. error: function error() {
  56391. var args = Array.prototype.slice.call(arguments);
  56392. globalScope.postMessage({
  56393. targetName: 'main',
  56394. action: 'console_error',
  56395. data: args
  56396. });
  56397. throw 'pdf.js execution error';
  56398. },
  56399. time: function time(name) {
  56400. consoleTimer[name] = Date.now();
  56401. },
  56402. timeEnd: function timeEnd(name) {
  56403. var time = consoleTimer[name];
  56404. if (!time) {
  56405. error('Unknown timer name ' + name);
  56406. }
  56407. this.log('Timer:', name, Date.now() - time);
  56408. }
  56409. };
  56410. globalScope.console = workerConsole;
  56411. }
  56412. var handler = new MessageHandler('worker', 'main', self);
  56413. WorkerMessageHandler.setup(handler, self);
  56414. handler.send('ready', null);
  56415. }
  56416. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56417. initializeWorker();
  56418. }
  56419. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56420. exports.WorkerTask = WorkerTask;
  56421. exports.WorkerMessageHandler = WorkerMessageHandler;
  56422. }));
  56423. (function (root, factory) {
  56424. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56425. }(this, function (exports, sharedUtil, coreWorker) {
  56426. var OK_RESPONSE = 200;
  56427. var PARTIAL_CONTENT_RESPONSE = 206;
  56428. function NetworkManager(url, args) {
  56429. this.url = url;
  56430. args = args || {};
  56431. this.isHttp = /^https?:/i.test(url);
  56432. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56433. this.withCredentials = args.withCredentials || false;
  56434. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56435. return new XMLHttpRequest();
  56436. };
  56437. this.currXhrId = 0;
  56438. this.pendingRequests = Object.create(null);
  56439. this.loadedRequests = Object.create(null);
  56440. }
  56441. function getArrayBuffer(xhr) {
  56442. var data = xhr.response;
  56443. if (typeof data !== 'string') {
  56444. return data;
  56445. }
  56446. var length = data.length;
  56447. var array = new Uint8Array(length);
  56448. for (var i = 0; i < length; i++) {
  56449. array[i] = data.charCodeAt(i) & 0xFF;
  56450. }
  56451. return array.buffer;
  56452. }
  56453. var supportsMozChunked = function supportsMozChunkedClosure() {
  56454. try {
  56455. var x = new XMLHttpRequest();
  56456. x.open('GET', 'https://example.com');
  56457. x.responseType = 'moz-chunked-arraybuffer';
  56458. return x.responseType === 'moz-chunked-arraybuffer';
  56459. } catch (e) {
  56460. return false;
  56461. }
  56462. }();
  56463. NetworkManager.prototype = {
  56464. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56465. var args = {
  56466. begin: begin,
  56467. end: end
  56468. };
  56469. for (var prop in listeners) {
  56470. args[prop] = listeners[prop];
  56471. }
  56472. return this.request(args);
  56473. },
  56474. requestFull: function NetworkManager_requestFull(listeners) {
  56475. return this.request(listeners);
  56476. },
  56477. request: function NetworkManager_request(args) {
  56478. var xhr = this.getXhr();
  56479. var xhrId = this.currXhrId++;
  56480. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56481. xhr.open('GET', this.url);
  56482. xhr.withCredentials = this.withCredentials;
  56483. for (var property in this.httpHeaders) {
  56484. var value = this.httpHeaders[property];
  56485. if (typeof value === 'undefined') {
  56486. continue;
  56487. }
  56488. xhr.setRequestHeader(property, value);
  56489. }
  56490. if (this.isHttp && 'begin' in args && 'end' in args) {
  56491. var rangeStr = args.begin + '-' + (args.end - 1);
  56492. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56493. pendingRequest.expectedStatus = 206;
  56494. } else {
  56495. pendingRequest.expectedStatus = 200;
  56496. }
  56497. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56498. if (useMozChunkedLoading) {
  56499. xhr.responseType = 'moz-chunked-arraybuffer';
  56500. pendingRequest.onProgressiveData = args.onProgressiveData;
  56501. pendingRequest.mozChunked = true;
  56502. } else {
  56503. xhr.responseType = 'arraybuffer';
  56504. }
  56505. if (args.onError) {
  56506. xhr.onerror = function (evt) {
  56507. args.onError(xhr.status);
  56508. };
  56509. }
  56510. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56511. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56512. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56513. pendingRequest.onDone = args.onDone;
  56514. pendingRequest.onError = args.onError;
  56515. pendingRequest.onProgress = args.onProgress;
  56516. xhr.send(null);
  56517. return xhrId;
  56518. },
  56519. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56520. var pendingRequest = this.pendingRequests[xhrId];
  56521. if (!pendingRequest) {
  56522. return;
  56523. }
  56524. if (pendingRequest.mozChunked) {
  56525. var chunk = getArrayBuffer(pendingRequest.xhr);
  56526. pendingRequest.onProgressiveData(chunk);
  56527. }
  56528. var onProgress = pendingRequest.onProgress;
  56529. if (onProgress) {
  56530. onProgress(evt);
  56531. }
  56532. },
  56533. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56534. var pendingRequest = this.pendingRequests[xhrId];
  56535. if (!pendingRequest) {
  56536. return;
  56537. }
  56538. var xhr = pendingRequest.xhr;
  56539. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56540. pendingRequest.onHeadersReceived();
  56541. delete pendingRequest.onHeadersReceived;
  56542. }
  56543. if (xhr.readyState !== 4) {
  56544. return;
  56545. }
  56546. if (!(xhrId in this.pendingRequests)) {
  56547. return;
  56548. }
  56549. delete this.pendingRequests[xhrId];
  56550. if (xhr.status === 0 && this.isHttp) {
  56551. if (pendingRequest.onError) {
  56552. pendingRequest.onError(xhr.status);
  56553. }
  56554. return;
  56555. }
  56556. var xhrStatus = xhr.status || OK_RESPONSE;
  56557. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56558. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56559. if (pendingRequest.onError) {
  56560. pendingRequest.onError(xhr.status);
  56561. }
  56562. return;
  56563. }
  56564. this.loadedRequests[xhrId] = true;
  56565. var chunk = getArrayBuffer(xhr);
  56566. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56567. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56568. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56569. var begin = parseInt(matches[1], 10);
  56570. pendingRequest.onDone({
  56571. begin: begin,
  56572. chunk: chunk
  56573. });
  56574. } else if (pendingRequest.onProgressiveData) {
  56575. pendingRequest.onDone(null);
  56576. } else if (chunk) {
  56577. pendingRequest.onDone({
  56578. begin: 0,
  56579. chunk: chunk
  56580. });
  56581. } else if (pendingRequest.onError) {
  56582. pendingRequest.onError(xhr.status);
  56583. }
  56584. },
  56585. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56586. for (var xhrId in this.pendingRequests) {
  56587. return true;
  56588. }
  56589. return false;
  56590. },
  56591. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56592. return this.pendingRequests[xhrId].xhr;
  56593. },
  56594. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56595. return !!this.pendingRequests[xhrId].onProgressiveData;
  56596. },
  56597. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56598. return xhrId in this.pendingRequests;
  56599. },
  56600. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56601. return xhrId in this.loadedRequests;
  56602. },
  56603. abortAllRequests: function NetworkManager_abortAllRequests() {
  56604. for (var xhrId in this.pendingRequests) {
  56605. this.abortRequest(xhrId | 0);
  56606. }
  56607. },
  56608. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56609. var xhr = this.pendingRequests[xhrId].xhr;
  56610. delete this.pendingRequests[xhrId];
  56611. xhr.abort();
  56612. }
  56613. };
  56614. var assert = sharedUtil.assert;
  56615. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56616. var isInt = sharedUtil.isInt;
  56617. var MissingPDFException = sharedUtil.MissingPDFException;
  56618. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56619. function PDFNetworkStream(options) {
  56620. this._options = options;
  56621. var source = options.source;
  56622. this._manager = new NetworkManager(source.url, {
  56623. httpHeaders: source.httpHeaders,
  56624. withCredentials: source.withCredentials
  56625. });
  56626. this._rangeChunkSize = source.rangeChunkSize;
  56627. this._fullRequestReader = null;
  56628. this._rangeRequestReaders = [];
  56629. }
  56630. PDFNetworkStream.prototype = {
  56631. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56632. var i = this._rangeRequestReaders.indexOf(reader);
  56633. if (i >= 0) {
  56634. this._rangeRequestReaders.splice(i, 1);
  56635. }
  56636. },
  56637. getFullReader: function PDFNetworkStream_getFullReader() {
  56638. assert(!this._fullRequestReader);
  56639. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56640. return this._fullRequestReader;
  56641. },
  56642. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56643. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56644. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56645. this._rangeRequestReaders.push(reader);
  56646. return reader;
  56647. },
  56648. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56649. if (this._fullRequestReader) {
  56650. this._fullRequestReader.cancel(reason);
  56651. }
  56652. var readers = this._rangeRequestReaders.slice(0);
  56653. readers.forEach(function (reader) {
  56654. reader.cancel(reason);
  56655. });
  56656. }
  56657. };
  56658. function PDFNetworkStreamFullRequestReader(manager, options) {
  56659. this._manager = manager;
  56660. var source = options.source;
  56661. var args = {
  56662. onHeadersReceived: this._onHeadersReceived.bind(this),
  56663. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56664. onDone: this._onDone.bind(this),
  56665. onError: this._onError.bind(this),
  56666. onProgress: this._onProgress.bind(this)
  56667. };
  56668. this._url = source.url;
  56669. this._fullRequestId = manager.requestFull(args);
  56670. this._headersReceivedCapability = createPromiseCapability();
  56671. this._disableRange = options.disableRange || false;
  56672. this._contentLength = source.length;
  56673. this._rangeChunkSize = source.rangeChunkSize;
  56674. if (!this._rangeChunkSize && !this._disableRange) {
  56675. this._disableRange = true;
  56676. }
  56677. this._isStreamingSupported = false;
  56678. this._isRangeSupported = false;
  56679. this._cachedChunks = [];
  56680. this._requests = [];
  56681. this._done = false;
  56682. this._storedError = undefined;
  56683. this.onProgress = null;
  56684. }
  56685. PDFNetworkStreamFullRequestReader.prototype = {
  56686. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56687. if (this._disableRange) {
  56688. return false;
  56689. }
  56690. var networkManager = this._manager;
  56691. if (!networkManager.isHttp) {
  56692. return false;
  56693. }
  56694. var fullRequestXhrId = this._fullRequestId;
  56695. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56696. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56697. return false;
  56698. }
  56699. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56700. if (contentEncoding !== 'identity') {
  56701. return false;
  56702. }
  56703. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56704. length = parseInt(length, 10);
  56705. if (!isInt(length)) {
  56706. return false;
  56707. }
  56708. this._contentLength = length;
  56709. if (length <= 2 * this._rangeChunkSize) {
  56710. return false;
  56711. }
  56712. return true;
  56713. },
  56714. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56715. if (this._validateRangeRequestCapabilities()) {
  56716. this._isRangeSupported = true;
  56717. }
  56718. var networkManager = this._manager;
  56719. var fullRequestXhrId = this._fullRequestId;
  56720. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56721. this._isStreamingSupported = true;
  56722. } else if (this._isRangeSupported) {
  56723. networkManager.abortRequest(fullRequestXhrId);
  56724. }
  56725. this._headersReceivedCapability.resolve();
  56726. },
  56727. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56728. if (this._requests.length > 0) {
  56729. var requestCapability = this._requests.shift();
  56730. requestCapability.resolve({
  56731. value: chunk,
  56732. done: false
  56733. });
  56734. } else {
  56735. this._cachedChunks.push(chunk);
  56736. }
  56737. },
  56738. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56739. if (args) {
  56740. this._onProgressiveData(args.chunk);
  56741. }
  56742. this._done = true;
  56743. if (this._cachedChunks.length > 0) {
  56744. return;
  56745. }
  56746. this._requests.forEach(function (requestCapability) {
  56747. requestCapability.resolve({
  56748. value: undefined,
  56749. done: true
  56750. });
  56751. });
  56752. this._requests = [];
  56753. },
  56754. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  56755. var url = this._url;
  56756. var exception;
  56757. if (status === 404 || status === 0 && /^file:/.test(url)) {
  56758. exception = new MissingPDFException('Missing PDF "' + url + '".');
  56759. } else {
  56760. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  56761. }
  56762. this._storedError = exception;
  56763. this._headersReceivedCapability.reject(exception);
  56764. this._requests.forEach(function (requestCapability) {
  56765. requestCapability.reject(exception);
  56766. });
  56767. this._requests = [];
  56768. this._cachedChunks = [];
  56769. },
  56770. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  56771. if (this.onProgress) {
  56772. this.onProgress({
  56773. loaded: data.loaded,
  56774. total: data.lengthComputable ? data.total : this._contentLength
  56775. });
  56776. }
  56777. },
  56778. get isRangeSupported() {
  56779. return this._isRangeSupported;
  56780. },
  56781. get isStreamingSupported() {
  56782. return this._isStreamingSupported;
  56783. },
  56784. get contentLength() {
  56785. return this._contentLength;
  56786. },
  56787. get headersReady() {
  56788. return this._headersReceivedCapability.promise;
  56789. },
  56790. read: function PDFNetworkStreamFullRequestReader_read() {
  56791. if (this._storedError) {
  56792. return Promise.reject(this._storedError);
  56793. }
  56794. if (this._cachedChunks.length > 0) {
  56795. var chunk = this._cachedChunks.shift();
  56796. return Promise.resolve(chunk);
  56797. }
  56798. if (this._done) {
  56799. return Promise.resolve({
  56800. value: undefined,
  56801. done: true
  56802. });
  56803. }
  56804. var requestCapability = createPromiseCapability();
  56805. this._requests.push(requestCapability);
  56806. return requestCapability.promise;
  56807. },
  56808. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  56809. this._done = true;
  56810. this._headersReceivedCapability.reject(reason);
  56811. this._requests.forEach(function (requestCapability) {
  56812. requestCapability.resolve({
  56813. value: undefined,
  56814. done: true
  56815. });
  56816. });
  56817. this._requests = [];
  56818. if (this._manager.isPendingRequest(this._fullRequestId)) {
  56819. this._manager.abortRequest(this._fullRequestId);
  56820. }
  56821. this._fullRequestReader = null;
  56822. }
  56823. };
  56824. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  56825. this._manager = manager;
  56826. var args = {
  56827. onDone: this._onDone.bind(this),
  56828. onProgress: this._onProgress.bind(this)
  56829. };
  56830. this._requestId = manager.requestRange(begin, end, args);
  56831. this._requests = [];
  56832. this._queuedChunk = null;
  56833. this._done = false;
  56834. this.onProgress = null;
  56835. this.onClosed = null;
  56836. }
  56837. PDFNetworkStreamRangeRequestReader.prototype = {
  56838. _close: function PDFNetworkStreamRangeRequestReader_close() {
  56839. if (this.onClosed) {
  56840. this.onClosed(this);
  56841. }
  56842. },
  56843. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  56844. var chunk = data.chunk;
  56845. if (this._requests.length > 0) {
  56846. var requestCapability = this._requests.shift();
  56847. requestCapability.resolve({
  56848. value: chunk,
  56849. done: false
  56850. });
  56851. } else {
  56852. this._queuedChunk = chunk;
  56853. }
  56854. this._done = true;
  56855. this._requests.forEach(function (requestCapability) {
  56856. requestCapability.resolve({
  56857. value: undefined,
  56858. done: true
  56859. });
  56860. });
  56861. this._requests = [];
  56862. this._close();
  56863. },
  56864. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  56865. if (!this.isStreamingSupported && this.onProgress) {
  56866. this.onProgress({ loaded: evt.loaded });
  56867. }
  56868. },
  56869. get isStreamingSupported() {
  56870. return false;
  56871. },
  56872. read: function PDFNetworkStreamRangeRequestReader_read() {
  56873. if (this._queuedChunk !== null) {
  56874. var chunk = this._queuedChunk;
  56875. this._queuedChunk = null;
  56876. return Promise.resolve({
  56877. value: chunk,
  56878. done: false
  56879. });
  56880. }
  56881. if (this._done) {
  56882. return Promise.resolve({
  56883. value: undefined,
  56884. done: true
  56885. });
  56886. }
  56887. var requestCapability = createPromiseCapability();
  56888. this._requests.push(requestCapability);
  56889. return requestCapability.promise;
  56890. },
  56891. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  56892. this._done = true;
  56893. this._requests.forEach(function (requestCapability) {
  56894. requestCapability.resolve({
  56895. value: undefined,
  56896. done: true
  56897. });
  56898. });
  56899. this._requests = [];
  56900. if (this._manager.isPendingRequest(this._requestId)) {
  56901. this._manager.abortRequest(this._requestId);
  56902. }
  56903. this._close();
  56904. }
  56905. };
  56906. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  56907. exports.PDFNetworkStream = PDFNetworkStream;
  56908. exports.NetworkManager = NetworkManager;
  56909. }));
  56910. }.call(pdfjsLibs));
  56911. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  56912. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  56913. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  56914. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  56915. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  56916. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  56917. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  56918. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56919. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  56920. exports.createPromiseCapability = pdfjsLibs.pdfjsSharedUtil.createPromiseCapability;
  56921. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  56922. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  56923. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  56924. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  56925. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  56926. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  56927. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56928. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  56929. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  56930. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  56931. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  56932. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  56933. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  56934. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56935. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  56936. }));