pdf.worker.js 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317
  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.worker', ['exports'], factory);
  19. } else if (typeof exports !== 'undefined') {
  20. factory(exports);
  21. } else {
  22. factory(root['pdfjsDistBuildPdfWorker'] = {});
  23. }
  24. }(this, function (exports) {
  25. 'use strict';
  26. var pdfjsVersion = '1.6.370';
  27. var pdfjsBuild = '94ddd8f';
  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 ('file' === this._scheme) {
  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 ('file' === this._scheme) {
  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 ('\t' === cp || '\n' === cp || '\r' === cp) {
  4590. err('Invalid whitespace in authority.');
  4591. continue;
  4592. }
  4593. if (':' === cp && null === this._password) {
  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 (EOF === c || '/' === 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 (EOF === c || '/' === 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 ('\t' === c || '\n' === c || '\r' === c) {
  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 ('hostname' === stateOverride) {
  4639. break loop;
  4640. }
  4641. } else if (EOF === c || '/' === 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 (EOF === c || '/' === 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 ('\t' === c || '\n' === c || '\r' === c) {
  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 (EOF === c || '/' === 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 ('file' === this._scheme && 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 (strLength / numBidi < 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. } else {
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. }
  6503. function parseFloatOperand() {
  6504. var str = '';
  6505. var eof = 15;
  6506. var lookup = [
  6507. '0',
  6508. '1',
  6509. '2',
  6510. '3',
  6511. '4',
  6512. '5',
  6513. '6',
  6514. '7',
  6515. '8',
  6516. '9',
  6517. '.',
  6518. 'E',
  6519. 'E-',
  6520. null,
  6521. '-'
  6522. ];
  6523. var length = dict.length;
  6524. while (pos < length) {
  6525. var b = dict[pos++];
  6526. var b1 = b >> 4;
  6527. var b2 = b & 15;
  6528. if (b1 === eof) {
  6529. break;
  6530. }
  6531. str += lookup[b1];
  6532. if (b2 === eof) {
  6533. break;
  6534. }
  6535. str += lookup[b2];
  6536. }
  6537. return parseFloat(str);
  6538. }
  6539. var operands = [];
  6540. var entries = [];
  6541. pos = 0;
  6542. var end = dict.length;
  6543. while (pos < end) {
  6544. var b = dict[pos];
  6545. if (b <= 21) {
  6546. if (b === 12) {
  6547. b = b << 8 | dict[++pos];
  6548. }
  6549. entries.push([
  6550. b,
  6551. operands
  6552. ]);
  6553. operands = [];
  6554. ++pos;
  6555. } else {
  6556. operands.push(parseOperand());
  6557. }
  6558. }
  6559. return entries;
  6560. },
  6561. parseIndex: function CFFParser_parseIndex(pos) {
  6562. var cffIndex = new CFFIndex();
  6563. var bytes = this.bytes;
  6564. var count = bytes[pos++] << 8 | bytes[pos++];
  6565. var offsets = [];
  6566. var end = pos;
  6567. var i, ii;
  6568. if (count !== 0) {
  6569. var offsetSize = bytes[pos++];
  6570. var startPos = pos + (count + 1) * offsetSize - 1;
  6571. for (i = 0, ii = count + 1; i < ii; ++i) {
  6572. var offset = 0;
  6573. for (var j = 0; j < offsetSize; ++j) {
  6574. offset <<= 8;
  6575. offset += bytes[pos++];
  6576. }
  6577. offsets.push(startPos + offset);
  6578. }
  6579. end = offsets[count];
  6580. }
  6581. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6582. var offsetStart = offsets[i];
  6583. var offsetEnd = offsets[i + 1];
  6584. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6585. }
  6586. return {
  6587. obj: cffIndex,
  6588. endPos: end
  6589. };
  6590. },
  6591. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6592. var names = [];
  6593. for (var i = 0, ii = index.count; i < ii; ++i) {
  6594. var name = index.get(i);
  6595. var length = Math.min(name.length, 127);
  6596. var data = [];
  6597. for (var j = 0; j < length; ++j) {
  6598. var c = name[j];
  6599. if (j === 0 && c === 0) {
  6600. data[j] = c;
  6601. continue;
  6602. }
  6603. 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)
  6604. {
  6605. data[j] = 95;
  6606. continue;
  6607. }
  6608. data[j] = c;
  6609. }
  6610. names.push(bytesToString(data));
  6611. }
  6612. return names;
  6613. },
  6614. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6615. var strings = new CFFStrings();
  6616. for (var i = 0, ii = index.count; i < ii; ++i) {
  6617. var data = index.get(i);
  6618. strings.add(bytesToString(data));
  6619. }
  6620. return strings;
  6621. },
  6622. createDict: function CFFParser_createDict(Type, dict, strings) {
  6623. var cffDict = new Type(strings);
  6624. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6625. var pair = dict[i];
  6626. var key = pair[0];
  6627. var value = pair[1];
  6628. cffDict.setByKey(key, value);
  6629. }
  6630. return cffDict;
  6631. },
  6632. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6633. if (state.callDepth > MAX_SUBR_NESTING) {
  6634. return false;
  6635. }
  6636. var stackSize = state.stackSize;
  6637. var stack = state.stack;
  6638. var length = data.length;
  6639. for (var j = 0; j < length;) {
  6640. var value = data[j++];
  6641. var validationCommand = null;
  6642. if (value === 12) {
  6643. var q = data[j++];
  6644. if (q === 0) {
  6645. data[j - 2] = 139;
  6646. data[j - 1] = 22;
  6647. stackSize = 0;
  6648. } else {
  6649. validationCommand = CharstringValidationData12[q];
  6650. }
  6651. } else if (value === 28) {
  6652. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6653. j += 2;
  6654. stackSize++;
  6655. } else if (value === 14) {
  6656. if (stackSize >= 4) {
  6657. stackSize -= 4;
  6658. if (this.seacAnalysisEnabled) {
  6659. state.seac = stack.slice(stackSize, stackSize + 4);
  6660. return false;
  6661. }
  6662. }
  6663. validationCommand = CharstringValidationData[value];
  6664. } else if (value >= 32 && value <= 246) {
  6665. stack[stackSize] = value - 139;
  6666. stackSize++;
  6667. } else if (value >= 247 && value <= 254) {
  6668. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6669. j++;
  6670. stackSize++;
  6671. } else if (value === 255) {
  6672. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6673. j += 4;
  6674. stackSize++;
  6675. } else if (value === 19 || value === 20) {
  6676. state.hints += stackSize >> 1;
  6677. j += state.hints + 7 >> 3;
  6678. stackSize %= 2;
  6679. validationCommand = CharstringValidationData[value];
  6680. } else if (value === 10 || value === 29) {
  6681. var subrsIndex;
  6682. if (value === 10) {
  6683. subrsIndex = localSubrIndex;
  6684. } else {
  6685. subrsIndex = globalSubrIndex;
  6686. }
  6687. if (!subrsIndex) {
  6688. validationCommand = CharstringValidationData[value];
  6689. warn('Missing subrsIndex for ' + validationCommand.id);
  6690. return false;
  6691. }
  6692. var bias = 32768;
  6693. if (subrsIndex.count < 1240) {
  6694. bias = 107;
  6695. } else if (subrsIndex.count < 33900) {
  6696. bias = 1131;
  6697. }
  6698. var subrNumber = stack[--stackSize] + bias;
  6699. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6700. validationCommand = CharstringValidationData[value];
  6701. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6702. return false;
  6703. }
  6704. state.stackSize = stackSize;
  6705. state.callDepth++;
  6706. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6707. if (!valid) {
  6708. return false;
  6709. }
  6710. state.callDepth--;
  6711. stackSize = state.stackSize;
  6712. continue;
  6713. } else if (value === 11) {
  6714. state.stackSize = stackSize;
  6715. return true;
  6716. } else {
  6717. validationCommand = CharstringValidationData[value];
  6718. }
  6719. if (validationCommand) {
  6720. if (validationCommand.stem) {
  6721. state.hints += stackSize >> 1;
  6722. }
  6723. if ('min' in validationCommand) {
  6724. if (!state.undefStack && stackSize < validationCommand.min) {
  6725. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6726. return false;
  6727. }
  6728. }
  6729. if (state.firstStackClearing && validationCommand.stackClearing) {
  6730. state.firstStackClearing = false;
  6731. stackSize -= validationCommand.min;
  6732. if (stackSize >= 2 && validationCommand.stem) {
  6733. stackSize %= 2;
  6734. } else if (stackSize > 1) {
  6735. warn('Found too many parameters for stack-clearing command');
  6736. }
  6737. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6738. state.width = stack[stackSize - 1];
  6739. }
  6740. }
  6741. if ('stackDelta' in validationCommand) {
  6742. if ('stackFn' in validationCommand) {
  6743. validationCommand.stackFn(stack, stackSize);
  6744. }
  6745. stackSize += validationCommand.stackDelta;
  6746. } else if (validationCommand.stackClearing) {
  6747. stackSize = 0;
  6748. } else if (validationCommand.resetStack) {
  6749. stackSize = 0;
  6750. state.undefStack = false;
  6751. } else if (validationCommand.undefStack) {
  6752. stackSize = 0;
  6753. state.undefStack = true;
  6754. state.firstStackClearing = false;
  6755. }
  6756. }
  6757. }
  6758. state.stackSize = stackSize;
  6759. return true;
  6760. },
  6761. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6762. var seacs = [];
  6763. var widths = [];
  6764. var count = charStrings.count;
  6765. for (var i = 0; i < count; i++) {
  6766. var charstring = charStrings.get(i);
  6767. var state = {
  6768. callDepth: 0,
  6769. stackSize: 0,
  6770. stack: [],
  6771. undefStack: true,
  6772. hints: 0,
  6773. firstStackClearing: true,
  6774. seac: null,
  6775. width: null
  6776. };
  6777. var valid = true;
  6778. var localSubrToUse = null;
  6779. if (fdSelect && fdArray.length) {
  6780. var fdIndex = fdSelect.getFDIndex(i);
  6781. if (fdIndex === -1) {
  6782. warn('Glyph index is not in fd select.');
  6783. valid = false;
  6784. }
  6785. if (fdIndex >= fdArray.length) {
  6786. warn('Invalid fd index for glyph index.');
  6787. valid = false;
  6788. }
  6789. if (valid) {
  6790. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6791. }
  6792. } else if (localSubrIndex) {
  6793. localSubrToUse = localSubrIndex;
  6794. }
  6795. if (valid) {
  6796. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6797. }
  6798. if (state.width !== null) {
  6799. widths[i] = state.width;
  6800. }
  6801. if (state.seac !== null) {
  6802. seacs[i] = state.seac;
  6803. }
  6804. if (!valid) {
  6805. charStrings.set(i, new Uint8Array([14]));
  6806. }
  6807. }
  6808. return {
  6809. charStrings: charStrings,
  6810. seacs: seacs,
  6811. widths: widths
  6812. };
  6813. },
  6814. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6815. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6816. parentDict.setByKey(18, [
  6817. 0,
  6818. 0
  6819. ]);
  6820. parentDict.privateDict = privateDict;
  6821. },
  6822. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6823. if (!parentDict.hasName('Private')) {
  6824. this.emptyPrivateDictionary(parentDict);
  6825. return;
  6826. }
  6827. var privateOffset = parentDict.getByName('Private');
  6828. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6829. parentDict.removeByName('Private');
  6830. return;
  6831. }
  6832. var size = privateOffset[0];
  6833. var offset = privateOffset[1];
  6834. if (size === 0 || offset >= this.bytes.length) {
  6835. this.emptyPrivateDictionary(parentDict);
  6836. return;
  6837. }
  6838. var privateDictEnd = offset + size;
  6839. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6840. var dict = this.parseDict(dictData);
  6841. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6842. parentDict.privateDict = privateDict;
  6843. if (!privateDict.getByName('Subrs')) {
  6844. return;
  6845. }
  6846. var subrsOffset = privateDict.getByName('Subrs');
  6847. var relativeOffset = offset + subrsOffset;
  6848. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6849. this.emptyPrivateDictionary(parentDict);
  6850. return;
  6851. }
  6852. var subrsIndex = this.parseIndex(relativeOffset);
  6853. privateDict.subrsIndex = subrsIndex.obj;
  6854. },
  6855. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6856. if (pos === 0) {
  6857. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6858. } else if (pos === 1) {
  6859. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6860. } else if (pos === 2) {
  6861. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6862. }
  6863. var bytes = this.bytes;
  6864. var start = pos;
  6865. var format = bytes[pos++];
  6866. var charset = ['.notdef'];
  6867. var id, count, i;
  6868. length -= 1;
  6869. switch (format) {
  6870. case 0:
  6871. for (i = 0; i < length; i++) {
  6872. id = bytes[pos++] << 8 | bytes[pos++];
  6873. charset.push(cid ? id : strings.get(id));
  6874. }
  6875. break;
  6876. case 1:
  6877. while (charset.length <= length) {
  6878. id = bytes[pos++] << 8 | bytes[pos++];
  6879. count = bytes[pos++];
  6880. for (i = 0; i <= count; i++) {
  6881. charset.push(cid ? id++ : strings.get(id++));
  6882. }
  6883. }
  6884. break;
  6885. case 2:
  6886. while (charset.length <= length) {
  6887. id = bytes[pos++] << 8 | bytes[pos++];
  6888. count = bytes[pos++] << 8 | bytes[pos++];
  6889. for (i = 0; i <= count; i++) {
  6890. charset.push(cid ? id++ : strings.get(id++));
  6891. }
  6892. }
  6893. break;
  6894. default:
  6895. error('Unknown charset format');
  6896. }
  6897. var end = pos;
  6898. var raw = bytes.subarray(start, end);
  6899. return new CFFCharset(false, format, charset, raw);
  6900. },
  6901. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6902. var encoding = Object.create(null);
  6903. var bytes = this.bytes;
  6904. var predefined = false;
  6905. var hasSupplement = false;
  6906. var format, i, ii;
  6907. var raw = null;
  6908. function readSupplement() {
  6909. var supplementsCount = bytes[pos++];
  6910. for (i = 0; i < supplementsCount; i++) {
  6911. var code = bytes[pos++];
  6912. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6913. encoding[code] = charset.indexOf(strings.get(sid));
  6914. }
  6915. }
  6916. if (pos === 0 || pos === 1) {
  6917. predefined = true;
  6918. format = pos;
  6919. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6920. for (i = 0, ii = charset.length; i < ii; i++) {
  6921. var index = baseEncoding.indexOf(charset[i]);
  6922. if (index !== -1) {
  6923. encoding[index] = i;
  6924. }
  6925. }
  6926. } else {
  6927. var dataStart = pos;
  6928. format = bytes[pos++];
  6929. switch (format & 0x7f) {
  6930. case 0:
  6931. var glyphsCount = bytes[pos++];
  6932. for (i = 1; i <= glyphsCount; i++) {
  6933. encoding[bytes[pos++]] = i;
  6934. }
  6935. break;
  6936. case 1:
  6937. var rangesCount = bytes[pos++];
  6938. var gid = 1;
  6939. for (i = 0; i < rangesCount; i++) {
  6940. var start = bytes[pos++];
  6941. var left = bytes[pos++];
  6942. for (var j = start; j <= start + left; j++) {
  6943. encoding[j] = gid++;
  6944. }
  6945. }
  6946. break;
  6947. default:
  6948. error('Unknown encoding format: ' + format + ' in CFF');
  6949. break;
  6950. }
  6951. var dataEnd = pos;
  6952. if (format & 0x80) {
  6953. bytes[dataStart] &= 0x7f;
  6954. readSupplement();
  6955. hasSupplement = true;
  6956. }
  6957. raw = bytes.subarray(dataStart, dataEnd);
  6958. }
  6959. format = format & 0x7f;
  6960. return new CFFEncoding(predefined, format, encoding, raw);
  6961. },
  6962. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6963. var start = pos;
  6964. var bytes = this.bytes;
  6965. var format = bytes[pos++];
  6966. var fdSelect = [], rawBytes;
  6967. var i, invalidFirstGID = false;
  6968. switch (format) {
  6969. case 0:
  6970. for (i = 0; i < length; ++i) {
  6971. var id = bytes[pos++];
  6972. fdSelect.push(id);
  6973. }
  6974. rawBytes = bytes.subarray(start, pos);
  6975. break;
  6976. case 3:
  6977. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6978. for (i = 0; i < rangesCount; ++i) {
  6979. var first = bytes[pos++] << 8 | bytes[pos++];
  6980. if (i === 0 && first !== 0) {
  6981. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6982. invalidFirstGID = true;
  6983. first = 0;
  6984. }
  6985. var fdIndex = bytes[pos++];
  6986. var next = bytes[pos] << 8 | bytes[pos + 1];
  6987. for (var j = first; j < next; ++j) {
  6988. fdSelect.push(fdIndex);
  6989. }
  6990. }
  6991. pos += 2;
  6992. rawBytes = bytes.subarray(start, pos);
  6993. if (invalidFirstGID) {
  6994. rawBytes[3] = rawBytes[4] = 0;
  6995. }
  6996. break;
  6997. default:
  6998. error('parseFDSelect: Unknown format "' + format + '".');
  6999. break;
  7000. }
  7001. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  7002. return new CFFFDSelect(fdSelect, rawBytes);
  7003. }
  7004. };
  7005. return CFFParser;
  7006. }();
  7007. var CFF = function CFFClosure() {
  7008. function CFF() {
  7009. this.header = null;
  7010. this.names = [];
  7011. this.topDict = null;
  7012. this.strings = new CFFStrings();
  7013. this.globalSubrIndex = null;
  7014. this.encoding = null;
  7015. this.charset = null;
  7016. this.charStrings = null;
  7017. this.fdArray = [];
  7018. this.fdSelect = null;
  7019. this.isCIDFont = false;
  7020. }
  7021. return CFF;
  7022. }();
  7023. var CFFHeader = function CFFHeaderClosure() {
  7024. function CFFHeader(major, minor, hdrSize, offSize) {
  7025. this.major = major;
  7026. this.minor = minor;
  7027. this.hdrSize = hdrSize;
  7028. this.offSize = offSize;
  7029. }
  7030. return CFFHeader;
  7031. }();
  7032. var CFFStrings = function CFFStringsClosure() {
  7033. function CFFStrings() {
  7034. this.strings = [];
  7035. }
  7036. CFFStrings.prototype = {
  7037. get: function CFFStrings_get(index) {
  7038. if (index >= 0 && index <= 390) {
  7039. return CFFStandardStrings[index];
  7040. }
  7041. if (index - 391 <= this.strings.length) {
  7042. return this.strings[index - 391];
  7043. }
  7044. return CFFStandardStrings[0];
  7045. },
  7046. add: function CFFStrings_add(value) {
  7047. this.strings.push(value);
  7048. },
  7049. get count() {
  7050. return this.strings.length;
  7051. }
  7052. };
  7053. return CFFStrings;
  7054. }();
  7055. var CFFIndex = function CFFIndexClosure() {
  7056. function CFFIndex() {
  7057. this.objects = [];
  7058. this.length = 0;
  7059. }
  7060. CFFIndex.prototype = {
  7061. add: function CFFIndex_add(data) {
  7062. this.length += data.length;
  7063. this.objects.push(data);
  7064. },
  7065. set: function CFFIndex_set(index, data) {
  7066. this.length += data.length - this.objects[index].length;
  7067. this.objects[index] = data;
  7068. },
  7069. get: function CFFIndex_get(index) {
  7070. return this.objects[index];
  7071. },
  7072. get count() {
  7073. return this.objects.length;
  7074. }
  7075. };
  7076. return CFFIndex;
  7077. }();
  7078. var CFFDict = function CFFDictClosure() {
  7079. function CFFDict(tables, strings) {
  7080. this.keyToNameMap = tables.keyToNameMap;
  7081. this.nameToKeyMap = tables.nameToKeyMap;
  7082. this.defaults = tables.defaults;
  7083. this.types = tables.types;
  7084. this.opcodes = tables.opcodes;
  7085. this.order = tables.order;
  7086. this.strings = strings;
  7087. this.values = Object.create(null);
  7088. }
  7089. CFFDict.prototype = {
  7090. setByKey: function CFFDict_setByKey(key, value) {
  7091. if (!(key in this.keyToNameMap)) {
  7092. return false;
  7093. }
  7094. var valueLength = value.length;
  7095. if (valueLength === 0) {
  7096. return true;
  7097. }
  7098. for (var i = 0; i < valueLength; i++) {
  7099. if (isNaN(value[i])) {
  7100. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7101. return true;
  7102. }
  7103. }
  7104. var type = this.types[key];
  7105. if (type === 'num' || type === 'sid' || type === 'offset') {
  7106. value = value[0];
  7107. }
  7108. this.values[key] = value;
  7109. return true;
  7110. },
  7111. setByName: function CFFDict_setByName(name, value) {
  7112. if (!(name in this.nameToKeyMap)) {
  7113. error('Invalid dictionary name "' + name + '"');
  7114. }
  7115. this.values[this.nameToKeyMap[name]] = value;
  7116. },
  7117. hasName: function CFFDict_hasName(name) {
  7118. return this.nameToKeyMap[name] in this.values;
  7119. },
  7120. getByName: function CFFDict_getByName(name) {
  7121. if (!(name in this.nameToKeyMap)) {
  7122. error('Invalid dictionary name "' + name + '"');
  7123. }
  7124. var key = this.nameToKeyMap[name];
  7125. if (!(key in this.values)) {
  7126. return this.defaults[key];
  7127. }
  7128. return this.values[key];
  7129. },
  7130. removeByName: function CFFDict_removeByName(name) {
  7131. delete this.values[this.nameToKeyMap[name]];
  7132. }
  7133. };
  7134. CFFDict.createTables = function CFFDict_createTables(layout) {
  7135. var tables = {
  7136. keyToNameMap: {},
  7137. nameToKeyMap: {},
  7138. defaults: {},
  7139. types: {},
  7140. opcodes: {},
  7141. order: []
  7142. };
  7143. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7144. var entry = layout[i];
  7145. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7146. tables.keyToNameMap[key] = entry[1];
  7147. tables.nameToKeyMap[entry[1]] = key;
  7148. tables.types[key] = entry[2];
  7149. tables.defaults[key] = entry[3];
  7150. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7151. tables.order.push(key);
  7152. }
  7153. return tables;
  7154. };
  7155. return CFFDict;
  7156. }();
  7157. var CFFTopDict = function CFFTopDictClosure() {
  7158. var layout = [
  7159. [
  7160. [
  7161. 12,
  7162. 30
  7163. ],
  7164. 'ROS',
  7165. [
  7166. 'sid',
  7167. 'sid',
  7168. 'num'
  7169. ],
  7170. null
  7171. ],
  7172. [
  7173. [
  7174. 12,
  7175. 20
  7176. ],
  7177. 'SyntheticBase',
  7178. 'num',
  7179. null
  7180. ],
  7181. [
  7182. 0,
  7183. 'version',
  7184. 'sid',
  7185. null
  7186. ],
  7187. [
  7188. 1,
  7189. 'Notice',
  7190. 'sid',
  7191. null
  7192. ],
  7193. [
  7194. [
  7195. 12,
  7196. 0
  7197. ],
  7198. 'Copyright',
  7199. 'sid',
  7200. null
  7201. ],
  7202. [
  7203. 2,
  7204. 'FullName',
  7205. 'sid',
  7206. null
  7207. ],
  7208. [
  7209. 3,
  7210. 'FamilyName',
  7211. 'sid',
  7212. null
  7213. ],
  7214. [
  7215. 4,
  7216. 'Weight',
  7217. 'sid',
  7218. null
  7219. ],
  7220. [
  7221. [
  7222. 12,
  7223. 1
  7224. ],
  7225. 'isFixedPitch',
  7226. 'num',
  7227. 0
  7228. ],
  7229. [
  7230. [
  7231. 12,
  7232. 2
  7233. ],
  7234. 'ItalicAngle',
  7235. 'num',
  7236. 0
  7237. ],
  7238. [
  7239. [
  7240. 12,
  7241. 3
  7242. ],
  7243. 'UnderlinePosition',
  7244. 'num',
  7245. -100
  7246. ],
  7247. [
  7248. [
  7249. 12,
  7250. 4
  7251. ],
  7252. 'UnderlineThickness',
  7253. 'num',
  7254. 50
  7255. ],
  7256. [
  7257. [
  7258. 12,
  7259. 5
  7260. ],
  7261. 'PaintType',
  7262. 'num',
  7263. 0
  7264. ],
  7265. [
  7266. [
  7267. 12,
  7268. 6
  7269. ],
  7270. 'CharstringType',
  7271. 'num',
  7272. 2
  7273. ],
  7274. [
  7275. [
  7276. 12,
  7277. 7
  7278. ],
  7279. 'FontMatrix',
  7280. [
  7281. 'num',
  7282. 'num',
  7283. 'num',
  7284. 'num',
  7285. 'num',
  7286. 'num'
  7287. ],
  7288. [
  7289. 0.001,
  7290. 0,
  7291. 0,
  7292. 0.001,
  7293. 0,
  7294. 0
  7295. ]
  7296. ],
  7297. [
  7298. 13,
  7299. 'UniqueID',
  7300. 'num',
  7301. null
  7302. ],
  7303. [
  7304. 5,
  7305. 'FontBBox',
  7306. [
  7307. 'num',
  7308. 'num',
  7309. 'num',
  7310. 'num'
  7311. ],
  7312. [
  7313. 0,
  7314. 0,
  7315. 0,
  7316. 0
  7317. ]
  7318. ],
  7319. [
  7320. [
  7321. 12,
  7322. 8
  7323. ],
  7324. 'StrokeWidth',
  7325. 'num',
  7326. 0
  7327. ],
  7328. [
  7329. 14,
  7330. 'XUID',
  7331. 'array',
  7332. null
  7333. ],
  7334. [
  7335. 15,
  7336. 'charset',
  7337. 'offset',
  7338. 0
  7339. ],
  7340. [
  7341. 16,
  7342. 'Encoding',
  7343. 'offset',
  7344. 0
  7345. ],
  7346. [
  7347. 17,
  7348. 'CharStrings',
  7349. 'offset',
  7350. 0
  7351. ],
  7352. [
  7353. 18,
  7354. 'Private',
  7355. [
  7356. 'offset',
  7357. 'offset'
  7358. ],
  7359. null
  7360. ],
  7361. [
  7362. [
  7363. 12,
  7364. 21
  7365. ],
  7366. 'PostScript',
  7367. 'sid',
  7368. null
  7369. ],
  7370. [
  7371. [
  7372. 12,
  7373. 22
  7374. ],
  7375. 'BaseFontName',
  7376. 'sid',
  7377. null
  7378. ],
  7379. [
  7380. [
  7381. 12,
  7382. 23
  7383. ],
  7384. 'BaseFontBlend',
  7385. 'delta',
  7386. null
  7387. ],
  7388. [
  7389. [
  7390. 12,
  7391. 31
  7392. ],
  7393. 'CIDFontVersion',
  7394. 'num',
  7395. 0
  7396. ],
  7397. [
  7398. [
  7399. 12,
  7400. 32
  7401. ],
  7402. 'CIDFontRevision',
  7403. 'num',
  7404. 0
  7405. ],
  7406. [
  7407. [
  7408. 12,
  7409. 33
  7410. ],
  7411. 'CIDFontType',
  7412. 'num',
  7413. 0
  7414. ],
  7415. [
  7416. [
  7417. 12,
  7418. 34
  7419. ],
  7420. 'CIDCount',
  7421. 'num',
  7422. 8720
  7423. ],
  7424. [
  7425. [
  7426. 12,
  7427. 35
  7428. ],
  7429. 'UIDBase',
  7430. 'num',
  7431. null
  7432. ],
  7433. [
  7434. [
  7435. 12,
  7436. 37
  7437. ],
  7438. 'FDSelect',
  7439. 'offset',
  7440. null
  7441. ],
  7442. [
  7443. [
  7444. 12,
  7445. 36
  7446. ],
  7447. 'FDArray',
  7448. 'offset',
  7449. null
  7450. ],
  7451. [
  7452. [
  7453. 12,
  7454. 38
  7455. ],
  7456. 'FontName',
  7457. 'sid',
  7458. null
  7459. ]
  7460. ];
  7461. var tables = null;
  7462. function CFFTopDict(strings) {
  7463. if (tables === null) {
  7464. tables = CFFDict.createTables(layout);
  7465. }
  7466. CFFDict.call(this, tables, strings);
  7467. this.privateDict = null;
  7468. }
  7469. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7470. return CFFTopDict;
  7471. }();
  7472. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7473. var layout = [
  7474. [
  7475. 6,
  7476. 'BlueValues',
  7477. 'delta',
  7478. null
  7479. ],
  7480. [
  7481. 7,
  7482. 'OtherBlues',
  7483. 'delta',
  7484. null
  7485. ],
  7486. [
  7487. 8,
  7488. 'FamilyBlues',
  7489. 'delta',
  7490. null
  7491. ],
  7492. [
  7493. 9,
  7494. 'FamilyOtherBlues',
  7495. 'delta',
  7496. null
  7497. ],
  7498. [
  7499. [
  7500. 12,
  7501. 9
  7502. ],
  7503. 'BlueScale',
  7504. 'num',
  7505. 0.039625
  7506. ],
  7507. [
  7508. [
  7509. 12,
  7510. 10
  7511. ],
  7512. 'BlueShift',
  7513. 'num',
  7514. 7
  7515. ],
  7516. [
  7517. [
  7518. 12,
  7519. 11
  7520. ],
  7521. 'BlueFuzz',
  7522. 'num',
  7523. 1
  7524. ],
  7525. [
  7526. 10,
  7527. 'StdHW',
  7528. 'num',
  7529. null
  7530. ],
  7531. [
  7532. 11,
  7533. 'StdVW',
  7534. 'num',
  7535. null
  7536. ],
  7537. [
  7538. [
  7539. 12,
  7540. 12
  7541. ],
  7542. 'StemSnapH',
  7543. 'delta',
  7544. null
  7545. ],
  7546. [
  7547. [
  7548. 12,
  7549. 13
  7550. ],
  7551. 'StemSnapV',
  7552. 'delta',
  7553. null
  7554. ],
  7555. [
  7556. [
  7557. 12,
  7558. 14
  7559. ],
  7560. 'ForceBold',
  7561. 'num',
  7562. 0
  7563. ],
  7564. [
  7565. [
  7566. 12,
  7567. 17
  7568. ],
  7569. 'LanguageGroup',
  7570. 'num',
  7571. 0
  7572. ],
  7573. [
  7574. [
  7575. 12,
  7576. 18
  7577. ],
  7578. 'ExpansionFactor',
  7579. 'num',
  7580. 0.06
  7581. ],
  7582. [
  7583. [
  7584. 12,
  7585. 19
  7586. ],
  7587. 'initialRandomSeed',
  7588. 'num',
  7589. 0
  7590. ],
  7591. [
  7592. 20,
  7593. 'defaultWidthX',
  7594. 'num',
  7595. 0
  7596. ],
  7597. [
  7598. 21,
  7599. 'nominalWidthX',
  7600. 'num',
  7601. 0
  7602. ],
  7603. [
  7604. 19,
  7605. 'Subrs',
  7606. 'offset',
  7607. null
  7608. ]
  7609. ];
  7610. var tables = null;
  7611. function CFFPrivateDict(strings) {
  7612. if (tables === null) {
  7613. tables = CFFDict.createTables(layout);
  7614. }
  7615. CFFDict.call(this, tables, strings);
  7616. this.subrsIndex = null;
  7617. }
  7618. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7619. return CFFPrivateDict;
  7620. }();
  7621. var CFFCharsetPredefinedTypes = {
  7622. ISO_ADOBE: 0,
  7623. EXPERT: 1,
  7624. EXPERT_SUBSET: 2
  7625. };
  7626. var CFFCharset = function CFFCharsetClosure() {
  7627. function CFFCharset(predefined, format, charset, raw) {
  7628. this.predefined = predefined;
  7629. this.format = format;
  7630. this.charset = charset;
  7631. this.raw = raw;
  7632. }
  7633. return CFFCharset;
  7634. }();
  7635. var CFFEncoding = function CFFEncodingClosure() {
  7636. function CFFEncoding(predefined, format, encoding, raw) {
  7637. this.predefined = predefined;
  7638. this.format = format;
  7639. this.encoding = encoding;
  7640. this.raw = raw;
  7641. }
  7642. return CFFEncoding;
  7643. }();
  7644. var CFFFDSelect = function CFFFDSelectClosure() {
  7645. function CFFFDSelect(fdSelect, raw) {
  7646. this.fdSelect = fdSelect;
  7647. this.raw = raw;
  7648. }
  7649. CFFFDSelect.prototype = {
  7650. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7651. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7652. return -1;
  7653. }
  7654. return this.fdSelect[glyphIndex];
  7655. }
  7656. };
  7657. return CFFFDSelect;
  7658. }();
  7659. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7660. function CFFOffsetTracker() {
  7661. this.offsets = Object.create(null);
  7662. }
  7663. CFFOffsetTracker.prototype = {
  7664. isTracking: function CFFOffsetTracker_isTracking(key) {
  7665. return key in this.offsets;
  7666. },
  7667. track: function CFFOffsetTracker_track(key, location) {
  7668. if (key in this.offsets) {
  7669. error('Already tracking location of ' + key);
  7670. }
  7671. this.offsets[key] = location;
  7672. },
  7673. offset: function CFFOffsetTracker_offset(value) {
  7674. for (var key in this.offsets) {
  7675. this.offsets[key] += value;
  7676. }
  7677. },
  7678. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7679. if (!(key in this.offsets)) {
  7680. error('Not tracking location of ' + key);
  7681. }
  7682. var data = output.data;
  7683. var dataOffset = this.offsets[key];
  7684. var size = 5;
  7685. for (var i = 0, ii = values.length; i < ii; ++i) {
  7686. var offset0 = i * size + dataOffset;
  7687. var offset1 = offset0 + 1;
  7688. var offset2 = offset0 + 2;
  7689. var offset3 = offset0 + 3;
  7690. var offset4 = offset0 + 4;
  7691. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7692. error('writing to an offset that is not empty');
  7693. }
  7694. var value = values[i];
  7695. data[offset0] = 0x1d;
  7696. data[offset1] = value >> 24 & 0xFF;
  7697. data[offset2] = value >> 16 & 0xFF;
  7698. data[offset3] = value >> 8 & 0xFF;
  7699. data[offset4] = value & 0xFF;
  7700. }
  7701. }
  7702. };
  7703. return CFFOffsetTracker;
  7704. }();
  7705. var CFFCompiler = function CFFCompilerClosure() {
  7706. function CFFCompiler(cff) {
  7707. this.cff = cff;
  7708. }
  7709. CFFCompiler.prototype = {
  7710. compile: function CFFCompiler_compile() {
  7711. var cff = this.cff;
  7712. var output = {
  7713. data: [],
  7714. length: 0,
  7715. add: function CFFCompiler_add(data) {
  7716. this.data = this.data.concat(data);
  7717. this.length = this.data.length;
  7718. }
  7719. };
  7720. var header = this.compileHeader(cff.header);
  7721. output.add(header);
  7722. var nameIndex = this.compileNameIndex(cff.names);
  7723. output.add(nameIndex);
  7724. if (cff.isCIDFont) {
  7725. if (cff.topDict.hasName('FontMatrix')) {
  7726. var base = cff.topDict.getByName('FontMatrix');
  7727. cff.topDict.removeByName('FontMatrix');
  7728. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7729. var subDict = cff.fdArray[i];
  7730. var matrix = base.slice(0);
  7731. if (subDict.hasName('FontMatrix')) {
  7732. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7733. }
  7734. subDict.setByName('FontMatrix', matrix);
  7735. }
  7736. }
  7737. }
  7738. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7739. output.add(compiled.output);
  7740. var topDictTracker = compiled.trackers[0];
  7741. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7742. output.add(stringIndex);
  7743. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7744. output.add(globalSubrIndex);
  7745. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7746. if (cff.encoding.predefined) {
  7747. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7748. } else {
  7749. var encoding = this.compileEncoding(cff.encoding);
  7750. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7751. output.add(encoding);
  7752. }
  7753. }
  7754. if (cff.charset && cff.topDict.hasName('charset')) {
  7755. if (cff.charset.predefined) {
  7756. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7757. } else {
  7758. var charset = this.compileCharset(cff.charset);
  7759. topDictTracker.setEntryLocation('charset', [output.length], output);
  7760. output.add(charset);
  7761. }
  7762. }
  7763. var charStrings = this.compileCharStrings(cff.charStrings);
  7764. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7765. output.add(charStrings);
  7766. if (cff.isCIDFont) {
  7767. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7768. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7769. output.add(fdSelect);
  7770. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7771. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7772. output.add(compiled.output);
  7773. var fontDictTrackers = compiled.trackers;
  7774. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7775. }
  7776. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7777. output.add([0]);
  7778. return output.data;
  7779. },
  7780. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7781. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7782. return this.encodeInteger(value);
  7783. } else {
  7784. return this.encodeFloat(value);
  7785. }
  7786. },
  7787. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7788. var value = num.toString();
  7789. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7790. if (m) {
  7791. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7792. value = (Math.round(num * epsilon) / epsilon).toString();
  7793. }
  7794. var nibbles = '';
  7795. var i, ii;
  7796. for (i = 0, ii = value.length; i < ii; ++i) {
  7797. var a = value[i];
  7798. if (a === 'e') {
  7799. nibbles += value[++i] === '-' ? 'c' : 'b';
  7800. } else if (a === '.') {
  7801. nibbles += 'a';
  7802. } else if (a === '-') {
  7803. nibbles += 'e';
  7804. } else {
  7805. nibbles += a;
  7806. }
  7807. }
  7808. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7809. var out = [30];
  7810. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7811. out.push(parseInt(nibbles.substr(i, 2), 16));
  7812. }
  7813. return out;
  7814. },
  7815. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7816. var code;
  7817. if (value >= -107 && value <= 107) {
  7818. code = [value + 139];
  7819. } else if (value >= 108 && value <= 1131) {
  7820. value = value - 108;
  7821. code = [
  7822. (value >> 8) + 247,
  7823. value & 0xFF
  7824. ];
  7825. } else if (value >= -1131 && value <= -108) {
  7826. value = -value - 108;
  7827. code = [
  7828. (value >> 8) + 251,
  7829. value & 0xFF
  7830. ];
  7831. } else if (value >= -32768 && value <= 32767) {
  7832. code = [
  7833. 0x1c,
  7834. value >> 8 & 0xFF,
  7835. value & 0xFF
  7836. ];
  7837. } else {
  7838. code = [
  7839. 0x1d,
  7840. value >> 24 & 0xFF,
  7841. value >> 16 & 0xFF,
  7842. value >> 8 & 0xFF,
  7843. value & 0xFF
  7844. ];
  7845. }
  7846. return code;
  7847. },
  7848. compileHeader: function CFFCompiler_compileHeader(header) {
  7849. return [
  7850. header.major,
  7851. header.minor,
  7852. header.hdrSize,
  7853. header.offSize
  7854. ];
  7855. },
  7856. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7857. var nameIndex = new CFFIndex();
  7858. for (var i = 0, ii = names.length; i < ii; ++i) {
  7859. nameIndex.add(stringToBytes(names[i]));
  7860. }
  7861. return this.compileIndex(nameIndex);
  7862. },
  7863. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7864. var fontDictTrackers = [];
  7865. var fdArrayIndex = new CFFIndex();
  7866. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7867. var fontDict = dicts[i];
  7868. if (removeCidKeys) {
  7869. fontDict.removeByName('CIDFontVersion');
  7870. fontDict.removeByName('CIDFontRevision');
  7871. fontDict.removeByName('CIDFontType');
  7872. fontDict.removeByName('CIDCount');
  7873. fontDict.removeByName('UIDBase');
  7874. }
  7875. var fontDictTracker = new CFFOffsetTracker();
  7876. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7877. fontDictTrackers.push(fontDictTracker);
  7878. fdArrayIndex.add(fontDictData);
  7879. fontDictTracker.offset(length);
  7880. }
  7881. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7882. return {
  7883. trackers: fontDictTrackers,
  7884. output: fdArrayIndex
  7885. };
  7886. },
  7887. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7888. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7889. var fontDict = dicts[i];
  7890. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7891. var privateDict = fontDict.privateDict;
  7892. var privateDictTracker = new CFFOffsetTracker();
  7893. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7894. var outputLength = output.length;
  7895. privateDictTracker.offset(outputLength);
  7896. if (!privateDictData.length) {
  7897. outputLength = 0;
  7898. }
  7899. trackers[i].setEntryLocation('Private', [
  7900. privateDictData.length,
  7901. outputLength
  7902. ], output);
  7903. output.add(privateDictData);
  7904. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7905. var subrs = this.compileIndex(privateDict.subrsIndex);
  7906. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7907. output.add(subrs);
  7908. }
  7909. }
  7910. },
  7911. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7912. var out = [];
  7913. var order = dict.order;
  7914. for (var i = 0; i < order.length; ++i) {
  7915. var key = order[i];
  7916. if (!(key in dict.values)) {
  7917. continue;
  7918. }
  7919. var values = dict.values[key];
  7920. var types = dict.types[key];
  7921. if (!isArray(types)) {
  7922. types = [types];
  7923. }
  7924. if (!isArray(values)) {
  7925. values = [values];
  7926. }
  7927. if (values.length === 0) {
  7928. continue;
  7929. }
  7930. for (var j = 0, jj = types.length; j < jj; ++j) {
  7931. var type = types[j];
  7932. var value = values[j];
  7933. switch (type) {
  7934. case 'num':
  7935. case 'sid':
  7936. out = out.concat(this.encodeNumber(value));
  7937. break;
  7938. case 'offset':
  7939. var name = dict.keyToNameMap[key];
  7940. if (!offsetTracker.isTracking(name)) {
  7941. offsetTracker.track(name, out.length);
  7942. }
  7943. out = out.concat([
  7944. 0x1d,
  7945. 0,
  7946. 0,
  7947. 0,
  7948. 0
  7949. ]);
  7950. break;
  7951. case 'array':
  7952. case 'delta':
  7953. out = out.concat(this.encodeNumber(value));
  7954. for (var k = 1, kk = values.length; k < kk; ++k) {
  7955. out = out.concat(this.encodeNumber(values[k]));
  7956. }
  7957. break;
  7958. default:
  7959. error('Unknown data type of ' + type);
  7960. break;
  7961. }
  7962. }
  7963. out = out.concat(dict.opcodes[key]);
  7964. }
  7965. return out;
  7966. },
  7967. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7968. var stringIndex = new CFFIndex();
  7969. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7970. stringIndex.add(stringToBytes(strings[i]));
  7971. }
  7972. return this.compileIndex(stringIndex);
  7973. },
  7974. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7975. var globalSubrIndex = this.cff.globalSubrIndex;
  7976. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7977. },
  7978. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7979. return this.compileIndex(charStrings);
  7980. },
  7981. compileCharset: function CFFCompiler_compileCharset(charset) {
  7982. return this.compileTypedArray(charset.raw);
  7983. },
  7984. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7985. return this.compileTypedArray(encoding.raw);
  7986. },
  7987. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7988. return this.compileTypedArray(fdSelect);
  7989. },
  7990. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7991. var out = [];
  7992. for (var i = 0, ii = data.length; i < ii; ++i) {
  7993. out[i] = data[i];
  7994. }
  7995. return out;
  7996. },
  7997. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7998. trackers = trackers || [];
  7999. var objects = index.objects;
  8000. var count = objects.length;
  8001. if (count === 0) {
  8002. return [
  8003. 0,
  8004. 0,
  8005. 0
  8006. ];
  8007. }
  8008. var data = [
  8009. count >> 8 & 0xFF,
  8010. count & 0xff
  8011. ];
  8012. var lastOffset = 1, i;
  8013. for (i = 0; i < count; ++i) {
  8014. lastOffset += objects[i].length;
  8015. }
  8016. var offsetSize;
  8017. if (lastOffset < 0x100) {
  8018. offsetSize = 1;
  8019. } else if (lastOffset < 0x10000) {
  8020. offsetSize = 2;
  8021. } else if (lastOffset < 0x1000000) {
  8022. offsetSize = 3;
  8023. } else {
  8024. offsetSize = 4;
  8025. }
  8026. data.push(offsetSize);
  8027. var relativeOffset = 1;
  8028. for (i = 0; i < count + 1; i++) {
  8029. if (offsetSize === 1) {
  8030. data.push(relativeOffset & 0xFF);
  8031. } else if (offsetSize === 2) {
  8032. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. } else if (offsetSize === 3) {
  8034. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8035. } else {
  8036. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8037. }
  8038. if (objects[i]) {
  8039. relativeOffset += objects[i].length;
  8040. }
  8041. }
  8042. for (i = 0; i < count; i++) {
  8043. if (trackers[i]) {
  8044. trackers[i].offset(data.length);
  8045. }
  8046. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8047. data.push(objects[i][j]);
  8048. }
  8049. }
  8050. return data;
  8051. }
  8052. };
  8053. return CFFCompiler;
  8054. }();
  8055. exports.CFFStandardStrings = CFFStandardStrings;
  8056. exports.CFFParser = CFFParser;
  8057. exports.CFF = CFF;
  8058. exports.CFFHeader = CFFHeader;
  8059. exports.CFFStrings = CFFStrings;
  8060. exports.CFFIndex = CFFIndex;
  8061. exports.CFFCharset = CFFCharset;
  8062. exports.CFFTopDict = CFFTopDict;
  8063. exports.CFFPrivateDict = CFFPrivateDict;
  8064. exports.CFFCompiler = CFFCompiler;
  8065. }));
  8066. (function (root, factory) {
  8067. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8068. }(this, function (exports, sharedUtil) {
  8069. var MissingDataException = sharedUtil.MissingDataException;
  8070. var arrayByteLength = sharedUtil.arrayByteLength;
  8071. var arraysToBytes = sharedUtil.arraysToBytes;
  8072. var assert = sharedUtil.assert;
  8073. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8074. var isInt = sharedUtil.isInt;
  8075. var isEmptyObj = sharedUtil.isEmptyObj;
  8076. var ChunkedStream = function ChunkedStreamClosure() {
  8077. function ChunkedStream(length, chunkSize, manager) {
  8078. this.bytes = new Uint8Array(length);
  8079. this.start = 0;
  8080. this.pos = 0;
  8081. this.end = length;
  8082. this.chunkSize = chunkSize;
  8083. this.loadedChunks = [];
  8084. this.numChunksLoaded = 0;
  8085. this.numChunks = Math.ceil(length / chunkSize);
  8086. this.manager = manager;
  8087. this.progressiveDataLength = 0;
  8088. this.lastSuccessfulEnsureByteChunk = -1;
  8089. }
  8090. ChunkedStream.prototype = {
  8091. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8092. var chunks = [];
  8093. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8094. if (!this.loadedChunks[chunk]) {
  8095. chunks.push(chunk);
  8096. }
  8097. }
  8098. return chunks;
  8099. },
  8100. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8101. return [this];
  8102. },
  8103. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8104. return this.numChunksLoaded === this.numChunks;
  8105. },
  8106. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8107. var end = begin + chunk.byteLength;
  8108. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8109. var length = this.bytes.length;
  8110. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8111. this.bytes.set(new Uint8Array(chunk), begin);
  8112. var chunkSize = this.chunkSize;
  8113. var beginChunk = Math.floor(begin / chunkSize);
  8114. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8115. var curChunk;
  8116. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8117. if (!this.loadedChunks[curChunk]) {
  8118. this.loadedChunks[curChunk] = true;
  8119. ++this.numChunksLoaded;
  8120. }
  8121. }
  8122. },
  8123. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8124. var position = this.progressiveDataLength;
  8125. var beginChunk = Math.floor(position / this.chunkSize);
  8126. this.bytes.set(new Uint8Array(data), position);
  8127. position += data.byteLength;
  8128. this.progressiveDataLength = position;
  8129. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8130. var curChunk;
  8131. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8132. if (!this.loadedChunks[curChunk]) {
  8133. this.loadedChunks[curChunk] = true;
  8134. ++this.numChunksLoaded;
  8135. }
  8136. }
  8137. },
  8138. ensureByte: function ChunkedStream_ensureByte(pos) {
  8139. var chunk = Math.floor(pos / this.chunkSize);
  8140. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8141. return;
  8142. }
  8143. if (!this.loadedChunks[chunk]) {
  8144. throw new MissingDataException(pos, pos + 1);
  8145. }
  8146. this.lastSuccessfulEnsureByteChunk = chunk;
  8147. },
  8148. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8149. if (begin >= end) {
  8150. return;
  8151. }
  8152. if (end <= this.progressiveDataLength) {
  8153. return;
  8154. }
  8155. var chunkSize = this.chunkSize;
  8156. var beginChunk = Math.floor(begin / chunkSize);
  8157. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8158. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8159. if (!this.loadedChunks[chunk]) {
  8160. throw new MissingDataException(begin, end);
  8161. }
  8162. }
  8163. },
  8164. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8165. var chunk, numChunks = this.numChunks;
  8166. for (var i = 0; i < numChunks; ++i) {
  8167. chunk = (beginChunk + i) % numChunks;
  8168. if (!this.loadedChunks[chunk]) {
  8169. return chunk;
  8170. }
  8171. }
  8172. return null;
  8173. },
  8174. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8175. return !!this.loadedChunks[chunk];
  8176. },
  8177. get length() {
  8178. return this.end - this.start;
  8179. },
  8180. get isEmpty() {
  8181. return this.length === 0;
  8182. },
  8183. getByte: function ChunkedStream_getByte() {
  8184. var pos = this.pos;
  8185. if (pos >= this.end) {
  8186. return -1;
  8187. }
  8188. this.ensureByte(pos);
  8189. return this.bytes[this.pos++];
  8190. },
  8191. getUint16: function ChunkedStream_getUint16() {
  8192. var b0 = this.getByte();
  8193. var b1 = this.getByte();
  8194. if (b0 === -1 || b1 === -1) {
  8195. return -1;
  8196. }
  8197. return (b0 << 8) + b1;
  8198. },
  8199. getInt32: function ChunkedStream_getInt32() {
  8200. var b0 = this.getByte();
  8201. var b1 = this.getByte();
  8202. var b2 = this.getByte();
  8203. var b3 = this.getByte();
  8204. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8205. },
  8206. getBytes: function ChunkedStream_getBytes(length) {
  8207. var bytes = this.bytes;
  8208. var pos = this.pos;
  8209. var strEnd = this.end;
  8210. if (!length) {
  8211. this.ensureRange(pos, strEnd);
  8212. return bytes.subarray(pos, strEnd);
  8213. }
  8214. var end = pos + length;
  8215. if (end > strEnd) {
  8216. end = strEnd;
  8217. }
  8218. this.ensureRange(pos, end);
  8219. this.pos = end;
  8220. return bytes.subarray(pos, end);
  8221. },
  8222. peekByte: function ChunkedStream_peekByte() {
  8223. var peekedByte = this.getByte();
  8224. this.pos--;
  8225. return peekedByte;
  8226. },
  8227. peekBytes: function ChunkedStream_peekBytes(length) {
  8228. var bytes = this.getBytes(length);
  8229. this.pos -= bytes.length;
  8230. return bytes;
  8231. },
  8232. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8233. this.ensureRange(begin, end);
  8234. return this.bytes.subarray(begin, end);
  8235. },
  8236. skip: function ChunkedStream_skip(n) {
  8237. if (!n) {
  8238. n = 1;
  8239. }
  8240. this.pos += n;
  8241. },
  8242. reset: function ChunkedStream_reset() {
  8243. this.pos = this.start;
  8244. },
  8245. moveStart: function ChunkedStream_moveStart() {
  8246. this.start = this.pos;
  8247. },
  8248. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8249. this.ensureRange(start, start + length);
  8250. function ChunkedStreamSubstream() {
  8251. }
  8252. ChunkedStreamSubstream.prototype = Object.create(this);
  8253. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8254. var chunkSize = this.chunkSize;
  8255. var beginChunk = Math.floor(this.start / chunkSize);
  8256. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8257. var missingChunks = [];
  8258. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8259. if (!this.loadedChunks[chunk]) {
  8260. missingChunks.push(chunk);
  8261. }
  8262. }
  8263. return missingChunks;
  8264. };
  8265. var subStream = new ChunkedStreamSubstream();
  8266. subStream.pos = subStream.start = start;
  8267. subStream.end = start + length || this.end;
  8268. subStream.dict = dict;
  8269. return subStream;
  8270. },
  8271. isStream: true
  8272. };
  8273. return ChunkedStream;
  8274. }();
  8275. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8276. function ChunkedStreamManager(pdfNetworkStream, args) {
  8277. var chunkSize = args.rangeChunkSize;
  8278. var length = args.length;
  8279. this.stream = new ChunkedStream(length, chunkSize, this);
  8280. this.length = length;
  8281. this.chunkSize = chunkSize;
  8282. this.pdfNetworkStream = pdfNetworkStream;
  8283. this.url = args.url;
  8284. this.disableAutoFetch = args.disableAutoFetch;
  8285. this.msgHandler = args.msgHandler;
  8286. this.currRequestId = 0;
  8287. this.chunksNeededByRequest = Object.create(null);
  8288. this.requestsByChunk = Object.create(null);
  8289. this.promisesByRequest = Object.create(null);
  8290. this.progressiveDataLength = 0;
  8291. this.aborted = false;
  8292. this._loadedStreamCapability = createPromiseCapability();
  8293. }
  8294. ChunkedStreamManager.prototype = {
  8295. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8296. return this._loadedStreamCapability.promise;
  8297. },
  8298. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8299. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8300. if (!rangeReader.isStreamingSupported) {
  8301. rangeReader.onProgress = this.onProgress.bind(this);
  8302. }
  8303. var chunks = [], loaded = 0;
  8304. var manager = this;
  8305. var promise = new Promise(function (resolve, reject) {
  8306. var readChunk = function (chunk) {
  8307. try {
  8308. if (!chunk.done) {
  8309. var data = chunk.value;
  8310. chunks.push(data);
  8311. loaded += arrayByteLength(data);
  8312. if (rangeReader.isStreamingSupported) {
  8313. manager.onProgress({ loaded: loaded });
  8314. }
  8315. rangeReader.read().then(readChunk, reject);
  8316. return;
  8317. }
  8318. var chunkData = arraysToBytes(chunks);
  8319. chunks = null;
  8320. resolve(chunkData);
  8321. } catch (e) {
  8322. reject(e);
  8323. }
  8324. };
  8325. rangeReader.read().then(readChunk, reject);
  8326. });
  8327. promise.then(function (data) {
  8328. if (this.aborted) {
  8329. return;
  8330. }
  8331. this.onReceiveData({
  8332. chunk: data,
  8333. begin: begin
  8334. });
  8335. }.bind(this));
  8336. },
  8337. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8338. var missingChunks = this.stream.getMissingChunks();
  8339. this._requestChunks(missingChunks);
  8340. return this._loadedStreamCapability.promise;
  8341. },
  8342. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8343. var requestId = this.currRequestId++;
  8344. var i, ii;
  8345. var chunksNeeded = Object.create(null);
  8346. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8347. for (i = 0, ii = chunks.length; i < ii; i++) {
  8348. if (!this.stream.hasChunk(chunks[i])) {
  8349. chunksNeeded[chunks[i]] = true;
  8350. }
  8351. }
  8352. if (isEmptyObj(chunksNeeded)) {
  8353. return Promise.resolve();
  8354. }
  8355. var capability = createPromiseCapability();
  8356. this.promisesByRequest[requestId] = capability;
  8357. var chunksToRequest = [];
  8358. for (var chunk in chunksNeeded) {
  8359. chunk = chunk | 0;
  8360. if (!(chunk in this.requestsByChunk)) {
  8361. this.requestsByChunk[chunk] = [];
  8362. chunksToRequest.push(chunk);
  8363. }
  8364. this.requestsByChunk[chunk].push(requestId);
  8365. }
  8366. if (!chunksToRequest.length) {
  8367. return capability.promise;
  8368. }
  8369. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8370. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8371. var groupedChunk = groupedChunksToRequest[i];
  8372. var begin = groupedChunk.beginChunk * this.chunkSize;
  8373. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8374. this.sendRequest(begin, end);
  8375. }
  8376. return capability.promise;
  8377. },
  8378. getStream: function ChunkedStreamManager_getStream() {
  8379. return this.stream;
  8380. },
  8381. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8382. end = Math.min(end, this.length);
  8383. var beginChunk = this.getBeginChunk(begin);
  8384. var endChunk = this.getEndChunk(end);
  8385. var chunks = [];
  8386. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8387. chunks.push(chunk);
  8388. }
  8389. return this._requestChunks(chunks);
  8390. },
  8391. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8392. ranges = ranges || [];
  8393. var chunksToRequest = [];
  8394. for (var i = 0; i < ranges.length; i++) {
  8395. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8396. var endChunk = this.getEndChunk(ranges[i].end);
  8397. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8398. if (chunksToRequest.indexOf(chunk) < 0) {
  8399. chunksToRequest.push(chunk);
  8400. }
  8401. }
  8402. }
  8403. chunksToRequest.sort(function (a, b) {
  8404. return a - b;
  8405. });
  8406. return this._requestChunks(chunksToRequest);
  8407. },
  8408. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8409. var groupedChunks = [];
  8410. var beginChunk = -1;
  8411. var prevChunk = -1;
  8412. for (var i = 0; i < chunks.length; ++i) {
  8413. var chunk = chunks[i];
  8414. if (beginChunk < 0) {
  8415. beginChunk = chunk;
  8416. }
  8417. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8418. groupedChunks.push({
  8419. beginChunk: beginChunk,
  8420. endChunk: prevChunk + 1
  8421. });
  8422. beginChunk = chunk;
  8423. }
  8424. if (i + 1 === chunks.length) {
  8425. groupedChunks.push({
  8426. beginChunk: beginChunk,
  8427. endChunk: chunk + 1
  8428. });
  8429. }
  8430. prevChunk = chunk;
  8431. }
  8432. return groupedChunks;
  8433. },
  8434. onProgress: function ChunkedStreamManager_onProgress(args) {
  8435. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8436. this.msgHandler.send('DocProgress', {
  8437. loaded: bytesLoaded,
  8438. total: this.length
  8439. });
  8440. },
  8441. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8442. var chunk = args.chunk;
  8443. var isProgressive = args.begin === undefined;
  8444. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8445. var end = begin + chunk.byteLength;
  8446. var beginChunk = Math.floor(begin / this.chunkSize);
  8447. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8448. if (isProgressive) {
  8449. this.stream.onReceiveProgressiveData(chunk);
  8450. this.progressiveDataLength = end;
  8451. } else {
  8452. this.stream.onReceiveData(begin, chunk);
  8453. }
  8454. if (this.stream.allChunksLoaded()) {
  8455. this._loadedStreamCapability.resolve(this.stream);
  8456. }
  8457. var loadedRequests = [];
  8458. var i, requestId;
  8459. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8460. var requestIds = this.requestsByChunk[chunk] || [];
  8461. delete this.requestsByChunk[chunk];
  8462. for (i = 0; i < requestIds.length; ++i) {
  8463. requestId = requestIds[i];
  8464. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8465. if (chunk in chunksNeeded) {
  8466. delete chunksNeeded[chunk];
  8467. }
  8468. if (!isEmptyObj(chunksNeeded)) {
  8469. continue;
  8470. }
  8471. loadedRequests.push(requestId);
  8472. }
  8473. }
  8474. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8475. var nextEmptyChunk;
  8476. if (this.stream.numChunksLoaded === 1) {
  8477. var lastChunk = this.stream.numChunks - 1;
  8478. if (!this.stream.hasChunk(lastChunk)) {
  8479. nextEmptyChunk = lastChunk;
  8480. }
  8481. } else {
  8482. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8483. }
  8484. if (isInt(nextEmptyChunk)) {
  8485. this._requestChunks([nextEmptyChunk]);
  8486. }
  8487. }
  8488. for (i = 0; i < loadedRequests.length; ++i) {
  8489. requestId = loadedRequests[i];
  8490. var capability = this.promisesByRequest[requestId];
  8491. delete this.promisesByRequest[requestId];
  8492. capability.resolve();
  8493. }
  8494. this.msgHandler.send('DocProgress', {
  8495. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8496. total: this.length
  8497. });
  8498. },
  8499. onError: function ChunkedStreamManager_onError(err) {
  8500. this._loadedStreamCapability.reject(err);
  8501. },
  8502. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8503. var chunk = Math.floor(begin / this.chunkSize);
  8504. return chunk;
  8505. },
  8506. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8507. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8508. return chunk;
  8509. },
  8510. abort: function ChunkedStreamManager_abort() {
  8511. this.aborted = true;
  8512. if (this.pdfNetworkStream) {
  8513. this.pdfNetworkStream.cancelAllRequests('abort');
  8514. }
  8515. for (var requestId in this.promisesByRequest) {
  8516. var capability = this.promisesByRequest[requestId];
  8517. capability.reject(new Error('Request was aborted'));
  8518. }
  8519. }
  8520. };
  8521. return ChunkedStreamManager;
  8522. }();
  8523. exports.ChunkedStream = ChunkedStream;
  8524. exports.ChunkedStreamManager = ChunkedStreamManager;
  8525. }));
  8526. (function (root, factory) {
  8527. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8528. }(this, function (exports, sharedUtil) {
  8529. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8530. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8531. t['A'] = 0x0041;
  8532. t['AE'] = 0x00C6;
  8533. t['AEacute'] = 0x01FC;
  8534. t['AEmacron'] = 0x01E2;
  8535. t['AEsmall'] = 0xF7E6;
  8536. t['Aacute'] = 0x00C1;
  8537. t['Aacutesmall'] = 0xF7E1;
  8538. t['Abreve'] = 0x0102;
  8539. t['Abreveacute'] = 0x1EAE;
  8540. t['Abrevecyrillic'] = 0x04D0;
  8541. t['Abrevedotbelow'] = 0x1EB6;
  8542. t['Abrevegrave'] = 0x1EB0;
  8543. t['Abrevehookabove'] = 0x1EB2;
  8544. t['Abrevetilde'] = 0x1EB4;
  8545. t['Acaron'] = 0x01CD;
  8546. t['Acircle'] = 0x24B6;
  8547. t['Acircumflex'] = 0x00C2;
  8548. t['Acircumflexacute'] = 0x1EA4;
  8549. t['Acircumflexdotbelow'] = 0x1EAC;
  8550. t['Acircumflexgrave'] = 0x1EA6;
  8551. t['Acircumflexhookabove'] = 0x1EA8;
  8552. t['Acircumflexsmall'] = 0xF7E2;
  8553. t['Acircumflextilde'] = 0x1EAA;
  8554. t['Acute'] = 0xF6C9;
  8555. t['Acutesmall'] = 0xF7B4;
  8556. t['Acyrillic'] = 0x0410;
  8557. t['Adblgrave'] = 0x0200;
  8558. t['Adieresis'] = 0x00C4;
  8559. t['Adieresiscyrillic'] = 0x04D2;
  8560. t['Adieresismacron'] = 0x01DE;
  8561. t['Adieresissmall'] = 0xF7E4;
  8562. t['Adotbelow'] = 0x1EA0;
  8563. t['Adotmacron'] = 0x01E0;
  8564. t['Agrave'] = 0x00C0;
  8565. t['Agravesmall'] = 0xF7E0;
  8566. t['Ahookabove'] = 0x1EA2;
  8567. t['Aiecyrillic'] = 0x04D4;
  8568. t['Ainvertedbreve'] = 0x0202;
  8569. t['Alpha'] = 0x0391;
  8570. t['Alphatonos'] = 0x0386;
  8571. t['Amacron'] = 0x0100;
  8572. t['Amonospace'] = 0xFF21;
  8573. t['Aogonek'] = 0x0104;
  8574. t['Aring'] = 0x00C5;
  8575. t['Aringacute'] = 0x01FA;
  8576. t['Aringbelow'] = 0x1E00;
  8577. t['Aringsmall'] = 0xF7E5;
  8578. t['Asmall'] = 0xF761;
  8579. t['Atilde'] = 0x00C3;
  8580. t['Atildesmall'] = 0xF7E3;
  8581. t['Aybarmenian'] = 0x0531;
  8582. t['B'] = 0x0042;
  8583. t['Bcircle'] = 0x24B7;
  8584. t['Bdotaccent'] = 0x1E02;
  8585. t['Bdotbelow'] = 0x1E04;
  8586. t['Becyrillic'] = 0x0411;
  8587. t['Benarmenian'] = 0x0532;
  8588. t['Beta'] = 0x0392;
  8589. t['Bhook'] = 0x0181;
  8590. t['Blinebelow'] = 0x1E06;
  8591. t['Bmonospace'] = 0xFF22;
  8592. t['Brevesmall'] = 0xF6F4;
  8593. t['Bsmall'] = 0xF762;
  8594. t['Btopbar'] = 0x0182;
  8595. t['C'] = 0x0043;
  8596. t['Caarmenian'] = 0x053E;
  8597. t['Cacute'] = 0x0106;
  8598. t['Caron'] = 0xF6CA;
  8599. t['Caronsmall'] = 0xF6F5;
  8600. t['Ccaron'] = 0x010C;
  8601. t['Ccedilla'] = 0x00C7;
  8602. t['Ccedillaacute'] = 0x1E08;
  8603. t['Ccedillasmall'] = 0xF7E7;
  8604. t['Ccircle'] = 0x24B8;
  8605. t['Ccircumflex'] = 0x0108;
  8606. t['Cdot'] = 0x010A;
  8607. t['Cdotaccent'] = 0x010A;
  8608. t['Cedillasmall'] = 0xF7B8;
  8609. t['Chaarmenian'] = 0x0549;
  8610. t['Cheabkhasiancyrillic'] = 0x04BC;
  8611. t['Checyrillic'] = 0x0427;
  8612. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8613. t['Chedescendercyrillic'] = 0x04B6;
  8614. t['Chedieresiscyrillic'] = 0x04F4;
  8615. t['Cheharmenian'] = 0x0543;
  8616. t['Chekhakassiancyrillic'] = 0x04CB;
  8617. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8618. t['Chi'] = 0x03A7;
  8619. t['Chook'] = 0x0187;
  8620. t['Circumflexsmall'] = 0xF6F6;
  8621. t['Cmonospace'] = 0xFF23;
  8622. t['Coarmenian'] = 0x0551;
  8623. t['Csmall'] = 0xF763;
  8624. t['D'] = 0x0044;
  8625. t['DZ'] = 0x01F1;
  8626. t['DZcaron'] = 0x01C4;
  8627. t['Daarmenian'] = 0x0534;
  8628. t['Dafrican'] = 0x0189;
  8629. t['Dcaron'] = 0x010E;
  8630. t['Dcedilla'] = 0x1E10;
  8631. t['Dcircle'] = 0x24B9;
  8632. t['Dcircumflexbelow'] = 0x1E12;
  8633. t['Dcroat'] = 0x0110;
  8634. t['Ddotaccent'] = 0x1E0A;
  8635. t['Ddotbelow'] = 0x1E0C;
  8636. t['Decyrillic'] = 0x0414;
  8637. t['Deicoptic'] = 0x03EE;
  8638. t['Delta'] = 0x2206;
  8639. t['Deltagreek'] = 0x0394;
  8640. t['Dhook'] = 0x018A;
  8641. t['Dieresis'] = 0xF6CB;
  8642. t['DieresisAcute'] = 0xF6CC;
  8643. t['DieresisGrave'] = 0xF6CD;
  8644. t['Dieresissmall'] = 0xF7A8;
  8645. t['Digammagreek'] = 0x03DC;
  8646. t['Djecyrillic'] = 0x0402;
  8647. t['Dlinebelow'] = 0x1E0E;
  8648. t['Dmonospace'] = 0xFF24;
  8649. t['Dotaccentsmall'] = 0xF6F7;
  8650. t['Dslash'] = 0x0110;
  8651. t['Dsmall'] = 0xF764;
  8652. t['Dtopbar'] = 0x018B;
  8653. t['Dz'] = 0x01F2;
  8654. t['Dzcaron'] = 0x01C5;
  8655. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8656. t['Dzecyrillic'] = 0x0405;
  8657. t['Dzhecyrillic'] = 0x040F;
  8658. t['E'] = 0x0045;
  8659. t['Eacute'] = 0x00C9;
  8660. t['Eacutesmall'] = 0xF7E9;
  8661. t['Ebreve'] = 0x0114;
  8662. t['Ecaron'] = 0x011A;
  8663. t['Ecedillabreve'] = 0x1E1C;
  8664. t['Echarmenian'] = 0x0535;
  8665. t['Ecircle'] = 0x24BA;
  8666. t['Ecircumflex'] = 0x00CA;
  8667. t['Ecircumflexacute'] = 0x1EBE;
  8668. t['Ecircumflexbelow'] = 0x1E18;
  8669. t['Ecircumflexdotbelow'] = 0x1EC6;
  8670. t['Ecircumflexgrave'] = 0x1EC0;
  8671. t['Ecircumflexhookabove'] = 0x1EC2;
  8672. t['Ecircumflexsmall'] = 0xF7EA;
  8673. t['Ecircumflextilde'] = 0x1EC4;
  8674. t['Ecyrillic'] = 0x0404;
  8675. t['Edblgrave'] = 0x0204;
  8676. t['Edieresis'] = 0x00CB;
  8677. t['Edieresissmall'] = 0xF7EB;
  8678. t['Edot'] = 0x0116;
  8679. t['Edotaccent'] = 0x0116;
  8680. t['Edotbelow'] = 0x1EB8;
  8681. t['Efcyrillic'] = 0x0424;
  8682. t['Egrave'] = 0x00C8;
  8683. t['Egravesmall'] = 0xF7E8;
  8684. t['Eharmenian'] = 0x0537;
  8685. t['Ehookabove'] = 0x1EBA;
  8686. t['Eightroman'] = 0x2167;
  8687. t['Einvertedbreve'] = 0x0206;
  8688. t['Eiotifiedcyrillic'] = 0x0464;
  8689. t['Elcyrillic'] = 0x041B;
  8690. t['Elevenroman'] = 0x216A;
  8691. t['Emacron'] = 0x0112;
  8692. t['Emacronacute'] = 0x1E16;
  8693. t['Emacrongrave'] = 0x1E14;
  8694. t['Emcyrillic'] = 0x041C;
  8695. t['Emonospace'] = 0xFF25;
  8696. t['Encyrillic'] = 0x041D;
  8697. t['Endescendercyrillic'] = 0x04A2;
  8698. t['Eng'] = 0x014A;
  8699. t['Enghecyrillic'] = 0x04A4;
  8700. t['Enhookcyrillic'] = 0x04C7;
  8701. t['Eogonek'] = 0x0118;
  8702. t['Eopen'] = 0x0190;
  8703. t['Epsilon'] = 0x0395;
  8704. t['Epsilontonos'] = 0x0388;
  8705. t['Ercyrillic'] = 0x0420;
  8706. t['Ereversed'] = 0x018E;
  8707. t['Ereversedcyrillic'] = 0x042D;
  8708. t['Escyrillic'] = 0x0421;
  8709. t['Esdescendercyrillic'] = 0x04AA;
  8710. t['Esh'] = 0x01A9;
  8711. t['Esmall'] = 0xF765;
  8712. t['Eta'] = 0x0397;
  8713. t['Etarmenian'] = 0x0538;
  8714. t['Etatonos'] = 0x0389;
  8715. t['Eth'] = 0x00D0;
  8716. t['Ethsmall'] = 0xF7F0;
  8717. t['Etilde'] = 0x1EBC;
  8718. t['Etildebelow'] = 0x1E1A;
  8719. t['Euro'] = 0x20AC;
  8720. t['Ezh'] = 0x01B7;
  8721. t['Ezhcaron'] = 0x01EE;
  8722. t['Ezhreversed'] = 0x01B8;
  8723. t['F'] = 0x0046;
  8724. t['Fcircle'] = 0x24BB;
  8725. t['Fdotaccent'] = 0x1E1E;
  8726. t['Feharmenian'] = 0x0556;
  8727. t['Feicoptic'] = 0x03E4;
  8728. t['Fhook'] = 0x0191;
  8729. t['Fitacyrillic'] = 0x0472;
  8730. t['Fiveroman'] = 0x2164;
  8731. t['Fmonospace'] = 0xFF26;
  8732. t['Fourroman'] = 0x2163;
  8733. t['Fsmall'] = 0xF766;
  8734. t['G'] = 0x0047;
  8735. t['GBsquare'] = 0x3387;
  8736. t['Gacute'] = 0x01F4;
  8737. t['Gamma'] = 0x0393;
  8738. t['Gammaafrican'] = 0x0194;
  8739. t['Gangiacoptic'] = 0x03EA;
  8740. t['Gbreve'] = 0x011E;
  8741. t['Gcaron'] = 0x01E6;
  8742. t['Gcedilla'] = 0x0122;
  8743. t['Gcircle'] = 0x24BC;
  8744. t['Gcircumflex'] = 0x011C;
  8745. t['Gcommaaccent'] = 0x0122;
  8746. t['Gdot'] = 0x0120;
  8747. t['Gdotaccent'] = 0x0120;
  8748. t['Gecyrillic'] = 0x0413;
  8749. t['Ghadarmenian'] = 0x0542;
  8750. t['Ghemiddlehookcyrillic'] = 0x0494;
  8751. t['Ghestrokecyrillic'] = 0x0492;
  8752. t['Gheupturncyrillic'] = 0x0490;
  8753. t['Ghook'] = 0x0193;
  8754. t['Gimarmenian'] = 0x0533;
  8755. t['Gjecyrillic'] = 0x0403;
  8756. t['Gmacron'] = 0x1E20;
  8757. t['Gmonospace'] = 0xFF27;
  8758. t['Grave'] = 0xF6CE;
  8759. t['Gravesmall'] = 0xF760;
  8760. t['Gsmall'] = 0xF767;
  8761. t['Gsmallhook'] = 0x029B;
  8762. t['Gstroke'] = 0x01E4;
  8763. t['H'] = 0x0048;
  8764. t['H18533'] = 0x25CF;
  8765. t['H18543'] = 0x25AA;
  8766. t['H18551'] = 0x25AB;
  8767. t['H22073'] = 0x25A1;
  8768. t['HPsquare'] = 0x33CB;
  8769. t['Haabkhasiancyrillic'] = 0x04A8;
  8770. t['Hadescendercyrillic'] = 0x04B2;
  8771. t['Hardsigncyrillic'] = 0x042A;
  8772. t['Hbar'] = 0x0126;
  8773. t['Hbrevebelow'] = 0x1E2A;
  8774. t['Hcedilla'] = 0x1E28;
  8775. t['Hcircle'] = 0x24BD;
  8776. t['Hcircumflex'] = 0x0124;
  8777. t['Hdieresis'] = 0x1E26;
  8778. t['Hdotaccent'] = 0x1E22;
  8779. t['Hdotbelow'] = 0x1E24;
  8780. t['Hmonospace'] = 0xFF28;
  8781. t['Hoarmenian'] = 0x0540;
  8782. t['Horicoptic'] = 0x03E8;
  8783. t['Hsmall'] = 0xF768;
  8784. t['Hungarumlaut'] = 0xF6CF;
  8785. t['Hungarumlautsmall'] = 0xF6F8;
  8786. t['Hzsquare'] = 0x3390;
  8787. t['I'] = 0x0049;
  8788. t['IAcyrillic'] = 0x042F;
  8789. t['IJ'] = 0x0132;
  8790. t['IUcyrillic'] = 0x042E;
  8791. t['Iacute'] = 0x00CD;
  8792. t['Iacutesmall'] = 0xF7ED;
  8793. t['Ibreve'] = 0x012C;
  8794. t['Icaron'] = 0x01CF;
  8795. t['Icircle'] = 0x24BE;
  8796. t['Icircumflex'] = 0x00CE;
  8797. t['Icircumflexsmall'] = 0xF7EE;
  8798. t['Icyrillic'] = 0x0406;
  8799. t['Idblgrave'] = 0x0208;
  8800. t['Idieresis'] = 0x00CF;
  8801. t['Idieresisacute'] = 0x1E2E;
  8802. t['Idieresiscyrillic'] = 0x04E4;
  8803. t['Idieresissmall'] = 0xF7EF;
  8804. t['Idot'] = 0x0130;
  8805. t['Idotaccent'] = 0x0130;
  8806. t['Idotbelow'] = 0x1ECA;
  8807. t['Iebrevecyrillic'] = 0x04D6;
  8808. t['Iecyrillic'] = 0x0415;
  8809. t['Ifraktur'] = 0x2111;
  8810. t['Igrave'] = 0x00CC;
  8811. t['Igravesmall'] = 0xF7EC;
  8812. t['Ihookabove'] = 0x1EC8;
  8813. t['Iicyrillic'] = 0x0418;
  8814. t['Iinvertedbreve'] = 0x020A;
  8815. t['Iishortcyrillic'] = 0x0419;
  8816. t['Imacron'] = 0x012A;
  8817. t['Imacroncyrillic'] = 0x04E2;
  8818. t['Imonospace'] = 0xFF29;
  8819. t['Iniarmenian'] = 0x053B;
  8820. t['Iocyrillic'] = 0x0401;
  8821. t['Iogonek'] = 0x012E;
  8822. t['Iota'] = 0x0399;
  8823. t['Iotaafrican'] = 0x0196;
  8824. t['Iotadieresis'] = 0x03AA;
  8825. t['Iotatonos'] = 0x038A;
  8826. t['Ismall'] = 0xF769;
  8827. t['Istroke'] = 0x0197;
  8828. t['Itilde'] = 0x0128;
  8829. t['Itildebelow'] = 0x1E2C;
  8830. t['Izhitsacyrillic'] = 0x0474;
  8831. t['Izhitsadblgravecyrillic'] = 0x0476;
  8832. t['J'] = 0x004A;
  8833. t['Jaarmenian'] = 0x0541;
  8834. t['Jcircle'] = 0x24BF;
  8835. t['Jcircumflex'] = 0x0134;
  8836. t['Jecyrillic'] = 0x0408;
  8837. t['Jheharmenian'] = 0x054B;
  8838. t['Jmonospace'] = 0xFF2A;
  8839. t['Jsmall'] = 0xF76A;
  8840. t['K'] = 0x004B;
  8841. t['KBsquare'] = 0x3385;
  8842. t['KKsquare'] = 0x33CD;
  8843. t['Kabashkircyrillic'] = 0x04A0;
  8844. t['Kacute'] = 0x1E30;
  8845. t['Kacyrillic'] = 0x041A;
  8846. t['Kadescendercyrillic'] = 0x049A;
  8847. t['Kahookcyrillic'] = 0x04C3;
  8848. t['Kappa'] = 0x039A;
  8849. t['Kastrokecyrillic'] = 0x049E;
  8850. t['Kaverticalstrokecyrillic'] = 0x049C;
  8851. t['Kcaron'] = 0x01E8;
  8852. t['Kcedilla'] = 0x0136;
  8853. t['Kcircle'] = 0x24C0;
  8854. t['Kcommaaccent'] = 0x0136;
  8855. t['Kdotbelow'] = 0x1E32;
  8856. t['Keharmenian'] = 0x0554;
  8857. t['Kenarmenian'] = 0x053F;
  8858. t['Khacyrillic'] = 0x0425;
  8859. t['Kheicoptic'] = 0x03E6;
  8860. t['Khook'] = 0x0198;
  8861. t['Kjecyrillic'] = 0x040C;
  8862. t['Klinebelow'] = 0x1E34;
  8863. t['Kmonospace'] = 0xFF2B;
  8864. t['Koppacyrillic'] = 0x0480;
  8865. t['Koppagreek'] = 0x03DE;
  8866. t['Ksicyrillic'] = 0x046E;
  8867. t['Ksmall'] = 0xF76B;
  8868. t['L'] = 0x004C;
  8869. t['LJ'] = 0x01C7;
  8870. t['LL'] = 0xF6BF;
  8871. t['Lacute'] = 0x0139;
  8872. t['Lambda'] = 0x039B;
  8873. t['Lcaron'] = 0x013D;
  8874. t['Lcedilla'] = 0x013B;
  8875. t['Lcircle'] = 0x24C1;
  8876. t['Lcircumflexbelow'] = 0x1E3C;
  8877. t['Lcommaaccent'] = 0x013B;
  8878. t['Ldot'] = 0x013F;
  8879. t['Ldotaccent'] = 0x013F;
  8880. t['Ldotbelow'] = 0x1E36;
  8881. t['Ldotbelowmacron'] = 0x1E38;
  8882. t['Liwnarmenian'] = 0x053C;
  8883. t['Lj'] = 0x01C8;
  8884. t['Ljecyrillic'] = 0x0409;
  8885. t['Llinebelow'] = 0x1E3A;
  8886. t['Lmonospace'] = 0xFF2C;
  8887. t['Lslash'] = 0x0141;
  8888. t['Lslashsmall'] = 0xF6F9;
  8889. t['Lsmall'] = 0xF76C;
  8890. t['M'] = 0x004D;
  8891. t['MBsquare'] = 0x3386;
  8892. t['Macron'] = 0xF6D0;
  8893. t['Macronsmall'] = 0xF7AF;
  8894. t['Macute'] = 0x1E3E;
  8895. t['Mcircle'] = 0x24C2;
  8896. t['Mdotaccent'] = 0x1E40;
  8897. t['Mdotbelow'] = 0x1E42;
  8898. t['Menarmenian'] = 0x0544;
  8899. t['Mmonospace'] = 0xFF2D;
  8900. t['Msmall'] = 0xF76D;
  8901. t['Mturned'] = 0x019C;
  8902. t['Mu'] = 0x039C;
  8903. t['N'] = 0x004E;
  8904. t['NJ'] = 0x01CA;
  8905. t['Nacute'] = 0x0143;
  8906. t['Ncaron'] = 0x0147;
  8907. t['Ncedilla'] = 0x0145;
  8908. t['Ncircle'] = 0x24C3;
  8909. t['Ncircumflexbelow'] = 0x1E4A;
  8910. t['Ncommaaccent'] = 0x0145;
  8911. t['Ndotaccent'] = 0x1E44;
  8912. t['Ndotbelow'] = 0x1E46;
  8913. t['Nhookleft'] = 0x019D;
  8914. t['Nineroman'] = 0x2168;
  8915. t['Nj'] = 0x01CB;
  8916. t['Njecyrillic'] = 0x040A;
  8917. t['Nlinebelow'] = 0x1E48;
  8918. t['Nmonospace'] = 0xFF2E;
  8919. t['Nowarmenian'] = 0x0546;
  8920. t['Nsmall'] = 0xF76E;
  8921. t['Ntilde'] = 0x00D1;
  8922. t['Ntildesmall'] = 0xF7F1;
  8923. t['Nu'] = 0x039D;
  8924. t['O'] = 0x004F;
  8925. t['OE'] = 0x0152;
  8926. t['OEsmall'] = 0xF6FA;
  8927. t['Oacute'] = 0x00D3;
  8928. t['Oacutesmall'] = 0xF7F3;
  8929. t['Obarredcyrillic'] = 0x04E8;
  8930. t['Obarreddieresiscyrillic'] = 0x04EA;
  8931. t['Obreve'] = 0x014E;
  8932. t['Ocaron'] = 0x01D1;
  8933. t['Ocenteredtilde'] = 0x019F;
  8934. t['Ocircle'] = 0x24C4;
  8935. t['Ocircumflex'] = 0x00D4;
  8936. t['Ocircumflexacute'] = 0x1ED0;
  8937. t['Ocircumflexdotbelow'] = 0x1ED8;
  8938. t['Ocircumflexgrave'] = 0x1ED2;
  8939. t['Ocircumflexhookabove'] = 0x1ED4;
  8940. t['Ocircumflexsmall'] = 0xF7F4;
  8941. t['Ocircumflextilde'] = 0x1ED6;
  8942. t['Ocyrillic'] = 0x041E;
  8943. t['Odblacute'] = 0x0150;
  8944. t['Odblgrave'] = 0x020C;
  8945. t['Odieresis'] = 0x00D6;
  8946. t['Odieresiscyrillic'] = 0x04E6;
  8947. t['Odieresissmall'] = 0xF7F6;
  8948. t['Odotbelow'] = 0x1ECC;
  8949. t['Ogoneksmall'] = 0xF6FB;
  8950. t['Ograve'] = 0x00D2;
  8951. t['Ogravesmall'] = 0xF7F2;
  8952. t['Oharmenian'] = 0x0555;
  8953. t['Ohm'] = 0x2126;
  8954. t['Ohookabove'] = 0x1ECE;
  8955. t['Ohorn'] = 0x01A0;
  8956. t['Ohornacute'] = 0x1EDA;
  8957. t['Ohorndotbelow'] = 0x1EE2;
  8958. t['Ohorngrave'] = 0x1EDC;
  8959. t['Ohornhookabove'] = 0x1EDE;
  8960. t['Ohorntilde'] = 0x1EE0;
  8961. t['Ohungarumlaut'] = 0x0150;
  8962. t['Oi'] = 0x01A2;
  8963. t['Oinvertedbreve'] = 0x020E;
  8964. t['Omacron'] = 0x014C;
  8965. t['Omacronacute'] = 0x1E52;
  8966. t['Omacrongrave'] = 0x1E50;
  8967. t['Omega'] = 0x2126;
  8968. t['Omegacyrillic'] = 0x0460;
  8969. t['Omegagreek'] = 0x03A9;
  8970. t['Omegaroundcyrillic'] = 0x047A;
  8971. t['Omegatitlocyrillic'] = 0x047C;
  8972. t['Omegatonos'] = 0x038F;
  8973. t['Omicron'] = 0x039F;
  8974. t['Omicrontonos'] = 0x038C;
  8975. t['Omonospace'] = 0xFF2F;
  8976. t['Oneroman'] = 0x2160;
  8977. t['Oogonek'] = 0x01EA;
  8978. t['Oogonekmacron'] = 0x01EC;
  8979. t['Oopen'] = 0x0186;
  8980. t['Oslash'] = 0x00D8;
  8981. t['Oslashacute'] = 0x01FE;
  8982. t['Oslashsmall'] = 0xF7F8;
  8983. t['Osmall'] = 0xF76F;
  8984. t['Ostrokeacute'] = 0x01FE;
  8985. t['Otcyrillic'] = 0x047E;
  8986. t['Otilde'] = 0x00D5;
  8987. t['Otildeacute'] = 0x1E4C;
  8988. t['Otildedieresis'] = 0x1E4E;
  8989. t['Otildesmall'] = 0xF7F5;
  8990. t['P'] = 0x0050;
  8991. t['Pacute'] = 0x1E54;
  8992. t['Pcircle'] = 0x24C5;
  8993. t['Pdotaccent'] = 0x1E56;
  8994. t['Pecyrillic'] = 0x041F;
  8995. t['Peharmenian'] = 0x054A;
  8996. t['Pemiddlehookcyrillic'] = 0x04A6;
  8997. t['Phi'] = 0x03A6;
  8998. t['Phook'] = 0x01A4;
  8999. t['Pi'] = 0x03A0;
  9000. t['Piwrarmenian'] = 0x0553;
  9001. t['Pmonospace'] = 0xFF30;
  9002. t['Psi'] = 0x03A8;
  9003. t['Psicyrillic'] = 0x0470;
  9004. t['Psmall'] = 0xF770;
  9005. t['Q'] = 0x0051;
  9006. t['Qcircle'] = 0x24C6;
  9007. t['Qmonospace'] = 0xFF31;
  9008. t['Qsmall'] = 0xF771;
  9009. t['R'] = 0x0052;
  9010. t['Raarmenian'] = 0x054C;
  9011. t['Racute'] = 0x0154;
  9012. t['Rcaron'] = 0x0158;
  9013. t['Rcedilla'] = 0x0156;
  9014. t['Rcircle'] = 0x24C7;
  9015. t['Rcommaaccent'] = 0x0156;
  9016. t['Rdblgrave'] = 0x0210;
  9017. t['Rdotaccent'] = 0x1E58;
  9018. t['Rdotbelow'] = 0x1E5A;
  9019. t['Rdotbelowmacron'] = 0x1E5C;
  9020. t['Reharmenian'] = 0x0550;
  9021. t['Rfraktur'] = 0x211C;
  9022. t['Rho'] = 0x03A1;
  9023. t['Ringsmall'] = 0xF6FC;
  9024. t['Rinvertedbreve'] = 0x0212;
  9025. t['Rlinebelow'] = 0x1E5E;
  9026. t['Rmonospace'] = 0xFF32;
  9027. t['Rsmall'] = 0xF772;
  9028. t['Rsmallinverted'] = 0x0281;
  9029. t['Rsmallinvertedsuperior'] = 0x02B6;
  9030. t['S'] = 0x0053;
  9031. t['SF010000'] = 0x250C;
  9032. t['SF020000'] = 0x2514;
  9033. t['SF030000'] = 0x2510;
  9034. t['SF040000'] = 0x2518;
  9035. t['SF050000'] = 0x253C;
  9036. t['SF060000'] = 0x252C;
  9037. t['SF070000'] = 0x2534;
  9038. t['SF080000'] = 0x251C;
  9039. t['SF090000'] = 0x2524;
  9040. t['SF100000'] = 0x2500;
  9041. t['SF110000'] = 0x2502;
  9042. t['SF190000'] = 0x2561;
  9043. t['SF200000'] = 0x2562;
  9044. t['SF210000'] = 0x2556;
  9045. t['SF220000'] = 0x2555;
  9046. t['SF230000'] = 0x2563;
  9047. t['SF240000'] = 0x2551;
  9048. t['SF250000'] = 0x2557;
  9049. t['SF260000'] = 0x255D;
  9050. t['SF270000'] = 0x255C;
  9051. t['SF280000'] = 0x255B;
  9052. t['SF360000'] = 0x255E;
  9053. t['SF370000'] = 0x255F;
  9054. t['SF380000'] = 0x255A;
  9055. t['SF390000'] = 0x2554;
  9056. t['SF400000'] = 0x2569;
  9057. t['SF410000'] = 0x2566;
  9058. t['SF420000'] = 0x2560;
  9059. t['SF430000'] = 0x2550;
  9060. t['SF440000'] = 0x256C;
  9061. t['SF450000'] = 0x2567;
  9062. t['SF460000'] = 0x2568;
  9063. t['SF470000'] = 0x2564;
  9064. t['SF480000'] = 0x2565;
  9065. t['SF490000'] = 0x2559;
  9066. t['SF500000'] = 0x2558;
  9067. t['SF510000'] = 0x2552;
  9068. t['SF520000'] = 0x2553;
  9069. t['SF530000'] = 0x256B;
  9070. t['SF540000'] = 0x256A;
  9071. t['Sacute'] = 0x015A;
  9072. t['Sacutedotaccent'] = 0x1E64;
  9073. t['Sampigreek'] = 0x03E0;
  9074. t['Scaron'] = 0x0160;
  9075. t['Scarondotaccent'] = 0x1E66;
  9076. t['Scaronsmall'] = 0xF6FD;
  9077. t['Scedilla'] = 0x015E;
  9078. t['Schwa'] = 0x018F;
  9079. t['Schwacyrillic'] = 0x04D8;
  9080. t['Schwadieresiscyrillic'] = 0x04DA;
  9081. t['Scircle'] = 0x24C8;
  9082. t['Scircumflex'] = 0x015C;
  9083. t['Scommaaccent'] = 0x0218;
  9084. t['Sdotaccent'] = 0x1E60;
  9085. t['Sdotbelow'] = 0x1E62;
  9086. t['Sdotbelowdotaccent'] = 0x1E68;
  9087. t['Seharmenian'] = 0x054D;
  9088. t['Sevenroman'] = 0x2166;
  9089. t['Shaarmenian'] = 0x0547;
  9090. t['Shacyrillic'] = 0x0428;
  9091. t['Shchacyrillic'] = 0x0429;
  9092. t['Sheicoptic'] = 0x03E2;
  9093. t['Shhacyrillic'] = 0x04BA;
  9094. t['Shimacoptic'] = 0x03EC;
  9095. t['Sigma'] = 0x03A3;
  9096. t['Sixroman'] = 0x2165;
  9097. t['Smonospace'] = 0xFF33;
  9098. t['Softsigncyrillic'] = 0x042C;
  9099. t['Ssmall'] = 0xF773;
  9100. t['Stigmagreek'] = 0x03DA;
  9101. t['T'] = 0x0054;
  9102. t['Tau'] = 0x03A4;
  9103. t['Tbar'] = 0x0166;
  9104. t['Tcaron'] = 0x0164;
  9105. t['Tcedilla'] = 0x0162;
  9106. t['Tcircle'] = 0x24C9;
  9107. t['Tcircumflexbelow'] = 0x1E70;
  9108. t['Tcommaaccent'] = 0x0162;
  9109. t['Tdotaccent'] = 0x1E6A;
  9110. t['Tdotbelow'] = 0x1E6C;
  9111. t['Tecyrillic'] = 0x0422;
  9112. t['Tedescendercyrillic'] = 0x04AC;
  9113. t['Tenroman'] = 0x2169;
  9114. t['Tetsecyrillic'] = 0x04B4;
  9115. t['Theta'] = 0x0398;
  9116. t['Thook'] = 0x01AC;
  9117. t['Thorn'] = 0x00DE;
  9118. t['Thornsmall'] = 0xF7FE;
  9119. t['Threeroman'] = 0x2162;
  9120. t['Tildesmall'] = 0xF6FE;
  9121. t['Tiwnarmenian'] = 0x054F;
  9122. t['Tlinebelow'] = 0x1E6E;
  9123. t['Tmonospace'] = 0xFF34;
  9124. t['Toarmenian'] = 0x0539;
  9125. t['Tonefive'] = 0x01BC;
  9126. t['Tonesix'] = 0x0184;
  9127. t['Tonetwo'] = 0x01A7;
  9128. t['Tretroflexhook'] = 0x01AE;
  9129. t['Tsecyrillic'] = 0x0426;
  9130. t['Tshecyrillic'] = 0x040B;
  9131. t['Tsmall'] = 0xF774;
  9132. t['Twelveroman'] = 0x216B;
  9133. t['Tworoman'] = 0x2161;
  9134. t['U'] = 0x0055;
  9135. t['Uacute'] = 0x00DA;
  9136. t['Uacutesmall'] = 0xF7FA;
  9137. t['Ubreve'] = 0x016C;
  9138. t['Ucaron'] = 0x01D3;
  9139. t['Ucircle'] = 0x24CA;
  9140. t['Ucircumflex'] = 0x00DB;
  9141. t['Ucircumflexbelow'] = 0x1E76;
  9142. t['Ucircumflexsmall'] = 0xF7FB;
  9143. t['Ucyrillic'] = 0x0423;
  9144. t['Udblacute'] = 0x0170;
  9145. t['Udblgrave'] = 0x0214;
  9146. t['Udieresis'] = 0x00DC;
  9147. t['Udieresisacute'] = 0x01D7;
  9148. t['Udieresisbelow'] = 0x1E72;
  9149. t['Udieresiscaron'] = 0x01D9;
  9150. t['Udieresiscyrillic'] = 0x04F0;
  9151. t['Udieresisgrave'] = 0x01DB;
  9152. t['Udieresismacron'] = 0x01D5;
  9153. t['Udieresissmall'] = 0xF7FC;
  9154. t['Udotbelow'] = 0x1EE4;
  9155. t['Ugrave'] = 0x00D9;
  9156. t['Ugravesmall'] = 0xF7F9;
  9157. t['Uhookabove'] = 0x1EE6;
  9158. t['Uhorn'] = 0x01AF;
  9159. t['Uhornacute'] = 0x1EE8;
  9160. t['Uhorndotbelow'] = 0x1EF0;
  9161. t['Uhorngrave'] = 0x1EEA;
  9162. t['Uhornhookabove'] = 0x1EEC;
  9163. t['Uhorntilde'] = 0x1EEE;
  9164. t['Uhungarumlaut'] = 0x0170;
  9165. t['Uhungarumlautcyrillic'] = 0x04F2;
  9166. t['Uinvertedbreve'] = 0x0216;
  9167. t['Ukcyrillic'] = 0x0478;
  9168. t['Umacron'] = 0x016A;
  9169. t['Umacroncyrillic'] = 0x04EE;
  9170. t['Umacrondieresis'] = 0x1E7A;
  9171. t['Umonospace'] = 0xFF35;
  9172. t['Uogonek'] = 0x0172;
  9173. t['Upsilon'] = 0x03A5;
  9174. t['Upsilon1'] = 0x03D2;
  9175. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9176. t['Upsilonafrican'] = 0x01B1;
  9177. t['Upsilondieresis'] = 0x03AB;
  9178. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9179. t['Upsilonhooksymbol'] = 0x03D2;
  9180. t['Upsilontonos'] = 0x038E;
  9181. t['Uring'] = 0x016E;
  9182. t['Ushortcyrillic'] = 0x040E;
  9183. t['Usmall'] = 0xF775;
  9184. t['Ustraightcyrillic'] = 0x04AE;
  9185. t['Ustraightstrokecyrillic'] = 0x04B0;
  9186. t['Utilde'] = 0x0168;
  9187. t['Utildeacute'] = 0x1E78;
  9188. t['Utildebelow'] = 0x1E74;
  9189. t['V'] = 0x0056;
  9190. t['Vcircle'] = 0x24CB;
  9191. t['Vdotbelow'] = 0x1E7E;
  9192. t['Vecyrillic'] = 0x0412;
  9193. t['Vewarmenian'] = 0x054E;
  9194. t['Vhook'] = 0x01B2;
  9195. t['Vmonospace'] = 0xFF36;
  9196. t['Voarmenian'] = 0x0548;
  9197. t['Vsmall'] = 0xF776;
  9198. t['Vtilde'] = 0x1E7C;
  9199. t['W'] = 0x0057;
  9200. t['Wacute'] = 0x1E82;
  9201. t['Wcircle'] = 0x24CC;
  9202. t['Wcircumflex'] = 0x0174;
  9203. t['Wdieresis'] = 0x1E84;
  9204. t['Wdotaccent'] = 0x1E86;
  9205. t['Wdotbelow'] = 0x1E88;
  9206. t['Wgrave'] = 0x1E80;
  9207. t['Wmonospace'] = 0xFF37;
  9208. t['Wsmall'] = 0xF777;
  9209. t['X'] = 0x0058;
  9210. t['Xcircle'] = 0x24CD;
  9211. t['Xdieresis'] = 0x1E8C;
  9212. t['Xdotaccent'] = 0x1E8A;
  9213. t['Xeharmenian'] = 0x053D;
  9214. t['Xi'] = 0x039E;
  9215. t['Xmonospace'] = 0xFF38;
  9216. t['Xsmall'] = 0xF778;
  9217. t['Y'] = 0x0059;
  9218. t['Yacute'] = 0x00DD;
  9219. t['Yacutesmall'] = 0xF7FD;
  9220. t['Yatcyrillic'] = 0x0462;
  9221. t['Ycircle'] = 0x24CE;
  9222. t['Ycircumflex'] = 0x0176;
  9223. t['Ydieresis'] = 0x0178;
  9224. t['Ydieresissmall'] = 0xF7FF;
  9225. t['Ydotaccent'] = 0x1E8E;
  9226. t['Ydotbelow'] = 0x1EF4;
  9227. t['Yericyrillic'] = 0x042B;
  9228. t['Yerudieresiscyrillic'] = 0x04F8;
  9229. t['Ygrave'] = 0x1EF2;
  9230. t['Yhook'] = 0x01B3;
  9231. t['Yhookabove'] = 0x1EF6;
  9232. t['Yiarmenian'] = 0x0545;
  9233. t['Yicyrillic'] = 0x0407;
  9234. t['Yiwnarmenian'] = 0x0552;
  9235. t['Ymonospace'] = 0xFF39;
  9236. t['Ysmall'] = 0xF779;
  9237. t['Ytilde'] = 0x1EF8;
  9238. t['Yusbigcyrillic'] = 0x046A;
  9239. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9240. t['Yuslittlecyrillic'] = 0x0466;
  9241. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9242. t['Z'] = 0x005A;
  9243. t['Zaarmenian'] = 0x0536;
  9244. t['Zacute'] = 0x0179;
  9245. t['Zcaron'] = 0x017D;
  9246. t['Zcaronsmall'] = 0xF6FF;
  9247. t['Zcircle'] = 0x24CF;
  9248. t['Zcircumflex'] = 0x1E90;
  9249. t['Zdot'] = 0x017B;
  9250. t['Zdotaccent'] = 0x017B;
  9251. t['Zdotbelow'] = 0x1E92;
  9252. t['Zecyrillic'] = 0x0417;
  9253. t['Zedescendercyrillic'] = 0x0498;
  9254. t['Zedieresiscyrillic'] = 0x04DE;
  9255. t['Zeta'] = 0x0396;
  9256. t['Zhearmenian'] = 0x053A;
  9257. t['Zhebrevecyrillic'] = 0x04C1;
  9258. t['Zhecyrillic'] = 0x0416;
  9259. t['Zhedescendercyrillic'] = 0x0496;
  9260. t['Zhedieresiscyrillic'] = 0x04DC;
  9261. t['Zlinebelow'] = 0x1E94;
  9262. t['Zmonospace'] = 0xFF3A;
  9263. t['Zsmall'] = 0xF77A;
  9264. t['Zstroke'] = 0x01B5;
  9265. t['a'] = 0x0061;
  9266. t['aabengali'] = 0x0986;
  9267. t['aacute'] = 0x00E1;
  9268. t['aadeva'] = 0x0906;
  9269. t['aagujarati'] = 0x0A86;
  9270. t['aagurmukhi'] = 0x0A06;
  9271. t['aamatragurmukhi'] = 0x0A3E;
  9272. t['aarusquare'] = 0x3303;
  9273. t['aavowelsignbengali'] = 0x09BE;
  9274. t['aavowelsigndeva'] = 0x093E;
  9275. t['aavowelsigngujarati'] = 0x0ABE;
  9276. t['abbreviationmarkarmenian'] = 0x055F;
  9277. t['abbreviationsigndeva'] = 0x0970;
  9278. t['abengali'] = 0x0985;
  9279. t['abopomofo'] = 0x311A;
  9280. t['abreve'] = 0x0103;
  9281. t['abreveacute'] = 0x1EAF;
  9282. t['abrevecyrillic'] = 0x04D1;
  9283. t['abrevedotbelow'] = 0x1EB7;
  9284. t['abrevegrave'] = 0x1EB1;
  9285. t['abrevehookabove'] = 0x1EB3;
  9286. t['abrevetilde'] = 0x1EB5;
  9287. t['acaron'] = 0x01CE;
  9288. t['acircle'] = 0x24D0;
  9289. t['acircumflex'] = 0x00E2;
  9290. t['acircumflexacute'] = 0x1EA5;
  9291. t['acircumflexdotbelow'] = 0x1EAD;
  9292. t['acircumflexgrave'] = 0x1EA7;
  9293. t['acircumflexhookabove'] = 0x1EA9;
  9294. t['acircumflextilde'] = 0x1EAB;
  9295. t['acute'] = 0x00B4;
  9296. t['acutebelowcmb'] = 0x0317;
  9297. t['acutecmb'] = 0x0301;
  9298. t['acutecomb'] = 0x0301;
  9299. t['acutedeva'] = 0x0954;
  9300. t['acutelowmod'] = 0x02CF;
  9301. t['acutetonecmb'] = 0x0341;
  9302. t['acyrillic'] = 0x0430;
  9303. t['adblgrave'] = 0x0201;
  9304. t['addakgurmukhi'] = 0x0A71;
  9305. t['adeva'] = 0x0905;
  9306. t['adieresis'] = 0x00E4;
  9307. t['adieresiscyrillic'] = 0x04D3;
  9308. t['adieresismacron'] = 0x01DF;
  9309. t['adotbelow'] = 0x1EA1;
  9310. t['adotmacron'] = 0x01E1;
  9311. t['ae'] = 0x00E6;
  9312. t['aeacute'] = 0x01FD;
  9313. t['aekorean'] = 0x3150;
  9314. t['aemacron'] = 0x01E3;
  9315. t['afii00208'] = 0x2015;
  9316. t['afii08941'] = 0x20A4;
  9317. t['afii10017'] = 0x0410;
  9318. t['afii10018'] = 0x0411;
  9319. t['afii10019'] = 0x0412;
  9320. t['afii10020'] = 0x0413;
  9321. t['afii10021'] = 0x0414;
  9322. t['afii10022'] = 0x0415;
  9323. t['afii10023'] = 0x0401;
  9324. t['afii10024'] = 0x0416;
  9325. t['afii10025'] = 0x0417;
  9326. t['afii10026'] = 0x0418;
  9327. t['afii10027'] = 0x0419;
  9328. t['afii10028'] = 0x041A;
  9329. t['afii10029'] = 0x041B;
  9330. t['afii10030'] = 0x041C;
  9331. t['afii10031'] = 0x041D;
  9332. t['afii10032'] = 0x041E;
  9333. t['afii10033'] = 0x041F;
  9334. t['afii10034'] = 0x0420;
  9335. t['afii10035'] = 0x0421;
  9336. t['afii10036'] = 0x0422;
  9337. t['afii10037'] = 0x0423;
  9338. t['afii10038'] = 0x0424;
  9339. t['afii10039'] = 0x0425;
  9340. t['afii10040'] = 0x0426;
  9341. t['afii10041'] = 0x0427;
  9342. t['afii10042'] = 0x0428;
  9343. t['afii10043'] = 0x0429;
  9344. t['afii10044'] = 0x042A;
  9345. t['afii10045'] = 0x042B;
  9346. t['afii10046'] = 0x042C;
  9347. t['afii10047'] = 0x042D;
  9348. t['afii10048'] = 0x042E;
  9349. t['afii10049'] = 0x042F;
  9350. t['afii10050'] = 0x0490;
  9351. t['afii10051'] = 0x0402;
  9352. t['afii10052'] = 0x0403;
  9353. t['afii10053'] = 0x0404;
  9354. t['afii10054'] = 0x0405;
  9355. t['afii10055'] = 0x0406;
  9356. t['afii10056'] = 0x0407;
  9357. t['afii10057'] = 0x0408;
  9358. t['afii10058'] = 0x0409;
  9359. t['afii10059'] = 0x040A;
  9360. t['afii10060'] = 0x040B;
  9361. t['afii10061'] = 0x040C;
  9362. t['afii10062'] = 0x040E;
  9363. t['afii10063'] = 0xF6C4;
  9364. t['afii10064'] = 0xF6C5;
  9365. t['afii10065'] = 0x0430;
  9366. t['afii10066'] = 0x0431;
  9367. t['afii10067'] = 0x0432;
  9368. t['afii10068'] = 0x0433;
  9369. t['afii10069'] = 0x0434;
  9370. t['afii10070'] = 0x0435;
  9371. t['afii10071'] = 0x0451;
  9372. t['afii10072'] = 0x0436;
  9373. t['afii10073'] = 0x0437;
  9374. t['afii10074'] = 0x0438;
  9375. t['afii10075'] = 0x0439;
  9376. t['afii10076'] = 0x043A;
  9377. t['afii10077'] = 0x043B;
  9378. t['afii10078'] = 0x043C;
  9379. t['afii10079'] = 0x043D;
  9380. t['afii10080'] = 0x043E;
  9381. t['afii10081'] = 0x043F;
  9382. t['afii10082'] = 0x0440;
  9383. t['afii10083'] = 0x0441;
  9384. t['afii10084'] = 0x0442;
  9385. t['afii10085'] = 0x0443;
  9386. t['afii10086'] = 0x0444;
  9387. t['afii10087'] = 0x0445;
  9388. t['afii10088'] = 0x0446;
  9389. t['afii10089'] = 0x0447;
  9390. t['afii10090'] = 0x0448;
  9391. t['afii10091'] = 0x0449;
  9392. t['afii10092'] = 0x044A;
  9393. t['afii10093'] = 0x044B;
  9394. t['afii10094'] = 0x044C;
  9395. t['afii10095'] = 0x044D;
  9396. t['afii10096'] = 0x044E;
  9397. t['afii10097'] = 0x044F;
  9398. t['afii10098'] = 0x0491;
  9399. t['afii10099'] = 0x0452;
  9400. t['afii10100'] = 0x0453;
  9401. t['afii10101'] = 0x0454;
  9402. t['afii10102'] = 0x0455;
  9403. t['afii10103'] = 0x0456;
  9404. t['afii10104'] = 0x0457;
  9405. t['afii10105'] = 0x0458;
  9406. t['afii10106'] = 0x0459;
  9407. t['afii10107'] = 0x045A;
  9408. t['afii10108'] = 0x045B;
  9409. t['afii10109'] = 0x045C;
  9410. t['afii10110'] = 0x045E;
  9411. t['afii10145'] = 0x040F;
  9412. t['afii10146'] = 0x0462;
  9413. t['afii10147'] = 0x0472;
  9414. t['afii10148'] = 0x0474;
  9415. t['afii10192'] = 0xF6C6;
  9416. t['afii10193'] = 0x045F;
  9417. t['afii10194'] = 0x0463;
  9418. t['afii10195'] = 0x0473;
  9419. t['afii10196'] = 0x0475;
  9420. t['afii10831'] = 0xF6C7;
  9421. t['afii10832'] = 0xF6C8;
  9422. t['afii10846'] = 0x04D9;
  9423. t['afii299'] = 0x200E;
  9424. t['afii300'] = 0x200F;
  9425. t['afii301'] = 0x200D;
  9426. t['afii57381'] = 0x066A;
  9427. t['afii57388'] = 0x060C;
  9428. t['afii57392'] = 0x0660;
  9429. t['afii57393'] = 0x0661;
  9430. t['afii57394'] = 0x0662;
  9431. t['afii57395'] = 0x0663;
  9432. t['afii57396'] = 0x0664;
  9433. t['afii57397'] = 0x0665;
  9434. t['afii57398'] = 0x0666;
  9435. t['afii57399'] = 0x0667;
  9436. t['afii57400'] = 0x0668;
  9437. t['afii57401'] = 0x0669;
  9438. t['afii57403'] = 0x061B;
  9439. t['afii57407'] = 0x061F;
  9440. t['afii57409'] = 0x0621;
  9441. t['afii57410'] = 0x0622;
  9442. t['afii57411'] = 0x0623;
  9443. t['afii57412'] = 0x0624;
  9444. t['afii57413'] = 0x0625;
  9445. t['afii57414'] = 0x0626;
  9446. t['afii57415'] = 0x0627;
  9447. t['afii57416'] = 0x0628;
  9448. t['afii57417'] = 0x0629;
  9449. t['afii57418'] = 0x062A;
  9450. t['afii57419'] = 0x062B;
  9451. t['afii57420'] = 0x062C;
  9452. t['afii57421'] = 0x062D;
  9453. t['afii57422'] = 0x062E;
  9454. t['afii57423'] = 0x062F;
  9455. t['afii57424'] = 0x0630;
  9456. t['afii57425'] = 0x0631;
  9457. t['afii57426'] = 0x0632;
  9458. t['afii57427'] = 0x0633;
  9459. t['afii57428'] = 0x0634;
  9460. t['afii57429'] = 0x0635;
  9461. t['afii57430'] = 0x0636;
  9462. t['afii57431'] = 0x0637;
  9463. t['afii57432'] = 0x0638;
  9464. t['afii57433'] = 0x0639;
  9465. t['afii57434'] = 0x063A;
  9466. t['afii57440'] = 0x0640;
  9467. t['afii57441'] = 0x0641;
  9468. t['afii57442'] = 0x0642;
  9469. t['afii57443'] = 0x0643;
  9470. t['afii57444'] = 0x0644;
  9471. t['afii57445'] = 0x0645;
  9472. t['afii57446'] = 0x0646;
  9473. t['afii57448'] = 0x0648;
  9474. t['afii57449'] = 0x0649;
  9475. t['afii57450'] = 0x064A;
  9476. t['afii57451'] = 0x064B;
  9477. t['afii57452'] = 0x064C;
  9478. t['afii57453'] = 0x064D;
  9479. t['afii57454'] = 0x064E;
  9480. t['afii57455'] = 0x064F;
  9481. t['afii57456'] = 0x0650;
  9482. t['afii57457'] = 0x0651;
  9483. t['afii57458'] = 0x0652;
  9484. t['afii57470'] = 0x0647;
  9485. t['afii57505'] = 0x06A4;
  9486. t['afii57506'] = 0x067E;
  9487. t['afii57507'] = 0x0686;
  9488. t['afii57508'] = 0x0698;
  9489. t['afii57509'] = 0x06AF;
  9490. t['afii57511'] = 0x0679;
  9491. t['afii57512'] = 0x0688;
  9492. t['afii57513'] = 0x0691;
  9493. t['afii57514'] = 0x06BA;
  9494. t['afii57519'] = 0x06D2;
  9495. t['afii57534'] = 0x06D5;
  9496. t['afii57636'] = 0x20AA;
  9497. t['afii57645'] = 0x05BE;
  9498. t['afii57658'] = 0x05C3;
  9499. t['afii57664'] = 0x05D0;
  9500. t['afii57665'] = 0x05D1;
  9501. t['afii57666'] = 0x05D2;
  9502. t['afii57667'] = 0x05D3;
  9503. t['afii57668'] = 0x05D4;
  9504. t['afii57669'] = 0x05D5;
  9505. t['afii57670'] = 0x05D6;
  9506. t['afii57671'] = 0x05D7;
  9507. t['afii57672'] = 0x05D8;
  9508. t['afii57673'] = 0x05D9;
  9509. t['afii57674'] = 0x05DA;
  9510. t['afii57675'] = 0x05DB;
  9511. t['afii57676'] = 0x05DC;
  9512. t['afii57677'] = 0x05DD;
  9513. t['afii57678'] = 0x05DE;
  9514. t['afii57679'] = 0x05DF;
  9515. t['afii57680'] = 0x05E0;
  9516. t['afii57681'] = 0x05E1;
  9517. t['afii57682'] = 0x05E2;
  9518. t['afii57683'] = 0x05E3;
  9519. t['afii57684'] = 0x05E4;
  9520. t['afii57685'] = 0x05E5;
  9521. t['afii57686'] = 0x05E6;
  9522. t['afii57687'] = 0x05E7;
  9523. t['afii57688'] = 0x05E8;
  9524. t['afii57689'] = 0x05E9;
  9525. t['afii57690'] = 0x05EA;
  9526. t['afii57694'] = 0xFB2A;
  9527. t['afii57695'] = 0xFB2B;
  9528. t['afii57700'] = 0xFB4B;
  9529. t['afii57705'] = 0xFB1F;
  9530. t['afii57716'] = 0x05F0;
  9531. t['afii57717'] = 0x05F1;
  9532. t['afii57718'] = 0x05F2;
  9533. t['afii57723'] = 0xFB35;
  9534. t['afii57793'] = 0x05B4;
  9535. t['afii57794'] = 0x05B5;
  9536. t['afii57795'] = 0x05B6;
  9537. t['afii57796'] = 0x05BB;
  9538. t['afii57797'] = 0x05B8;
  9539. t['afii57798'] = 0x05B7;
  9540. t['afii57799'] = 0x05B0;
  9541. t['afii57800'] = 0x05B2;
  9542. t['afii57801'] = 0x05B1;
  9543. t['afii57802'] = 0x05B3;
  9544. t['afii57803'] = 0x05C2;
  9545. t['afii57804'] = 0x05C1;
  9546. t['afii57806'] = 0x05B9;
  9547. t['afii57807'] = 0x05BC;
  9548. t['afii57839'] = 0x05BD;
  9549. t['afii57841'] = 0x05BF;
  9550. t['afii57842'] = 0x05C0;
  9551. t['afii57929'] = 0x02BC;
  9552. t['afii61248'] = 0x2105;
  9553. t['afii61289'] = 0x2113;
  9554. t['afii61352'] = 0x2116;
  9555. t['afii61573'] = 0x202C;
  9556. t['afii61574'] = 0x202D;
  9557. t['afii61575'] = 0x202E;
  9558. t['afii61664'] = 0x200C;
  9559. t['afii63167'] = 0x066D;
  9560. t['afii64937'] = 0x02BD;
  9561. t['agrave'] = 0x00E0;
  9562. t['agujarati'] = 0x0A85;
  9563. t['agurmukhi'] = 0x0A05;
  9564. t['ahiragana'] = 0x3042;
  9565. t['ahookabove'] = 0x1EA3;
  9566. t['aibengali'] = 0x0990;
  9567. t['aibopomofo'] = 0x311E;
  9568. t['aideva'] = 0x0910;
  9569. t['aiecyrillic'] = 0x04D5;
  9570. t['aigujarati'] = 0x0A90;
  9571. t['aigurmukhi'] = 0x0A10;
  9572. t['aimatragurmukhi'] = 0x0A48;
  9573. t['ainarabic'] = 0x0639;
  9574. t['ainfinalarabic'] = 0xFECA;
  9575. t['aininitialarabic'] = 0xFECB;
  9576. t['ainmedialarabic'] = 0xFECC;
  9577. t['ainvertedbreve'] = 0x0203;
  9578. t['aivowelsignbengali'] = 0x09C8;
  9579. t['aivowelsigndeva'] = 0x0948;
  9580. t['aivowelsigngujarati'] = 0x0AC8;
  9581. t['akatakana'] = 0x30A2;
  9582. t['akatakanahalfwidth'] = 0xFF71;
  9583. t['akorean'] = 0x314F;
  9584. t['alef'] = 0x05D0;
  9585. t['alefarabic'] = 0x0627;
  9586. t['alefdageshhebrew'] = 0xFB30;
  9587. t['aleffinalarabic'] = 0xFE8E;
  9588. t['alefhamzaabovearabic'] = 0x0623;
  9589. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9590. t['alefhamzabelowarabic'] = 0x0625;
  9591. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9592. t['alefhebrew'] = 0x05D0;
  9593. t['aleflamedhebrew'] = 0xFB4F;
  9594. t['alefmaddaabovearabic'] = 0x0622;
  9595. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9596. t['alefmaksuraarabic'] = 0x0649;
  9597. t['alefmaksurafinalarabic'] = 0xFEF0;
  9598. t['alefmaksurainitialarabic'] = 0xFEF3;
  9599. t['alefmaksuramedialarabic'] = 0xFEF4;
  9600. t['alefpatahhebrew'] = 0xFB2E;
  9601. t['alefqamatshebrew'] = 0xFB2F;
  9602. t['aleph'] = 0x2135;
  9603. t['allequal'] = 0x224C;
  9604. t['alpha'] = 0x03B1;
  9605. t['alphatonos'] = 0x03AC;
  9606. t['amacron'] = 0x0101;
  9607. t['amonospace'] = 0xFF41;
  9608. t['ampersand'] = 0x0026;
  9609. t['ampersandmonospace'] = 0xFF06;
  9610. t['ampersandsmall'] = 0xF726;
  9611. t['amsquare'] = 0x33C2;
  9612. t['anbopomofo'] = 0x3122;
  9613. t['angbopomofo'] = 0x3124;
  9614. t['angbracketleft'] = 0x3008;
  9615. t['angbracketright'] = 0x3009;
  9616. t['angkhankhuthai'] = 0x0E5A;
  9617. t['angle'] = 0x2220;
  9618. t['anglebracketleft'] = 0x3008;
  9619. t['anglebracketleftvertical'] = 0xFE3F;
  9620. t['anglebracketright'] = 0x3009;
  9621. t['anglebracketrightvertical'] = 0xFE40;
  9622. t['angleleft'] = 0x2329;
  9623. t['angleright'] = 0x232A;
  9624. t['angstrom'] = 0x212B;
  9625. t['anoteleia'] = 0x0387;
  9626. t['anudattadeva'] = 0x0952;
  9627. t['anusvarabengali'] = 0x0982;
  9628. t['anusvaradeva'] = 0x0902;
  9629. t['anusvaragujarati'] = 0x0A82;
  9630. t['aogonek'] = 0x0105;
  9631. t['apaatosquare'] = 0x3300;
  9632. t['aparen'] = 0x249C;
  9633. t['apostrophearmenian'] = 0x055A;
  9634. t['apostrophemod'] = 0x02BC;
  9635. t['apple'] = 0xF8FF;
  9636. t['approaches'] = 0x2250;
  9637. t['approxequal'] = 0x2248;
  9638. t['approxequalorimage'] = 0x2252;
  9639. t['approximatelyequal'] = 0x2245;
  9640. t['araeaekorean'] = 0x318E;
  9641. t['araeakorean'] = 0x318D;
  9642. t['arc'] = 0x2312;
  9643. t['arighthalfring'] = 0x1E9A;
  9644. t['aring'] = 0x00E5;
  9645. t['aringacute'] = 0x01FB;
  9646. t['aringbelow'] = 0x1E01;
  9647. t['arrowboth'] = 0x2194;
  9648. t['arrowdashdown'] = 0x21E3;
  9649. t['arrowdashleft'] = 0x21E0;
  9650. t['arrowdashright'] = 0x21E2;
  9651. t['arrowdashup'] = 0x21E1;
  9652. t['arrowdblboth'] = 0x21D4;
  9653. t['arrowdbldown'] = 0x21D3;
  9654. t['arrowdblleft'] = 0x21D0;
  9655. t['arrowdblright'] = 0x21D2;
  9656. t['arrowdblup'] = 0x21D1;
  9657. t['arrowdown'] = 0x2193;
  9658. t['arrowdownleft'] = 0x2199;
  9659. t['arrowdownright'] = 0x2198;
  9660. t['arrowdownwhite'] = 0x21E9;
  9661. t['arrowheaddownmod'] = 0x02C5;
  9662. t['arrowheadleftmod'] = 0x02C2;
  9663. t['arrowheadrightmod'] = 0x02C3;
  9664. t['arrowheadupmod'] = 0x02C4;
  9665. t['arrowhorizex'] = 0xF8E7;
  9666. t['arrowleft'] = 0x2190;
  9667. t['arrowleftdbl'] = 0x21D0;
  9668. t['arrowleftdblstroke'] = 0x21CD;
  9669. t['arrowleftoverright'] = 0x21C6;
  9670. t['arrowleftwhite'] = 0x21E6;
  9671. t['arrowright'] = 0x2192;
  9672. t['arrowrightdblstroke'] = 0x21CF;
  9673. t['arrowrightheavy'] = 0x279E;
  9674. t['arrowrightoverleft'] = 0x21C4;
  9675. t['arrowrightwhite'] = 0x21E8;
  9676. t['arrowtableft'] = 0x21E4;
  9677. t['arrowtabright'] = 0x21E5;
  9678. t['arrowup'] = 0x2191;
  9679. t['arrowupdn'] = 0x2195;
  9680. t['arrowupdnbse'] = 0x21A8;
  9681. t['arrowupdownbase'] = 0x21A8;
  9682. t['arrowupleft'] = 0x2196;
  9683. t['arrowupleftofdown'] = 0x21C5;
  9684. t['arrowupright'] = 0x2197;
  9685. t['arrowupwhite'] = 0x21E7;
  9686. t['arrowvertex'] = 0xF8E6;
  9687. t['asciicircum'] = 0x005E;
  9688. t['asciicircummonospace'] = 0xFF3E;
  9689. t['asciitilde'] = 0x007E;
  9690. t['asciitildemonospace'] = 0xFF5E;
  9691. t['ascript'] = 0x0251;
  9692. t['ascriptturned'] = 0x0252;
  9693. t['asmallhiragana'] = 0x3041;
  9694. t['asmallkatakana'] = 0x30A1;
  9695. t['asmallkatakanahalfwidth'] = 0xFF67;
  9696. t['asterisk'] = 0x002A;
  9697. t['asteriskaltonearabic'] = 0x066D;
  9698. t['asteriskarabic'] = 0x066D;
  9699. t['asteriskmath'] = 0x2217;
  9700. t['asteriskmonospace'] = 0xFF0A;
  9701. t['asterisksmall'] = 0xFE61;
  9702. t['asterism'] = 0x2042;
  9703. t['asuperior'] = 0xF6E9;
  9704. t['asymptoticallyequal'] = 0x2243;
  9705. t['at'] = 0x0040;
  9706. t['atilde'] = 0x00E3;
  9707. t['atmonospace'] = 0xFF20;
  9708. t['atsmall'] = 0xFE6B;
  9709. t['aturned'] = 0x0250;
  9710. t['aubengali'] = 0x0994;
  9711. t['aubopomofo'] = 0x3120;
  9712. t['audeva'] = 0x0914;
  9713. t['augujarati'] = 0x0A94;
  9714. t['augurmukhi'] = 0x0A14;
  9715. t['aulengthmarkbengali'] = 0x09D7;
  9716. t['aumatragurmukhi'] = 0x0A4C;
  9717. t['auvowelsignbengali'] = 0x09CC;
  9718. t['auvowelsigndeva'] = 0x094C;
  9719. t['auvowelsigngujarati'] = 0x0ACC;
  9720. t['avagrahadeva'] = 0x093D;
  9721. t['aybarmenian'] = 0x0561;
  9722. t['ayin'] = 0x05E2;
  9723. t['ayinaltonehebrew'] = 0xFB20;
  9724. t['ayinhebrew'] = 0x05E2;
  9725. t['b'] = 0x0062;
  9726. t['babengali'] = 0x09AC;
  9727. t['backslash'] = 0x005C;
  9728. t['backslashmonospace'] = 0xFF3C;
  9729. t['badeva'] = 0x092C;
  9730. t['bagujarati'] = 0x0AAC;
  9731. t['bagurmukhi'] = 0x0A2C;
  9732. t['bahiragana'] = 0x3070;
  9733. t['bahtthai'] = 0x0E3F;
  9734. t['bakatakana'] = 0x30D0;
  9735. t['bar'] = 0x007C;
  9736. t['barmonospace'] = 0xFF5C;
  9737. t['bbopomofo'] = 0x3105;
  9738. t['bcircle'] = 0x24D1;
  9739. t['bdotaccent'] = 0x1E03;
  9740. t['bdotbelow'] = 0x1E05;
  9741. t['beamedsixteenthnotes'] = 0x266C;
  9742. t['because'] = 0x2235;
  9743. t['becyrillic'] = 0x0431;
  9744. t['beharabic'] = 0x0628;
  9745. t['behfinalarabic'] = 0xFE90;
  9746. t['behinitialarabic'] = 0xFE91;
  9747. t['behiragana'] = 0x3079;
  9748. t['behmedialarabic'] = 0xFE92;
  9749. t['behmeeminitialarabic'] = 0xFC9F;
  9750. t['behmeemisolatedarabic'] = 0xFC08;
  9751. t['behnoonfinalarabic'] = 0xFC6D;
  9752. t['bekatakana'] = 0x30D9;
  9753. t['benarmenian'] = 0x0562;
  9754. t['bet'] = 0x05D1;
  9755. t['beta'] = 0x03B2;
  9756. t['betasymbolgreek'] = 0x03D0;
  9757. t['betdagesh'] = 0xFB31;
  9758. t['betdageshhebrew'] = 0xFB31;
  9759. t['bethebrew'] = 0x05D1;
  9760. t['betrafehebrew'] = 0xFB4C;
  9761. t['bhabengali'] = 0x09AD;
  9762. t['bhadeva'] = 0x092D;
  9763. t['bhagujarati'] = 0x0AAD;
  9764. t['bhagurmukhi'] = 0x0A2D;
  9765. t['bhook'] = 0x0253;
  9766. t['bihiragana'] = 0x3073;
  9767. t['bikatakana'] = 0x30D3;
  9768. t['bilabialclick'] = 0x0298;
  9769. t['bindigurmukhi'] = 0x0A02;
  9770. t['birusquare'] = 0x3331;
  9771. t['blackcircle'] = 0x25CF;
  9772. t['blackdiamond'] = 0x25C6;
  9773. t['blackdownpointingtriangle'] = 0x25BC;
  9774. t['blackleftpointingpointer'] = 0x25C4;
  9775. t['blackleftpointingtriangle'] = 0x25C0;
  9776. t['blacklenticularbracketleft'] = 0x3010;
  9777. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9778. t['blacklenticularbracketright'] = 0x3011;
  9779. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9780. t['blacklowerlefttriangle'] = 0x25E3;
  9781. t['blacklowerrighttriangle'] = 0x25E2;
  9782. t['blackrectangle'] = 0x25AC;
  9783. t['blackrightpointingpointer'] = 0x25BA;
  9784. t['blackrightpointingtriangle'] = 0x25B6;
  9785. t['blacksmallsquare'] = 0x25AA;
  9786. t['blacksmilingface'] = 0x263B;
  9787. t['blacksquare'] = 0x25A0;
  9788. t['blackstar'] = 0x2605;
  9789. t['blackupperlefttriangle'] = 0x25E4;
  9790. t['blackupperrighttriangle'] = 0x25E5;
  9791. t['blackuppointingsmalltriangle'] = 0x25B4;
  9792. t['blackuppointingtriangle'] = 0x25B2;
  9793. t['blank'] = 0x2423;
  9794. t['blinebelow'] = 0x1E07;
  9795. t['block'] = 0x2588;
  9796. t['bmonospace'] = 0xFF42;
  9797. t['bobaimaithai'] = 0x0E1A;
  9798. t['bohiragana'] = 0x307C;
  9799. t['bokatakana'] = 0x30DC;
  9800. t['bparen'] = 0x249D;
  9801. t['bqsquare'] = 0x33C3;
  9802. t['braceex'] = 0xF8F4;
  9803. t['braceleft'] = 0x007B;
  9804. t['braceleftbt'] = 0xF8F3;
  9805. t['braceleftmid'] = 0xF8F2;
  9806. t['braceleftmonospace'] = 0xFF5B;
  9807. t['braceleftsmall'] = 0xFE5B;
  9808. t['bracelefttp'] = 0xF8F1;
  9809. t['braceleftvertical'] = 0xFE37;
  9810. t['braceright'] = 0x007D;
  9811. t['bracerightbt'] = 0xF8FE;
  9812. t['bracerightmid'] = 0xF8FD;
  9813. t['bracerightmonospace'] = 0xFF5D;
  9814. t['bracerightsmall'] = 0xFE5C;
  9815. t['bracerighttp'] = 0xF8FC;
  9816. t['bracerightvertical'] = 0xFE38;
  9817. t['bracketleft'] = 0x005B;
  9818. t['bracketleftbt'] = 0xF8F0;
  9819. t['bracketleftex'] = 0xF8EF;
  9820. t['bracketleftmonospace'] = 0xFF3B;
  9821. t['bracketlefttp'] = 0xF8EE;
  9822. t['bracketright'] = 0x005D;
  9823. t['bracketrightbt'] = 0xF8FB;
  9824. t['bracketrightex'] = 0xF8FA;
  9825. t['bracketrightmonospace'] = 0xFF3D;
  9826. t['bracketrighttp'] = 0xF8F9;
  9827. t['breve'] = 0x02D8;
  9828. t['brevebelowcmb'] = 0x032E;
  9829. t['brevecmb'] = 0x0306;
  9830. t['breveinvertedbelowcmb'] = 0x032F;
  9831. t['breveinvertedcmb'] = 0x0311;
  9832. t['breveinverteddoublecmb'] = 0x0361;
  9833. t['bridgebelowcmb'] = 0x032A;
  9834. t['bridgeinvertedbelowcmb'] = 0x033A;
  9835. t['brokenbar'] = 0x00A6;
  9836. t['bstroke'] = 0x0180;
  9837. t['bsuperior'] = 0xF6EA;
  9838. t['btopbar'] = 0x0183;
  9839. t['buhiragana'] = 0x3076;
  9840. t['bukatakana'] = 0x30D6;
  9841. t['bullet'] = 0x2022;
  9842. t['bulletinverse'] = 0x25D8;
  9843. t['bulletoperator'] = 0x2219;
  9844. t['bullseye'] = 0x25CE;
  9845. t['c'] = 0x0063;
  9846. t['caarmenian'] = 0x056E;
  9847. t['cabengali'] = 0x099A;
  9848. t['cacute'] = 0x0107;
  9849. t['cadeva'] = 0x091A;
  9850. t['cagujarati'] = 0x0A9A;
  9851. t['cagurmukhi'] = 0x0A1A;
  9852. t['calsquare'] = 0x3388;
  9853. t['candrabindubengali'] = 0x0981;
  9854. t['candrabinducmb'] = 0x0310;
  9855. t['candrabindudeva'] = 0x0901;
  9856. t['candrabindugujarati'] = 0x0A81;
  9857. t['capslock'] = 0x21EA;
  9858. t['careof'] = 0x2105;
  9859. t['caron'] = 0x02C7;
  9860. t['caronbelowcmb'] = 0x032C;
  9861. t['caroncmb'] = 0x030C;
  9862. t['carriagereturn'] = 0x21B5;
  9863. t['cbopomofo'] = 0x3118;
  9864. t['ccaron'] = 0x010D;
  9865. t['ccedilla'] = 0x00E7;
  9866. t['ccedillaacute'] = 0x1E09;
  9867. t['ccircle'] = 0x24D2;
  9868. t['ccircumflex'] = 0x0109;
  9869. t['ccurl'] = 0x0255;
  9870. t['cdot'] = 0x010B;
  9871. t['cdotaccent'] = 0x010B;
  9872. t['cdsquare'] = 0x33C5;
  9873. t['cedilla'] = 0x00B8;
  9874. t['cedillacmb'] = 0x0327;
  9875. t['cent'] = 0x00A2;
  9876. t['centigrade'] = 0x2103;
  9877. t['centinferior'] = 0xF6DF;
  9878. t['centmonospace'] = 0xFFE0;
  9879. t['centoldstyle'] = 0xF7A2;
  9880. t['centsuperior'] = 0xF6E0;
  9881. t['chaarmenian'] = 0x0579;
  9882. t['chabengali'] = 0x099B;
  9883. t['chadeva'] = 0x091B;
  9884. t['chagujarati'] = 0x0A9B;
  9885. t['chagurmukhi'] = 0x0A1B;
  9886. t['chbopomofo'] = 0x3114;
  9887. t['cheabkhasiancyrillic'] = 0x04BD;
  9888. t['checkmark'] = 0x2713;
  9889. t['checyrillic'] = 0x0447;
  9890. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9891. t['chedescendercyrillic'] = 0x04B7;
  9892. t['chedieresiscyrillic'] = 0x04F5;
  9893. t['cheharmenian'] = 0x0573;
  9894. t['chekhakassiancyrillic'] = 0x04CC;
  9895. t['cheverticalstrokecyrillic'] = 0x04B9;
  9896. t['chi'] = 0x03C7;
  9897. t['chieuchacirclekorean'] = 0x3277;
  9898. t['chieuchaparenkorean'] = 0x3217;
  9899. t['chieuchcirclekorean'] = 0x3269;
  9900. t['chieuchkorean'] = 0x314A;
  9901. t['chieuchparenkorean'] = 0x3209;
  9902. t['chochangthai'] = 0x0E0A;
  9903. t['chochanthai'] = 0x0E08;
  9904. t['chochingthai'] = 0x0E09;
  9905. t['chochoethai'] = 0x0E0C;
  9906. t['chook'] = 0x0188;
  9907. t['cieucacirclekorean'] = 0x3276;
  9908. t['cieucaparenkorean'] = 0x3216;
  9909. t['cieuccirclekorean'] = 0x3268;
  9910. t['cieuckorean'] = 0x3148;
  9911. t['cieucparenkorean'] = 0x3208;
  9912. t['cieucuparenkorean'] = 0x321C;
  9913. t['circle'] = 0x25CB;
  9914. t['circlecopyrt'] = 0x00A9;
  9915. t['circlemultiply'] = 0x2297;
  9916. t['circleot'] = 0x2299;
  9917. t['circleplus'] = 0x2295;
  9918. t['circlepostalmark'] = 0x3036;
  9919. t['circlewithlefthalfblack'] = 0x25D0;
  9920. t['circlewithrighthalfblack'] = 0x25D1;
  9921. t['circumflex'] = 0x02C6;
  9922. t['circumflexbelowcmb'] = 0x032D;
  9923. t['circumflexcmb'] = 0x0302;
  9924. t['clear'] = 0x2327;
  9925. t['clickalveolar'] = 0x01C2;
  9926. t['clickdental'] = 0x01C0;
  9927. t['clicklateral'] = 0x01C1;
  9928. t['clickretroflex'] = 0x01C3;
  9929. t['club'] = 0x2663;
  9930. t['clubsuitblack'] = 0x2663;
  9931. t['clubsuitwhite'] = 0x2667;
  9932. t['cmcubedsquare'] = 0x33A4;
  9933. t['cmonospace'] = 0xFF43;
  9934. t['cmsquaredsquare'] = 0x33A0;
  9935. t['coarmenian'] = 0x0581;
  9936. t['colon'] = 0x003A;
  9937. t['colonmonetary'] = 0x20A1;
  9938. t['colonmonospace'] = 0xFF1A;
  9939. t['colonsign'] = 0x20A1;
  9940. t['colonsmall'] = 0xFE55;
  9941. t['colontriangularhalfmod'] = 0x02D1;
  9942. t['colontriangularmod'] = 0x02D0;
  9943. t['comma'] = 0x002C;
  9944. t['commaabovecmb'] = 0x0313;
  9945. t['commaaboverightcmb'] = 0x0315;
  9946. t['commaaccent'] = 0xF6C3;
  9947. t['commaarabic'] = 0x060C;
  9948. t['commaarmenian'] = 0x055D;
  9949. t['commainferior'] = 0xF6E1;
  9950. t['commamonospace'] = 0xFF0C;
  9951. t['commareversedabovecmb'] = 0x0314;
  9952. t['commareversedmod'] = 0x02BD;
  9953. t['commasmall'] = 0xFE50;
  9954. t['commasuperior'] = 0xF6E2;
  9955. t['commaturnedabovecmb'] = 0x0312;
  9956. t['commaturnedmod'] = 0x02BB;
  9957. t['compass'] = 0x263C;
  9958. t['congruent'] = 0x2245;
  9959. t['contourintegral'] = 0x222E;
  9960. t['control'] = 0x2303;
  9961. t['controlACK'] = 0x0006;
  9962. t['controlBEL'] = 0x0007;
  9963. t['controlBS'] = 0x0008;
  9964. t['controlCAN'] = 0x0018;
  9965. t['controlCR'] = 0x000D;
  9966. t['controlDC1'] = 0x0011;
  9967. t['controlDC2'] = 0x0012;
  9968. t['controlDC3'] = 0x0013;
  9969. t['controlDC4'] = 0x0014;
  9970. t['controlDEL'] = 0x007F;
  9971. t['controlDLE'] = 0x0010;
  9972. t['controlEM'] = 0x0019;
  9973. t['controlENQ'] = 0x0005;
  9974. t['controlEOT'] = 0x0004;
  9975. t['controlESC'] = 0x001B;
  9976. t['controlETB'] = 0x0017;
  9977. t['controlETX'] = 0x0003;
  9978. t['controlFF'] = 0x000C;
  9979. t['controlFS'] = 0x001C;
  9980. t['controlGS'] = 0x001D;
  9981. t['controlHT'] = 0x0009;
  9982. t['controlLF'] = 0x000A;
  9983. t['controlNAK'] = 0x0015;
  9984. t['controlRS'] = 0x001E;
  9985. t['controlSI'] = 0x000F;
  9986. t['controlSO'] = 0x000E;
  9987. t['controlSOT'] = 0x0002;
  9988. t['controlSTX'] = 0x0001;
  9989. t['controlSUB'] = 0x001A;
  9990. t['controlSYN'] = 0x0016;
  9991. t['controlUS'] = 0x001F;
  9992. t['controlVT'] = 0x000B;
  9993. t['copyright'] = 0x00A9;
  9994. t['copyrightsans'] = 0xF8E9;
  9995. t['copyrightserif'] = 0xF6D9;
  9996. t['cornerbracketleft'] = 0x300C;
  9997. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9998. t['cornerbracketleftvertical'] = 0xFE41;
  9999. t['cornerbracketright'] = 0x300D;
  10000. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10001. t['cornerbracketrightvertical'] = 0xFE42;
  10002. t['corporationsquare'] = 0x337F;
  10003. t['cosquare'] = 0x33C7;
  10004. t['coverkgsquare'] = 0x33C6;
  10005. t['cparen'] = 0x249E;
  10006. t['cruzeiro'] = 0x20A2;
  10007. t['cstretched'] = 0x0297;
  10008. t['curlyand'] = 0x22CF;
  10009. t['curlyor'] = 0x22CE;
  10010. t['currency'] = 0x00A4;
  10011. t['cyrBreve'] = 0xF6D1;
  10012. t['cyrFlex'] = 0xF6D2;
  10013. t['cyrbreve'] = 0xF6D4;
  10014. t['cyrflex'] = 0xF6D5;
  10015. t['d'] = 0x0064;
  10016. t['daarmenian'] = 0x0564;
  10017. t['dabengali'] = 0x09A6;
  10018. t['dadarabic'] = 0x0636;
  10019. t['dadeva'] = 0x0926;
  10020. t['dadfinalarabic'] = 0xFEBE;
  10021. t['dadinitialarabic'] = 0xFEBF;
  10022. t['dadmedialarabic'] = 0xFEC0;
  10023. t['dagesh'] = 0x05BC;
  10024. t['dageshhebrew'] = 0x05BC;
  10025. t['dagger'] = 0x2020;
  10026. t['daggerdbl'] = 0x2021;
  10027. t['dagujarati'] = 0x0AA6;
  10028. t['dagurmukhi'] = 0x0A26;
  10029. t['dahiragana'] = 0x3060;
  10030. t['dakatakana'] = 0x30C0;
  10031. t['dalarabic'] = 0x062F;
  10032. t['dalet'] = 0x05D3;
  10033. t['daletdagesh'] = 0xFB33;
  10034. t['daletdageshhebrew'] = 0xFB33;
  10035. t['dalethebrew'] = 0x05D3;
  10036. t['dalfinalarabic'] = 0xFEAA;
  10037. t['dammaarabic'] = 0x064F;
  10038. t['dammalowarabic'] = 0x064F;
  10039. t['dammatanaltonearabic'] = 0x064C;
  10040. t['dammatanarabic'] = 0x064C;
  10041. t['danda'] = 0x0964;
  10042. t['dargahebrew'] = 0x05A7;
  10043. t['dargalefthebrew'] = 0x05A7;
  10044. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10045. t['dblGrave'] = 0xF6D3;
  10046. t['dblanglebracketleft'] = 0x300A;
  10047. t['dblanglebracketleftvertical'] = 0xFE3D;
  10048. t['dblanglebracketright'] = 0x300B;
  10049. t['dblanglebracketrightvertical'] = 0xFE3E;
  10050. t['dblarchinvertedbelowcmb'] = 0x032B;
  10051. t['dblarrowleft'] = 0x21D4;
  10052. t['dblarrowright'] = 0x21D2;
  10053. t['dbldanda'] = 0x0965;
  10054. t['dblgrave'] = 0xF6D6;
  10055. t['dblgravecmb'] = 0x030F;
  10056. t['dblintegral'] = 0x222C;
  10057. t['dbllowline'] = 0x2017;
  10058. t['dbllowlinecmb'] = 0x0333;
  10059. t['dbloverlinecmb'] = 0x033F;
  10060. t['dblprimemod'] = 0x02BA;
  10061. t['dblverticalbar'] = 0x2016;
  10062. t['dblverticallineabovecmb'] = 0x030E;
  10063. t['dbopomofo'] = 0x3109;
  10064. t['dbsquare'] = 0x33C8;
  10065. t['dcaron'] = 0x010F;
  10066. t['dcedilla'] = 0x1E11;
  10067. t['dcircle'] = 0x24D3;
  10068. t['dcircumflexbelow'] = 0x1E13;
  10069. t['dcroat'] = 0x0111;
  10070. t['ddabengali'] = 0x09A1;
  10071. t['ddadeva'] = 0x0921;
  10072. t['ddagujarati'] = 0x0AA1;
  10073. t['ddagurmukhi'] = 0x0A21;
  10074. t['ddalarabic'] = 0x0688;
  10075. t['ddalfinalarabic'] = 0xFB89;
  10076. t['dddhadeva'] = 0x095C;
  10077. t['ddhabengali'] = 0x09A2;
  10078. t['ddhadeva'] = 0x0922;
  10079. t['ddhagujarati'] = 0x0AA2;
  10080. t['ddhagurmukhi'] = 0x0A22;
  10081. t['ddotaccent'] = 0x1E0B;
  10082. t['ddotbelow'] = 0x1E0D;
  10083. t['decimalseparatorarabic'] = 0x066B;
  10084. t['decimalseparatorpersian'] = 0x066B;
  10085. t['decyrillic'] = 0x0434;
  10086. t['degree'] = 0x00B0;
  10087. t['dehihebrew'] = 0x05AD;
  10088. t['dehiragana'] = 0x3067;
  10089. t['deicoptic'] = 0x03EF;
  10090. t['dekatakana'] = 0x30C7;
  10091. t['deleteleft'] = 0x232B;
  10092. t['deleteright'] = 0x2326;
  10093. t['delta'] = 0x03B4;
  10094. t['deltaturned'] = 0x018D;
  10095. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10096. t['dezh'] = 0x02A4;
  10097. t['dhabengali'] = 0x09A7;
  10098. t['dhadeva'] = 0x0927;
  10099. t['dhagujarati'] = 0x0AA7;
  10100. t['dhagurmukhi'] = 0x0A27;
  10101. t['dhook'] = 0x0257;
  10102. t['dialytikatonos'] = 0x0385;
  10103. t['dialytikatonoscmb'] = 0x0344;
  10104. t['diamond'] = 0x2666;
  10105. t['diamondsuitwhite'] = 0x2662;
  10106. t['dieresis'] = 0x00A8;
  10107. t['dieresisacute'] = 0xF6D7;
  10108. t['dieresisbelowcmb'] = 0x0324;
  10109. t['dieresiscmb'] = 0x0308;
  10110. t['dieresisgrave'] = 0xF6D8;
  10111. t['dieresistonos'] = 0x0385;
  10112. t['dihiragana'] = 0x3062;
  10113. t['dikatakana'] = 0x30C2;
  10114. t['dittomark'] = 0x3003;
  10115. t['divide'] = 0x00F7;
  10116. t['divides'] = 0x2223;
  10117. t['divisionslash'] = 0x2215;
  10118. t['djecyrillic'] = 0x0452;
  10119. t['dkshade'] = 0x2593;
  10120. t['dlinebelow'] = 0x1E0F;
  10121. t['dlsquare'] = 0x3397;
  10122. t['dmacron'] = 0x0111;
  10123. t['dmonospace'] = 0xFF44;
  10124. t['dnblock'] = 0x2584;
  10125. t['dochadathai'] = 0x0E0E;
  10126. t['dodekthai'] = 0x0E14;
  10127. t['dohiragana'] = 0x3069;
  10128. t['dokatakana'] = 0x30C9;
  10129. t['dollar'] = 0x0024;
  10130. t['dollarinferior'] = 0xF6E3;
  10131. t['dollarmonospace'] = 0xFF04;
  10132. t['dollaroldstyle'] = 0xF724;
  10133. t['dollarsmall'] = 0xFE69;
  10134. t['dollarsuperior'] = 0xF6E4;
  10135. t['dong'] = 0x20AB;
  10136. t['dorusquare'] = 0x3326;
  10137. t['dotaccent'] = 0x02D9;
  10138. t['dotaccentcmb'] = 0x0307;
  10139. t['dotbelowcmb'] = 0x0323;
  10140. t['dotbelowcomb'] = 0x0323;
  10141. t['dotkatakana'] = 0x30FB;
  10142. t['dotlessi'] = 0x0131;
  10143. t['dotlessj'] = 0xF6BE;
  10144. t['dotlessjstrokehook'] = 0x0284;
  10145. t['dotmath'] = 0x22C5;
  10146. t['dottedcircle'] = 0x25CC;
  10147. t['doubleyodpatah'] = 0xFB1F;
  10148. t['doubleyodpatahhebrew'] = 0xFB1F;
  10149. t['downtackbelowcmb'] = 0x031E;
  10150. t['downtackmod'] = 0x02D5;
  10151. t['dparen'] = 0x249F;
  10152. t['dsuperior'] = 0xF6EB;
  10153. t['dtail'] = 0x0256;
  10154. t['dtopbar'] = 0x018C;
  10155. t['duhiragana'] = 0x3065;
  10156. t['dukatakana'] = 0x30C5;
  10157. t['dz'] = 0x01F3;
  10158. t['dzaltone'] = 0x02A3;
  10159. t['dzcaron'] = 0x01C6;
  10160. t['dzcurl'] = 0x02A5;
  10161. t['dzeabkhasiancyrillic'] = 0x04E1;
  10162. t['dzecyrillic'] = 0x0455;
  10163. t['dzhecyrillic'] = 0x045F;
  10164. t['e'] = 0x0065;
  10165. t['eacute'] = 0x00E9;
  10166. t['earth'] = 0x2641;
  10167. t['ebengali'] = 0x098F;
  10168. t['ebopomofo'] = 0x311C;
  10169. t['ebreve'] = 0x0115;
  10170. t['ecandradeva'] = 0x090D;
  10171. t['ecandragujarati'] = 0x0A8D;
  10172. t['ecandravowelsigndeva'] = 0x0945;
  10173. t['ecandravowelsigngujarati'] = 0x0AC5;
  10174. t['ecaron'] = 0x011B;
  10175. t['ecedillabreve'] = 0x1E1D;
  10176. t['echarmenian'] = 0x0565;
  10177. t['echyiwnarmenian'] = 0x0587;
  10178. t['ecircle'] = 0x24D4;
  10179. t['ecircumflex'] = 0x00EA;
  10180. t['ecircumflexacute'] = 0x1EBF;
  10181. t['ecircumflexbelow'] = 0x1E19;
  10182. t['ecircumflexdotbelow'] = 0x1EC7;
  10183. t['ecircumflexgrave'] = 0x1EC1;
  10184. t['ecircumflexhookabove'] = 0x1EC3;
  10185. t['ecircumflextilde'] = 0x1EC5;
  10186. t['ecyrillic'] = 0x0454;
  10187. t['edblgrave'] = 0x0205;
  10188. t['edeva'] = 0x090F;
  10189. t['edieresis'] = 0x00EB;
  10190. t['edot'] = 0x0117;
  10191. t['edotaccent'] = 0x0117;
  10192. t['edotbelow'] = 0x1EB9;
  10193. t['eegurmukhi'] = 0x0A0F;
  10194. t['eematragurmukhi'] = 0x0A47;
  10195. t['efcyrillic'] = 0x0444;
  10196. t['egrave'] = 0x00E8;
  10197. t['egujarati'] = 0x0A8F;
  10198. t['eharmenian'] = 0x0567;
  10199. t['ehbopomofo'] = 0x311D;
  10200. t['ehiragana'] = 0x3048;
  10201. t['ehookabove'] = 0x1EBB;
  10202. t['eibopomofo'] = 0x311F;
  10203. t['eight'] = 0x0038;
  10204. t['eightarabic'] = 0x0668;
  10205. t['eightbengali'] = 0x09EE;
  10206. t['eightcircle'] = 0x2467;
  10207. t['eightcircleinversesansserif'] = 0x2791;
  10208. t['eightdeva'] = 0x096E;
  10209. t['eighteencircle'] = 0x2471;
  10210. t['eighteenparen'] = 0x2485;
  10211. t['eighteenperiod'] = 0x2499;
  10212. t['eightgujarati'] = 0x0AEE;
  10213. t['eightgurmukhi'] = 0x0A6E;
  10214. t['eighthackarabic'] = 0x0668;
  10215. t['eighthangzhou'] = 0x3028;
  10216. t['eighthnotebeamed'] = 0x266B;
  10217. t['eightideographicparen'] = 0x3227;
  10218. t['eightinferior'] = 0x2088;
  10219. t['eightmonospace'] = 0xFF18;
  10220. t['eightoldstyle'] = 0xF738;
  10221. t['eightparen'] = 0x247B;
  10222. t['eightperiod'] = 0x248F;
  10223. t['eightpersian'] = 0x06F8;
  10224. t['eightroman'] = 0x2177;
  10225. t['eightsuperior'] = 0x2078;
  10226. t['eightthai'] = 0x0E58;
  10227. t['einvertedbreve'] = 0x0207;
  10228. t['eiotifiedcyrillic'] = 0x0465;
  10229. t['ekatakana'] = 0x30A8;
  10230. t['ekatakanahalfwidth'] = 0xFF74;
  10231. t['ekonkargurmukhi'] = 0x0A74;
  10232. t['ekorean'] = 0x3154;
  10233. t['elcyrillic'] = 0x043B;
  10234. t['element'] = 0x2208;
  10235. t['elevencircle'] = 0x246A;
  10236. t['elevenparen'] = 0x247E;
  10237. t['elevenperiod'] = 0x2492;
  10238. t['elevenroman'] = 0x217A;
  10239. t['ellipsis'] = 0x2026;
  10240. t['ellipsisvertical'] = 0x22EE;
  10241. t['emacron'] = 0x0113;
  10242. t['emacronacute'] = 0x1E17;
  10243. t['emacrongrave'] = 0x1E15;
  10244. t['emcyrillic'] = 0x043C;
  10245. t['emdash'] = 0x2014;
  10246. t['emdashvertical'] = 0xFE31;
  10247. t['emonospace'] = 0xFF45;
  10248. t['emphasismarkarmenian'] = 0x055B;
  10249. t['emptyset'] = 0x2205;
  10250. t['enbopomofo'] = 0x3123;
  10251. t['encyrillic'] = 0x043D;
  10252. t['endash'] = 0x2013;
  10253. t['endashvertical'] = 0xFE32;
  10254. t['endescendercyrillic'] = 0x04A3;
  10255. t['eng'] = 0x014B;
  10256. t['engbopomofo'] = 0x3125;
  10257. t['enghecyrillic'] = 0x04A5;
  10258. t['enhookcyrillic'] = 0x04C8;
  10259. t['enspace'] = 0x2002;
  10260. t['eogonek'] = 0x0119;
  10261. t['eokorean'] = 0x3153;
  10262. t['eopen'] = 0x025B;
  10263. t['eopenclosed'] = 0x029A;
  10264. t['eopenreversed'] = 0x025C;
  10265. t['eopenreversedclosed'] = 0x025E;
  10266. t['eopenreversedhook'] = 0x025D;
  10267. t['eparen'] = 0x24A0;
  10268. t['epsilon'] = 0x03B5;
  10269. t['epsilontonos'] = 0x03AD;
  10270. t['equal'] = 0x003D;
  10271. t['equalmonospace'] = 0xFF1D;
  10272. t['equalsmall'] = 0xFE66;
  10273. t['equalsuperior'] = 0x207C;
  10274. t['equivalence'] = 0x2261;
  10275. t['erbopomofo'] = 0x3126;
  10276. t['ercyrillic'] = 0x0440;
  10277. t['ereversed'] = 0x0258;
  10278. t['ereversedcyrillic'] = 0x044D;
  10279. t['escyrillic'] = 0x0441;
  10280. t['esdescendercyrillic'] = 0x04AB;
  10281. t['esh'] = 0x0283;
  10282. t['eshcurl'] = 0x0286;
  10283. t['eshortdeva'] = 0x090E;
  10284. t['eshortvowelsigndeva'] = 0x0946;
  10285. t['eshreversedloop'] = 0x01AA;
  10286. t['eshsquatreversed'] = 0x0285;
  10287. t['esmallhiragana'] = 0x3047;
  10288. t['esmallkatakana'] = 0x30A7;
  10289. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10290. t['estimated'] = 0x212E;
  10291. t['esuperior'] = 0xF6EC;
  10292. t['eta'] = 0x03B7;
  10293. t['etarmenian'] = 0x0568;
  10294. t['etatonos'] = 0x03AE;
  10295. t['eth'] = 0x00F0;
  10296. t['etilde'] = 0x1EBD;
  10297. t['etildebelow'] = 0x1E1B;
  10298. t['etnahtafoukhhebrew'] = 0x0591;
  10299. t['etnahtafoukhlefthebrew'] = 0x0591;
  10300. t['etnahtahebrew'] = 0x0591;
  10301. t['etnahtalefthebrew'] = 0x0591;
  10302. t['eturned'] = 0x01DD;
  10303. t['eukorean'] = 0x3161;
  10304. t['euro'] = 0x20AC;
  10305. t['evowelsignbengali'] = 0x09C7;
  10306. t['evowelsigndeva'] = 0x0947;
  10307. t['evowelsigngujarati'] = 0x0AC7;
  10308. t['exclam'] = 0x0021;
  10309. t['exclamarmenian'] = 0x055C;
  10310. t['exclamdbl'] = 0x203C;
  10311. t['exclamdown'] = 0x00A1;
  10312. t['exclamdownsmall'] = 0xF7A1;
  10313. t['exclammonospace'] = 0xFF01;
  10314. t['exclamsmall'] = 0xF721;
  10315. t['existential'] = 0x2203;
  10316. t['ezh'] = 0x0292;
  10317. t['ezhcaron'] = 0x01EF;
  10318. t['ezhcurl'] = 0x0293;
  10319. t['ezhreversed'] = 0x01B9;
  10320. t['ezhtail'] = 0x01BA;
  10321. t['f'] = 0x0066;
  10322. t['fadeva'] = 0x095E;
  10323. t['fagurmukhi'] = 0x0A5E;
  10324. t['fahrenheit'] = 0x2109;
  10325. t['fathaarabic'] = 0x064E;
  10326. t['fathalowarabic'] = 0x064E;
  10327. t['fathatanarabic'] = 0x064B;
  10328. t['fbopomofo'] = 0x3108;
  10329. t['fcircle'] = 0x24D5;
  10330. t['fdotaccent'] = 0x1E1F;
  10331. t['feharabic'] = 0x0641;
  10332. t['feharmenian'] = 0x0586;
  10333. t['fehfinalarabic'] = 0xFED2;
  10334. t['fehinitialarabic'] = 0xFED3;
  10335. t['fehmedialarabic'] = 0xFED4;
  10336. t['feicoptic'] = 0x03E5;
  10337. t['female'] = 0x2640;
  10338. t['ff'] = 0xFB00;
  10339. t['ffi'] = 0xFB03;
  10340. t['ffl'] = 0xFB04;
  10341. t['fi'] = 0xFB01;
  10342. t['fifteencircle'] = 0x246E;
  10343. t['fifteenparen'] = 0x2482;
  10344. t['fifteenperiod'] = 0x2496;
  10345. t['figuredash'] = 0x2012;
  10346. t['filledbox'] = 0x25A0;
  10347. t['filledrect'] = 0x25AC;
  10348. t['finalkaf'] = 0x05DA;
  10349. t['finalkafdagesh'] = 0xFB3A;
  10350. t['finalkafdageshhebrew'] = 0xFB3A;
  10351. t['finalkafhebrew'] = 0x05DA;
  10352. t['finalmem'] = 0x05DD;
  10353. t['finalmemhebrew'] = 0x05DD;
  10354. t['finalnun'] = 0x05DF;
  10355. t['finalnunhebrew'] = 0x05DF;
  10356. t['finalpe'] = 0x05E3;
  10357. t['finalpehebrew'] = 0x05E3;
  10358. t['finaltsadi'] = 0x05E5;
  10359. t['finaltsadihebrew'] = 0x05E5;
  10360. t['firsttonechinese'] = 0x02C9;
  10361. t['fisheye'] = 0x25C9;
  10362. t['fitacyrillic'] = 0x0473;
  10363. t['five'] = 0x0035;
  10364. t['fivearabic'] = 0x0665;
  10365. t['fivebengali'] = 0x09EB;
  10366. t['fivecircle'] = 0x2464;
  10367. t['fivecircleinversesansserif'] = 0x278E;
  10368. t['fivedeva'] = 0x096B;
  10369. t['fiveeighths'] = 0x215D;
  10370. t['fivegujarati'] = 0x0AEB;
  10371. t['fivegurmukhi'] = 0x0A6B;
  10372. t['fivehackarabic'] = 0x0665;
  10373. t['fivehangzhou'] = 0x3025;
  10374. t['fiveideographicparen'] = 0x3224;
  10375. t['fiveinferior'] = 0x2085;
  10376. t['fivemonospace'] = 0xFF15;
  10377. t['fiveoldstyle'] = 0xF735;
  10378. t['fiveparen'] = 0x2478;
  10379. t['fiveperiod'] = 0x248C;
  10380. t['fivepersian'] = 0x06F5;
  10381. t['fiveroman'] = 0x2174;
  10382. t['fivesuperior'] = 0x2075;
  10383. t['fivethai'] = 0x0E55;
  10384. t['fl'] = 0xFB02;
  10385. t['florin'] = 0x0192;
  10386. t['fmonospace'] = 0xFF46;
  10387. t['fmsquare'] = 0x3399;
  10388. t['fofanthai'] = 0x0E1F;
  10389. t['fofathai'] = 0x0E1D;
  10390. t['fongmanthai'] = 0x0E4F;
  10391. t['forall'] = 0x2200;
  10392. t['four'] = 0x0034;
  10393. t['fourarabic'] = 0x0664;
  10394. t['fourbengali'] = 0x09EA;
  10395. t['fourcircle'] = 0x2463;
  10396. t['fourcircleinversesansserif'] = 0x278D;
  10397. t['fourdeva'] = 0x096A;
  10398. t['fourgujarati'] = 0x0AEA;
  10399. t['fourgurmukhi'] = 0x0A6A;
  10400. t['fourhackarabic'] = 0x0664;
  10401. t['fourhangzhou'] = 0x3024;
  10402. t['fourideographicparen'] = 0x3223;
  10403. t['fourinferior'] = 0x2084;
  10404. t['fourmonospace'] = 0xFF14;
  10405. t['fournumeratorbengali'] = 0x09F7;
  10406. t['fouroldstyle'] = 0xF734;
  10407. t['fourparen'] = 0x2477;
  10408. t['fourperiod'] = 0x248B;
  10409. t['fourpersian'] = 0x06F4;
  10410. t['fourroman'] = 0x2173;
  10411. t['foursuperior'] = 0x2074;
  10412. t['fourteencircle'] = 0x246D;
  10413. t['fourteenparen'] = 0x2481;
  10414. t['fourteenperiod'] = 0x2495;
  10415. t['fourthai'] = 0x0E54;
  10416. t['fourthtonechinese'] = 0x02CB;
  10417. t['fparen'] = 0x24A1;
  10418. t['fraction'] = 0x2044;
  10419. t['franc'] = 0x20A3;
  10420. t['g'] = 0x0067;
  10421. t['gabengali'] = 0x0997;
  10422. t['gacute'] = 0x01F5;
  10423. t['gadeva'] = 0x0917;
  10424. t['gafarabic'] = 0x06AF;
  10425. t['gaffinalarabic'] = 0xFB93;
  10426. t['gafinitialarabic'] = 0xFB94;
  10427. t['gafmedialarabic'] = 0xFB95;
  10428. t['gagujarati'] = 0x0A97;
  10429. t['gagurmukhi'] = 0x0A17;
  10430. t['gahiragana'] = 0x304C;
  10431. t['gakatakana'] = 0x30AC;
  10432. t['gamma'] = 0x03B3;
  10433. t['gammalatinsmall'] = 0x0263;
  10434. t['gammasuperior'] = 0x02E0;
  10435. t['gangiacoptic'] = 0x03EB;
  10436. t['gbopomofo'] = 0x310D;
  10437. t['gbreve'] = 0x011F;
  10438. t['gcaron'] = 0x01E7;
  10439. t['gcedilla'] = 0x0123;
  10440. t['gcircle'] = 0x24D6;
  10441. t['gcircumflex'] = 0x011D;
  10442. t['gcommaaccent'] = 0x0123;
  10443. t['gdot'] = 0x0121;
  10444. t['gdotaccent'] = 0x0121;
  10445. t['gecyrillic'] = 0x0433;
  10446. t['gehiragana'] = 0x3052;
  10447. t['gekatakana'] = 0x30B2;
  10448. t['geometricallyequal'] = 0x2251;
  10449. t['gereshaccenthebrew'] = 0x059C;
  10450. t['gereshhebrew'] = 0x05F3;
  10451. t['gereshmuqdamhebrew'] = 0x059D;
  10452. t['germandbls'] = 0x00DF;
  10453. t['gershayimaccenthebrew'] = 0x059E;
  10454. t['gershayimhebrew'] = 0x05F4;
  10455. t['getamark'] = 0x3013;
  10456. t['ghabengali'] = 0x0998;
  10457. t['ghadarmenian'] = 0x0572;
  10458. t['ghadeva'] = 0x0918;
  10459. t['ghagujarati'] = 0x0A98;
  10460. t['ghagurmukhi'] = 0x0A18;
  10461. t['ghainarabic'] = 0x063A;
  10462. t['ghainfinalarabic'] = 0xFECE;
  10463. t['ghaininitialarabic'] = 0xFECF;
  10464. t['ghainmedialarabic'] = 0xFED0;
  10465. t['ghemiddlehookcyrillic'] = 0x0495;
  10466. t['ghestrokecyrillic'] = 0x0493;
  10467. t['gheupturncyrillic'] = 0x0491;
  10468. t['ghhadeva'] = 0x095A;
  10469. t['ghhagurmukhi'] = 0x0A5A;
  10470. t['ghook'] = 0x0260;
  10471. t['ghzsquare'] = 0x3393;
  10472. t['gihiragana'] = 0x304E;
  10473. t['gikatakana'] = 0x30AE;
  10474. t['gimarmenian'] = 0x0563;
  10475. t['gimel'] = 0x05D2;
  10476. t['gimeldagesh'] = 0xFB32;
  10477. t['gimeldageshhebrew'] = 0xFB32;
  10478. t['gimelhebrew'] = 0x05D2;
  10479. t['gjecyrillic'] = 0x0453;
  10480. t['glottalinvertedstroke'] = 0x01BE;
  10481. t['glottalstop'] = 0x0294;
  10482. t['glottalstopinverted'] = 0x0296;
  10483. t['glottalstopmod'] = 0x02C0;
  10484. t['glottalstopreversed'] = 0x0295;
  10485. t['glottalstopreversedmod'] = 0x02C1;
  10486. t['glottalstopreversedsuperior'] = 0x02E4;
  10487. t['glottalstopstroke'] = 0x02A1;
  10488. t['glottalstopstrokereversed'] = 0x02A2;
  10489. t['gmacron'] = 0x1E21;
  10490. t['gmonospace'] = 0xFF47;
  10491. t['gohiragana'] = 0x3054;
  10492. t['gokatakana'] = 0x30B4;
  10493. t['gparen'] = 0x24A2;
  10494. t['gpasquare'] = 0x33AC;
  10495. t['gradient'] = 0x2207;
  10496. t['grave'] = 0x0060;
  10497. t['gravebelowcmb'] = 0x0316;
  10498. t['gravecmb'] = 0x0300;
  10499. t['gravecomb'] = 0x0300;
  10500. t['gravedeva'] = 0x0953;
  10501. t['gravelowmod'] = 0x02CE;
  10502. t['gravemonospace'] = 0xFF40;
  10503. t['gravetonecmb'] = 0x0340;
  10504. t['greater'] = 0x003E;
  10505. t['greaterequal'] = 0x2265;
  10506. t['greaterequalorless'] = 0x22DB;
  10507. t['greatermonospace'] = 0xFF1E;
  10508. t['greaterorequivalent'] = 0x2273;
  10509. t['greaterorless'] = 0x2277;
  10510. t['greateroverequal'] = 0x2267;
  10511. t['greatersmall'] = 0xFE65;
  10512. t['gscript'] = 0x0261;
  10513. t['gstroke'] = 0x01E5;
  10514. t['guhiragana'] = 0x3050;
  10515. t['guillemotleft'] = 0x00AB;
  10516. t['guillemotright'] = 0x00BB;
  10517. t['guilsinglleft'] = 0x2039;
  10518. t['guilsinglright'] = 0x203A;
  10519. t['gukatakana'] = 0x30B0;
  10520. t['guramusquare'] = 0x3318;
  10521. t['gysquare'] = 0x33C9;
  10522. t['h'] = 0x0068;
  10523. t['haabkhasiancyrillic'] = 0x04A9;
  10524. t['haaltonearabic'] = 0x06C1;
  10525. t['habengali'] = 0x09B9;
  10526. t['hadescendercyrillic'] = 0x04B3;
  10527. t['hadeva'] = 0x0939;
  10528. t['hagujarati'] = 0x0AB9;
  10529. t['hagurmukhi'] = 0x0A39;
  10530. t['haharabic'] = 0x062D;
  10531. t['hahfinalarabic'] = 0xFEA2;
  10532. t['hahinitialarabic'] = 0xFEA3;
  10533. t['hahiragana'] = 0x306F;
  10534. t['hahmedialarabic'] = 0xFEA4;
  10535. t['haitusquare'] = 0x332A;
  10536. t['hakatakana'] = 0x30CF;
  10537. t['hakatakanahalfwidth'] = 0xFF8A;
  10538. t['halantgurmukhi'] = 0x0A4D;
  10539. t['hamzaarabic'] = 0x0621;
  10540. t['hamzalowarabic'] = 0x0621;
  10541. t['hangulfiller'] = 0x3164;
  10542. t['hardsigncyrillic'] = 0x044A;
  10543. t['harpoonleftbarbup'] = 0x21BC;
  10544. t['harpoonrightbarbup'] = 0x21C0;
  10545. t['hasquare'] = 0x33CA;
  10546. t['hatafpatah'] = 0x05B2;
  10547. t['hatafpatah16'] = 0x05B2;
  10548. t['hatafpatah23'] = 0x05B2;
  10549. t['hatafpatah2f'] = 0x05B2;
  10550. t['hatafpatahhebrew'] = 0x05B2;
  10551. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10552. t['hatafpatahquarterhebrew'] = 0x05B2;
  10553. t['hatafpatahwidehebrew'] = 0x05B2;
  10554. t['hatafqamats'] = 0x05B3;
  10555. t['hatafqamats1b'] = 0x05B3;
  10556. t['hatafqamats28'] = 0x05B3;
  10557. t['hatafqamats34'] = 0x05B3;
  10558. t['hatafqamatshebrew'] = 0x05B3;
  10559. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10560. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10561. t['hatafqamatswidehebrew'] = 0x05B3;
  10562. t['hatafsegol'] = 0x05B1;
  10563. t['hatafsegol17'] = 0x05B1;
  10564. t['hatafsegol24'] = 0x05B1;
  10565. t['hatafsegol30'] = 0x05B1;
  10566. t['hatafsegolhebrew'] = 0x05B1;
  10567. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10568. t['hatafsegolquarterhebrew'] = 0x05B1;
  10569. t['hatafsegolwidehebrew'] = 0x05B1;
  10570. t['hbar'] = 0x0127;
  10571. t['hbopomofo'] = 0x310F;
  10572. t['hbrevebelow'] = 0x1E2B;
  10573. t['hcedilla'] = 0x1E29;
  10574. t['hcircle'] = 0x24D7;
  10575. t['hcircumflex'] = 0x0125;
  10576. t['hdieresis'] = 0x1E27;
  10577. t['hdotaccent'] = 0x1E23;
  10578. t['hdotbelow'] = 0x1E25;
  10579. t['he'] = 0x05D4;
  10580. t['heart'] = 0x2665;
  10581. t['heartsuitblack'] = 0x2665;
  10582. t['heartsuitwhite'] = 0x2661;
  10583. t['hedagesh'] = 0xFB34;
  10584. t['hedageshhebrew'] = 0xFB34;
  10585. t['hehaltonearabic'] = 0x06C1;
  10586. t['heharabic'] = 0x0647;
  10587. t['hehebrew'] = 0x05D4;
  10588. t['hehfinalaltonearabic'] = 0xFBA7;
  10589. t['hehfinalalttwoarabic'] = 0xFEEA;
  10590. t['hehfinalarabic'] = 0xFEEA;
  10591. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10592. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10593. t['hehinitialaltonearabic'] = 0xFBA8;
  10594. t['hehinitialarabic'] = 0xFEEB;
  10595. t['hehiragana'] = 0x3078;
  10596. t['hehmedialaltonearabic'] = 0xFBA9;
  10597. t['hehmedialarabic'] = 0xFEEC;
  10598. t['heiseierasquare'] = 0x337B;
  10599. t['hekatakana'] = 0x30D8;
  10600. t['hekatakanahalfwidth'] = 0xFF8D;
  10601. t['hekutaarusquare'] = 0x3336;
  10602. t['henghook'] = 0x0267;
  10603. t['herutusquare'] = 0x3339;
  10604. t['het'] = 0x05D7;
  10605. t['hethebrew'] = 0x05D7;
  10606. t['hhook'] = 0x0266;
  10607. t['hhooksuperior'] = 0x02B1;
  10608. t['hieuhacirclekorean'] = 0x327B;
  10609. t['hieuhaparenkorean'] = 0x321B;
  10610. t['hieuhcirclekorean'] = 0x326D;
  10611. t['hieuhkorean'] = 0x314E;
  10612. t['hieuhparenkorean'] = 0x320D;
  10613. t['hihiragana'] = 0x3072;
  10614. t['hikatakana'] = 0x30D2;
  10615. t['hikatakanahalfwidth'] = 0xFF8B;
  10616. t['hiriq'] = 0x05B4;
  10617. t['hiriq14'] = 0x05B4;
  10618. t['hiriq21'] = 0x05B4;
  10619. t['hiriq2d'] = 0x05B4;
  10620. t['hiriqhebrew'] = 0x05B4;
  10621. t['hiriqnarrowhebrew'] = 0x05B4;
  10622. t['hiriqquarterhebrew'] = 0x05B4;
  10623. t['hiriqwidehebrew'] = 0x05B4;
  10624. t['hlinebelow'] = 0x1E96;
  10625. t['hmonospace'] = 0xFF48;
  10626. t['hoarmenian'] = 0x0570;
  10627. t['hohipthai'] = 0x0E2B;
  10628. t['hohiragana'] = 0x307B;
  10629. t['hokatakana'] = 0x30DB;
  10630. t['hokatakanahalfwidth'] = 0xFF8E;
  10631. t['holam'] = 0x05B9;
  10632. t['holam19'] = 0x05B9;
  10633. t['holam26'] = 0x05B9;
  10634. t['holam32'] = 0x05B9;
  10635. t['holamhebrew'] = 0x05B9;
  10636. t['holamnarrowhebrew'] = 0x05B9;
  10637. t['holamquarterhebrew'] = 0x05B9;
  10638. t['holamwidehebrew'] = 0x05B9;
  10639. t['honokhukthai'] = 0x0E2E;
  10640. t['hookabovecomb'] = 0x0309;
  10641. t['hookcmb'] = 0x0309;
  10642. t['hookpalatalizedbelowcmb'] = 0x0321;
  10643. t['hookretroflexbelowcmb'] = 0x0322;
  10644. t['hoonsquare'] = 0x3342;
  10645. t['horicoptic'] = 0x03E9;
  10646. t['horizontalbar'] = 0x2015;
  10647. t['horncmb'] = 0x031B;
  10648. t['hotsprings'] = 0x2668;
  10649. t['house'] = 0x2302;
  10650. t['hparen'] = 0x24A3;
  10651. t['hsuperior'] = 0x02B0;
  10652. t['hturned'] = 0x0265;
  10653. t['huhiragana'] = 0x3075;
  10654. t['huiitosquare'] = 0x3333;
  10655. t['hukatakana'] = 0x30D5;
  10656. t['hukatakanahalfwidth'] = 0xFF8C;
  10657. t['hungarumlaut'] = 0x02DD;
  10658. t['hungarumlautcmb'] = 0x030B;
  10659. t['hv'] = 0x0195;
  10660. t['hyphen'] = 0x002D;
  10661. t['hypheninferior'] = 0xF6E5;
  10662. t['hyphenmonospace'] = 0xFF0D;
  10663. t['hyphensmall'] = 0xFE63;
  10664. t['hyphensuperior'] = 0xF6E6;
  10665. t['hyphentwo'] = 0x2010;
  10666. t['i'] = 0x0069;
  10667. t['iacute'] = 0x00ED;
  10668. t['iacyrillic'] = 0x044F;
  10669. t['ibengali'] = 0x0987;
  10670. t['ibopomofo'] = 0x3127;
  10671. t['ibreve'] = 0x012D;
  10672. t['icaron'] = 0x01D0;
  10673. t['icircle'] = 0x24D8;
  10674. t['icircumflex'] = 0x00EE;
  10675. t['icyrillic'] = 0x0456;
  10676. t['idblgrave'] = 0x0209;
  10677. t['ideographearthcircle'] = 0x328F;
  10678. t['ideographfirecircle'] = 0x328B;
  10679. t['ideographicallianceparen'] = 0x323F;
  10680. t['ideographiccallparen'] = 0x323A;
  10681. t['ideographiccentrecircle'] = 0x32A5;
  10682. t['ideographicclose'] = 0x3006;
  10683. t['ideographiccomma'] = 0x3001;
  10684. t['ideographiccommaleft'] = 0xFF64;
  10685. t['ideographiccongratulationparen'] = 0x3237;
  10686. t['ideographiccorrectcircle'] = 0x32A3;
  10687. t['ideographicearthparen'] = 0x322F;
  10688. t['ideographicenterpriseparen'] = 0x323D;
  10689. t['ideographicexcellentcircle'] = 0x329D;
  10690. t['ideographicfestivalparen'] = 0x3240;
  10691. t['ideographicfinancialcircle'] = 0x3296;
  10692. t['ideographicfinancialparen'] = 0x3236;
  10693. t['ideographicfireparen'] = 0x322B;
  10694. t['ideographichaveparen'] = 0x3232;
  10695. t['ideographichighcircle'] = 0x32A4;
  10696. t['ideographiciterationmark'] = 0x3005;
  10697. t['ideographiclaborcircle'] = 0x3298;
  10698. t['ideographiclaborparen'] = 0x3238;
  10699. t['ideographicleftcircle'] = 0x32A7;
  10700. t['ideographiclowcircle'] = 0x32A6;
  10701. t['ideographicmedicinecircle'] = 0x32A9;
  10702. t['ideographicmetalparen'] = 0x322E;
  10703. t['ideographicmoonparen'] = 0x322A;
  10704. t['ideographicnameparen'] = 0x3234;
  10705. t['ideographicperiod'] = 0x3002;
  10706. t['ideographicprintcircle'] = 0x329E;
  10707. t['ideographicreachparen'] = 0x3243;
  10708. t['ideographicrepresentparen'] = 0x3239;
  10709. t['ideographicresourceparen'] = 0x323E;
  10710. t['ideographicrightcircle'] = 0x32A8;
  10711. t['ideographicsecretcircle'] = 0x3299;
  10712. t['ideographicselfparen'] = 0x3242;
  10713. t['ideographicsocietyparen'] = 0x3233;
  10714. t['ideographicspace'] = 0x3000;
  10715. t['ideographicspecialparen'] = 0x3235;
  10716. t['ideographicstockparen'] = 0x3231;
  10717. t['ideographicstudyparen'] = 0x323B;
  10718. t['ideographicsunparen'] = 0x3230;
  10719. t['ideographicsuperviseparen'] = 0x323C;
  10720. t['ideographicwaterparen'] = 0x322C;
  10721. t['ideographicwoodparen'] = 0x322D;
  10722. t['ideographiczero'] = 0x3007;
  10723. t['ideographmetalcircle'] = 0x328E;
  10724. t['ideographmooncircle'] = 0x328A;
  10725. t['ideographnamecircle'] = 0x3294;
  10726. t['ideographsuncircle'] = 0x3290;
  10727. t['ideographwatercircle'] = 0x328C;
  10728. t['ideographwoodcircle'] = 0x328D;
  10729. t['ideva'] = 0x0907;
  10730. t['idieresis'] = 0x00EF;
  10731. t['idieresisacute'] = 0x1E2F;
  10732. t['idieresiscyrillic'] = 0x04E5;
  10733. t['idotbelow'] = 0x1ECB;
  10734. t['iebrevecyrillic'] = 0x04D7;
  10735. t['iecyrillic'] = 0x0435;
  10736. t['ieungacirclekorean'] = 0x3275;
  10737. t['ieungaparenkorean'] = 0x3215;
  10738. t['ieungcirclekorean'] = 0x3267;
  10739. t['ieungkorean'] = 0x3147;
  10740. t['ieungparenkorean'] = 0x3207;
  10741. t['igrave'] = 0x00EC;
  10742. t['igujarati'] = 0x0A87;
  10743. t['igurmukhi'] = 0x0A07;
  10744. t['ihiragana'] = 0x3044;
  10745. t['ihookabove'] = 0x1EC9;
  10746. t['iibengali'] = 0x0988;
  10747. t['iicyrillic'] = 0x0438;
  10748. t['iideva'] = 0x0908;
  10749. t['iigujarati'] = 0x0A88;
  10750. t['iigurmukhi'] = 0x0A08;
  10751. t['iimatragurmukhi'] = 0x0A40;
  10752. t['iinvertedbreve'] = 0x020B;
  10753. t['iishortcyrillic'] = 0x0439;
  10754. t['iivowelsignbengali'] = 0x09C0;
  10755. t['iivowelsigndeva'] = 0x0940;
  10756. t['iivowelsigngujarati'] = 0x0AC0;
  10757. t['ij'] = 0x0133;
  10758. t['ikatakana'] = 0x30A4;
  10759. t['ikatakanahalfwidth'] = 0xFF72;
  10760. t['ikorean'] = 0x3163;
  10761. t['ilde'] = 0x02DC;
  10762. t['iluyhebrew'] = 0x05AC;
  10763. t['imacron'] = 0x012B;
  10764. t['imacroncyrillic'] = 0x04E3;
  10765. t['imageorapproximatelyequal'] = 0x2253;
  10766. t['imatragurmukhi'] = 0x0A3F;
  10767. t['imonospace'] = 0xFF49;
  10768. t['increment'] = 0x2206;
  10769. t['infinity'] = 0x221E;
  10770. t['iniarmenian'] = 0x056B;
  10771. t['integral'] = 0x222B;
  10772. t['integralbottom'] = 0x2321;
  10773. t['integralbt'] = 0x2321;
  10774. t['integralex'] = 0xF8F5;
  10775. t['integraltop'] = 0x2320;
  10776. t['integraltp'] = 0x2320;
  10777. t['intersection'] = 0x2229;
  10778. t['intisquare'] = 0x3305;
  10779. t['invbullet'] = 0x25D8;
  10780. t['invcircle'] = 0x25D9;
  10781. t['invsmileface'] = 0x263B;
  10782. t['iocyrillic'] = 0x0451;
  10783. t['iogonek'] = 0x012F;
  10784. t['iota'] = 0x03B9;
  10785. t['iotadieresis'] = 0x03CA;
  10786. t['iotadieresistonos'] = 0x0390;
  10787. t['iotalatin'] = 0x0269;
  10788. t['iotatonos'] = 0x03AF;
  10789. t['iparen'] = 0x24A4;
  10790. t['irigurmukhi'] = 0x0A72;
  10791. t['ismallhiragana'] = 0x3043;
  10792. t['ismallkatakana'] = 0x30A3;
  10793. t['ismallkatakanahalfwidth'] = 0xFF68;
  10794. t['issharbengali'] = 0x09FA;
  10795. t['istroke'] = 0x0268;
  10796. t['isuperior'] = 0xF6ED;
  10797. t['iterationhiragana'] = 0x309D;
  10798. t['iterationkatakana'] = 0x30FD;
  10799. t['itilde'] = 0x0129;
  10800. t['itildebelow'] = 0x1E2D;
  10801. t['iubopomofo'] = 0x3129;
  10802. t['iucyrillic'] = 0x044E;
  10803. t['ivowelsignbengali'] = 0x09BF;
  10804. t['ivowelsigndeva'] = 0x093F;
  10805. t['ivowelsigngujarati'] = 0x0ABF;
  10806. t['izhitsacyrillic'] = 0x0475;
  10807. t['izhitsadblgravecyrillic'] = 0x0477;
  10808. t['j'] = 0x006A;
  10809. t['jaarmenian'] = 0x0571;
  10810. t['jabengali'] = 0x099C;
  10811. t['jadeva'] = 0x091C;
  10812. t['jagujarati'] = 0x0A9C;
  10813. t['jagurmukhi'] = 0x0A1C;
  10814. t['jbopomofo'] = 0x3110;
  10815. t['jcaron'] = 0x01F0;
  10816. t['jcircle'] = 0x24D9;
  10817. t['jcircumflex'] = 0x0135;
  10818. t['jcrossedtail'] = 0x029D;
  10819. t['jdotlessstroke'] = 0x025F;
  10820. t['jecyrillic'] = 0x0458;
  10821. t['jeemarabic'] = 0x062C;
  10822. t['jeemfinalarabic'] = 0xFE9E;
  10823. t['jeeminitialarabic'] = 0xFE9F;
  10824. t['jeemmedialarabic'] = 0xFEA0;
  10825. t['jeharabic'] = 0x0698;
  10826. t['jehfinalarabic'] = 0xFB8B;
  10827. t['jhabengali'] = 0x099D;
  10828. t['jhadeva'] = 0x091D;
  10829. t['jhagujarati'] = 0x0A9D;
  10830. t['jhagurmukhi'] = 0x0A1D;
  10831. t['jheharmenian'] = 0x057B;
  10832. t['jis'] = 0x3004;
  10833. t['jmonospace'] = 0xFF4A;
  10834. t['jparen'] = 0x24A5;
  10835. t['jsuperior'] = 0x02B2;
  10836. t['k'] = 0x006B;
  10837. t['kabashkircyrillic'] = 0x04A1;
  10838. t['kabengali'] = 0x0995;
  10839. t['kacute'] = 0x1E31;
  10840. t['kacyrillic'] = 0x043A;
  10841. t['kadescendercyrillic'] = 0x049B;
  10842. t['kadeva'] = 0x0915;
  10843. t['kaf'] = 0x05DB;
  10844. t['kafarabic'] = 0x0643;
  10845. t['kafdagesh'] = 0xFB3B;
  10846. t['kafdageshhebrew'] = 0xFB3B;
  10847. t['kaffinalarabic'] = 0xFEDA;
  10848. t['kafhebrew'] = 0x05DB;
  10849. t['kafinitialarabic'] = 0xFEDB;
  10850. t['kafmedialarabic'] = 0xFEDC;
  10851. t['kafrafehebrew'] = 0xFB4D;
  10852. t['kagujarati'] = 0x0A95;
  10853. t['kagurmukhi'] = 0x0A15;
  10854. t['kahiragana'] = 0x304B;
  10855. t['kahookcyrillic'] = 0x04C4;
  10856. t['kakatakana'] = 0x30AB;
  10857. t['kakatakanahalfwidth'] = 0xFF76;
  10858. t['kappa'] = 0x03BA;
  10859. t['kappasymbolgreek'] = 0x03F0;
  10860. t['kapyeounmieumkorean'] = 0x3171;
  10861. t['kapyeounphieuphkorean'] = 0x3184;
  10862. t['kapyeounpieupkorean'] = 0x3178;
  10863. t['kapyeounssangpieupkorean'] = 0x3179;
  10864. t['karoriisquare'] = 0x330D;
  10865. t['kashidaautoarabic'] = 0x0640;
  10866. t['kashidaautonosidebearingarabic'] = 0x0640;
  10867. t['kasmallkatakana'] = 0x30F5;
  10868. t['kasquare'] = 0x3384;
  10869. t['kasraarabic'] = 0x0650;
  10870. t['kasratanarabic'] = 0x064D;
  10871. t['kastrokecyrillic'] = 0x049F;
  10872. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10873. t['kaverticalstrokecyrillic'] = 0x049D;
  10874. t['kbopomofo'] = 0x310E;
  10875. t['kcalsquare'] = 0x3389;
  10876. t['kcaron'] = 0x01E9;
  10877. t['kcedilla'] = 0x0137;
  10878. t['kcircle'] = 0x24DA;
  10879. t['kcommaaccent'] = 0x0137;
  10880. t['kdotbelow'] = 0x1E33;
  10881. t['keharmenian'] = 0x0584;
  10882. t['kehiragana'] = 0x3051;
  10883. t['kekatakana'] = 0x30B1;
  10884. t['kekatakanahalfwidth'] = 0xFF79;
  10885. t['kenarmenian'] = 0x056F;
  10886. t['kesmallkatakana'] = 0x30F6;
  10887. t['kgreenlandic'] = 0x0138;
  10888. t['khabengali'] = 0x0996;
  10889. t['khacyrillic'] = 0x0445;
  10890. t['khadeva'] = 0x0916;
  10891. t['khagujarati'] = 0x0A96;
  10892. t['khagurmukhi'] = 0x0A16;
  10893. t['khaharabic'] = 0x062E;
  10894. t['khahfinalarabic'] = 0xFEA6;
  10895. t['khahinitialarabic'] = 0xFEA7;
  10896. t['khahmedialarabic'] = 0xFEA8;
  10897. t['kheicoptic'] = 0x03E7;
  10898. t['khhadeva'] = 0x0959;
  10899. t['khhagurmukhi'] = 0x0A59;
  10900. t['khieukhacirclekorean'] = 0x3278;
  10901. t['khieukhaparenkorean'] = 0x3218;
  10902. t['khieukhcirclekorean'] = 0x326A;
  10903. t['khieukhkorean'] = 0x314B;
  10904. t['khieukhparenkorean'] = 0x320A;
  10905. t['khokhaithai'] = 0x0E02;
  10906. t['khokhonthai'] = 0x0E05;
  10907. t['khokhuatthai'] = 0x0E03;
  10908. t['khokhwaithai'] = 0x0E04;
  10909. t['khomutthai'] = 0x0E5B;
  10910. t['khook'] = 0x0199;
  10911. t['khorakhangthai'] = 0x0E06;
  10912. t['khzsquare'] = 0x3391;
  10913. t['kihiragana'] = 0x304D;
  10914. t['kikatakana'] = 0x30AD;
  10915. t['kikatakanahalfwidth'] = 0xFF77;
  10916. t['kiroguramusquare'] = 0x3315;
  10917. t['kiromeetorusquare'] = 0x3316;
  10918. t['kirosquare'] = 0x3314;
  10919. t['kiyeokacirclekorean'] = 0x326E;
  10920. t['kiyeokaparenkorean'] = 0x320E;
  10921. t['kiyeokcirclekorean'] = 0x3260;
  10922. t['kiyeokkorean'] = 0x3131;
  10923. t['kiyeokparenkorean'] = 0x3200;
  10924. t['kiyeoksioskorean'] = 0x3133;
  10925. t['kjecyrillic'] = 0x045C;
  10926. t['klinebelow'] = 0x1E35;
  10927. t['klsquare'] = 0x3398;
  10928. t['kmcubedsquare'] = 0x33A6;
  10929. t['kmonospace'] = 0xFF4B;
  10930. t['kmsquaredsquare'] = 0x33A2;
  10931. t['kohiragana'] = 0x3053;
  10932. t['kohmsquare'] = 0x33C0;
  10933. t['kokaithai'] = 0x0E01;
  10934. t['kokatakana'] = 0x30B3;
  10935. t['kokatakanahalfwidth'] = 0xFF7A;
  10936. t['kooposquare'] = 0x331E;
  10937. t['koppacyrillic'] = 0x0481;
  10938. t['koreanstandardsymbol'] = 0x327F;
  10939. t['koroniscmb'] = 0x0343;
  10940. t['kparen'] = 0x24A6;
  10941. t['kpasquare'] = 0x33AA;
  10942. t['ksicyrillic'] = 0x046F;
  10943. t['ktsquare'] = 0x33CF;
  10944. t['kturned'] = 0x029E;
  10945. t['kuhiragana'] = 0x304F;
  10946. t['kukatakana'] = 0x30AF;
  10947. t['kukatakanahalfwidth'] = 0xFF78;
  10948. t['kvsquare'] = 0x33B8;
  10949. t['kwsquare'] = 0x33BE;
  10950. t['l'] = 0x006C;
  10951. t['labengali'] = 0x09B2;
  10952. t['lacute'] = 0x013A;
  10953. t['ladeva'] = 0x0932;
  10954. t['lagujarati'] = 0x0AB2;
  10955. t['lagurmukhi'] = 0x0A32;
  10956. t['lakkhangyaothai'] = 0x0E45;
  10957. t['lamaleffinalarabic'] = 0xFEFC;
  10958. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10959. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10960. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10961. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10962. t['lamalefisolatedarabic'] = 0xFEFB;
  10963. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10964. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10965. t['lamarabic'] = 0x0644;
  10966. t['lambda'] = 0x03BB;
  10967. t['lambdastroke'] = 0x019B;
  10968. t['lamed'] = 0x05DC;
  10969. t['lameddagesh'] = 0xFB3C;
  10970. t['lameddageshhebrew'] = 0xFB3C;
  10971. t['lamedhebrew'] = 0x05DC;
  10972. t['lamfinalarabic'] = 0xFEDE;
  10973. t['lamhahinitialarabic'] = 0xFCCA;
  10974. t['laminitialarabic'] = 0xFEDF;
  10975. t['lamjeeminitialarabic'] = 0xFCC9;
  10976. t['lamkhahinitialarabic'] = 0xFCCB;
  10977. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10978. t['lammedialarabic'] = 0xFEE0;
  10979. t['lammeemhahinitialarabic'] = 0xFD88;
  10980. t['lammeeminitialarabic'] = 0xFCCC;
  10981. t['largecircle'] = 0x25EF;
  10982. t['lbar'] = 0x019A;
  10983. t['lbelt'] = 0x026C;
  10984. t['lbopomofo'] = 0x310C;
  10985. t['lcaron'] = 0x013E;
  10986. t['lcedilla'] = 0x013C;
  10987. t['lcircle'] = 0x24DB;
  10988. t['lcircumflexbelow'] = 0x1E3D;
  10989. t['lcommaaccent'] = 0x013C;
  10990. t['ldot'] = 0x0140;
  10991. t['ldotaccent'] = 0x0140;
  10992. t['ldotbelow'] = 0x1E37;
  10993. t['ldotbelowmacron'] = 0x1E39;
  10994. t['leftangleabovecmb'] = 0x031A;
  10995. t['lefttackbelowcmb'] = 0x0318;
  10996. t['less'] = 0x003C;
  10997. t['lessequal'] = 0x2264;
  10998. t['lessequalorgreater'] = 0x22DA;
  10999. t['lessmonospace'] = 0xFF1C;
  11000. t['lessorequivalent'] = 0x2272;
  11001. t['lessorgreater'] = 0x2276;
  11002. t['lessoverequal'] = 0x2266;
  11003. t['lesssmall'] = 0xFE64;
  11004. t['lezh'] = 0x026E;
  11005. t['lfblock'] = 0x258C;
  11006. t['lhookretroflex'] = 0x026D;
  11007. t['lira'] = 0x20A4;
  11008. t['liwnarmenian'] = 0x056C;
  11009. t['lj'] = 0x01C9;
  11010. t['ljecyrillic'] = 0x0459;
  11011. t['ll'] = 0xF6C0;
  11012. t['lladeva'] = 0x0933;
  11013. t['llagujarati'] = 0x0AB3;
  11014. t['llinebelow'] = 0x1E3B;
  11015. t['llladeva'] = 0x0934;
  11016. t['llvocalicbengali'] = 0x09E1;
  11017. t['llvocalicdeva'] = 0x0961;
  11018. t['llvocalicvowelsignbengali'] = 0x09E3;
  11019. t['llvocalicvowelsigndeva'] = 0x0963;
  11020. t['lmiddletilde'] = 0x026B;
  11021. t['lmonospace'] = 0xFF4C;
  11022. t['lmsquare'] = 0x33D0;
  11023. t['lochulathai'] = 0x0E2C;
  11024. t['logicaland'] = 0x2227;
  11025. t['logicalnot'] = 0x00AC;
  11026. t['logicalnotreversed'] = 0x2310;
  11027. t['logicalor'] = 0x2228;
  11028. t['lolingthai'] = 0x0E25;
  11029. t['longs'] = 0x017F;
  11030. t['lowlinecenterline'] = 0xFE4E;
  11031. t['lowlinecmb'] = 0x0332;
  11032. t['lowlinedashed'] = 0xFE4D;
  11033. t['lozenge'] = 0x25CA;
  11034. t['lparen'] = 0x24A7;
  11035. t['lslash'] = 0x0142;
  11036. t['lsquare'] = 0x2113;
  11037. t['lsuperior'] = 0xF6EE;
  11038. t['ltshade'] = 0x2591;
  11039. t['luthai'] = 0x0E26;
  11040. t['lvocalicbengali'] = 0x098C;
  11041. t['lvocalicdeva'] = 0x090C;
  11042. t['lvocalicvowelsignbengali'] = 0x09E2;
  11043. t['lvocalicvowelsigndeva'] = 0x0962;
  11044. t['lxsquare'] = 0x33D3;
  11045. t['m'] = 0x006D;
  11046. t['mabengali'] = 0x09AE;
  11047. t['macron'] = 0x00AF;
  11048. t['macronbelowcmb'] = 0x0331;
  11049. t['macroncmb'] = 0x0304;
  11050. t['macronlowmod'] = 0x02CD;
  11051. t['macronmonospace'] = 0xFFE3;
  11052. t['macute'] = 0x1E3F;
  11053. t['madeva'] = 0x092E;
  11054. t['magujarati'] = 0x0AAE;
  11055. t['magurmukhi'] = 0x0A2E;
  11056. t['mahapakhhebrew'] = 0x05A4;
  11057. t['mahapakhlefthebrew'] = 0x05A4;
  11058. t['mahiragana'] = 0x307E;
  11059. t['maichattawalowleftthai'] = 0xF895;
  11060. t['maichattawalowrightthai'] = 0xF894;
  11061. t['maichattawathai'] = 0x0E4B;
  11062. t['maichattawaupperleftthai'] = 0xF893;
  11063. t['maieklowleftthai'] = 0xF88C;
  11064. t['maieklowrightthai'] = 0xF88B;
  11065. t['maiekthai'] = 0x0E48;
  11066. t['maiekupperleftthai'] = 0xF88A;
  11067. t['maihanakatleftthai'] = 0xF884;
  11068. t['maihanakatthai'] = 0x0E31;
  11069. t['maitaikhuleftthai'] = 0xF889;
  11070. t['maitaikhuthai'] = 0x0E47;
  11071. t['maitholowleftthai'] = 0xF88F;
  11072. t['maitholowrightthai'] = 0xF88E;
  11073. t['maithothai'] = 0x0E49;
  11074. t['maithoupperleftthai'] = 0xF88D;
  11075. t['maitrilowleftthai'] = 0xF892;
  11076. t['maitrilowrightthai'] = 0xF891;
  11077. t['maitrithai'] = 0x0E4A;
  11078. t['maitriupperleftthai'] = 0xF890;
  11079. t['maiyamokthai'] = 0x0E46;
  11080. t['makatakana'] = 0x30DE;
  11081. t['makatakanahalfwidth'] = 0xFF8F;
  11082. t['male'] = 0x2642;
  11083. t['mansyonsquare'] = 0x3347;
  11084. t['maqafhebrew'] = 0x05BE;
  11085. t['mars'] = 0x2642;
  11086. t['masoracirclehebrew'] = 0x05AF;
  11087. t['masquare'] = 0x3383;
  11088. t['mbopomofo'] = 0x3107;
  11089. t['mbsquare'] = 0x33D4;
  11090. t['mcircle'] = 0x24DC;
  11091. t['mcubedsquare'] = 0x33A5;
  11092. t['mdotaccent'] = 0x1E41;
  11093. t['mdotbelow'] = 0x1E43;
  11094. t['meemarabic'] = 0x0645;
  11095. t['meemfinalarabic'] = 0xFEE2;
  11096. t['meeminitialarabic'] = 0xFEE3;
  11097. t['meemmedialarabic'] = 0xFEE4;
  11098. t['meemmeeminitialarabic'] = 0xFCD1;
  11099. t['meemmeemisolatedarabic'] = 0xFC48;
  11100. t['meetorusquare'] = 0x334D;
  11101. t['mehiragana'] = 0x3081;
  11102. t['meizierasquare'] = 0x337E;
  11103. t['mekatakana'] = 0x30E1;
  11104. t['mekatakanahalfwidth'] = 0xFF92;
  11105. t['mem'] = 0x05DE;
  11106. t['memdagesh'] = 0xFB3E;
  11107. t['memdageshhebrew'] = 0xFB3E;
  11108. t['memhebrew'] = 0x05DE;
  11109. t['menarmenian'] = 0x0574;
  11110. t['merkhahebrew'] = 0x05A5;
  11111. t['merkhakefulahebrew'] = 0x05A6;
  11112. t['merkhakefulalefthebrew'] = 0x05A6;
  11113. t['merkhalefthebrew'] = 0x05A5;
  11114. t['mhook'] = 0x0271;
  11115. t['mhzsquare'] = 0x3392;
  11116. t['middledotkatakanahalfwidth'] = 0xFF65;
  11117. t['middot'] = 0x00B7;
  11118. t['mieumacirclekorean'] = 0x3272;
  11119. t['mieumaparenkorean'] = 0x3212;
  11120. t['mieumcirclekorean'] = 0x3264;
  11121. t['mieumkorean'] = 0x3141;
  11122. t['mieumpansioskorean'] = 0x3170;
  11123. t['mieumparenkorean'] = 0x3204;
  11124. t['mieumpieupkorean'] = 0x316E;
  11125. t['mieumsioskorean'] = 0x316F;
  11126. t['mihiragana'] = 0x307F;
  11127. t['mikatakana'] = 0x30DF;
  11128. t['mikatakanahalfwidth'] = 0xFF90;
  11129. t['minus'] = 0x2212;
  11130. t['minusbelowcmb'] = 0x0320;
  11131. t['minuscircle'] = 0x2296;
  11132. t['minusmod'] = 0x02D7;
  11133. t['minusplus'] = 0x2213;
  11134. t['minute'] = 0x2032;
  11135. t['miribaarusquare'] = 0x334A;
  11136. t['mirisquare'] = 0x3349;
  11137. t['mlonglegturned'] = 0x0270;
  11138. t['mlsquare'] = 0x3396;
  11139. t['mmcubedsquare'] = 0x33A3;
  11140. t['mmonospace'] = 0xFF4D;
  11141. t['mmsquaredsquare'] = 0x339F;
  11142. t['mohiragana'] = 0x3082;
  11143. t['mohmsquare'] = 0x33C1;
  11144. t['mokatakana'] = 0x30E2;
  11145. t['mokatakanahalfwidth'] = 0xFF93;
  11146. t['molsquare'] = 0x33D6;
  11147. t['momathai'] = 0x0E21;
  11148. t['moverssquare'] = 0x33A7;
  11149. t['moverssquaredsquare'] = 0x33A8;
  11150. t['mparen'] = 0x24A8;
  11151. t['mpasquare'] = 0x33AB;
  11152. t['mssquare'] = 0x33B3;
  11153. t['msuperior'] = 0xF6EF;
  11154. t['mturned'] = 0x026F;
  11155. t['mu'] = 0x00B5;
  11156. t['mu1'] = 0x00B5;
  11157. t['muasquare'] = 0x3382;
  11158. t['muchgreater'] = 0x226B;
  11159. t['muchless'] = 0x226A;
  11160. t['mufsquare'] = 0x338C;
  11161. t['mugreek'] = 0x03BC;
  11162. t['mugsquare'] = 0x338D;
  11163. t['muhiragana'] = 0x3080;
  11164. t['mukatakana'] = 0x30E0;
  11165. t['mukatakanahalfwidth'] = 0xFF91;
  11166. t['mulsquare'] = 0x3395;
  11167. t['multiply'] = 0x00D7;
  11168. t['mumsquare'] = 0x339B;
  11169. t['munahhebrew'] = 0x05A3;
  11170. t['munahlefthebrew'] = 0x05A3;
  11171. t['musicalnote'] = 0x266A;
  11172. t['musicalnotedbl'] = 0x266B;
  11173. t['musicflatsign'] = 0x266D;
  11174. t['musicsharpsign'] = 0x266F;
  11175. t['mussquare'] = 0x33B2;
  11176. t['muvsquare'] = 0x33B6;
  11177. t['muwsquare'] = 0x33BC;
  11178. t['mvmegasquare'] = 0x33B9;
  11179. t['mvsquare'] = 0x33B7;
  11180. t['mwmegasquare'] = 0x33BF;
  11181. t['mwsquare'] = 0x33BD;
  11182. t['n'] = 0x006E;
  11183. t['nabengali'] = 0x09A8;
  11184. t['nabla'] = 0x2207;
  11185. t['nacute'] = 0x0144;
  11186. t['nadeva'] = 0x0928;
  11187. t['nagujarati'] = 0x0AA8;
  11188. t['nagurmukhi'] = 0x0A28;
  11189. t['nahiragana'] = 0x306A;
  11190. t['nakatakana'] = 0x30CA;
  11191. t['nakatakanahalfwidth'] = 0xFF85;
  11192. t['napostrophe'] = 0x0149;
  11193. t['nasquare'] = 0x3381;
  11194. t['nbopomofo'] = 0x310B;
  11195. t['nbspace'] = 0x00A0;
  11196. t['ncaron'] = 0x0148;
  11197. t['ncedilla'] = 0x0146;
  11198. t['ncircle'] = 0x24DD;
  11199. t['ncircumflexbelow'] = 0x1E4B;
  11200. t['ncommaaccent'] = 0x0146;
  11201. t['ndotaccent'] = 0x1E45;
  11202. t['ndotbelow'] = 0x1E47;
  11203. t['nehiragana'] = 0x306D;
  11204. t['nekatakana'] = 0x30CD;
  11205. t['nekatakanahalfwidth'] = 0xFF88;
  11206. t['newsheqelsign'] = 0x20AA;
  11207. t['nfsquare'] = 0x338B;
  11208. t['ngabengali'] = 0x0999;
  11209. t['ngadeva'] = 0x0919;
  11210. t['ngagujarati'] = 0x0A99;
  11211. t['ngagurmukhi'] = 0x0A19;
  11212. t['ngonguthai'] = 0x0E07;
  11213. t['nhiragana'] = 0x3093;
  11214. t['nhookleft'] = 0x0272;
  11215. t['nhookretroflex'] = 0x0273;
  11216. t['nieunacirclekorean'] = 0x326F;
  11217. t['nieunaparenkorean'] = 0x320F;
  11218. t['nieuncieuckorean'] = 0x3135;
  11219. t['nieuncirclekorean'] = 0x3261;
  11220. t['nieunhieuhkorean'] = 0x3136;
  11221. t['nieunkorean'] = 0x3134;
  11222. t['nieunpansioskorean'] = 0x3168;
  11223. t['nieunparenkorean'] = 0x3201;
  11224. t['nieunsioskorean'] = 0x3167;
  11225. t['nieuntikeutkorean'] = 0x3166;
  11226. t['nihiragana'] = 0x306B;
  11227. t['nikatakana'] = 0x30CB;
  11228. t['nikatakanahalfwidth'] = 0xFF86;
  11229. t['nikhahitleftthai'] = 0xF899;
  11230. t['nikhahitthai'] = 0x0E4D;
  11231. t['nine'] = 0x0039;
  11232. t['ninearabic'] = 0x0669;
  11233. t['ninebengali'] = 0x09EF;
  11234. t['ninecircle'] = 0x2468;
  11235. t['ninecircleinversesansserif'] = 0x2792;
  11236. t['ninedeva'] = 0x096F;
  11237. t['ninegujarati'] = 0x0AEF;
  11238. t['ninegurmukhi'] = 0x0A6F;
  11239. t['ninehackarabic'] = 0x0669;
  11240. t['ninehangzhou'] = 0x3029;
  11241. t['nineideographicparen'] = 0x3228;
  11242. t['nineinferior'] = 0x2089;
  11243. t['ninemonospace'] = 0xFF19;
  11244. t['nineoldstyle'] = 0xF739;
  11245. t['nineparen'] = 0x247C;
  11246. t['nineperiod'] = 0x2490;
  11247. t['ninepersian'] = 0x06F9;
  11248. t['nineroman'] = 0x2178;
  11249. t['ninesuperior'] = 0x2079;
  11250. t['nineteencircle'] = 0x2472;
  11251. t['nineteenparen'] = 0x2486;
  11252. t['nineteenperiod'] = 0x249A;
  11253. t['ninethai'] = 0x0E59;
  11254. t['nj'] = 0x01CC;
  11255. t['njecyrillic'] = 0x045A;
  11256. t['nkatakana'] = 0x30F3;
  11257. t['nkatakanahalfwidth'] = 0xFF9D;
  11258. t['nlegrightlong'] = 0x019E;
  11259. t['nlinebelow'] = 0x1E49;
  11260. t['nmonospace'] = 0xFF4E;
  11261. t['nmsquare'] = 0x339A;
  11262. t['nnabengali'] = 0x09A3;
  11263. t['nnadeva'] = 0x0923;
  11264. t['nnagujarati'] = 0x0AA3;
  11265. t['nnagurmukhi'] = 0x0A23;
  11266. t['nnnadeva'] = 0x0929;
  11267. t['nohiragana'] = 0x306E;
  11268. t['nokatakana'] = 0x30CE;
  11269. t['nokatakanahalfwidth'] = 0xFF89;
  11270. t['nonbreakingspace'] = 0x00A0;
  11271. t['nonenthai'] = 0x0E13;
  11272. t['nonuthai'] = 0x0E19;
  11273. t['noonarabic'] = 0x0646;
  11274. t['noonfinalarabic'] = 0xFEE6;
  11275. t['noonghunnaarabic'] = 0x06BA;
  11276. t['noonghunnafinalarabic'] = 0xFB9F;
  11277. t['nooninitialarabic'] = 0xFEE7;
  11278. t['noonjeeminitialarabic'] = 0xFCD2;
  11279. t['noonjeemisolatedarabic'] = 0xFC4B;
  11280. t['noonmedialarabic'] = 0xFEE8;
  11281. t['noonmeeminitialarabic'] = 0xFCD5;
  11282. t['noonmeemisolatedarabic'] = 0xFC4E;
  11283. t['noonnoonfinalarabic'] = 0xFC8D;
  11284. t['notcontains'] = 0x220C;
  11285. t['notelement'] = 0x2209;
  11286. t['notelementof'] = 0x2209;
  11287. t['notequal'] = 0x2260;
  11288. t['notgreater'] = 0x226F;
  11289. t['notgreaternorequal'] = 0x2271;
  11290. t['notgreaternorless'] = 0x2279;
  11291. t['notidentical'] = 0x2262;
  11292. t['notless'] = 0x226E;
  11293. t['notlessnorequal'] = 0x2270;
  11294. t['notparallel'] = 0x2226;
  11295. t['notprecedes'] = 0x2280;
  11296. t['notsubset'] = 0x2284;
  11297. t['notsucceeds'] = 0x2281;
  11298. t['notsuperset'] = 0x2285;
  11299. t['nowarmenian'] = 0x0576;
  11300. t['nparen'] = 0x24A9;
  11301. t['nssquare'] = 0x33B1;
  11302. t['nsuperior'] = 0x207F;
  11303. t['ntilde'] = 0x00F1;
  11304. t['nu'] = 0x03BD;
  11305. t['nuhiragana'] = 0x306C;
  11306. t['nukatakana'] = 0x30CC;
  11307. t['nukatakanahalfwidth'] = 0xFF87;
  11308. t['nuktabengali'] = 0x09BC;
  11309. t['nuktadeva'] = 0x093C;
  11310. t['nuktagujarati'] = 0x0ABC;
  11311. t['nuktagurmukhi'] = 0x0A3C;
  11312. t['numbersign'] = 0x0023;
  11313. t['numbersignmonospace'] = 0xFF03;
  11314. t['numbersignsmall'] = 0xFE5F;
  11315. t['numeralsigngreek'] = 0x0374;
  11316. t['numeralsignlowergreek'] = 0x0375;
  11317. t['numero'] = 0x2116;
  11318. t['nun'] = 0x05E0;
  11319. t['nundagesh'] = 0xFB40;
  11320. t['nundageshhebrew'] = 0xFB40;
  11321. t['nunhebrew'] = 0x05E0;
  11322. t['nvsquare'] = 0x33B5;
  11323. t['nwsquare'] = 0x33BB;
  11324. t['nyabengali'] = 0x099E;
  11325. t['nyadeva'] = 0x091E;
  11326. t['nyagujarati'] = 0x0A9E;
  11327. t['nyagurmukhi'] = 0x0A1E;
  11328. t['o'] = 0x006F;
  11329. t['oacute'] = 0x00F3;
  11330. t['oangthai'] = 0x0E2D;
  11331. t['obarred'] = 0x0275;
  11332. t['obarredcyrillic'] = 0x04E9;
  11333. t['obarreddieresiscyrillic'] = 0x04EB;
  11334. t['obengali'] = 0x0993;
  11335. t['obopomofo'] = 0x311B;
  11336. t['obreve'] = 0x014F;
  11337. t['ocandradeva'] = 0x0911;
  11338. t['ocandragujarati'] = 0x0A91;
  11339. t['ocandravowelsigndeva'] = 0x0949;
  11340. t['ocandravowelsigngujarati'] = 0x0AC9;
  11341. t['ocaron'] = 0x01D2;
  11342. t['ocircle'] = 0x24DE;
  11343. t['ocircumflex'] = 0x00F4;
  11344. t['ocircumflexacute'] = 0x1ED1;
  11345. t['ocircumflexdotbelow'] = 0x1ED9;
  11346. t['ocircumflexgrave'] = 0x1ED3;
  11347. t['ocircumflexhookabove'] = 0x1ED5;
  11348. t['ocircumflextilde'] = 0x1ED7;
  11349. t['ocyrillic'] = 0x043E;
  11350. t['odblacute'] = 0x0151;
  11351. t['odblgrave'] = 0x020D;
  11352. t['odeva'] = 0x0913;
  11353. t['odieresis'] = 0x00F6;
  11354. t['odieresiscyrillic'] = 0x04E7;
  11355. t['odotbelow'] = 0x1ECD;
  11356. t['oe'] = 0x0153;
  11357. t['oekorean'] = 0x315A;
  11358. t['ogonek'] = 0x02DB;
  11359. t['ogonekcmb'] = 0x0328;
  11360. t['ograve'] = 0x00F2;
  11361. t['ogujarati'] = 0x0A93;
  11362. t['oharmenian'] = 0x0585;
  11363. t['ohiragana'] = 0x304A;
  11364. t['ohookabove'] = 0x1ECF;
  11365. t['ohorn'] = 0x01A1;
  11366. t['ohornacute'] = 0x1EDB;
  11367. t['ohorndotbelow'] = 0x1EE3;
  11368. t['ohorngrave'] = 0x1EDD;
  11369. t['ohornhookabove'] = 0x1EDF;
  11370. t['ohorntilde'] = 0x1EE1;
  11371. t['ohungarumlaut'] = 0x0151;
  11372. t['oi'] = 0x01A3;
  11373. t['oinvertedbreve'] = 0x020F;
  11374. t['okatakana'] = 0x30AA;
  11375. t['okatakanahalfwidth'] = 0xFF75;
  11376. t['okorean'] = 0x3157;
  11377. t['olehebrew'] = 0x05AB;
  11378. t['omacron'] = 0x014D;
  11379. t['omacronacute'] = 0x1E53;
  11380. t['omacrongrave'] = 0x1E51;
  11381. t['omdeva'] = 0x0950;
  11382. t['omega'] = 0x03C9;
  11383. t['omega1'] = 0x03D6;
  11384. t['omegacyrillic'] = 0x0461;
  11385. t['omegalatinclosed'] = 0x0277;
  11386. t['omegaroundcyrillic'] = 0x047B;
  11387. t['omegatitlocyrillic'] = 0x047D;
  11388. t['omegatonos'] = 0x03CE;
  11389. t['omgujarati'] = 0x0AD0;
  11390. t['omicron'] = 0x03BF;
  11391. t['omicrontonos'] = 0x03CC;
  11392. t['omonospace'] = 0xFF4F;
  11393. t['one'] = 0x0031;
  11394. t['onearabic'] = 0x0661;
  11395. t['onebengali'] = 0x09E7;
  11396. t['onecircle'] = 0x2460;
  11397. t['onecircleinversesansserif'] = 0x278A;
  11398. t['onedeva'] = 0x0967;
  11399. t['onedotenleader'] = 0x2024;
  11400. t['oneeighth'] = 0x215B;
  11401. t['onefitted'] = 0xF6DC;
  11402. t['onegujarati'] = 0x0AE7;
  11403. t['onegurmukhi'] = 0x0A67;
  11404. t['onehackarabic'] = 0x0661;
  11405. t['onehalf'] = 0x00BD;
  11406. t['onehangzhou'] = 0x3021;
  11407. t['oneideographicparen'] = 0x3220;
  11408. t['oneinferior'] = 0x2081;
  11409. t['onemonospace'] = 0xFF11;
  11410. t['onenumeratorbengali'] = 0x09F4;
  11411. t['oneoldstyle'] = 0xF731;
  11412. t['oneparen'] = 0x2474;
  11413. t['oneperiod'] = 0x2488;
  11414. t['onepersian'] = 0x06F1;
  11415. t['onequarter'] = 0x00BC;
  11416. t['oneroman'] = 0x2170;
  11417. t['onesuperior'] = 0x00B9;
  11418. t['onethai'] = 0x0E51;
  11419. t['onethird'] = 0x2153;
  11420. t['oogonek'] = 0x01EB;
  11421. t['oogonekmacron'] = 0x01ED;
  11422. t['oogurmukhi'] = 0x0A13;
  11423. t['oomatragurmukhi'] = 0x0A4B;
  11424. t['oopen'] = 0x0254;
  11425. t['oparen'] = 0x24AA;
  11426. t['openbullet'] = 0x25E6;
  11427. t['option'] = 0x2325;
  11428. t['ordfeminine'] = 0x00AA;
  11429. t['ordmasculine'] = 0x00BA;
  11430. t['orthogonal'] = 0x221F;
  11431. t['oshortdeva'] = 0x0912;
  11432. t['oshortvowelsigndeva'] = 0x094A;
  11433. t['oslash'] = 0x00F8;
  11434. t['oslashacute'] = 0x01FF;
  11435. t['osmallhiragana'] = 0x3049;
  11436. t['osmallkatakana'] = 0x30A9;
  11437. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11438. t['ostrokeacute'] = 0x01FF;
  11439. t['osuperior'] = 0xF6F0;
  11440. t['otcyrillic'] = 0x047F;
  11441. t['otilde'] = 0x00F5;
  11442. t['otildeacute'] = 0x1E4D;
  11443. t['otildedieresis'] = 0x1E4F;
  11444. t['oubopomofo'] = 0x3121;
  11445. t['overline'] = 0x203E;
  11446. t['overlinecenterline'] = 0xFE4A;
  11447. t['overlinecmb'] = 0x0305;
  11448. t['overlinedashed'] = 0xFE49;
  11449. t['overlinedblwavy'] = 0xFE4C;
  11450. t['overlinewavy'] = 0xFE4B;
  11451. t['overscore'] = 0x00AF;
  11452. t['ovowelsignbengali'] = 0x09CB;
  11453. t['ovowelsigndeva'] = 0x094B;
  11454. t['ovowelsigngujarati'] = 0x0ACB;
  11455. t['p'] = 0x0070;
  11456. t['paampssquare'] = 0x3380;
  11457. t['paasentosquare'] = 0x332B;
  11458. t['pabengali'] = 0x09AA;
  11459. t['pacute'] = 0x1E55;
  11460. t['padeva'] = 0x092A;
  11461. t['pagedown'] = 0x21DF;
  11462. t['pageup'] = 0x21DE;
  11463. t['pagujarati'] = 0x0AAA;
  11464. t['pagurmukhi'] = 0x0A2A;
  11465. t['pahiragana'] = 0x3071;
  11466. t['paiyannoithai'] = 0x0E2F;
  11467. t['pakatakana'] = 0x30D1;
  11468. t['palatalizationcyrilliccmb'] = 0x0484;
  11469. t['palochkacyrillic'] = 0x04C0;
  11470. t['pansioskorean'] = 0x317F;
  11471. t['paragraph'] = 0x00B6;
  11472. t['parallel'] = 0x2225;
  11473. t['parenleft'] = 0x0028;
  11474. t['parenleftaltonearabic'] = 0xFD3E;
  11475. t['parenleftbt'] = 0xF8ED;
  11476. t['parenleftex'] = 0xF8EC;
  11477. t['parenleftinferior'] = 0x208D;
  11478. t['parenleftmonospace'] = 0xFF08;
  11479. t['parenleftsmall'] = 0xFE59;
  11480. t['parenleftsuperior'] = 0x207D;
  11481. t['parenlefttp'] = 0xF8EB;
  11482. t['parenleftvertical'] = 0xFE35;
  11483. t['parenright'] = 0x0029;
  11484. t['parenrightaltonearabic'] = 0xFD3F;
  11485. t['parenrightbt'] = 0xF8F8;
  11486. t['parenrightex'] = 0xF8F7;
  11487. t['parenrightinferior'] = 0x208E;
  11488. t['parenrightmonospace'] = 0xFF09;
  11489. t['parenrightsmall'] = 0xFE5A;
  11490. t['parenrightsuperior'] = 0x207E;
  11491. t['parenrighttp'] = 0xF8F6;
  11492. t['parenrightvertical'] = 0xFE36;
  11493. t['partialdiff'] = 0x2202;
  11494. t['paseqhebrew'] = 0x05C0;
  11495. t['pashtahebrew'] = 0x0599;
  11496. t['pasquare'] = 0x33A9;
  11497. t['patah'] = 0x05B7;
  11498. t['patah11'] = 0x05B7;
  11499. t['patah1d'] = 0x05B7;
  11500. t['patah2a'] = 0x05B7;
  11501. t['patahhebrew'] = 0x05B7;
  11502. t['patahnarrowhebrew'] = 0x05B7;
  11503. t['patahquarterhebrew'] = 0x05B7;
  11504. t['patahwidehebrew'] = 0x05B7;
  11505. t['pazerhebrew'] = 0x05A1;
  11506. t['pbopomofo'] = 0x3106;
  11507. t['pcircle'] = 0x24DF;
  11508. t['pdotaccent'] = 0x1E57;
  11509. t['pe'] = 0x05E4;
  11510. t['pecyrillic'] = 0x043F;
  11511. t['pedagesh'] = 0xFB44;
  11512. t['pedageshhebrew'] = 0xFB44;
  11513. t['peezisquare'] = 0x333B;
  11514. t['pefinaldageshhebrew'] = 0xFB43;
  11515. t['peharabic'] = 0x067E;
  11516. t['peharmenian'] = 0x057A;
  11517. t['pehebrew'] = 0x05E4;
  11518. t['pehfinalarabic'] = 0xFB57;
  11519. t['pehinitialarabic'] = 0xFB58;
  11520. t['pehiragana'] = 0x307A;
  11521. t['pehmedialarabic'] = 0xFB59;
  11522. t['pekatakana'] = 0x30DA;
  11523. t['pemiddlehookcyrillic'] = 0x04A7;
  11524. t['perafehebrew'] = 0xFB4E;
  11525. t['percent'] = 0x0025;
  11526. t['percentarabic'] = 0x066A;
  11527. t['percentmonospace'] = 0xFF05;
  11528. t['percentsmall'] = 0xFE6A;
  11529. t['period'] = 0x002E;
  11530. t['periodarmenian'] = 0x0589;
  11531. t['periodcentered'] = 0x00B7;
  11532. t['periodhalfwidth'] = 0xFF61;
  11533. t['periodinferior'] = 0xF6E7;
  11534. t['periodmonospace'] = 0xFF0E;
  11535. t['periodsmall'] = 0xFE52;
  11536. t['periodsuperior'] = 0xF6E8;
  11537. t['perispomenigreekcmb'] = 0x0342;
  11538. t['perpendicular'] = 0x22A5;
  11539. t['perthousand'] = 0x2030;
  11540. t['peseta'] = 0x20A7;
  11541. t['pfsquare'] = 0x338A;
  11542. t['phabengali'] = 0x09AB;
  11543. t['phadeva'] = 0x092B;
  11544. t['phagujarati'] = 0x0AAB;
  11545. t['phagurmukhi'] = 0x0A2B;
  11546. t['phi'] = 0x03C6;
  11547. t['phi1'] = 0x03D5;
  11548. t['phieuphacirclekorean'] = 0x327A;
  11549. t['phieuphaparenkorean'] = 0x321A;
  11550. t['phieuphcirclekorean'] = 0x326C;
  11551. t['phieuphkorean'] = 0x314D;
  11552. t['phieuphparenkorean'] = 0x320C;
  11553. t['philatin'] = 0x0278;
  11554. t['phinthuthai'] = 0x0E3A;
  11555. t['phisymbolgreek'] = 0x03D5;
  11556. t['phook'] = 0x01A5;
  11557. t['phophanthai'] = 0x0E1E;
  11558. t['phophungthai'] = 0x0E1C;
  11559. t['phosamphaothai'] = 0x0E20;
  11560. t['pi'] = 0x03C0;
  11561. t['pieupacirclekorean'] = 0x3273;
  11562. t['pieupaparenkorean'] = 0x3213;
  11563. t['pieupcieuckorean'] = 0x3176;
  11564. t['pieupcirclekorean'] = 0x3265;
  11565. t['pieupkiyeokkorean'] = 0x3172;
  11566. t['pieupkorean'] = 0x3142;
  11567. t['pieupparenkorean'] = 0x3205;
  11568. t['pieupsioskiyeokkorean'] = 0x3174;
  11569. t['pieupsioskorean'] = 0x3144;
  11570. t['pieupsiostikeutkorean'] = 0x3175;
  11571. t['pieupthieuthkorean'] = 0x3177;
  11572. t['pieuptikeutkorean'] = 0x3173;
  11573. t['pihiragana'] = 0x3074;
  11574. t['pikatakana'] = 0x30D4;
  11575. t['pisymbolgreek'] = 0x03D6;
  11576. t['piwrarmenian'] = 0x0583;
  11577. t['plus'] = 0x002B;
  11578. t['plusbelowcmb'] = 0x031F;
  11579. t['pluscircle'] = 0x2295;
  11580. t['plusminus'] = 0x00B1;
  11581. t['plusmod'] = 0x02D6;
  11582. t['plusmonospace'] = 0xFF0B;
  11583. t['plussmall'] = 0xFE62;
  11584. t['plussuperior'] = 0x207A;
  11585. t['pmonospace'] = 0xFF50;
  11586. t['pmsquare'] = 0x33D8;
  11587. t['pohiragana'] = 0x307D;
  11588. t['pointingindexdownwhite'] = 0x261F;
  11589. t['pointingindexleftwhite'] = 0x261C;
  11590. t['pointingindexrightwhite'] = 0x261E;
  11591. t['pointingindexupwhite'] = 0x261D;
  11592. t['pokatakana'] = 0x30DD;
  11593. t['poplathai'] = 0x0E1B;
  11594. t['postalmark'] = 0x3012;
  11595. t['postalmarkface'] = 0x3020;
  11596. t['pparen'] = 0x24AB;
  11597. t['precedes'] = 0x227A;
  11598. t['prescription'] = 0x211E;
  11599. t['primemod'] = 0x02B9;
  11600. t['primereversed'] = 0x2035;
  11601. t['product'] = 0x220F;
  11602. t['projective'] = 0x2305;
  11603. t['prolongedkana'] = 0x30FC;
  11604. t['propellor'] = 0x2318;
  11605. t['propersubset'] = 0x2282;
  11606. t['propersuperset'] = 0x2283;
  11607. t['proportion'] = 0x2237;
  11608. t['proportional'] = 0x221D;
  11609. t['psi'] = 0x03C8;
  11610. t['psicyrillic'] = 0x0471;
  11611. t['psilipneumatacyrilliccmb'] = 0x0486;
  11612. t['pssquare'] = 0x33B0;
  11613. t['puhiragana'] = 0x3077;
  11614. t['pukatakana'] = 0x30D7;
  11615. t['pvsquare'] = 0x33B4;
  11616. t['pwsquare'] = 0x33BA;
  11617. t['q'] = 0x0071;
  11618. t['qadeva'] = 0x0958;
  11619. t['qadmahebrew'] = 0x05A8;
  11620. t['qafarabic'] = 0x0642;
  11621. t['qaffinalarabic'] = 0xFED6;
  11622. t['qafinitialarabic'] = 0xFED7;
  11623. t['qafmedialarabic'] = 0xFED8;
  11624. t['qamats'] = 0x05B8;
  11625. t['qamats10'] = 0x05B8;
  11626. t['qamats1a'] = 0x05B8;
  11627. t['qamats1c'] = 0x05B8;
  11628. t['qamats27'] = 0x05B8;
  11629. t['qamats29'] = 0x05B8;
  11630. t['qamats33'] = 0x05B8;
  11631. t['qamatsde'] = 0x05B8;
  11632. t['qamatshebrew'] = 0x05B8;
  11633. t['qamatsnarrowhebrew'] = 0x05B8;
  11634. t['qamatsqatanhebrew'] = 0x05B8;
  11635. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11636. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11637. t['qamatsqatanwidehebrew'] = 0x05B8;
  11638. t['qamatsquarterhebrew'] = 0x05B8;
  11639. t['qamatswidehebrew'] = 0x05B8;
  11640. t['qarneyparahebrew'] = 0x059F;
  11641. t['qbopomofo'] = 0x3111;
  11642. t['qcircle'] = 0x24E0;
  11643. t['qhook'] = 0x02A0;
  11644. t['qmonospace'] = 0xFF51;
  11645. t['qof'] = 0x05E7;
  11646. t['qofdagesh'] = 0xFB47;
  11647. t['qofdageshhebrew'] = 0xFB47;
  11648. t['qofhebrew'] = 0x05E7;
  11649. t['qparen'] = 0x24AC;
  11650. t['quarternote'] = 0x2669;
  11651. t['qubuts'] = 0x05BB;
  11652. t['qubuts18'] = 0x05BB;
  11653. t['qubuts25'] = 0x05BB;
  11654. t['qubuts31'] = 0x05BB;
  11655. t['qubutshebrew'] = 0x05BB;
  11656. t['qubutsnarrowhebrew'] = 0x05BB;
  11657. t['qubutsquarterhebrew'] = 0x05BB;
  11658. t['qubutswidehebrew'] = 0x05BB;
  11659. t['question'] = 0x003F;
  11660. t['questionarabic'] = 0x061F;
  11661. t['questionarmenian'] = 0x055E;
  11662. t['questiondown'] = 0x00BF;
  11663. t['questiondownsmall'] = 0xF7BF;
  11664. t['questiongreek'] = 0x037E;
  11665. t['questionmonospace'] = 0xFF1F;
  11666. t['questionsmall'] = 0xF73F;
  11667. t['quotedbl'] = 0x0022;
  11668. t['quotedblbase'] = 0x201E;
  11669. t['quotedblleft'] = 0x201C;
  11670. t['quotedblmonospace'] = 0xFF02;
  11671. t['quotedblprime'] = 0x301E;
  11672. t['quotedblprimereversed'] = 0x301D;
  11673. t['quotedblright'] = 0x201D;
  11674. t['quoteleft'] = 0x2018;
  11675. t['quoteleftreversed'] = 0x201B;
  11676. t['quotereversed'] = 0x201B;
  11677. t['quoteright'] = 0x2019;
  11678. t['quoterightn'] = 0x0149;
  11679. t['quotesinglbase'] = 0x201A;
  11680. t['quotesingle'] = 0x0027;
  11681. t['quotesinglemonospace'] = 0xFF07;
  11682. t['r'] = 0x0072;
  11683. t['raarmenian'] = 0x057C;
  11684. t['rabengali'] = 0x09B0;
  11685. t['racute'] = 0x0155;
  11686. t['radeva'] = 0x0930;
  11687. t['radical'] = 0x221A;
  11688. t['radicalex'] = 0xF8E5;
  11689. t['radoverssquare'] = 0x33AE;
  11690. t['radoverssquaredsquare'] = 0x33AF;
  11691. t['radsquare'] = 0x33AD;
  11692. t['rafe'] = 0x05BF;
  11693. t['rafehebrew'] = 0x05BF;
  11694. t['ragujarati'] = 0x0AB0;
  11695. t['ragurmukhi'] = 0x0A30;
  11696. t['rahiragana'] = 0x3089;
  11697. t['rakatakana'] = 0x30E9;
  11698. t['rakatakanahalfwidth'] = 0xFF97;
  11699. t['ralowerdiagonalbengali'] = 0x09F1;
  11700. t['ramiddlediagonalbengali'] = 0x09F0;
  11701. t['ramshorn'] = 0x0264;
  11702. t['ratio'] = 0x2236;
  11703. t['rbopomofo'] = 0x3116;
  11704. t['rcaron'] = 0x0159;
  11705. t['rcedilla'] = 0x0157;
  11706. t['rcircle'] = 0x24E1;
  11707. t['rcommaaccent'] = 0x0157;
  11708. t['rdblgrave'] = 0x0211;
  11709. t['rdotaccent'] = 0x1E59;
  11710. t['rdotbelow'] = 0x1E5B;
  11711. t['rdotbelowmacron'] = 0x1E5D;
  11712. t['referencemark'] = 0x203B;
  11713. t['reflexsubset'] = 0x2286;
  11714. t['reflexsuperset'] = 0x2287;
  11715. t['registered'] = 0x00AE;
  11716. t['registersans'] = 0xF8E8;
  11717. t['registerserif'] = 0xF6DA;
  11718. t['reharabic'] = 0x0631;
  11719. t['reharmenian'] = 0x0580;
  11720. t['rehfinalarabic'] = 0xFEAE;
  11721. t['rehiragana'] = 0x308C;
  11722. t['rekatakana'] = 0x30EC;
  11723. t['rekatakanahalfwidth'] = 0xFF9A;
  11724. t['resh'] = 0x05E8;
  11725. t['reshdageshhebrew'] = 0xFB48;
  11726. t['reshhebrew'] = 0x05E8;
  11727. t['reversedtilde'] = 0x223D;
  11728. t['reviahebrew'] = 0x0597;
  11729. t['reviamugrashhebrew'] = 0x0597;
  11730. t['revlogicalnot'] = 0x2310;
  11731. t['rfishhook'] = 0x027E;
  11732. t['rfishhookreversed'] = 0x027F;
  11733. t['rhabengali'] = 0x09DD;
  11734. t['rhadeva'] = 0x095D;
  11735. t['rho'] = 0x03C1;
  11736. t['rhook'] = 0x027D;
  11737. t['rhookturned'] = 0x027B;
  11738. t['rhookturnedsuperior'] = 0x02B5;
  11739. t['rhosymbolgreek'] = 0x03F1;
  11740. t['rhotichookmod'] = 0x02DE;
  11741. t['rieulacirclekorean'] = 0x3271;
  11742. t['rieulaparenkorean'] = 0x3211;
  11743. t['rieulcirclekorean'] = 0x3263;
  11744. t['rieulhieuhkorean'] = 0x3140;
  11745. t['rieulkiyeokkorean'] = 0x313A;
  11746. t['rieulkiyeoksioskorean'] = 0x3169;
  11747. t['rieulkorean'] = 0x3139;
  11748. t['rieulmieumkorean'] = 0x313B;
  11749. t['rieulpansioskorean'] = 0x316C;
  11750. t['rieulparenkorean'] = 0x3203;
  11751. t['rieulphieuphkorean'] = 0x313F;
  11752. t['rieulpieupkorean'] = 0x313C;
  11753. t['rieulpieupsioskorean'] = 0x316B;
  11754. t['rieulsioskorean'] = 0x313D;
  11755. t['rieulthieuthkorean'] = 0x313E;
  11756. t['rieultikeutkorean'] = 0x316A;
  11757. t['rieulyeorinhieuhkorean'] = 0x316D;
  11758. t['rightangle'] = 0x221F;
  11759. t['righttackbelowcmb'] = 0x0319;
  11760. t['righttriangle'] = 0x22BF;
  11761. t['rihiragana'] = 0x308A;
  11762. t['rikatakana'] = 0x30EA;
  11763. t['rikatakanahalfwidth'] = 0xFF98;
  11764. t['ring'] = 0x02DA;
  11765. t['ringbelowcmb'] = 0x0325;
  11766. t['ringcmb'] = 0x030A;
  11767. t['ringhalfleft'] = 0x02BF;
  11768. t['ringhalfleftarmenian'] = 0x0559;
  11769. t['ringhalfleftbelowcmb'] = 0x031C;
  11770. t['ringhalfleftcentered'] = 0x02D3;
  11771. t['ringhalfright'] = 0x02BE;
  11772. t['ringhalfrightbelowcmb'] = 0x0339;
  11773. t['ringhalfrightcentered'] = 0x02D2;
  11774. t['rinvertedbreve'] = 0x0213;
  11775. t['rittorusquare'] = 0x3351;
  11776. t['rlinebelow'] = 0x1E5F;
  11777. t['rlongleg'] = 0x027C;
  11778. t['rlonglegturned'] = 0x027A;
  11779. t['rmonospace'] = 0xFF52;
  11780. t['rohiragana'] = 0x308D;
  11781. t['rokatakana'] = 0x30ED;
  11782. t['rokatakanahalfwidth'] = 0xFF9B;
  11783. t['roruathai'] = 0x0E23;
  11784. t['rparen'] = 0x24AD;
  11785. t['rrabengali'] = 0x09DC;
  11786. t['rradeva'] = 0x0931;
  11787. t['rragurmukhi'] = 0x0A5C;
  11788. t['rreharabic'] = 0x0691;
  11789. t['rrehfinalarabic'] = 0xFB8D;
  11790. t['rrvocalicbengali'] = 0x09E0;
  11791. t['rrvocalicdeva'] = 0x0960;
  11792. t['rrvocalicgujarati'] = 0x0AE0;
  11793. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11794. t['rrvocalicvowelsigndeva'] = 0x0944;
  11795. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11796. t['rsuperior'] = 0xF6F1;
  11797. t['rtblock'] = 0x2590;
  11798. t['rturned'] = 0x0279;
  11799. t['rturnedsuperior'] = 0x02B4;
  11800. t['ruhiragana'] = 0x308B;
  11801. t['rukatakana'] = 0x30EB;
  11802. t['rukatakanahalfwidth'] = 0xFF99;
  11803. t['rupeemarkbengali'] = 0x09F2;
  11804. t['rupeesignbengali'] = 0x09F3;
  11805. t['rupiah'] = 0xF6DD;
  11806. t['ruthai'] = 0x0E24;
  11807. t['rvocalicbengali'] = 0x098B;
  11808. t['rvocalicdeva'] = 0x090B;
  11809. t['rvocalicgujarati'] = 0x0A8B;
  11810. t['rvocalicvowelsignbengali'] = 0x09C3;
  11811. t['rvocalicvowelsigndeva'] = 0x0943;
  11812. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11813. t['s'] = 0x0073;
  11814. t['sabengali'] = 0x09B8;
  11815. t['sacute'] = 0x015B;
  11816. t['sacutedotaccent'] = 0x1E65;
  11817. t['sadarabic'] = 0x0635;
  11818. t['sadeva'] = 0x0938;
  11819. t['sadfinalarabic'] = 0xFEBA;
  11820. t['sadinitialarabic'] = 0xFEBB;
  11821. t['sadmedialarabic'] = 0xFEBC;
  11822. t['sagujarati'] = 0x0AB8;
  11823. t['sagurmukhi'] = 0x0A38;
  11824. t['sahiragana'] = 0x3055;
  11825. t['sakatakana'] = 0x30B5;
  11826. t['sakatakanahalfwidth'] = 0xFF7B;
  11827. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11828. t['samekh'] = 0x05E1;
  11829. t['samekhdagesh'] = 0xFB41;
  11830. t['samekhdageshhebrew'] = 0xFB41;
  11831. t['samekhhebrew'] = 0x05E1;
  11832. t['saraaathai'] = 0x0E32;
  11833. t['saraaethai'] = 0x0E41;
  11834. t['saraaimaimalaithai'] = 0x0E44;
  11835. t['saraaimaimuanthai'] = 0x0E43;
  11836. t['saraamthai'] = 0x0E33;
  11837. t['saraathai'] = 0x0E30;
  11838. t['saraethai'] = 0x0E40;
  11839. t['saraiileftthai'] = 0xF886;
  11840. t['saraiithai'] = 0x0E35;
  11841. t['saraileftthai'] = 0xF885;
  11842. t['saraithai'] = 0x0E34;
  11843. t['saraothai'] = 0x0E42;
  11844. t['saraueeleftthai'] = 0xF888;
  11845. t['saraueethai'] = 0x0E37;
  11846. t['saraueleftthai'] = 0xF887;
  11847. t['sarauethai'] = 0x0E36;
  11848. t['sarauthai'] = 0x0E38;
  11849. t['sarauuthai'] = 0x0E39;
  11850. t['sbopomofo'] = 0x3119;
  11851. t['scaron'] = 0x0161;
  11852. t['scarondotaccent'] = 0x1E67;
  11853. t['scedilla'] = 0x015F;
  11854. t['schwa'] = 0x0259;
  11855. t['schwacyrillic'] = 0x04D9;
  11856. t['schwadieresiscyrillic'] = 0x04DB;
  11857. t['schwahook'] = 0x025A;
  11858. t['scircle'] = 0x24E2;
  11859. t['scircumflex'] = 0x015D;
  11860. t['scommaaccent'] = 0x0219;
  11861. t['sdotaccent'] = 0x1E61;
  11862. t['sdotbelow'] = 0x1E63;
  11863. t['sdotbelowdotaccent'] = 0x1E69;
  11864. t['seagullbelowcmb'] = 0x033C;
  11865. t['second'] = 0x2033;
  11866. t['secondtonechinese'] = 0x02CA;
  11867. t['section'] = 0x00A7;
  11868. t['seenarabic'] = 0x0633;
  11869. t['seenfinalarabic'] = 0xFEB2;
  11870. t['seeninitialarabic'] = 0xFEB3;
  11871. t['seenmedialarabic'] = 0xFEB4;
  11872. t['segol'] = 0x05B6;
  11873. t['segol13'] = 0x05B6;
  11874. t['segol1f'] = 0x05B6;
  11875. t['segol2c'] = 0x05B6;
  11876. t['segolhebrew'] = 0x05B6;
  11877. t['segolnarrowhebrew'] = 0x05B6;
  11878. t['segolquarterhebrew'] = 0x05B6;
  11879. t['segoltahebrew'] = 0x0592;
  11880. t['segolwidehebrew'] = 0x05B6;
  11881. t['seharmenian'] = 0x057D;
  11882. t['sehiragana'] = 0x305B;
  11883. t['sekatakana'] = 0x30BB;
  11884. t['sekatakanahalfwidth'] = 0xFF7E;
  11885. t['semicolon'] = 0x003B;
  11886. t['semicolonarabic'] = 0x061B;
  11887. t['semicolonmonospace'] = 0xFF1B;
  11888. t['semicolonsmall'] = 0xFE54;
  11889. t['semivoicedmarkkana'] = 0x309C;
  11890. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11891. t['sentisquare'] = 0x3322;
  11892. t['sentosquare'] = 0x3323;
  11893. t['seven'] = 0x0037;
  11894. t['sevenarabic'] = 0x0667;
  11895. t['sevenbengali'] = 0x09ED;
  11896. t['sevencircle'] = 0x2466;
  11897. t['sevencircleinversesansserif'] = 0x2790;
  11898. t['sevendeva'] = 0x096D;
  11899. t['seveneighths'] = 0x215E;
  11900. t['sevengujarati'] = 0x0AED;
  11901. t['sevengurmukhi'] = 0x0A6D;
  11902. t['sevenhackarabic'] = 0x0667;
  11903. t['sevenhangzhou'] = 0x3027;
  11904. t['sevenideographicparen'] = 0x3226;
  11905. t['seveninferior'] = 0x2087;
  11906. t['sevenmonospace'] = 0xFF17;
  11907. t['sevenoldstyle'] = 0xF737;
  11908. t['sevenparen'] = 0x247A;
  11909. t['sevenperiod'] = 0x248E;
  11910. t['sevenpersian'] = 0x06F7;
  11911. t['sevenroman'] = 0x2176;
  11912. t['sevensuperior'] = 0x2077;
  11913. t['seventeencircle'] = 0x2470;
  11914. t['seventeenparen'] = 0x2484;
  11915. t['seventeenperiod'] = 0x2498;
  11916. t['seventhai'] = 0x0E57;
  11917. t['sfthyphen'] = 0x00AD;
  11918. t['shaarmenian'] = 0x0577;
  11919. t['shabengali'] = 0x09B6;
  11920. t['shacyrillic'] = 0x0448;
  11921. t['shaddaarabic'] = 0x0651;
  11922. t['shaddadammaarabic'] = 0xFC61;
  11923. t['shaddadammatanarabic'] = 0xFC5E;
  11924. t['shaddafathaarabic'] = 0xFC60;
  11925. t['shaddakasraarabic'] = 0xFC62;
  11926. t['shaddakasratanarabic'] = 0xFC5F;
  11927. t['shade'] = 0x2592;
  11928. t['shadedark'] = 0x2593;
  11929. t['shadelight'] = 0x2591;
  11930. t['shademedium'] = 0x2592;
  11931. t['shadeva'] = 0x0936;
  11932. t['shagujarati'] = 0x0AB6;
  11933. t['shagurmukhi'] = 0x0A36;
  11934. t['shalshelethebrew'] = 0x0593;
  11935. t['shbopomofo'] = 0x3115;
  11936. t['shchacyrillic'] = 0x0449;
  11937. t['sheenarabic'] = 0x0634;
  11938. t['sheenfinalarabic'] = 0xFEB6;
  11939. t['sheeninitialarabic'] = 0xFEB7;
  11940. t['sheenmedialarabic'] = 0xFEB8;
  11941. t['sheicoptic'] = 0x03E3;
  11942. t['sheqel'] = 0x20AA;
  11943. t['sheqelhebrew'] = 0x20AA;
  11944. t['sheva'] = 0x05B0;
  11945. t['sheva115'] = 0x05B0;
  11946. t['sheva15'] = 0x05B0;
  11947. t['sheva22'] = 0x05B0;
  11948. t['sheva2e'] = 0x05B0;
  11949. t['shevahebrew'] = 0x05B0;
  11950. t['shevanarrowhebrew'] = 0x05B0;
  11951. t['shevaquarterhebrew'] = 0x05B0;
  11952. t['shevawidehebrew'] = 0x05B0;
  11953. t['shhacyrillic'] = 0x04BB;
  11954. t['shimacoptic'] = 0x03ED;
  11955. t['shin'] = 0x05E9;
  11956. t['shindagesh'] = 0xFB49;
  11957. t['shindageshhebrew'] = 0xFB49;
  11958. t['shindageshshindot'] = 0xFB2C;
  11959. t['shindageshshindothebrew'] = 0xFB2C;
  11960. t['shindageshsindot'] = 0xFB2D;
  11961. t['shindageshsindothebrew'] = 0xFB2D;
  11962. t['shindothebrew'] = 0x05C1;
  11963. t['shinhebrew'] = 0x05E9;
  11964. t['shinshindot'] = 0xFB2A;
  11965. t['shinshindothebrew'] = 0xFB2A;
  11966. t['shinsindot'] = 0xFB2B;
  11967. t['shinsindothebrew'] = 0xFB2B;
  11968. t['shook'] = 0x0282;
  11969. t['sigma'] = 0x03C3;
  11970. t['sigma1'] = 0x03C2;
  11971. t['sigmafinal'] = 0x03C2;
  11972. t['sigmalunatesymbolgreek'] = 0x03F2;
  11973. t['sihiragana'] = 0x3057;
  11974. t['sikatakana'] = 0x30B7;
  11975. t['sikatakanahalfwidth'] = 0xFF7C;
  11976. t['siluqhebrew'] = 0x05BD;
  11977. t['siluqlefthebrew'] = 0x05BD;
  11978. t['similar'] = 0x223C;
  11979. t['sindothebrew'] = 0x05C2;
  11980. t['siosacirclekorean'] = 0x3274;
  11981. t['siosaparenkorean'] = 0x3214;
  11982. t['sioscieuckorean'] = 0x317E;
  11983. t['sioscirclekorean'] = 0x3266;
  11984. t['sioskiyeokkorean'] = 0x317A;
  11985. t['sioskorean'] = 0x3145;
  11986. t['siosnieunkorean'] = 0x317B;
  11987. t['siosparenkorean'] = 0x3206;
  11988. t['siospieupkorean'] = 0x317D;
  11989. t['siostikeutkorean'] = 0x317C;
  11990. t['six'] = 0x0036;
  11991. t['sixarabic'] = 0x0666;
  11992. t['sixbengali'] = 0x09EC;
  11993. t['sixcircle'] = 0x2465;
  11994. t['sixcircleinversesansserif'] = 0x278F;
  11995. t['sixdeva'] = 0x096C;
  11996. t['sixgujarati'] = 0x0AEC;
  11997. t['sixgurmukhi'] = 0x0A6C;
  11998. t['sixhackarabic'] = 0x0666;
  11999. t['sixhangzhou'] = 0x3026;
  12000. t['sixideographicparen'] = 0x3225;
  12001. t['sixinferior'] = 0x2086;
  12002. t['sixmonospace'] = 0xFF16;
  12003. t['sixoldstyle'] = 0xF736;
  12004. t['sixparen'] = 0x2479;
  12005. t['sixperiod'] = 0x248D;
  12006. t['sixpersian'] = 0x06F6;
  12007. t['sixroman'] = 0x2175;
  12008. t['sixsuperior'] = 0x2076;
  12009. t['sixteencircle'] = 0x246F;
  12010. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12011. t['sixteenparen'] = 0x2483;
  12012. t['sixteenperiod'] = 0x2497;
  12013. t['sixthai'] = 0x0E56;
  12014. t['slash'] = 0x002F;
  12015. t['slashmonospace'] = 0xFF0F;
  12016. t['slong'] = 0x017F;
  12017. t['slongdotaccent'] = 0x1E9B;
  12018. t['smileface'] = 0x263A;
  12019. t['smonospace'] = 0xFF53;
  12020. t['sofpasuqhebrew'] = 0x05C3;
  12021. t['softhyphen'] = 0x00AD;
  12022. t['softsigncyrillic'] = 0x044C;
  12023. t['sohiragana'] = 0x305D;
  12024. t['sokatakana'] = 0x30BD;
  12025. t['sokatakanahalfwidth'] = 0xFF7F;
  12026. t['soliduslongoverlaycmb'] = 0x0338;
  12027. t['solidusshortoverlaycmb'] = 0x0337;
  12028. t['sorusithai'] = 0x0E29;
  12029. t['sosalathai'] = 0x0E28;
  12030. t['sosothai'] = 0x0E0B;
  12031. t['sosuathai'] = 0x0E2A;
  12032. t['space'] = 0x0020;
  12033. t['spacehackarabic'] = 0x0020;
  12034. t['spade'] = 0x2660;
  12035. t['spadesuitblack'] = 0x2660;
  12036. t['spadesuitwhite'] = 0x2664;
  12037. t['sparen'] = 0x24AE;
  12038. t['squarebelowcmb'] = 0x033B;
  12039. t['squarecc'] = 0x33C4;
  12040. t['squarecm'] = 0x339D;
  12041. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12042. t['squarehorizontalfill'] = 0x25A4;
  12043. t['squarekg'] = 0x338F;
  12044. t['squarekm'] = 0x339E;
  12045. t['squarekmcapital'] = 0x33CE;
  12046. t['squareln'] = 0x33D1;
  12047. t['squarelog'] = 0x33D2;
  12048. t['squaremg'] = 0x338E;
  12049. t['squaremil'] = 0x33D5;
  12050. t['squaremm'] = 0x339C;
  12051. t['squaremsquared'] = 0x33A1;
  12052. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12053. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12054. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12055. t['squareverticalfill'] = 0x25A5;
  12056. t['squarewhitewithsmallblack'] = 0x25A3;
  12057. t['srsquare'] = 0x33DB;
  12058. t['ssabengali'] = 0x09B7;
  12059. t['ssadeva'] = 0x0937;
  12060. t['ssagujarati'] = 0x0AB7;
  12061. t['ssangcieuckorean'] = 0x3149;
  12062. t['ssanghieuhkorean'] = 0x3185;
  12063. t['ssangieungkorean'] = 0x3180;
  12064. t['ssangkiyeokkorean'] = 0x3132;
  12065. t['ssangnieunkorean'] = 0x3165;
  12066. t['ssangpieupkorean'] = 0x3143;
  12067. t['ssangsioskorean'] = 0x3146;
  12068. t['ssangtikeutkorean'] = 0x3138;
  12069. t['ssuperior'] = 0xF6F2;
  12070. t['sterling'] = 0x00A3;
  12071. t['sterlingmonospace'] = 0xFFE1;
  12072. t['strokelongoverlaycmb'] = 0x0336;
  12073. t['strokeshortoverlaycmb'] = 0x0335;
  12074. t['subset'] = 0x2282;
  12075. t['subsetnotequal'] = 0x228A;
  12076. t['subsetorequal'] = 0x2286;
  12077. t['succeeds'] = 0x227B;
  12078. t['suchthat'] = 0x220B;
  12079. t['suhiragana'] = 0x3059;
  12080. t['sukatakana'] = 0x30B9;
  12081. t['sukatakanahalfwidth'] = 0xFF7D;
  12082. t['sukunarabic'] = 0x0652;
  12083. t['summation'] = 0x2211;
  12084. t['sun'] = 0x263C;
  12085. t['superset'] = 0x2283;
  12086. t['supersetnotequal'] = 0x228B;
  12087. t['supersetorequal'] = 0x2287;
  12088. t['svsquare'] = 0x33DC;
  12089. t['syouwaerasquare'] = 0x337C;
  12090. t['t'] = 0x0074;
  12091. t['tabengali'] = 0x09A4;
  12092. t['tackdown'] = 0x22A4;
  12093. t['tackleft'] = 0x22A3;
  12094. t['tadeva'] = 0x0924;
  12095. t['tagujarati'] = 0x0AA4;
  12096. t['tagurmukhi'] = 0x0A24;
  12097. t['taharabic'] = 0x0637;
  12098. t['tahfinalarabic'] = 0xFEC2;
  12099. t['tahinitialarabic'] = 0xFEC3;
  12100. t['tahiragana'] = 0x305F;
  12101. t['tahmedialarabic'] = 0xFEC4;
  12102. t['taisyouerasquare'] = 0x337D;
  12103. t['takatakana'] = 0x30BF;
  12104. t['takatakanahalfwidth'] = 0xFF80;
  12105. t['tatweelarabic'] = 0x0640;
  12106. t['tau'] = 0x03C4;
  12107. t['tav'] = 0x05EA;
  12108. t['tavdages'] = 0xFB4A;
  12109. t['tavdagesh'] = 0xFB4A;
  12110. t['tavdageshhebrew'] = 0xFB4A;
  12111. t['tavhebrew'] = 0x05EA;
  12112. t['tbar'] = 0x0167;
  12113. t['tbopomofo'] = 0x310A;
  12114. t['tcaron'] = 0x0165;
  12115. t['tccurl'] = 0x02A8;
  12116. t['tcedilla'] = 0x0163;
  12117. t['tcheharabic'] = 0x0686;
  12118. t['tchehfinalarabic'] = 0xFB7B;
  12119. t['tchehinitialarabic'] = 0xFB7C;
  12120. t['tchehmedialarabic'] = 0xFB7D;
  12121. t['tcircle'] = 0x24E3;
  12122. t['tcircumflexbelow'] = 0x1E71;
  12123. t['tcommaaccent'] = 0x0163;
  12124. t['tdieresis'] = 0x1E97;
  12125. t['tdotaccent'] = 0x1E6B;
  12126. t['tdotbelow'] = 0x1E6D;
  12127. t['tecyrillic'] = 0x0442;
  12128. t['tedescendercyrillic'] = 0x04AD;
  12129. t['teharabic'] = 0x062A;
  12130. t['tehfinalarabic'] = 0xFE96;
  12131. t['tehhahinitialarabic'] = 0xFCA2;
  12132. t['tehhahisolatedarabic'] = 0xFC0C;
  12133. t['tehinitialarabic'] = 0xFE97;
  12134. t['tehiragana'] = 0x3066;
  12135. t['tehjeeminitialarabic'] = 0xFCA1;
  12136. t['tehjeemisolatedarabic'] = 0xFC0B;
  12137. t['tehmarbutaarabic'] = 0x0629;
  12138. t['tehmarbutafinalarabic'] = 0xFE94;
  12139. t['tehmedialarabic'] = 0xFE98;
  12140. t['tehmeeminitialarabic'] = 0xFCA4;
  12141. t['tehmeemisolatedarabic'] = 0xFC0E;
  12142. t['tehnoonfinalarabic'] = 0xFC73;
  12143. t['tekatakana'] = 0x30C6;
  12144. t['tekatakanahalfwidth'] = 0xFF83;
  12145. t['telephone'] = 0x2121;
  12146. t['telephoneblack'] = 0x260E;
  12147. t['telishagedolahebrew'] = 0x05A0;
  12148. t['telishaqetanahebrew'] = 0x05A9;
  12149. t['tencircle'] = 0x2469;
  12150. t['tenideographicparen'] = 0x3229;
  12151. t['tenparen'] = 0x247D;
  12152. t['tenperiod'] = 0x2491;
  12153. t['tenroman'] = 0x2179;
  12154. t['tesh'] = 0x02A7;
  12155. t['tet'] = 0x05D8;
  12156. t['tetdagesh'] = 0xFB38;
  12157. t['tetdageshhebrew'] = 0xFB38;
  12158. t['tethebrew'] = 0x05D8;
  12159. t['tetsecyrillic'] = 0x04B5;
  12160. t['tevirhebrew'] = 0x059B;
  12161. t['tevirlefthebrew'] = 0x059B;
  12162. t['thabengali'] = 0x09A5;
  12163. t['thadeva'] = 0x0925;
  12164. t['thagujarati'] = 0x0AA5;
  12165. t['thagurmukhi'] = 0x0A25;
  12166. t['thalarabic'] = 0x0630;
  12167. t['thalfinalarabic'] = 0xFEAC;
  12168. t['thanthakhatlowleftthai'] = 0xF898;
  12169. t['thanthakhatlowrightthai'] = 0xF897;
  12170. t['thanthakhatthai'] = 0x0E4C;
  12171. t['thanthakhatupperleftthai'] = 0xF896;
  12172. t['theharabic'] = 0x062B;
  12173. t['thehfinalarabic'] = 0xFE9A;
  12174. t['thehinitialarabic'] = 0xFE9B;
  12175. t['thehmedialarabic'] = 0xFE9C;
  12176. t['thereexists'] = 0x2203;
  12177. t['therefore'] = 0x2234;
  12178. t['theta'] = 0x03B8;
  12179. t['theta1'] = 0x03D1;
  12180. t['thetasymbolgreek'] = 0x03D1;
  12181. t['thieuthacirclekorean'] = 0x3279;
  12182. t['thieuthaparenkorean'] = 0x3219;
  12183. t['thieuthcirclekorean'] = 0x326B;
  12184. t['thieuthkorean'] = 0x314C;
  12185. t['thieuthparenkorean'] = 0x320B;
  12186. t['thirteencircle'] = 0x246C;
  12187. t['thirteenparen'] = 0x2480;
  12188. t['thirteenperiod'] = 0x2494;
  12189. t['thonangmonthothai'] = 0x0E11;
  12190. t['thook'] = 0x01AD;
  12191. t['thophuthaothai'] = 0x0E12;
  12192. t['thorn'] = 0x00FE;
  12193. t['thothahanthai'] = 0x0E17;
  12194. t['thothanthai'] = 0x0E10;
  12195. t['thothongthai'] = 0x0E18;
  12196. t['thothungthai'] = 0x0E16;
  12197. t['thousandcyrillic'] = 0x0482;
  12198. t['thousandsseparatorarabic'] = 0x066C;
  12199. t['thousandsseparatorpersian'] = 0x066C;
  12200. t['three'] = 0x0033;
  12201. t['threearabic'] = 0x0663;
  12202. t['threebengali'] = 0x09E9;
  12203. t['threecircle'] = 0x2462;
  12204. t['threecircleinversesansserif'] = 0x278C;
  12205. t['threedeva'] = 0x0969;
  12206. t['threeeighths'] = 0x215C;
  12207. t['threegujarati'] = 0x0AE9;
  12208. t['threegurmukhi'] = 0x0A69;
  12209. t['threehackarabic'] = 0x0663;
  12210. t['threehangzhou'] = 0x3023;
  12211. t['threeideographicparen'] = 0x3222;
  12212. t['threeinferior'] = 0x2083;
  12213. t['threemonospace'] = 0xFF13;
  12214. t['threenumeratorbengali'] = 0x09F6;
  12215. t['threeoldstyle'] = 0xF733;
  12216. t['threeparen'] = 0x2476;
  12217. t['threeperiod'] = 0x248A;
  12218. t['threepersian'] = 0x06F3;
  12219. t['threequarters'] = 0x00BE;
  12220. t['threequartersemdash'] = 0xF6DE;
  12221. t['threeroman'] = 0x2172;
  12222. t['threesuperior'] = 0x00B3;
  12223. t['threethai'] = 0x0E53;
  12224. t['thzsquare'] = 0x3394;
  12225. t['tihiragana'] = 0x3061;
  12226. t['tikatakana'] = 0x30C1;
  12227. t['tikatakanahalfwidth'] = 0xFF81;
  12228. t['tikeutacirclekorean'] = 0x3270;
  12229. t['tikeutaparenkorean'] = 0x3210;
  12230. t['tikeutcirclekorean'] = 0x3262;
  12231. t['tikeutkorean'] = 0x3137;
  12232. t['tikeutparenkorean'] = 0x3202;
  12233. t['tilde'] = 0x02DC;
  12234. t['tildebelowcmb'] = 0x0330;
  12235. t['tildecmb'] = 0x0303;
  12236. t['tildecomb'] = 0x0303;
  12237. t['tildedoublecmb'] = 0x0360;
  12238. t['tildeoperator'] = 0x223C;
  12239. t['tildeoverlaycmb'] = 0x0334;
  12240. t['tildeverticalcmb'] = 0x033E;
  12241. t['timescircle'] = 0x2297;
  12242. t['tipehahebrew'] = 0x0596;
  12243. t['tipehalefthebrew'] = 0x0596;
  12244. t['tippigurmukhi'] = 0x0A70;
  12245. t['titlocyrilliccmb'] = 0x0483;
  12246. t['tiwnarmenian'] = 0x057F;
  12247. t['tlinebelow'] = 0x1E6F;
  12248. t['tmonospace'] = 0xFF54;
  12249. t['toarmenian'] = 0x0569;
  12250. t['tohiragana'] = 0x3068;
  12251. t['tokatakana'] = 0x30C8;
  12252. t['tokatakanahalfwidth'] = 0xFF84;
  12253. t['tonebarextrahighmod'] = 0x02E5;
  12254. t['tonebarextralowmod'] = 0x02E9;
  12255. t['tonebarhighmod'] = 0x02E6;
  12256. t['tonebarlowmod'] = 0x02E8;
  12257. t['tonebarmidmod'] = 0x02E7;
  12258. t['tonefive'] = 0x01BD;
  12259. t['tonesix'] = 0x0185;
  12260. t['tonetwo'] = 0x01A8;
  12261. t['tonos'] = 0x0384;
  12262. t['tonsquare'] = 0x3327;
  12263. t['topatakthai'] = 0x0E0F;
  12264. t['tortoiseshellbracketleft'] = 0x3014;
  12265. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12266. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12267. t['tortoiseshellbracketright'] = 0x3015;
  12268. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12269. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12270. t['totaothai'] = 0x0E15;
  12271. t['tpalatalhook'] = 0x01AB;
  12272. t['tparen'] = 0x24AF;
  12273. t['trademark'] = 0x2122;
  12274. t['trademarksans'] = 0xF8EA;
  12275. t['trademarkserif'] = 0xF6DB;
  12276. t['tretroflexhook'] = 0x0288;
  12277. t['triagdn'] = 0x25BC;
  12278. t['triaglf'] = 0x25C4;
  12279. t['triagrt'] = 0x25BA;
  12280. t['triagup'] = 0x25B2;
  12281. t['ts'] = 0x02A6;
  12282. t['tsadi'] = 0x05E6;
  12283. t['tsadidagesh'] = 0xFB46;
  12284. t['tsadidageshhebrew'] = 0xFB46;
  12285. t['tsadihebrew'] = 0x05E6;
  12286. t['tsecyrillic'] = 0x0446;
  12287. t['tsere'] = 0x05B5;
  12288. t['tsere12'] = 0x05B5;
  12289. t['tsere1e'] = 0x05B5;
  12290. t['tsere2b'] = 0x05B5;
  12291. t['tserehebrew'] = 0x05B5;
  12292. t['tserenarrowhebrew'] = 0x05B5;
  12293. t['tserequarterhebrew'] = 0x05B5;
  12294. t['tserewidehebrew'] = 0x05B5;
  12295. t['tshecyrillic'] = 0x045B;
  12296. t['tsuperior'] = 0xF6F3;
  12297. t['ttabengali'] = 0x099F;
  12298. t['ttadeva'] = 0x091F;
  12299. t['ttagujarati'] = 0x0A9F;
  12300. t['ttagurmukhi'] = 0x0A1F;
  12301. t['tteharabic'] = 0x0679;
  12302. t['ttehfinalarabic'] = 0xFB67;
  12303. t['ttehinitialarabic'] = 0xFB68;
  12304. t['ttehmedialarabic'] = 0xFB69;
  12305. t['tthabengali'] = 0x09A0;
  12306. t['tthadeva'] = 0x0920;
  12307. t['tthagujarati'] = 0x0AA0;
  12308. t['tthagurmukhi'] = 0x0A20;
  12309. t['tturned'] = 0x0287;
  12310. t['tuhiragana'] = 0x3064;
  12311. t['tukatakana'] = 0x30C4;
  12312. t['tukatakanahalfwidth'] = 0xFF82;
  12313. t['tusmallhiragana'] = 0x3063;
  12314. t['tusmallkatakana'] = 0x30C3;
  12315. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12316. t['twelvecircle'] = 0x246B;
  12317. t['twelveparen'] = 0x247F;
  12318. t['twelveperiod'] = 0x2493;
  12319. t['twelveroman'] = 0x217B;
  12320. t['twentycircle'] = 0x2473;
  12321. t['twentyhangzhou'] = 0x5344;
  12322. t['twentyparen'] = 0x2487;
  12323. t['twentyperiod'] = 0x249B;
  12324. t['two'] = 0x0032;
  12325. t['twoarabic'] = 0x0662;
  12326. t['twobengali'] = 0x09E8;
  12327. t['twocircle'] = 0x2461;
  12328. t['twocircleinversesansserif'] = 0x278B;
  12329. t['twodeva'] = 0x0968;
  12330. t['twodotenleader'] = 0x2025;
  12331. t['twodotleader'] = 0x2025;
  12332. t['twodotleadervertical'] = 0xFE30;
  12333. t['twogujarati'] = 0x0AE8;
  12334. t['twogurmukhi'] = 0x0A68;
  12335. t['twohackarabic'] = 0x0662;
  12336. t['twohangzhou'] = 0x3022;
  12337. t['twoideographicparen'] = 0x3221;
  12338. t['twoinferior'] = 0x2082;
  12339. t['twomonospace'] = 0xFF12;
  12340. t['twonumeratorbengali'] = 0x09F5;
  12341. t['twooldstyle'] = 0xF732;
  12342. t['twoparen'] = 0x2475;
  12343. t['twoperiod'] = 0x2489;
  12344. t['twopersian'] = 0x06F2;
  12345. t['tworoman'] = 0x2171;
  12346. t['twostroke'] = 0x01BB;
  12347. t['twosuperior'] = 0x00B2;
  12348. t['twothai'] = 0x0E52;
  12349. t['twothirds'] = 0x2154;
  12350. t['u'] = 0x0075;
  12351. t['uacute'] = 0x00FA;
  12352. t['ubar'] = 0x0289;
  12353. t['ubengali'] = 0x0989;
  12354. t['ubopomofo'] = 0x3128;
  12355. t['ubreve'] = 0x016D;
  12356. t['ucaron'] = 0x01D4;
  12357. t['ucircle'] = 0x24E4;
  12358. t['ucircumflex'] = 0x00FB;
  12359. t['ucircumflexbelow'] = 0x1E77;
  12360. t['ucyrillic'] = 0x0443;
  12361. t['udattadeva'] = 0x0951;
  12362. t['udblacute'] = 0x0171;
  12363. t['udblgrave'] = 0x0215;
  12364. t['udeva'] = 0x0909;
  12365. t['udieresis'] = 0x00FC;
  12366. t['udieresisacute'] = 0x01D8;
  12367. t['udieresisbelow'] = 0x1E73;
  12368. t['udieresiscaron'] = 0x01DA;
  12369. t['udieresiscyrillic'] = 0x04F1;
  12370. t['udieresisgrave'] = 0x01DC;
  12371. t['udieresismacron'] = 0x01D6;
  12372. t['udotbelow'] = 0x1EE5;
  12373. t['ugrave'] = 0x00F9;
  12374. t['ugujarati'] = 0x0A89;
  12375. t['ugurmukhi'] = 0x0A09;
  12376. t['uhiragana'] = 0x3046;
  12377. t['uhookabove'] = 0x1EE7;
  12378. t['uhorn'] = 0x01B0;
  12379. t['uhornacute'] = 0x1EE9;
  12380. t['uhorndotbelow'] = 0x1EF1;
  12381. t['uhorngrave'] = 0x1EEB;
  12382. t['uhornhookabove'] = 0x1EED;
  12383. t['uhorntilde'] = 0x1EEF;
  12384. t['uhungarumlaut'] = 0x0171;
  12385. t['uhungarumlautcyrillic'] = 0x04F3;
  12386. t['uinvertedbreve'] = 0x0217;
  12387. t['ukatakana'] = 0x30A6;
  12388. t['ukatakanahalfwidth'] = 0xFF73;
  12389. t['ukcyrillic'] = 0x0479;
  12390. t['ukorean'] = 0x315C;
  12391. t['umacron'] = 0x016B;
  12392. t['umacroncyrillic'] = 0x04EF;
  12393. t['umacrondieresis'] = 0x1E7B;
  12394. t['umatragurmukhi'] = 0x0A41;
  12395. t['umonospace'] = 0xFF55;
  12396. t['underscore'] = 0x005F;
  12397. t['underscoredbl'] = 0x2017;
  12398. t['underscoremonospace'] = 0xFF3F;
  12399. t['underscorevertical'] = 0xFE33;
  12400. t['underscorewavy'] = 0xFE4F;
  12401. t['union'] = 0x222A;
  12402. t['universal'] = 0x2200;
  12403. t['uogonek'] = 0x0173;
  12404. t['uparen'] = 0x24B0;
  12405. t['upblock'] = 0x2580;
  12406. t['upperdothebrew'] = 0x05C4;
  12407. t['upsilon'] = 0x03C5;
  12408. t['upsilondieresis'] = 0x03CB;
  12409. t['upsilondieresistonos'] = 0x03B0;
  12410. t['upsilonlatin'] = 0x028A;
  12411. t['upsilontonos'] = 0x03CD;
  12412. t['uptackbelowcmb'] = 0x031D;
  12413. t['uptackmod'] = 0x02D4;
  12414. t['uragurmukhi'] = 0x0A73;
  12415. t['uring'] = 0x016F;
  12416. t['ushortcyrillic'] = 0x045E;
  12417. t['usmallhiragana'] = 0x3045;
  12418. t['usmallkatakana'] = 0x30A5;
  12419. t['usmallkatakanahalfwidth'] = 0xFF69;
  12420. t['ustraightcyrillic'] = 0x04AF;
  12421. t['ustraightstrokecyrillic'] = 0x04B1;
  12422. t['utilde'] = 0x0169;
  12423. t['utildeacute'] = 0x1E79;
  12424. t['utildebelow'] = 0x1E75;
  12425. t['uubengali'] = 0x098A;
  12426. t['uudeva'] = 0x090A;
  12427. t['uugujarati'] = 0x0A8A;
  12428. t['uugurmukhi'] = 0x0A0A;
  12429. t['uumatragurmukhi'] = 0x0A42;
  12430. t['uuvowelsignbengali'] = 0x09C2;
  12431. t['uuvowelsigndeva'] = 0x0942;
  12432. t['uuvowelsigngujarati'] = 0x0AC2;
  12433. t['uvowelsignbengali'] = 0x09C1;
  12434. t['uvowelsigndeva'] = 0x0941;
  12435. t['uvowelsigngujarati'] = 0x0AC1;
  12436. t['v'] = 0x0076;
  12437. t['vadeva'] = 0x0935;
  12438. t['vagujarati'] = 0x0AB5;
  12439. t['vagurmukhi'] = 0x0A35;
  12440. t['vakatakana'] = 0x30F7;
  12441. t['vav'] = 0x05D5;
  12442. t['vavdagesh'] = 0xFB35;
  12443. t['vavdagesh65'] = 0xFB35;
  12444. t['vavdageshhebrew'] = 0xFB35;
  12445. t['vavhebrew'] = 0x05D5;
  12446. t['vavholam'] = 0xFB4B;
  12447. t['vavholamhebrew'] = 0xFB4B;
  12448. t['vavvavhebrew'] = 0x05F0;
  12449. t['vavyodhebrew'] = 0x05F1;
  12450. t['vcircle'] = 0x24E5;
  12451. t['vdotbelow'] = 0x1E7F;
  12452. t['vecyrillic'] = 0x0432;
  12453. t['veharabic'] = 0x06A4;
  12454. t['vehfinalarabic'] = 0xFB6B;
  12455. t['vehinitialarabic'] = 0xFB6C;
  12456. t['vehmedialarabic'] = 0xFB6D;
  12457. t['vekatakana'] = 0x30F9;
  12458. t['venus'] = 0x2640;
  12459. t['verticalbar'] = 0x007C;
  12460. t['verticallineabovecmb'] = 0x030D;
  12461. t['verticallinebelowcmb'] = 0x0329;
  12462. t['verticallinelowmod'] = 0x02CC;
  12463. t['verticallinemod'] = 0x02C8;
  12464. t['vewarmenian'] = 0x057E;
  12465. t['vhook'] = 0x028B;
  12466. t['vikatakana'] = 0x30F8;
  12467. t['viramabengali'] = 0x09CD;
  12468. t['viramadeva'] = 0x094D;
  12469. t['viramagujarati'] = 0x0ACD;
  12470. t['visargabengali'] = 0x0983;
  12471. t['visargadeva'] = 0x0903;
  12472. t['visargagujarati'] = 0x0A83;
  12473. t['vmonospace'] = 0xFF56;
  12474. t['voarmenian'] = 0x0578;
  12475. t['voicediterationhiragana'] = 0x309E;
  12476. t['voicediterationkatakana'] = 0x30FE;
  12477. t['voicedmarkkana'] = 0x309B;
  12478. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12479. t['vokatakana'] = 0x30FA;
  12480. t['vparen'] = 0x24B1;
  12481. t['vtilde'] = 0x1E7D;
  12482. t['vturned'] = 0x028C;
  12483. t['vuhiragana'] = 0x3094;
  12484. t['vukatakana'] = 0x30F4;
  12485. t['w'] = 0x0077;
  12486. t['wacute'] = 0x1E83;
  12487. t['waekorean'] = 0x3159;
  12488. t['wahiragana'] = 0x308F;
  12489. t['wakatakana'] = 0x30EF;
  12490. t['wakatakanahalfwidth'] = 0xFF9C;
  12491. t['wakorean'] = 0x3158;
  12492. t['wasmallhiragana'] = 0x308E;
  12493. t['wasmallkatakana'] = 0x30EE;
  12494. t['wattosquare'] = 0x3357;
  12495. t['wavedash'] = 0x301C;
  12496. t['wavyunderscorevertical'] = 0xFE34;
  12497. t['wawarabic'] = 0x0648;
  12498. t['wawfinalarabic'] = 0xFEEE;
  12499. t['wawhamzaabovearabic'] = 0x0624;
  12500. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12501. t['wbsquare'] = 0x33DD;
  12502. t['wcircle'] = 0x24E6;
  12503. t['wcircumflex'] = 0x0175;
  12504. t['wdieresis'] = 0x1E85;
  12505. t['wdotaccent'] = 0x1E87;
  12506. t['wdotbelow'] = 0x1E89;
  12507. t['wehiragana'] = 0x3091;
  12508. t['weierstrass'] = 0x2118;
  12509. t['wekatakana'] = 0x30F1;
  12510. t['wekorean'] = 0x315E;
  12511. t['weokorean'] = 0x315D;
  12512. t['wgrave'] = 0x1E81;
  12513. t['whitebullet'] = 0x25E6;
  12514. t['whitecircle'] = 0x25CB;
  12515. t['whitecircleinverse'] = 0x25D9;
  12516. t['whitecornerbracketleft'] = 0x300E;
  12517. t['whitecornerbracketleftvertical'] = 0xFE43;
  12518. t['whitecornerbracketright'] = 0x300F;
  12519. t['whitecornerbracketrightvertical'] = 0xFE44;
  12520. t['whitediamond'] = 0x25C7;
  12521. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12522. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12523. t['whitedownpointingtriangle'] = 0x25BD;
  12524. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12525. t['whiteleftpointingtriangle'] = 0x25C1;
  12526. t['whitelenticularbracketleft'] = 0x3016;
  12527. t['whitelenticularbracketright'] = 0x3017;
  12528. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12529. t['whiterightpointingtriangle'] = 0x25B7;
  12530. t['whitesmallsquare'] = 0x25AB;
  12531. t['whitesmilingface'] = 0x263A;
  12532. t['whitesquare'] = 0x25A1;
  12533. t['whitestar'] = 0x2606;
  12534. t['whitetelephone'] = 0x260F;
  12535. t['whitetortoiseshellbracketleft'] = 0x3018;
  12536. t['whitetortoiseshellbracketright'] = 0x3019;
  12537. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12538. t['whiteuppointingtriangle'] = 0x25B3;
  12539. t['wihiragana'] = 0x3090;
  12540. t['wikatakana'] = 0x30F0;
  12541. t['wikorean'] = 0x315F;
  12542. t['wmonospace'] = 0xFF57;
  12543. t['wohiragana'] = 0x3092;
  12544. t['wokatakana'] = 0x30F2;
  12545. t['wokatakanahalfwidth'] = 0xFF66;
  12546. t['won'] = 0x20A9;
  12547. t['wonmonospace'] = 0xFFE6;
  12548. t['wowaenthai'] = 0x0E27;
  12549. t['wparen'] = 0x24B2;
  12550. t['wring'] = 0x1E98;
  12551. t['wsuperior'] = 0x02B7;
  12552. t['wturned'] = 0x028D;
  12553. t['wynn'] = 0x01BF;
  12554. t['x'] = 0x0078;
  12555. t['xabovecmb'] = 0x033D;
  12556. t['xbopomofo'] = 0x3112;
  12557. t['xcircle'] = 0x24E7;
  12558. t['xdieresis'] = 0x1E8D;
  12559. t['xdotaccent'] = 0x1E8B;
  12560. t['xeharmenian'] = 0x056D;
  12561. t['xi'] = 0x03BE;
  12562. t['xmonospace'] = 0xFF58;
  12563. t['xparen'] = 0x24B3;
  12564. t['xsuperior'] = 0x02E3;
  12565. t['y'] = 0x0079;
  12566. t['yaadosquare'] = 0x334E;
  12567. t['yabengali'] = 0x09AF;
  12568. t['yacute'] = 0x00FD;
  12569. t['yadeva'] = 0x092F;
  12570. t['yaekorean'] = 0x3152;
  12571. t['yagujarati'] = 0x0AAF;
  12572. t['yagurmukhi'] = 0x0A2F;
  12573. t['yahiragana'] = 0x3084;
  12574. t['yakatakana'] = 0x30E4;
  12575. t['yakatakanahalfwidth'] = 0xFF94;
  12576. t['yakorean'] = 0x3151;
  12577. t['yamakkanthai'] = 0x0E4E;
  12578. t['yasmallhiragana'] = 0x3083;
  12579. t['yasmallkatakana'] = 0x30E3;
  12580. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12581. t['yatcyrillic'] = 0x0463;
  12582. t['ycircle'] = 0x24E8;
  12583. t['ycircumflex'] = 0x0177;
  12584. t['ydieresis'] = 0x00FF;
  12585. t['ydotaccent'] = 0x1E8F;
  12586. t['ydotbelow'] = 0x1EF5;
  12587. t['yeharabic'] = 0x064A;
  12588. t['yehbarreearabic'] = 0x06D2;
  12589. t['yehbarreefinalarabic'] = 0xFBAF;
  12590. t['yehfinalarabic'] = 0xFEF2;
  12591. t['yehhamzaabovearabic'] = 0x0626;
  12592. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12593. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12594. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12595. t['yehinitialarabic'] = 0xFEF3;
  12596. t['yehmedialarabic'] = 0xFEF4;
  12597. t['yehmeeminitialarabic'] = 0xFCDD;
  12598. t['yehmeemisolatedarabic'] = 0xFC58;
  12599. t['yehnoonfinalarabic'] = 0xFC94;
  12600. t['yehthreedotsbelowarabic'] = 0x06D1;
  12601. t['yekorean'] = 0x3156;
  12602. t['yen'] = 0x00A5;
  12603. t['yenmonospace'] = 0xFFE5;
  12604. t['yeokorean'] = 0x3155;
  12605. t['yeorinhieuhkorean'] = 0x3186;
  12606. t['yerahbenyomohebrew'] = 0x05AA;
  12607. t['yerahbenyomolefthebrew'] = 0x05AA;
  12608. t['yericyrillic'] = 0x044B;
  12609. t['yerudieresiscyrillic'] = 0x04F9;
  12610. t['yesieungkorean'] = 0x3181;
  12611. t['yesieungpansioskorean'] = 0x3183;
  12612. t['yesieungsioskorean'] = 0x3182;
  12613. t['yetivhebrew'] = 0x059A;
  12614. t['ygrave'] = 0x1EF3;
  12615. t['yhook'] = 0x01B4;
  12616. t['yhookabove'] = 0x1EF7;
  12617. t['yiarmenian'] = 0x0575;
  12618. t['yicyrillic'] = 0x0457;
  12619. t['yikorean'] = 0x3162;
  12620. t['yinyang'] = 0x262F;
  12621. t['yiwnarmenian'] = 0x0582;
  12622. t['ymonospace'] = 0xFF59;
  12623. t['yod'] = 0x05D9;
  12624. t['yoddagesh'] = 0xFB39;
  12625. t['yoddageshhebrew'] = 0xFB39;
  12626. t['yodhebrew'] = 0x05D9;
  12627. t['yodyodhebrew'] = 0x05F2;
  12628. t['yodyodpatahhebrew'] = 0xFB1F;
  12629. t['yohiragana'] = 0x3088;
  12630. t['yoikorean'] = 0x3189;
  12631. t['yokatakana'] = 0x30E8;
  12632. t['yokatakanahalfwidth'] = 0xFF96;
  12633. t['yokorean'] = 0x315B;
  12634. t['yosmallhiragana'] = 0x3087;
  12635. t['yosmallkatakana'] = 0x30E7;
  12636. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12637. t['yotgreek'] = 0x03F3;
  12638. t['yoyaekorean'] = 0x3188;
  12639. t['yoyakorean'] = 0x3187;
  12640. t['yoyakthai'] = 0x0E22;
  12641. t['yoyingthai'] = 0x0E0D;
  12642. t['yparen'] = 0x24B4;
  12643. t['ypogegrammeni'] = 0x037A;
  12644. t['ypogegrammenigreekcmb'] = 0x0345;
  12645. t['yr'] = 0x01A6;
  12646. t['yring'] = 0x1E99;
  12647. t['ysuperior'] = 0x02B8;
  12648. t['ytilde'] = 0x1EF9;
  12649. t['yturned'] = 0x028E;
  12650. t['yuhiragana'] = 0x3086;
  12651. t['yuikorean'] = 0x318C;
  12652. t['yukatakana'] = 0x30E6;
  12653. t['yukatakanahalfwidth'] = 0xFF95;
  12654. t['yukorean'] = 0x3160;
  12655. t['yusbigcyrillic'] = 0x046B;
  12656. t['yusbigiotifiedcyrillic'] = 0x046D;
  12657. t['yuslittlecyrillic'] = 0x0467;
  12658. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12659. t['yusmallhiragana'] = 0x3085;
  12660. t['yusmallkatakana'] = 0x30E5;
  12661. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12662. t['yuyekorean'] = 0x318B;
  12663. t['yuyeokorean'] = 0x318A;
  12664. t['yyabengali'] = 0x09DF;
  12665. t['yyadeva'] = 0x095F;
  12666. t['z'] = 0x007A;
  12667. t['zaarmenian'] = 0x0566;
  12668. t['zacute'] = 0x017A;
  12669. t['zadeva'] = 0x095B;
  12670. t['zagurmukhi'] = 0x0A5B;
  12671. t['zaharabic'] = 0x0638;
  12672. t['zahfinalarabic'] = 0xFEC6;
  12673. t['zahinitialarabic'] = 0xFEC7;
  12674. t['zahiragana'] = 0x3056;
  12675. t['zahmedialarabic'] = 0xFEC8;
  12676. t['zainarabic'] = 0x0632;
  12677. t['zainfinalarabic'] = 0xFEB0;
  12678. t['zakatakana'] = 0x30B6;
  12679. t['zaqefgadolhebrew'] = 0x0595;
  12680. t['zaqefqatanhebrew'] = 0x0594;
  12681. t['zarqahebrew'] = 0x0598;
  12682. t['zayin'] = 0x05D6;
  12683. t['zayindagesh'] = 0xFB36;
  12684. t['zayindageshhebrew'] = 0xFB36;
  12685. t['zayinhebrew'] = 0x05D6;
  12686. t['zbopomofo'] = 0x3117;
  12687. t['zcaron'] = 0x017E;
  12688. t['zcircle'] = 0x24E9;
  12689. t['zcircumflex'] = 0x1E91;
  12690. t['zcurl'] = 0x0291;
  12691. t['zdot'] = 0x017C;
  12692. t['zdotaccent'] = 0x017C;
  12693. t['zdotbelow'] = 0x1E93;
  12694. t['zecyrillic'] = 0x0437;
  12695. t['zedescendercyrillic'] = 0x0499;
  12696. t['zedieresiscyrillic'] = 0x04DF;
  12697. t['zehiragana'] = 0x305C;
  12698. t['zekatakana'] = 0x30BC;
  12699. t['zero'] = 0x0030;
  12700. t['zeroarabic'] = 0x0660;
  12701. t['zerobengali'] = 0x09E6;
  12702. t['zerodeva'] = 0x0966;
  12703. t['zerogujarati'] = 0x0AE6;
  12704. t['zerogurmukhi'] = 0x0A66;
  12705. t['zerohackarabic'] = 0x0660;
  12706. t['zeroinferior'] = 0x2080;
  12707. t['zeromonospace'] = 0xFF10;
  12708. t['zerooldstyle'] = 0xF730;
  12709. t['zeropersian'] = 0x06F0;
  12710. t['zerosuperior'] = 0x2070;
  12711. t['zerothai'] = 0x0E50;
  12712. t['zerowidthjoiner'] = 0xFEFF;
  12713. t['zerowidthnonjoiner'] = 0x200C;
  12714. t['zerowidthspace'] = 0x200B;
  12715. t['zeta'] = 0x03B6;
  12716. t['zhbopomofo'] = 0x3113;
  12717. t['zhearmenian'] = 0x056A;
  12718. t['zhebrevecyrillic'] = 0x04C2;
  12719. t['zhecyrillic'] = 0x0436;
  12720. t['zhedescendercyrillic'] = 0x0497;
  12721. t['zhedieresiscyrillic'] = 0x04DD;
  12722. t['zihiragana'] = 0x3058;
  12723. t['zikatakana'] = 0x30B8;
  12724. t['zinorhebrew'] = 0x05AE;
  12725. t['zlinebelow'] = 0x1E95;
  12726. t['zmonospace'] = 0xFF5A;
  12727. t['zohiragana'] = 0x305E;
  12728. t['zokatakana'] = 0x30BE;
  12729. t['zparen'] = 0x24B5;
  12730. t['zretroflexhook'] = 0x0290;
  12731. t['zstroke'] = 0x01B6;
  12732. t['zuhiragana'] = 0x305A;
  12733. t['zukatakana'] = 0x30BA;
  12734. t['.notdef'] = 0x0000;
  12735. });
  12736. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12737. t['space'] = 0x0020;
  12738. t['a1'] = 0x2701;
  12739. t['a2'] = 0x2702;
  12740. t['a202'] = 0x2703;
  12741. t['a3'] = 0x2704;
  12742. t['a4'] = 0x260E;
  12743. t['a5'] = 0x2706;
  12744. t['a119'] = 0x2707;
  12745. t['a118'] = 0x2708;
  12746. t['a117'] = 0x2709;
  12747. t['a11'] = 0x261B;
  12748. t['a12'] = 0x261E;
  12749. t['a13'] = 0x270C;
  12750. t['a14'] = 0x270D;
  12751. t['a15'] = 0x270E;
  12752. t['a16'] = 0x270F;
  12753. t['a105'] = 0x2710;
  12754. t['a17'] = 0x2711;
  12755. t['a18'] = 0x2712;
  12756. t['a19'] = 0x2713;
  12757. t['a20'] = 0x2714;
  12758. t['a21'] = 0x2715;
  12759. t['a22'] = 0x2716;
  12760. t['a23'] = 0x2717;
  12761. t['a24'] = 0x2718;
  12762. t['a25'] = 0x2719;
  12763. t['a26'] = 0x271A;
  12764. t['a27'] = 0x271B;
  12765. t['a28'] = 0x271C;
  12766. t['a6'] = 0x271D;
  12767. t['a7'] = 0x271E;
  12768. t['a8'] = 0x271F;
  12769. t['a9'] = 0x2720;
  12770. t['a10'] = 0x2721;
  12771. t['a29'] = 0x2722;
  12772. t['a30'] = 0x2723;
  12773. t['a31'] = 0x2724;
  12774. t['a32'] = 0x2725;
  12775. t['a33'] = 0x2726;
  12776. t['a34'] = 0x2727;
  12777. t['a35'] = 0x2605;
  12778. t['a36'] = 0x2729;
  12779. t['a37'] = 0x272A;
  12780. t['a38'] = 0x272B;
  12781. t['a39'] = 0x272C;
  12782. t['a40'] = 0x272D;
  12783. t['a41'] = 0x272E;
  12784. t['a42'] = 0x272F;
  12785. t['a43'] = 0x2730;
  12786. t['a44'] = 0x2731;
  12787. t['a45'] = 0x2732;
  12788. t['a46'] = 0x2733;
  12789. t['a47'] = 0x2734;
  12790. t['a48'] = 0x2735;
  12791. t['a49'] = 0x2736;
  12792. t['a50'] = 0x2737;
  12793. t['a51'] = 0x2738;
  12794. t['a52'] = 0x2739;
  12795. t['a53'] = 0x273A;
  12796. t['a54'] = 0x273B;
  12797. t['a55'] = 0x273C;
  12798. t['a56'] = 0x273D;
  12799. t['a57'] = 0x273E;
  12800. t['a58'] = 0x273F;
  12801. t['a59'] = 0x2740;
  12802. t['a60'] = 0x2741;
  12803. t['a61'] = 0x2742;
  12804. t['a62'] = 0x2743;
  12805. t['a63'] = 0x2744;
  12806. t['a64'] = 0x2745;
  12807. t['a65'] = 0x2746;
  12808. t['a66'] = 0x2747;
  12809. t['a67'] = 0x2748;
  12810. t['a68'] = 0x2749;
  12811. t['a69'] = 0x274A;
  12812. t['a70'] = 0x274B;
  12813. t['a71'] = 0x25CF;
  12814. t['a72'] = 0x274D;
  12815. t['a73'] = 0x25A0;
  12816. t['a74'] = 0x274F;
  12817. t['a203'] = 0x2750;
  12818. t['a75'] = 0x2751;
  12819. t['a204'] = 0x2752;
  12820. t['a76'] = 0x25B2;
  12821. t['a77'] = 0x25BC;
  12822. t['a78'] = 0x25C6;
  12823. t['a79'] = 0x2756;
  12824. t['a81'] = 0x25D7;
  12825. t['a82'] = 0x2758;
  12826. t['a83'] = 0x2759;
  12827. t['a84'] = 0x275A;
  12828. t['a97'] = 0x275B;
  12829. t['a98'] = 0x275C;
  12830. t['a99'] = 0x275D;
  12831. t['a100'] = 0x275E;
  12832. t['a101'] = 0x2761;
  12833. t['a102'] = 0x2762;
  12834. t['a103'] = 0x2763;
  12835. t['a104'] = 0x2764;
  12836. t['a106'] = 0x2765;
  12837. t['a107'] = 0x2766;
  12838. t['a108'] = 0x2767;
  12839. t['a112'] = 0x2663;
  12840. t['a111'] = 0x2666;
  12841. t['a110'] = 0x2665;
  12842. t['a109'] = 0x2660;
  12843. t['a120'] = 0x2460;
  12844. t['a121'] = 0x2461;
  12845. t['a122'] = 0x2462;
  12846. t['a123'] = 0x2463;
  12847. t['a124'] = 0x2464;
  12848. t['a125'] = 0x2465;
  12849. t['a126'] = 0x2466;
  12850. t['a127'] = 0x2467;
  12851. t['a128'] = 0x2468;
  12852. t['a129'] = 0x2469;
  12853. t['a130'] = 0x2776;
  12854. t['a131'] = 0x2777;
  12855. t['a132'] = 0x2778;
  12856. t['a133'] = 0x2779;
  12857. t['a134'] = 0x277A;
  12858. t['a135'] = 0x277B;
  12859. t['a136'] = 0x277C;
  12860. t['a137'] = 0x277D;
  12861. t['a138'] = 0x277E;
  12862. t['a139'] = 0x277F;
  12863. t['a140'] = 0x2780;
  12864. t['a141'] = 0x2781;
  12865. t['a142'] = 0x2782;
  12866. t['a143'] = 0x2783;
  12867. t['a144'] = 0x2784;
  12868. t['a145'] = 0x2785;
  12869. t['a146'] = 0x2786;
  12870. t['a147'] = 0x2787;
  12871. t['a148'] = 0x2788;
  12872. t['a149'] = 0x2789;
  12873. t['a150'] = 0x278A;
  12874. t['a151'] = 0x278B;
  12875. t['a152'] = 0x278C;
  12876. t['a153'] = 0x278D;
  12877. t['a154'] = 0x278E;
  12878. t['a155'] = 0x278F;
  12879. t['a156'] = 0x2790;
  12880. t['a157'] = 0x2791;
  12881. t['a158'] = 0x2792;
  12882. t['a159'] = 0x2793;
  12883. t['a160'] = 0x2794;
  12884. t['a161'] = 0x2192;
  12885. t['a163'] = 0x2194;
  12886. t['a164'] = 0x2195;
  12887. t['a196'] = 0x2798;
  12888. t['a165'] = 0x2799;
  12889. t['a192'] = 0x279A;
  12890. t['a166'] = 0x279B;
  12891. t['a167'] = 0x279C;
  12892. t['a168'] = 0x279D;
  12893. t['a169'] = 0x279E;
  12894. t['a170'] = 0x279F;
  12895. t['a171'] = 0x27A0;
  12896. t['a172'] = 0x27A1;
  12897. t['a173'] = 0x27A2;
  12898. t['a162'] = 0x27A3;
  12899. t['a174'] = 0x27A4;
  12900. t['a175'] = 0x27A5;
  12901. t['a176'] = 0x27A6;
  12902. t['a177'] = 0x27A7;
  12903. t['a178'] = 0x27A8;
  12904. t['a179'] = 0x27A9;
  12905. t['a193'] = 0x27AA;
  12906. t['a180'] = 0x27AB;
  12907. t['a199'] = 0x27AC;
  12908. t['a181'] = 0x27AD;
  12909. t['a200'] = 0x27AE;
  12910. t['a182'] = 0x27AF;
  12911. t['a201'] = 0x27B1;
  12912. t['a183'] = 0x27B2;
  12913. t['a184'] = 0x27B3;
  12914. t['a197'] = 0x27B4;
  12915. t['a185'] = 0x27B5;
  12916. t['a194'] = 0x27B6;
  12917. t['a198'] = 0x27B7;
  12918. t['a186'] = 0x27B8;
  12919. t['a195'] = 0x27B9;
  12920. t['a187'] = 0x27BA;
  12921. t['a188'] = 0x27BB;
  12922. t['a189'] = 0x27BC;
  12923. t['a190'] = 0x27BD;
  12924. t['a191'] = 0x27BE;
  12925. t['a89'] = 0x2768;
  12926. t['a90'] = 0x2769;
  12927. t['a93'] = 0x276A;
  12928. t['a94'] = 0x276B;
  12929. t['a91'] = 0x276C;
  12930. t['a92'] = 0x276D;
  12931. t['a205'] = 0x276E;
  12932. t['a85'] = 0x276F;
  12933. t['a206'] = 0x2770;
  12934. t['a86'] = 0x2771;
  12935. t['a87'] = 0x2772;
  12936. t['a88'] = 0x2773;
  12937. t['a95'] = 0x2774;
  12938. t['a96'] = 0x2775;
  12939. t['.notdef'] = 0x0000;
  12940. });
  12941. exports.getGlyphsUnicode = getGlyphsUnicode;
  12942. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  12943. }));
  12944. (function (root, factory) {
  12945. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  12946. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  12947. var error = sharedUtil.error;
  12948. var log2 = sharedUtil.log2;
  12949. var readInt8 = sharedUtil.readInt8;
  12950. var readUint16 = sharedUtil.readUint16;
  12951. var readUint32 = sharedUtil.readUint32;
  12952. var shadow = sharedUtil.shadow;
  12953. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  12954. var Jbig2Image = function Jbig2ImageClosure() {
  12955. function ContextCache() {
  12956. }
  12957. ContextCache.prototype = {
  12958. getContexts: function (id) {
  12959. if (id in this) {
  12960. return this[id];
  12961. }
  12962. return this[id] = new Int8Array(1 << 16);
  12963. }
  12964. };
  12965. function DecodingContext(data, start, end) {
  12966. this.data = data;
  12967. this.start = start;
  12968. this.end = end;
  12969. }
  12970. DecodingContext.prototype = {
  12971. get decoder() {
  12972. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  12973. return shadow(this, 'decoder', decoder);
  12974. },
  12975. get contextCache() {
  12976. var cache = new ContextCache();
  12977. return shadow(this, 'contextCache', cache);
  12978. }
  12979. };
  12980. function decodeInteger(contextCache, procedure, decoder) {
  12981. var contexts = contextCache.getContexts(procedure);
  12982. var prev = 1;
  12983. function readBits(length) {
  12984. var v = 0;
  12985. for (var i = 0; i < length; i++) {
  12986. var bit = decoder.readBit(contexts, prev);
  12987. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  12988. v = v << 1 | bit;
  12989. }
  12990. return v >>> 0;
  12991. }
  12992. var sign = readBits(1);
  12993. 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);
  12994. return sign === 0 ? value : value > 0 ? -value : null;
  12995. }
  12996. function decodeIAID(contextCache, decoder, codeLength) {
  12997. var contexts = contextCache.getContexts('IAID');
  12998. var prev = 1;
  12999. for (var i = 0; i < codeLength; i++) {
  13000. var bit = decoder.readBit(contexts, prev);
  13001. prev = prev << 1 | bit;
  13002. }
  13003. if (codeLength < 31) {
  13004. return prev & (1 << codeLength) - 1;
  13005. }
  13006. return prev & 0x7FFFFFFF;
  13007. }
  13008. var SegmentTypes = [
  13009. 'SymbolDictionary',
  13010. null,
  13011. null,
  13012. null,
  13013. 'IntermediateTextRegion',
  13014. null,
  13015. 'ImmediateTextRegion',
  13016. 'ImmediateLosslessTextRegion',
  13017. null,
  13018. null,
  13019. null,
  13020. null,
  13021. null,
  13022. null,
  13023. null,
  13024. null,
  13025. 'patternDictionary',
  13026. null,
  13027. null,
  13028. null,
  13029. 'IntermediateHalftoneRegion',
  13030. null,
  13031. 'ImmediateHalftoneRegion',
  13032. 'ImmediateLosslessHalftoneRegion',
  13033. null,
  13034. null,
  13035. null,
  13036. null,
  13037. null,
  13038. null,
  13039. null,
  13040. null,
  13041. null,
  13042. null,
  13043. null,
  13044. null,
  13045. 'IntermediateGenericRegion',
  13046. null,
  13047. 'ImmediateGenericRegion',
  13048. 'ImmediateLosslessGenericRegion',
  13049. 'IntermediateGenericRefinementRegion',
  13050. null,
  13051. 'ImmediateGenericRefinementRegion',
  13052. 'ImmediateLosslessGenericRefinementRegion',
  13053. null,
  13054. null,
  13055. null,
  13056. null,
  13057. 'PageInformation',
  13058. 'EndOfPage',
  13059. 'EndOfStripe',
  13060. 'EndOfFile',
  13061. 'Profiles',
  13062. 'Tables',
  13063. null,
  13064. null,
  13065. null,
  13066. null,
  13067. null,
  13068. null,
  13069. null,
  13070. null,
  13071. 'Extension'
  13072. ];
  13073. var CodingTemplates = [
  13074. [
  13075. {
  13076. x: -1,
  13077. y: -2
  13078. },
  13079. {
  13080. x: 0,
  13081. y: -2
  13082. },
  13083. {
  13084. x: 1,
  13085. y: -2
  13086. },
  13087. {
  13088. x: -2,
  13089. y: -1
  13090. },
  13091. {
  13092. x: -1,
  13093. y: -1
  13094. },
  13095. {
  13096. x: 0,
  13097. y: -1
  13098. },
  13099. {
  13100. x: 1,
  13101. y: -1
  13102. },
  13103. {
  13104. x: 2,
  13105. y: -1
  13106. },
  13107. {
  13108. x: -4,
  13109. y: 0
  13110. },
  13111. {
  13112. x: -3,
  13113. y: 0
  13114. },
  13115. {
  13116. x: -2,
  13117. y: 0
  13118. },
  13119. {
  13120. x: -1,
  13121. y: 0
  13122. }
  13123. ],
  13124. [
  13125. {
  13126. x: -1,
  13127. y: -2
  13128. },
  13129. {
  13130. x: 0,
  13131. y: -2
  13132. },
  13133. {
  13134. x: 1,
  13135. y: -2
  13136. },
  13137. {
  13138. x: 2,
  13139. y: -2
  13140. },
  13141. {
  13142. x: -2,
  13143. y: -1
  13144. },
  13145. {
  13146. x: -1,
  13147. y: -1
  13148. },
  13149. {
  13150. x: 0,
  13151. y: -1
  13152. },
  13153. {
  13154. x: 1,
  13155. y: -1
  13156. },
  13157. {
  13158. x: 2,
  13159. y: -1
  13160. },
  13161. {
  13162. x: -3,
  13163. y: 0
  13164. },
  13165. {
  13166. x: -2,
  13167. y: 0
  13168. },
  13169. {
  13170. x: -1,
  13171. y: 0
  13172. }
  13173. ],
  13174. [
  13175. {
  13176. x: -1,
  13177. y: -2
  13178. },
  13179. {
  13180. x: 0,
  13181. y: -2
  13182. },
  13183. {
  13184. x: 1,
  13185. y: -2
  13186. },
  13187. {
  13188. x: -2,
  13189. y: -1
  13190. },
  13191. {
  13192. x: -1,
  13193. y: -1
  13194. },
  13195. {
  13196. x: 0,
  13197. y: -1
  13198. },
  13199. {
  13200. x: 1,
  13201. y: -1
  13202. },
  13203. {
  13204. x: -2,
  13205. y: 0
  13206. },
  13207. {
  13208. x: -1,
  13209. y: 0
  13210. }
  13211. ],
  13212. [
  13213. {
  13214. x: -3,
  13215. y: -1
  13216. },
  13217. {
  13218. x: -2,
  13219. y: -1
  13220. },
  13221. {
  13222. x: -1,
  13223. y: -1
  13224. },
  13225. {
  13226. x: 0,
  13227. y: -1
  13228. },
  13229. {
  13230. x: 1,
  13231. y: -1
  13232. },
  13233. {
  13234. x: -4,
  13235. y: 0
  13236. },
  13237. {
  13238. x: -3,
  13239. y: 0
  13240. },
  13241. {
  13242. x: -2,
  13243. y: 0
  13244. },
  13245. {
  13246. x: -1,
  13247. y: 0
  13248. }
  13249. ]
  13250. ];
  13251. var RefinementTemplates = [
  13252. {
  13253. coding: [
  13254. {
  13255. x: 0,
  13256. y: -1
  13257. },
  13258. {
  13259. x: 1,
  13260. y: -1
  13261. },
  13262. {
  13263. x: -1,
  13264. y: 0
  13265. }
  13266. ],
  13267. reference: [
  13268. {
  13269. x: 0,
  13270. y: -1
  13271. },
  13272. {
  13273. x: 1,
  13274. y: -1
  13275. },
  13276. {
  13277. x: -1,
  13278. y: 0
  13279. },
  13280. {
  13281. x: 0,
  13282. y: 0
  13283. },
  13284. {
  13285. x: 1,
  13286. y: 0
  13287. },
  13288. {
  13289. x: -1,
  13290. y: 1
  13291. },
  13292. {
  13293. x: 0,
  13294. y: 1
  13295. },
  13296. {
  13297. x: 1,
  13298. y: 1
  13299. }
  13300. ]
  13301. },
  13302. {
  13303. coding: [
  13304. {
  13305. x: -1,
  13306. y: -1
  13307. },
  13308. {
  13309. x: 0,
  13310. y: -1
  13311. },
  13312. {
  13313. x: 1,
  13314. y: -1
  13315. },
  13316. {
  13317. x: -1,
  13318. y: 0
  13319. }
  13320. ],
  13321. reference: [
  13322. {
  13323. x: 0,
  13324. y: -1
  13325. },
  13326. {
  13327. x: -1,
  13328. y: 0
  13329. },
  13330. {
  13331. x: 0,
  13332. y: 0
  13333. },
  13334. {
  13335. x: 1,
  13336. y: 0
  13337. },
  13338. {
  13339. x: 0,
  13340. y: 1
  13341. },
  13342. {
  13343. x: 1,
  13344. y: 1
  13345. }
  13346. ]
  13347. }
  13348. ];
  13349. var ReusedContexts = [
  13350. 0x9B25,
  13351. 0x0795,
  13352. 0x00E5,
  13353. 0x0195
  13354. ];
  13355. var RefinementReusedContexts = [
  13356. 0x0020,
  13357. 0x0008
  13358. ];
  13359. function decodeBitmapTemplate0(width, height, decodingContext) {
  13360. var decoder = decodingContext.decoder;
  13361. var contexts = decodingContext.contextCache.getContexts('GB');
  13362. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13363. var OLD_PIXEL_MASK = 0x7BF7;
  13364. for (i = 0; i < height; i++) {
  13365. row = bitmap[i] = new Uint8Array(width);
  13366. row1 = i < 1 ? row : bitmap[i - 1];
  13367. row2 = i < 2 ? row : bitmap[i - 2];
  13368. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13369. for (j = 0; j < width; j++) {
  13370. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13371. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13372. }
  13373. }
  13374. return bitmap;
  13375. }
  13376. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13377. if (mmr) {
  13378. error('JBIG2 error: MMR encoding is not supported');
  13379. }
  13380. 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) {
  13381. return decodeBitmapTemplate0(width, height, decodingContext);
  13382. }
  13383. var useskip = !!skip;
  13384. var template = CodingTemplates[templateIndex].concat(at);
  13385. template.sort(function (a, b) {
  13386. return a.y - b.y || a.x - b.x;
  13387. });
  13388. var templateLength = template.length;
  13389. var templateX = new Int8Array(templateLength);
  13390. var templateY = new Int8Array(templateLength);
  13391. var changingTemplateEntries = [];
  13392. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13393. var c, k;
  13394. for (k = 0; k < templateLength; k++) {
  13395. templateX[k] = template[k].x;
  13396. templateY[k] = template[k].y;
  13397. minX = Math.min(minX, template[k].x);
  13398. maxX = Math.max(maxX, template[k].x);
  13399. minY = Math.min(minY, template[k].y);
  13400. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13401. reuseMask |= 1 << templateLength - 1 - k;
  13402. } else {
  13403. changingTemplateEntries.push(k);
  13404. }
  13405. }
  13406. var changingEntriesLength = changingTemplateEntries.length;
  13407. var changingTemplateX = new Int8Array(changingEntriesLength);
  13408. var changingTemplateY = new Int8Array(changingEntriesLength);
  13409. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13410. for (c = 0; c < changingEntriesLength; c++) {
  13411. k = changingTemplateEntries[c];
  13412. changingTemplateX[c] = template[k].x;
  13413. changingTemplateY[c] = template[k].y;
  13414. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13415. }
  13416. var sbb_left = -minX;
  13417. var sbb_top = -minY;
  13418. var sbb_right = width - maxX;
  13419. var pseudoPixelContext = ReusedContexts[templateIndex];
  13420. var row = new Uint8Array(width);
  13421. var bitmap = [];
  13422. var decoder = decodingContext.decoder;
  13423. var contexts = decodingContext.contextCache.getContexts('GB');
  13424. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13425. for (var i = 0; i < height; i++) {
  13426. if (prediction) {
  13427. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13428. ltp ^= sltp;
  13429. if (ltp) {
  13430. bitmap.push(row);
  13431. continue;
  13432. }
  13433. }
  13434. row = new Uint8Array(row);
  13435. bitmap.push(row);
  13436. for (j = 0; j < width; j++) {
  13437. if (useskip && skip[i][j]) {
  13438. row[j] = 0;
  13439. continue;
  13440. }
  13441. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13442. contextLabel = contextLabel << 1 & reuseMask;
  13443. for (k = 0; k < changingEntriesLength; k++) {
  13444. i0 = i + changingTemplateY[k];
  13445. j0 = j + changingTemplateX[k];
  13446. bit = bitmap[i0][j0];
  13447. if (bit) {
  13448. bit = changingTemplateBit[k];
  13449. contextLabel |= bit;
  13450. }
  13451. }
  13452. } else {
  13453. contextLabel = 0;
  13454. shift = templateLength - 1;
  13455. for (k = 0; k < templateLength; k++, shift--) {
  13456. j0 = j + templateX[k];
  13457. if (j0 >= 0 && j0 < width) {
  13458. i0 = i + templateY[k];
  13459. if (i0 >= 0) {
  13460. bit = bitmap[i0][j0];
  13461. if (bit) {
  13462. contextLabel |= bit << shift;
  13463. }
  13464. }
  13465. }
  13466. }
  13467. }
  13468. var pixel = decoder.readBit(contexts, contextLabel);
  13469. row[j] = pixel;
  13470. }
  13471. }
  13472. return bitmap;
  13473. }
  13474. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13475. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13476. if (templateIndex === 0) {
  13477. codingTemplate = codingTemplate.concat([at[0]]);
  13478. }
  13479. var codingTemplateLength = codingTemplate.length;
  13480. var codingTemplateX = new Int32Array(codingTemplateLength);
  13481. var codingTemplateY = new Int32Array(codingTemplateLength);
  13482. var k;
  13483. for (k = 0; k < codingTemplateLength; k++) {
  13484. codingTemplateX[k] = codingTemplate[k].x;
  13485. codingTemplateY[k] = codingTemplate[k].y;
  13486. }
  13487. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13488. if (templateIndex === 0) {
  13489. referenceTemplate = referenceTemplate.concat([at[1]]);
  13490. }
  13491. var referenceTemplateLength = referenceTemplate.length;
  13492. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13493. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13494. for (k = 0; k < referenceTemplateLength; k++) {
  13495. referenceTemplateX[k] = referenceTemplate[k].x;
  13496. referenceTemplateY[k] = referenceTemplate[k].y;
  13497. }
  13498. var referenceWidth = referenceBitmap[0].length;
  13499. var referenceHeight = referenceBitmap.length;
  13500. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13501. var bitmap = [];
  13502. var decoder = decodingContext.decoder;
  13503. var contexts = decodingContext.contextCache.getContexts('GR');
  13504. var ltp = 0;
  13505. for (var i = 0; i < height; i++) {
  13506. if (prediction) {
  13507. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13508. ltp ^= sltp;
  13509. if (ltp) {
  13510. error('JBIG2 error: prediction is not supported');
  13511. }
  13512. }
  13513. var row = new Uint8Array(width);
  13514. bitmap.push(row);
  13515. for (var j = 0; j < width; j++) {
  13516. var i0, j0;
  13517. var contextLabel = 0;
  13518. for (k = 0; k < codingTemplateLength; k++) {
  13519. i0 = i + codingTemplateY[k];
  13520. j0 = j + codingTemplateX[k];
  13521. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13522. contextLabel <<= 1;
  13523. } else
  13524. {
  13525. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13526. }
  13527. }
  13528. for (k = 0; k < referenceTemplateLength; k++) {
  13529. i0 = i + referenceTemplateY[k] + offsetY;
  13530. j0 = j + referenceTemplateX[k] + offsetX;
  13531. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13532. contextLabel <<= 1;
  13533. } else
  13534. {
  13535. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13536. }
  13537. }
  13538. var pixel = decoder.readBit(contexts, contextLabel);
  13539. row[j] = pixel;
  13540. }
  13541. }
  13542. return bitmap;
  13543. }
  13544. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13545. if (huffman) {
  13546. error('JBIG2 error: huffman is not supported');
  13547. }
  13548. var newSymbols = [];
  13549. var currentHeight = 0;
  13550. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13551. var decoder = decodingContext.decoder;
  13552. var contextCache = decodingContext.contextCache;
  13553. while (newSymbols.length < numberOfNewSymbols) {
  13554. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13555. currentHeight += deltaHeight;
  13556. var currentWidth = 0;
  13557. var totalWidth = 0;
  13558. while (true) {
  13559. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13560. if (deltaWidth === null) {
  13561. break;
  13562. }
  13563. currentWidth += deltaWidth;
  13564. totalWidth += currentWidth;
  13565. var bitmap;
  13566. if (refinement) {
  13567. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13568. if (numberOfInstances > 1) {
  13569. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13570. } else {
  13571. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13572. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13573. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13574. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13575. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13576. }
  13577. } else {
  13578. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13579. }
  13580. newSymbols.push(bitmap);
  13581. }
  13582. }
  13583. var exportedSymbols = [];
  13584. var flags = [], currentFlag = false;
  13585. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13586. while (flags.length < totalSymbolsLength) {
  13587. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13588. while (runLength--) {
  13589. flags.push(currentFlag);
  13590. }
  13591. currentFlag = !currentFlag;
  13592. }
  13593. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13594. if (flags[i]) {
  13595. exportedSymbols.push(symbols[i]);
  13596. }
  13597. }
  13598. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13599. if (flags[i]) {
  13600. exportedSymbols.push(newSymbols[j]);
  13601. }
  13602. }
  13603. return exportedSymbols;
  13604. }
  13605. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13606. if (huffman) {
  13607. error('JBIG2 error: huffman is not supported');
  13608. }
  13609. var bitmap = [];
  13610. var i, row;
  13611. for (i = 0; i < height; i++) {
  13612. row = new Uint8Array(width);
  13613. if (defaultPixelValue) {
  13614. for (var j = 0; j < width; j++) {
  13615. row[j] = defaultPixelValue;
  13616. }
  13617. }
  13618. bitmap.push(row);
  13619. }
  13620. var decoder = decodingContext.decoder;
  13621. var contextCache = decodingContext.contextCache;
  13622. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13623. var firstS = 0;
  13624. i = 0;
  13625. while (i < numberOfSymbolInstances) {
  13626. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13627. stripT += deltaT;
  13628. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13629. firstS += deltaFirstS;
  13630. var currentS = firstS;
  13631. do {
  13632. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13633. var t = stripSize * stripT + currentT;
  13634. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13635. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13636. var symbolBitmap = inputSymbols[symbolId];
  13637. var symbolWidth = symbolBitmap[0].length;
  13638. var symbolHeight = symbolBitmap.length;
  13639. if (applyRefinement) {
  13640. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13641. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13642. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13643. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13644. symbolWidth += rdw;
  13645. symbolHeight += rdh;
  13646. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13647. }
  13648. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13649. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13650. var s2, t2, symbolRow;
  13651. if (transposed) {
  13652. for (s2 = 0; s2 < symbolHeight; s2++) {
  13653. row = bitmap[offsetS + s2];
  13654. if (!row) {
  13655. continue;
  13656. }
  13657. symbolRow = symbolBitmap[s2];
  13658. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13659. switch (combinationOperator) {
  13660. case 0:
  13661. for (t2 = 0; t2 < maxWidth; t2++) {
  13662. row[offsetT + t2] |= symbolRow[t2];
  13663. }
  13664. break;
  13665. case 2:
  13666. for (t2 = 0; t2 < maxWidth; t2++) {
  13667. row[offsetT + t2] ^= symbolRow[t2];
  13668. }
  13669. break;
  13670. default:
  13671. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13672. }
  13673. }
  13674. currentS += symbolHeight - 1;
  13675. } else {
  13676. for (t2 = 0; t2 < symbolHeight; t2++) {
  13677. row = bitmap[offsetT + t2];
  13678. if (!row) {
  13679. continue;
  13680. }
  13681. symbolRow = symbolBitmap[t2];
  13682. switch (combinationOperator) {
  13683. case 0:
  13684. for (s2 = 0; s2 < symbolWidth; s2++) {
  13685. row[offsetS + s2] |= symbolRow[s2];
  13686. }
  13687. break;
  13688. case 2:
  13689. for (s2 = 0; s2 < symbolWidth; s2++) {
  13690. row[offsetS + s2] ^= symbolRow[s2];
  13691. }
  13692. break;
  13693. default:
  13694. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13695. }
  13696. }
  13697. currentS += symbolWidth - 1;
  13698. }
  13699. i++;
  13700. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13701. if (deltaS === null) {
  13702. break;
  13703. }
  13704. currentS += deltaS + dsOffset;
  13705. } while (true);
  13706. }
  13707. return bitmap;
  13708. }
  13709. function readSegmentHeader(data, start) {
  13710. var segmentHeader = {};
  13711. segmentHeader.number = readUint32(data, start);
  13712. var flags = data[start + 4];
  13713. var segmentType = flags & 0x3F;
  13714. if (!SegmentTypes[segmentType]) {
  13715. error('JBIG2 error: invalid segment type: ' + segmentType);
  13716. }
  13717. segmentHeader.type = segmentType;
  13718. segmentHeader.typeName = SegmentTypes[segmentType];
  13719. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13720. var pageAssociationFieldSize = !!(flags & 0x40);
  13721. var referredFlags = data[start + 5];
  13722. var referredToCount = referredFlags >> 5 & 7;
  13723. var retainBits = [referredFlags & 31];
  13724. var position = start + 6;
  13725. if (referredFlags === 7) {
  13726. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13727. position += 3;
  13728. var bytes = referredToCount + 7 >> 3;
  13729. retainBits[0] = data[position++];
  13730. while (--bytes > 0) {
  13731. retainBits.push(data[position++]);
  13732. }
  13733. } else if (referredFlags === 5 || referredFlags === 6) {
  13734. error('JBIG2 error: invalid referred-to flags');
  13735. }
  13736. segmentHeader.retainBits = retainBits;
  13737. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13738. var referredTo = [];
  13739. var i, ii;
  13740. for (i = 0; i < referredToCount; i++) {
  13741. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13742. referredTo.push(number);
  13743. position += referredToSegmentNumberSize;
  13744. }
  13745. segmentHeader.referredTo = referredTo;
  13746. if (!pageAssociationFieldSize) {
  13747. segmentHeader.pageAssociation = data[position++];
  13748. } else {
  13749. segmentHeader.pageAssociation = readUint32(data, position);
  13750. position += 4;
  13751. }
  13752. segmentHeader.length = readUint32(data, position);
  13753. position += 4;
  13754. if (segmentHeader.length === 0xFFFFFFFF) {
  13755. if (segmentType === 38) {
  13756. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13757. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13758. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13759. var searchPatternLength = 6;
  13760. var searchPattern = new Uint8Array(searchPatternLength);
  13761. if (!genericRegionMmr) {
  13762. searchPattern[0] = 0xFF;
  13763. searchPattern[1] = 0xAC;
  13764. }
  13765. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13766. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13767. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13768. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13769. for (i = position, ii = data.length; i < ii; i++) {
  13770. var j = 0;
  13771. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13772. j++;
  13773. }
  13774. if (j === searchPatternLength) {
  13775. segmentHeader.length = i + searchPatternLength;
  13776. break;
  13777. }
  13778. }
  13779. if (segmentHeader.length === 0xFFFFFFFF) {
  13780. error('JBIG2 error: segment end was not found');
  13781. }
  13782. } else {
  13783. error('JBIG2 error: invalid unknown segment length');
  13784. }
  13785. }
  13786. segmentHeader.headerEnd = position;
  13787. return segmentHeader;
  13788. }
  13789. function readSegments(header, data, start, end) {
  13790. var segments = [];
  13791. var position = start;
  13792. while (position < end) {
  13793. var segmentHeader = readSegmentHeader(data, position);
  13794. position = segmentHeader.headerEnd;
  13795. var segment = {
  13796. header: segmentHeader,
  13797. data: data
  13798. };
  13799. if (!header.randomAccess) {
  13800. segment.start = position;
  13801. position += segmentHeader.length;
  13802. segment.end = position;
  13803. }
  13804. segments.push(segment);
  13805. if (segmentHeader.type === 51) {
  13806. break;
  13807. }
  13808. }
  13809. if (header.randomAccess) {
  13810. for (var i = 0, ii = segments.length; i < ii; i++) {
  13811. segments[i].start = position;
  13812. position += segments[i].header.length;
  13813. segments[i].end = position;
  13814. }
  13815. }
  13816. return segments;
  13817. }
  13818. function readRegionSegmentInformation(data, start) {
  13819. return {
  13820. width: readUint32(data, start),
  13821. height: readUint32(data, start + 4),
  13822. x: readUint32(data, start + 8),
  13823. y: readUint32(data, start + 12),
  13824. combinationOperator: data[start + 16] & 7
  13825. };
  13826. }
  13827. var RegionSegmentInformationFieldLength = 17;
  13828. function processSegment(segment, visitor) {
  13829. var header = segment.header;
  13830. var data = segment.data, position = segment.start, end = segment.end;
  13831. var args, at, i, atLength;
  13832. switch (header.type) {
  13833. case 0:
  13834. var dictionary = {};
  13835. var dictionaryFlags = readUint16(data, position);
  13836. dictionary.huffman = !!(dictionaryFlags & 1);
  13837. dictionary.refinement = !!(dictionaryFlags & 2);
  13838. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13839. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13840. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13841. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13842. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13843. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13844. dictionary.template = dictionaryFlags >> 10 & 3;
  13845. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13846. position += 2;
  13847. if (!dictionary.huffman) {
  13848. atLength = dictionary.template === 0 ? 4 : 1;
  13849. at = [];
  13850. for (i = 0; i < atLength; i++) {
  13851. at.push({
  13852. x: readInt8(data, position),
  13853. y: readInt8(data, position + 1)
  13854. });
  13855. position += 2;
  13856. }
  13857. dictionary.at = at;
  13858. }
  13859. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13860. at = [];
  13861. for (i = 0; i < 2; i++) {
  13862. at.push({
  13863. x: readInt8(data, position),
  13864. y: readInt8(data, position + 1)
  13865. });
  13866. position += 2;
  13867. }
  13868. dictionary.refinementAt = at;
  13869. }
  13870. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13871. position += 4;
  13872. dictionary.numberOfNewSymbols = readUint32(data, position);
  13873. position += 4;
  13874. args = [
  13875. dictionary,
  13876. header.number,
  13877. header.referredTo,
  13878. data,
  13879. position,
  13880. end
  13881. ];
  13882. break;
  13883. case 6:
  13884. case 7:
  13885. var textRegion = {};
  13886. textRegion.info = readRegionSegmentInformation(data, position);
  13887. position += RegionSegmentInformationFieldLength;
  13888. var textRegionSegmentFlags = readUint16(data, position);
  13889. position += 2;
  13890. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  13891. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  13892. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  13893. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  13894. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  13895. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  13896. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  13897. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  13898. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  13899. if (textRegion.huffman) {
  13900. var textRegionHuffmanFlags = readUint16(data, position);
  13901. position += 2;
  13902. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  13903. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  13904. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  13905. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  13906. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  13907. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  13908. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  13909. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  13910. }
  13911. if (textRegion.refinement && !textRegion.refinementTemplate) {
  13912. at = [];
  13913. for (i = 0; i < 2; i++) {
  13914. at.push({
  13915. x: readInt8(data, position),
  13916. y: readInt8(data, position + 1)
  13917. });
  13918. position += 2;
  13919. }
  13920. textRegion.refinementAt = at;
  13921. }
  13922. textRegion.numberOfSymbolInstances = readUint32(data, position);
  13923. position += 4;
  13924. if (textRegion.huffman) {
  13925. error('JBIG2 error: huffman is not supported');
  13926. }
  13927. args = [
  13928. textRegion,
  13929. header.referredTo,
  13930. data,
  13931. position,
  13932. end
  13933. ];
  13934. break;
  13935. case 38:
  13936. case 39:
  13937. var genericRegion = {};
  13938. genericRegion.info = readRegionSegmentInformation(data, position);
  13939. position += RegionSegmentInformationFieldLength;
  13940. var genericRegionSegmentFlags = data[position++];
  13941. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  13942. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  13943. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  13944. if (!genericRegion.mmr) {
  13945. atLength = genericRegion.template === 0 ? 4 : 1;
  13946. at = [];
  13947. for (i = 0; i < atLength; i++) {
  13948. at.push({
  13949. x: readInt8(data, position),
  13950. y: readInt8(data, position + 1)
  13951. });
  13952. position += 2;
  13953. }
  13954. genericRegion.at = at;
  13955. }
  13956. args = [
  13957. genericRegion,
  13958. data,
  13959. position,
  13960. end
  13961. ];
  13962. break;
  13963. case 48:
  13964. var pageInfo = {
  13965. width: readUint32(data, position),
  13966. height: readUint32(data, position + 4),
  13967. resolutionX: readUint32(data, position + 8),
  13968. resolutionY: readUint32(data, position + 12)
  13969. };
  13970. if (pageInfo.height === 0xFFFFFFFF) {
  13971. delete pageInfo.height;
  13972. }
  13973. var pageSegmentFlags = data[position + 16];
  13974. var pageStripingInformation = readUint16(data, position + 17);
  13975. pageInfo.lossless = !!(pageSegmentFlags & 1);
  13976. pageInfo.refinement = !!(pageSegmentFlags & 2);
  13977. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  13978. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  13979. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  13980. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  13981. args = [pageInfo];
  13982. break;
  13983. case 49:
  13984. break;
  13985. case 50:
  13986. break;
  13987. case 51:
  13988. break;
  13989. case 62:
  13990. break;
  13991. default:
  13992. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  13993. }
  13994. var callbackName = 'on' + header.typeName;
  13995. if (callbackName in visitor) {
  13996. visitor[callbackName].apply(visitor, args);
  13997. }
  13998. }
  13999. function processSegments(segments, visitor) {
  14000. for (var i = 0, ii = segments.length; i < ii; i++) {
  14001. processSegment(segments[i], visitor);
  14002. }
  14003. }
  14004. function parseJbig2(data, start, end) {
  14005. var position = start;
  14006. 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) {
  14007. error('JBIG2 error: invalid header');
  14008. }
  14009. var header = {};
  14010. position += 8;
  14011. var flags = data[position++];
  14012. header.randomAccess = !(flags & 1);
  14013. if (!(flags & 2)) {
  14014. header.numberOfPages = readUint32(data, position);
  14015. position += 4;
  14016. }
  14017. var segments = readSegments(header, data, position, end);
  14018. error('Not implemented');
  14019. }
  14020. function parseJbig2Chunks(chunks) {
  14021. var visitor = new SimpleSegmentVisitor();
  14022. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14023. var chunk = chunks[i];
  14024. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14025. processSegments(segments, visitor);
  14026. }
  14027. return visitor.buffer;
  14028. }
  14029. function SimpleSegmentVisitor() {
  14030. }
  14031. SimpleSegmentVisitor.prototype = {
  14032. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14033. this.currentPageInfo = info;
  14034. var rowSize = info.width + 7 >> 3;
  14035. var buffer = new Uint8Array(rowSize * info.height);
  14036. if (info.defaultPixelValue) {
  14037. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14038. buffer[i] = 0xFF;
  14039. }
  14040. }
  14041. this.buffer = buffer;
  14042. },
  14043. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14044. var pageInfo = this.currentPageInfo;
  14045. var width = regionInfo.width, height = regionInfo.height;
  14046. var rowSize = pageInfo.width + 7 >> 3;
  14047. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14048. var buffer = this.buffer;
  14049. var mask0 = 128 >> (regionInfo.x & 7);
  14050. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14051. var i, j, mask, offset;
  14052. switch (combinationOperator) {
  14053. case 0:
  14054. for (i = 0; i < height; i++) {
  14055. mask = mask0;
  14056. offset = offset0;
  14057. for (j = 0; j < width; j++) {
  14058. if (bitmap[i][j]) {
  14059. buffer[offset] |= mask;
  14060. }
  14061. mask >>= 1;
  14062. if (!mask) {
  14063. mask = 128;
  14064. offset++;
  14065. }
  14066. }
  14067. offset0 += rowSize;
  14068. }
  14069. break;
  14070. case 2:
  14071. for (i = 0; i < height; i++) {
  14072. mask = mask0;
  14073. offset = offset0;
  14074. for (j = 0; j < width; j++) {
  14075. if (bitmap[i][j]) {
  14076. buffer[offset] ^= mask;
  14077. }
  14078. mask >>= 1;
  14079. if (!mask) {
  14080. mask = 128;
  14081. offset++;
  14082. }
  14083. }
  14084. offset0 += rowSize;
  14085. }
  14086. break;
  14087. default:
  14088. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14089. }
  14090. },
  14091. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14092. var regionInfo = region.info;
  14093. var decodingContext = new DecodingContext(data, start, end);
  14094. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14095. this.drawBitmap(regionInfo, bitmap);
  14096. },
  14097. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14098. this.onImmediateGenericRegion.apply(this, arguments);
  14099. },
  14100. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14101. var huffmanTables;
  14102. if (dictionary.huffman) {
  14103. error('JBIG2 error: huffman is not supported');
  14104. }
  14105. var symbols = this.symbols;
  14106. if (!symbols) {
  14107. this.symbols = symbols = {};
  14108. }
  14109. var inputSymbols = [];
  14110. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14111. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14112. }
  14113. var decodingContext = new DecodingContext(data, start, end);
  14114. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14115. },
  14116. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14117. var regionInfo = region.info;
  14118. var huffmanTables;
  14119. var symbols = this.symbols;
  14120. var inputSymbols = [];
  14121. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14122. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14123. }
  14124. var symbolCodeLength = log2(inputSymbols.length);
  14125. var decodingContext = new DecodingContext(data, start, end);
  14126. 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);
  14127. this.drawBitmap(regionInfo, bitmap);
  14128. },
  14129. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14130. this.onImmediateTextRegion.apply(this, arguments);
  14131. }
  14132. };
  14133. function Jbig2Image() {
  14134. }
  14135. Jbig2Image.prototype = {
  14136. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14137. return parseJbig2Chunks(chunks);
  14138. }
  14139. };
  14140. return Jbig2Image;
  14141. }();
  14142. exports.Jbig2Image = Jbig2Image;
  14143. }));
  14144. (function (root, factory) {
  14145. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14146. }(this, function (exports, sharedUtil) {
  14147. var error = sharedUtil.error;
  14148. var JpegImage = function JpegImageClosure() {
  14149. var dctZigZag = new Uint8Array([
  14150. 0,
  14151. 1,
  14152. 8,
  14153. 16,
  14154. 9,
  14155. 2,
  14156. 3,
  14157. 10,
  14158. 17,
  14159. 24,
  14160. 32,
  14161. 25,
  14162. 18,
  14163. 11,
  14164. 4,
  14165. 5,
  14166. 12,
  14167. 19,
  14168. 26,
  14169. 33,
  14170. 40,
  14171. 48,
  14172. 41,
  14173. 34,
  14174. 27,
  14175. 20,
  14176. 13,
  14177. 6,
  14178. 7,
  14179. 14,
  14180. 21,
  14181. 28,
  14182. 35,
  14183. 42,
  14184. 49,
  14185. 56,
  14186. 57,
  14187. 50,
  14188. 43,
  14189. 36,
  14190. 29,
  14191. 22,
  14192. 15,
  14193. 23,
  14194. 30,
  14195. 37,
  14196. 44,
  14197. 51,
  14198. 58,
  14199. 59,
  14200. 52,
  14201. 45,
  14202. 38,
  14203. 31,
  14204. 39,
  14205. 46,
  14206. 53,
  14207. 60,
  14208. 61,
  14209. 54,
  14210. 47,
  14211. 55,
  14212. 62,
  14213. 63
  14214. ]);
  14215. var dctCos1 = 4017;
  14216. var dctSin1 = 799;
  14217. var dctCos3 = 3406;
  14218. var dctSin3 = 2276;
  14219. var dctCos6 = 1567;
  14220. var dctSin6 = 3784;
  14221. var dctSqrt2 = 5793;
  14222. var dctSqrt1d2 = 2896;
  14223. function JpegImage() {
  14224. this.decodeTransform = null;
  14225. this.colorTransform = -1;
  14226. }
  14227. function buildHuffmanTable(codeLengths, values) {
  14228. var k = 0, code = [], i, j, length = 16;
  14229. while (length > 0 && !codeLengths[length - 1]) {
  14230. length--;
  14231. }
  14232. code.push({
  14233. children: [],
  14234. index: 0
  14235. });
  14236. var p = code[0], q;
  14237. for (i = 0; i < length; i++) {
  14238. for (j = 0; j < codeLengths[i]; j++) {
  14239. p = code.pop();
  14240. p.children[p.index] = values[k];
  14241. while (p.index > 0) {
  14242. p = code.pop();
  14243. }
  14244. p.index++;
  14245. code.push(p);
  14246. while (code.length <= i) {
  14247. code.push(q = {
  14248. children: [],
  14249. index: 0
  14250. });
  14251. p.children[p.index] = q.children;
  14252. p = q;
  14253. }
  14254. k++;
  14255. }
  14256. if (i + 1 < length) {
  14257. code.push(q = {
  14258. children: [],
  14259. index: 0
  14260. });
  14261. p.children[p.index] = q.children;
  14262. p = q;
  14263. }
  14264. }
  14265. return code[0].children;
  14266. }
  14267. function getBlockBufferOffset(component, row, col) {
  14268. return 64 * ((component.blocksPerLine + 1) * row + col);
  14269. }
  14270. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14271. var mcusPerLine = frame.mcusPerLine;
  14272. var progressive = frame.progressive;
  14273. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14274. function readBit() {
  14275. if (bitsCount > 0) {
  14276. bitsCount--;
  14277. return bitsData >> bitsCount & 1;
  14278. }
  14279. bitsData = data[offset++];
  14280. if (bitsData === 0xFF) {
  14281. var nextByte = data[offset++];
  14282. if (nextByte) {
  14283. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14284. }
  14285. }
  14286. bitsCount = 7;
  14287. return bitsData >>> 7;
  14288. }
  14289. function decodeHuffman(tree) {
  14290. var node = tree;
  14291. while (true) {
  14292. node = node[readBit()];
  14293. if (typeof node === 'number') {
  14294. return node;
  14295. }
  14296. if (typeof node !== 'object') {
  14297. error('JPEG error: invalid huffman sequence');
  14298. }
  14299. }
  14300. }
  14301. function receive(length) {
  14302. var n = 0;
  14303. while (length > 0) {
  14304. n = n << 1 | readBit();
  14305. length--;
  14306. }
  14307. return n;
  14308. }
  14309. function receiveAndExtend(length) {
  14310. if (length === 1) {
  14311. return readBit() === 1 ? 1 : -1;
  14312. }
  14313. var n = receive(length);
  14314. if (n >= 1 << length - 1) {
  14315. return n;
  14316. }
  14317. return n + (-1 << length) + 1;
  14318. }
  14319. function decodeBaseline(component, offset) {
  14320. var t = decodeHuffman(component.huffmanTableDC);
  14321. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14322. component.blockData[offset] = component.pred += diff;
  14323. var k = 1;
  14324. while (k < 64) {
  14325. var rs = decodeHuffman(component.huffmanTableAC);
  14326. var s = rs & 15, r = rs >> 4;
  14327. if (s === 0) {
  14328. if (r < 15) {
  14329. break;
  14330. }
  14331. k += 16;
  14332. continue;
  14333. }
  14334. k += r;
  14335. var z = dctZigZag[k];
  14336. component.blockData[offset + z] = receiveAndExtend(s);
  14337. k++;
  14338. }
  14339. }
  14340. function decodeDCFirst(component, offset) {
  14341. var t = decodeHuffman(component.huffmanTableDC);
  14342. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14343. component.blockData[offset] = component.pred += diff;
  14344. }
  14345. function decodeDCSuccessive(component, offset) {
  14346. component.blockData[offset] |= readBit() << successive;
  14347. }
  14348. var eobrun = 0;
  14349. function decodeACFirst(component, offset) {
  14350. if (eobrun > 0) {
  14351. eobrun--;
  14352. return;
  14353. }
  14354. var k = spectralStart, e = spectralEnd;
  14355. while (k <= e) {
  14356. var rs = decodeHuffman(component.huffmanTableAC);
  14357. var s = rs & 15, r = rs >> 4;
  14358. if (s === 0) {
  14359. if (r < 15) {
  14360. eobrun = receive(r) + (1 << r) - 1;
  14361. break;
  14362. }
  14363. k += 16;
  14364. continue;
  14365. }
  14366. k += r;
  14367. var z = dctZigZag[k];
  14368. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14369. k++;
  14370. }
  14371. }
  14372. var successiveACState = 0, successiveACNextValue;
  14373. function decodeACSuccessive(component, offset) {
  14374. var k = spectralStart;
  14375. var e = spectralEnd;
  14376. var r = 0;
  14377. var s;
  14378. var rs;
  14379. while (k <= e) {
  14380. var z = dctZigZag[k];
  14381. switch (successiveACState) {
  14382. case 0:
  14383. rs = decodeHuffman(component.huffmanTableAC);
  14384. s = rs & 15;
  14385. r = rs >> 4;
  14386. if (s === 0) {
  14387. if (r < 15) {
  14388. eobrun = receive(r) + (1 << r);
  14389. successiveACState = 4;
  14390. } else {
  14391. r = 16;
  14392. successiveACState = 1;
  14393. }
  14394. } else {
  14395. if (s !== 1) {
  14396. error('JPEG error: invalid ACn encoding');
  14397. }
  14398. successiveACNextValue = receiveAndExtend(s);
  14399. successiveACState = r ? 2 : 3;
  14400. }
  14401. continue;
  14402. case 1:
  14403. case 2:
  14404. if (component.blockData[offset + z]) {
  14405. component.blockData[offset + z] += readBit() << successive;
  14406. } else {
  14407. r--;
  14408. if (r === 0) {
  14409. successiveACState = successiveACState === 2 ? 3 : 0;
  14410. }
  14411. }
  14412. break;
  14413. case 3:
  14414. if (component.blockData[offset + z]) {
  14415. component.blockData[offset + z] += readBit() << successive;
  14416. } else {
  14417. component.blockData[offset + z] = successiveACNextValue << successive;
  14418. successiveACState = 0;
  14419. }
  14420. break;
  14421. case 4:
  14422. if (component.blockData[offset + z]) {
  14423. component.blockData[offset + z] += readBit() << successive;
  14424. }
  14425. break;
  14426. }
  14427. k++;
  14428. }
  14429. if (successiveACState === 4) {
  14430. eobrun--;
  14431. if (eobrun === 0) {
  14432. successiveACState = 0;
  14433. }
  14434. }
  14435. }
  14436. function decodeMcu(component, decode, mcu, row, col) {
  14437. var mcuRow = mcu / mcusPerLine | 0;
  14438. var mcuCol = mcu % mcusPerLine;
  14439. var blockRow = mcuRow * component.v + row;
  14440. var blockCol = mcuCol * component.h + col;
  14441. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14442. decode(component, offset);
  14443. }
  14444. function decodeBlock(component, decode, mcu) {
  14445. var blockRow = mcu / component.blocksPerLine | 0;
  14446. var blockCol = mcu % component.blocksPerLine;
  14447. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14448. decode(component, offset);
  14449. }
  14450. var componentsLength = components.length;
  14451. var component, i, j, k, n;
  14452. var decodeFn;
  14453. if (progressive) {
  14454. if (spectralStart === 0) {
  14455. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14456. } else {
  14457. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14458. }
  14459. } else {
  14460. decodeFn = decodeBaseline;
  14461. }
  14462. var mcu = 0, marker;
  14463. var mcuExpected;
  14464. if (componentsLength === 1) {
  14465. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14466. } else {
  14467. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14468. }
  14469. if (!resetInterval) {
  14470. resetInterval = mcuExpected;
  14471. }
  14472. var h, v;
  14473. while (mcu < mcuExpected) {
  14474. for (i = 0; i < componentsLength; i++) {
  14475. components[i].pred = 0;
  14476. }
  14477. eobrun = 0;
  14478. if (componentsLength === 1) {
  14479. component = components[0];
  14480. for (n = 0; n < resetInterval; n++) {
  14481. decodeBlock(component, decodeFn, mcu);
  14482. mcu++;
  14483. }
  14484. } else {
  14485. for (n = 0; n < resetInterval; n++) {
  14486. for (i = 0; i < componentsLength; i++) {
  14487. component = components[i];
  14488. h = component.h;
  14489. v = component.v;
  14490. for (j = 0; j < v; j++) {
  14491. for (k = 0; k < h; k++) {
  14492. decodeMcu(component, decodeFn, mcu, j, k);
  14493. }
  14494. }
  14495. }
  14496. mcu++;
  14497. }
  14498. }
  14499. bitsCount = 0;
  14500. marker = data[offset] << 8 | data[offset + 1];
  14501. while (data[offset] === 0x00 && offset < data.length - 1) {
  14502. offset++;
  14503. marker = data[offset] << 8 | data[offset + 1];
  14504. }
  14505. if (marker <= 0xFF00) {
  14506. error('JPEG error: marker was not found');
  14507. }
  14508. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14509. offset += 2;
  14510. } else {
  14511. break;
  14512. }
  14513. }
  14514. return offset - startOffset;
  14515. }
  14516. function quantizeAndInverse(component, blockBufferOffset, p) {
  14517. var qt = component.quantizationTable, blockData = component.blockData;
  14518. var v0, v1, v2, v3, v4, v5, v6, v7;
  14519. var p0, p1, p2, p3, p4, p5, p6, p7;
  14520. var t;
  14521. if (!qt) {
  14522. error('JPEG error: missing required Quantization Table.');
  14523. }
  14524. for (var row = 0; row < 64; row += 8) {
  14525. p0 = blockData[blockBufferOffset + row];
  14526. p1 = blockData[blockBufferOffset + row + 1];
  14527. p2 = blockData[blockBufferOffset + row + 2];
  14528. p3 = blockData[blockBufferOffset + row + 3];
  14529. p4 = blockData[blockBufferOffset + row + 4];
  14530. p5 = blockData[blockBufferOffset + row + 5];
  14531. p6 = blockData[blockBufferOffset + row + 6];
  14532. p7 = blockData[blockBufferOffset + row + 7];
  14533. p0 *= qt[row];
  14534. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14535. t = dctSqrt2 * p0 + 512 >> 10;
  14536. p[row] = t;
  14537. p[row + 1] = t;
  14538. p[row + 2] = t;
  14539. p[row + 3] = t;
  14540. p[row + 4] = t;
  14541. p[row + 5] = t;
  14542. p[row + 6] = t;
  14543. p[row + 7] = t;
  14544. continue;
  14545. }
  14546. p1 *= qt[row + 1];
  14547. p2 *= qt[row + 2];
  14548. p3 *= qt[row + 3];
  14549. p4 *= qt[row + 4];
  14550. p5 *= qt[row + 5];
  14551. p6 *= qt[row + 6];
  14552. p7 *= qt[row + 7];
  14553. v0 = dctSqrt2 * p0 + 128 >> 8;
  14554. v1 = dctSqrt2 * p4 + 128 >> 8;
  14555. v2 = p2;
  14556. v3 = p6;
  14557. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14558. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14559. v5 = p3 << 4;
  14560. v6 = p5 << 4;
  14561. v0 = v0 + v1 + 1 >> 1;
  14562. v1 = v0 - v1;
  14563. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14564. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14565. v3 = t;
  14566. v4 = v4 + v6 + 1 >> 1;
  14567. v6 = v4 - v6;
  14568. v7 = v7 + v5 + 1 >> 1;
  14569. v5 = v7 - v5;
  14570. v0 = v0 + v3 + 1 >> 1;
  14571. v3 = v0 - v3;
  14572. v1 = v1 + v2 + 1 >> 1;
  14573. v2 = v1 - v2;
  14574. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14575. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14576. v7 = t;
  14577. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14578. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14579. v6 = t;
  14580. p[row] = v0 + v7;
  14581. p[row + 7] = v0 - v7;
  14582. p[row + 1] = v1 + v6;
  14583. p[row + 6] = v1 - v6;
  14584. p[row + 2] = v2 + v5;
  14585. p[row + 5] = v2 - v5;
  14586. p[row + 3] = v3 + v4;
  14587. p[row + 4] = v3 - v4;
  14588. }
  14589. for (var col = 0; col < 8; ++col) {
  14590. p0 = p[col];
  14591. p1 = p[col + 8];
  14592. p2 = p[col + 16];
  14593. p3 = p[col + 24];
  14594. p4 = p[col + 32];
  14595. p5 = p[col + 40];
  14596. p6 = p[col + 48];
  14597. p7 = p[col + 56];
  14598. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14599. t = dctSqrt2 * p0 + 8192 >> 14;
  14600. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14601. blockData[blockBufferOffset + col] = t;
  14602. blockData[blockBufferOffset + col + 8] = t;
  14603. blockData[blockBufferOffset + col + 16] = t;
  14604. blockData[blockBufferOffset + col + 24] = t;
  14605. blockData[blockBufferOffset + col + 32] = t;
  14606. blockData[blockBufferOffset + col + 40] = t;
  14607. blockData[blockBufferOffset + col + 48] = t;
  14608. blockData[blockBufferOffset + col + 56] = t;
  14609. continue;
  14610. }
  14611. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14612. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14613. v2 = p2;
  14614. v3 = p6;
  14615. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14616. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14617. v5 = p3;
  14618. v6 = p5;
  14619. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14620. v1 = v0 - v1;
  14621. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14622. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14623. v3 = t;
  14624. v4 = v4 + v6 + 1 >> 1;
  14625. v6 = v4 - v6;
  14626. v7 = v7 + v5 + 1 >> 1;
  14627. v5 = v7 - v5;
  14628. v0 = v0 + v3 + 1 >> 1;
  14629. v3 = v0 - v3;
  14630. v1 = v1 + v2 + 1 >> 1;
  14631. v2 = v1 - v2;
  14632. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14633. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14634. v7 = t;
  14635. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14636. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14637. v6 = t;
  14638. p0 = v0 + v7;
  14639. p7 = v0 - v7;
  14640. p1 = v1 + v6;
  14641. p6 = v1 - v6;
  14642. p2 = v2 + v5;
  14643. p5 = v2 - v5;
  14644. p3 = v3 + v4;
  14645. p4 = v3 - v4;
  14646. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14647. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14648. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14649. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14650. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14651. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14652. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14653. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14654. blockData[blockBufferOffset + col] = p0;
  14655. blockData[blockBufferOffset + col + 8] = p1;
  14656. blockData[blockBufferOffset + col + 16] = p2;
  14657. blockData[blockBufferOffset + col + 24] = p3;
  14658. blockData[blockBufferOffset + col + 32] = p4;
  14659. blockData[blockBufferOffset + col + 40] = p5;
  14660. blockData[blockBufferOffset + col + 48] = p6;
  14661. blockData[blockBufferOffset + col + 56] = p7;
  14662. }
  14663. }
  14664. function buildComponentData(frame, component) {
  14665. var blocksPerLine = component.blocksPerLine;
  14666. var blocksPerColumn = component.blocksPerColumn;
  14667. var computationBuffer = new Int16Array(64);
  14668. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14669. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14670. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14671. quantizeAndInverse(component, offset, computationBuffer);
  14672. }
  14673. }
  14674. return component.blockData;
  14675. }
  14676. function clamp0to255(a) {
  14677. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14678. }
  14679. JpegImage.prototype = {
  14680. parse: function parse(data) {
  14681. function readUint16() {
  14682. var value = data[offset] << 8 | data[offset + 1];
  14683. offset += 2;
  14684. return value;
  14685. }
  14686. function readDataBlock() {
  14687. var length = readUint16();
  14688. var array = data.subarray(offset, offset + length - 2);
  14689. offset += array.length;
  14690. return array;
  14691. }
  14692. function prepareComponents(frame) {
  14693. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14694. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14695. for (var i = 0; i < frame.components.length; i++) {
  14696. component = frame.components[i];
  14697. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14698. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14699. var blocksPerLineForMcu = mcusPerLine * component.h;
  14700. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14701. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14702. component.blockData = new Int16Array(blocksBufferSize);
  14703. component.blocksPerLine = blocksPerLine;
  14704. component.blocksPerColumn = blocksPerColumn;
  14705. }
  14706. frame.mcusPerLine = mcusPerLine;
  14707. frame.mcusPerColumn = mcusPerColumn;
  14708. }
  14709. var offset = 0;
  14710. var jfif = null;
  14711. var adobe = null;
  14712. var frame, resetInterval;
  14713. var quantizationTables = [];
  14714. var huffmanTablesAC = [], huffmanTablesDC = [];
  14715. var fileMarker = readUint16();
  14716. if (fileMarker !== 0xFFD8) {
  14717. error('JPEG error: SOI not found');
  14718. }
  14719. fileMarker = readUint16();
  14720. while (fileMarker !== 0xFFD9) {
  14721. var i, j, l;
  14722. switch (fileMarker) {
  14723. case 0xFFE0:
  14724. case 0xFFE1:
  14725. case 0xFFE2:
  14726. case 0xFFE3:
  14727. case 0xFFE4:
  14728. case 0xFFE5:
  14729. case 0xFFE6:
  14730. case 0xFFE7:
  14731. case 0xFFE8:
  14732. case 0xFFE9:
  14733. case 0xFFEA:
  14734. case 0xFFEB:
  14735. case 0xFFEC:
  14736. case 0xFFED:
  14737. case 0xFFEE:
  14738. case 0xFFEF:
  14739. case 0xFFFE:
  14740. var appData = readDataBlock();
  14741. if (fileMarker === 0xFFE0) {
  14742. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14743. jfif = {
  14744. version: {
  14745. major: appData[5],
  14746. minor: appData[6]
  14747. },
  14748. densityUnits: appData[7],
  14749. xDensity: appData[8] << 8 | appData[9],
  14750. yDensity: appData[10] << 8 | appData[11],
  14751. thumbWidth: appData[12],
  14752. thumbHeight: appData[13],
  14753. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14754. };
  14755. }
  14756. }
  14757. if (fileMarker === 0xFFEE) {
  14758. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14759. adobe = {
  14760. version: appData[5] << 8 | appData[6],
  14761. flags0: appData[7] << 8 | appData[8],
  14762. flags1: appData[9] << 8 | appData[10],
  14763. transformCode: appData[11]
  14764. };
  14765. }
  14766. }
  14767. break;
  14768. case 0xFFDB:
  14769. var quantizationTablesLength = readUint16();
  14770. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14771. var z;
  14772. while (offset < quantizationTablesEnd) {
  14773. var quantizationTableSpec = data[offset++];
  14774. var tableData = new Uint16Array(64);
  14775. if (quantizationTableSpec >> 4 === 0) {
  14776. for (j = 0; j < 64; j++) {
  14777. z = dctZigZag[j];
  14778. tableData[z] = data[offset++];
  14779. }
  14780. } else if (quantizationTableSpec >> 4 === 1) {
  14781. for (j = 0; j < 64; j++) {
  14782. z = dctZigZag[j];
  14783. tableData[z] = readUint16();
  14784. }
  14785. } else {
  14786. error('JPEG error: DQT - invalid table spec');
  14787. }
  14788. quantizationTables[quantizationTableSpec & 15] = tableData;
  14789. }
  14790. break;
  14791. case 0xFFC0:
  14792. case 0xFFC1:
  14793. case 0xFFC2:
  14794. if (frame) {
  14795. error('JPEG error: Only single frame JPEGs supported');
  14796. }
  14797. readUint16();
  14798. frame = {};
  14799. frame.extended = fileMarker === 0xFFC1;
  14800. frame.progressive = fileMarker === 0xFFC2;
  14801. frame.precision = data[offset++];
  14802. frame.scanLines = readUint16();
  14803. frame.samplesPerLine = readUint16();
  14804. frame.components = [];
  14805. frame.componentIds = {};
  14806. var componentsCount = data[offset++], componentId;
  14807. var maxH = 0, maxV = 0;
  14808. for (i = 0; i < componentsCount; i++) {
  14809. componentId = data[offset];
  14810. var h = data[offset + 1] >> 4;
  14811. var v = data[offset + 1] & 15;
  14812. if (maxH < h) {
  14813. maxH = h;
  14814. }
  14815. if (maxV < v) {
  14816. maxV = v;
  14817. }
  14818. var qId = data[offset + 2];
  14819. l = frame.components.push({
  14820. h: h,
  14821. v: v,
  14822. quantizationId: qId,
  14823. quantizationTable: null
  14824. });
  14825. frame.componentIds[componentId] = l - 1;
  14826. offset += 3;
  14827. }
  14828. frame.maxH = maxH;
  14829. frame.maxV = maxV;
  14830. prepareComponents(frame);
  14831. break;
  14832. case 0xFFC4:
  14833. var huffmanLength = readUint16();
  14834. for (i = 2; i < huffmanLength;) {
  14835. var huffmanTableSpec = data[offset++];
  14836. var codeLengths = new Uint8Array(16);
  14837. var codeLengthSum = 0;
  14838. for (j = 0; j < 16; j++, offset++) {
  14839. codeLengthSum += codeLengths[j] = data[offset];
  14840. }
  14841. var huffmanValues = new Uint8Array(codeLengthSum);
  14842. for (j = 0; j < codeLengthSum; j++, offset++) {
  14843. huffmanValues[j] = data[offset];
  14844. }
  14845. i += 17 + codeLengthSum;
  14846. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14847. }
  14848. break;
  14849. case 0xFFDD:
  14850. readUint16();
  14851. resetInterval = readUint16();
  14852. break;
  14853. case 0xFFDA:
  14854. var scanLength = readUint16();
  14855. var selectorsCount = data[offset++];
  14856. var components = [], component;
  14857. for (i = 0; i < selectorsCount; i++) {
  14858. var componentIndex = frame.componentIds[data[offset++]];
  14859. component = frame.components[componentIndex];
  14860. var tableSpec = data[offset++];
  14861. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14862. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14863. components.push(component);
  14864. }
  14865. var spectralStart = data[offset++];
  14866. var spectralEnd = data[offset++];
  14867. var successiveApproximation = data[offset++];
  14868. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14869. offset += processed;
  14870. break;
  14871. case 0xFFFF:
  14872. if (data[offset] !== 0xFF) {
  14873. offset--;
  14874. }
  14875. break;
  14876. default:
  14877. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14878. offset -= 3;
  14879. break;
  14880. }
  14881. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14882. }
  14883. fileMarker = readUint16();
  14884. }
  14885. this.width = frame.samplesPerLine;
  14886. this.height = frame.scanLines;
  14887. this.jfif = jfif;
  14888. this.adobe = adobe;
  14889. this.components = [];
  14890. for (i = 0; i < frame.components.length; i++) {
  14891. component = frame.components[i];
  14892. var quantizationTable = quantizationTables[component.quantizationId];
  14893. if (quantizationTable) {
  14894. component.quantizationTable = quantizationTable;
  14895. }
  14896. this.components.push({
  14897. output: buildComponentData(frame, component),
  14898. scaleX: component.h / frame.maxH,
  14899. scaleY: component.v / frame.maxV,
  14900. blocksPerLine: component.blocksPerLine,
  14901. blocksPerColumn: component.blocksPerColumn
  14902. });
  14903. }
  14904. this.numComponents = this.components.length;
  14905. },
  14906. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  14907. var scaleX = this.width / width, scaleY = this.height / height;
  14908. var component, componentScaleX, componentScaleY, blocksPerScanline;
  14909. var x, y, i, j, k;
  14910. var index;
  14911. var offset = 0;
  14912. var output;
  14913. var numComponents = this.components.length;
  14914. var dataLength = width * height * numComponents;
  14915. var data = new Uint8Array(dataLength);
  14916. var xScaleBlockOffset = new Uint32Array(width);
  14917. var mask3LSB = 0xfffffff8;
  14918. for (i = 0; i < numComponents; i++) {
  14919. component = this.components[i];
  14920. componentScaleX = component.scaleX * scaleX;
  14921. componentScaleY = component.scaleY * scaleY;
  14922. offset = i;
  14923. output = component.output;
  14924. blocksPerScanline = component.blocksPerLine + 1 << 3;
  14925. for (x = 0; x < width; x++) {
  14926. j = 0 | x * componentScaleX;
  14927. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  14928. }
  14929. for (y = 0; y < height; y++) {
  14930. j = 0 | y * componentScaleY;
  14931. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  14932. for (x = 0; x < width; x++) {
  14933. data[offset] = output[index + xScaleBlockOffset[x]];
  14934. offset += numComponents;
  14935. }
  14936. }
  14937. }
  14938. var transform = this.decodeTransform;
  14939. if (transform) {
  14940. for (i = 0; i < dataLength;) {
  14941. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  14942. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  14943. }
  14944. }
  14945. }
  14946. return data;
  14947. },
  14948. _isColorConversionNeeded: function isColorConversionNeeded() {
  14949. if (this.adobe && this.adobe.transformCode) {
  14950. return true;
  14951. } else if (this.numComponents === 3) {
  14952. if (!this.adobe && this.colorTransform === 0) {
  14953. return false;
  14954. }
  14955. return true;
  14956. } else {
  14957. if (!this.adobe && this.colorTransform === 1) {
  14958. return true;
  14959. }
  14960. return false;
  14961. }
  14962. },
  14963. _convertYccToRgb: function convertYccToRgb(data) {
  14964. var Y, Cb, Cr;
  14965. for (var i = 0, length = data.length; i < length; i += 3) {
  14966. Y = data[i];
  14967. Cb = data[i + 1];
  14968. Cr = data[i + 2];
  14969. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  14970. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  14971. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  14972. }
  14973. return data;
  14974. },
  14975. _convertYcckToRgb: function convertYcckToRgb(data) {
  14976. var Y, Cb, Cr, k;
  14977. var offset = 0;
  14978. for (var i = 0, length = data.length; i < length; i += 4) {
  14979. Y = data[i];
  14980. Cb = data[i + 1];
  14981. Cr = data[i + 2];
  14982. k = data[i + 3];
  14983. 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);
  14984. 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);
  14985. 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);
  14986. data[offset++] = clamp0to255(r);
  14987. data[offset++] = clamp0to255(g);
  14988. data[offset++] = clamp0to255(b);
  14989. }
  14990. return data;
  14991. },
  14992. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  14993. var Y, Cb, Cr;
  14994. for (var i = 0, length = data.length; i < length; i += 4) {
  14995. Y = data[i];
  14996. Cb = data[i + 1];
  14997. Cr = data[i + 2];
  14998. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  14999. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15000. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15001. }
  15002. return data;
  15003. },
  15004. _convertCmykToRgb: function convertCmykToRgb(data) {
  15005. var c, m, y, k;
  15006. var offset = 0;
  15007. var min = -255 * 255 * 255;
  15008. var scale = 1 / 255 / 255;
  15009. for (var i = 0, length = data.length; i < length; i += 4) {
  15010. c = data[i];
  15011. m = data[i + 1];
  15012. y = data[i + 2];
  15013. k = data[i + 3];
  15014. 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);
  15015. 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);
  15016. 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);
  15017. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15018. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15019. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15020. }
  15021. return data;
  15022. },
  15023. getData: function getData(width, height, forceRGBoutput) {
  15024. if (this.numComponents > 4) {
  15025. error('JPEG error: Unsupported color mode');
  15026. }
  15027. var data = this._getLinearizedBlockData(width, height);
  15028. if (this.numComponents === 1 && forceRGBoutput) {
  15029. var dataLength = data.length;
  15030. var rgbData = new Uint8Array(dataLength * 3);
  15031. var offset = 0;
  15032. for (var i = 0; i < dataLength; i++) {
  15033. var grayColor = data[i];
  15034. rgbData[offset++] = grayColor;
  15035. rgbData[offset++] = grayColor;
  15036. rgbData[offset++] = grayColor;
  15037. }
  15038. return rgbData;
  15039. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15040. return this._convertYccToRgb(data);
  15041. } else if (this.numComponents === 4) {
  15042. if (this._isColorConversionNeeded()) {
  15043. if (forceRGBoutput) {
  15044. return this._convertYcckToRgb(data);
  15045. } else {
  15046. return this._convertYcckToCmyk(data);
  15047. }
  15048. } else if (forceRGBoutput) {
  15049. return this._convertCmykToRgb(data);
  15050. }
  15051. }
  15052. return data;
  15053. }
  15054. };
  15055. return JpegImage;
  15056. }();
  15057. exports.JpegImage = JpegImage;
  15058. }));
  15059. (function (root, factory) {
  15060. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15061. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15062. var info = sharedUtil.info;
  15063. var warn = sharedUtil.warn;
  15064. var error = sharedUtil.error;
  15065. var log2 = sharedUtil.log2;
  15066. var readUint16 = sharedUtil.readUint16;
  15067. var readUint32 = sharedUtil.readUint32;
  15068. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15069. var JpxImage = function JpxImageClosure() {
  15070. var SubbandsGainLog2 = {
  15071. 'LL': 0,
  15072. 'LH': 1,
  15073. 'HL': 1,
  15074. 'HH': 2
  15075. };
  15076. function JpxImage() {
  15077. this.failOnCorruptedImage = false;
  15078. }
  15079. JpxImage.prototype = {
  15080. parse: function JpxImage_parse(data) {
  15081. var head = readUint16(data, 0);
  15082. if (head === 0xFF4F) {
  15083. this.parseCodestream(data, 0, data.length);
  15084. return;
  15085. }
  15086. var position = 0, length = data.length;
  15087. while (position < length) {
  15088. var headerSize = 8;
  15089. var lbox = readUint32(data, position);
  15090. var tbox = readUint32(data, position + 4);
  15091. position += headerSize;
  15092. if (lbox === 1) {
  15093. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15094. position += 8;
  15095. headerSize += 8;
  15096. }
  15097. if (lbox === 0) {
  15098. lbox = length - position + headerSize;
  15099. }
  15100. if (lbox < headerSize) {
  15101. error('JPX Error: Invalid box field size');
  15102. }
  15103. var dataLength = lbox - headerSize;
  15104. var jumpDataLength = true;
  15105. switch (tbox) {
  15106. case 0x6A703268:
  15107. jumpDataLength = false;
  15108. break;
  15109. case 0x636F6C72:
  15110. var method = data[position];
  15111. if (method === 1) {
  15112. var colorspace = readUint32(data, position + 3);
  15113. switch (colorspace) {
  15114. case 16:
  15115. case 17:
  15116. case 18:
  15117. break;
  15118. default:
  15119. warn('Unknown colorspace ' + colorspace);
  15120. break;
  15121. }
  15122. } else if (method === 2) {
  15123. info('ICC profile not supported');
  15124. }
  15125. break;
  15126. case 0x6A703263:
  15127. this.parseCodestream(data, position, position + dataLength);
  15128. break;
  15129. case 0x6A502020:
  15130. if (0x0d0a870a !== readUint32(data, position)) {
  15131. warn('Invalid JP2 signature');
  15132. }
  15133. break;
  15134. case 0x6A501A1A:
  15135. case 0x66747970:
  15136. case 0x72726571:
  15137. case 0x72657320:
  15138. case 0x69686472:
  15139. break;
  15140. default:
  15141. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15142. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15143. break;
  15144. }
  15145. if (jumpDataLength) {
  15146. position += dataLength;
  15147. }
  15148. }
  15149. },
  15150. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15151. var newByte = stream.getByte();
  15152. while (newByte >= 0) {
  15153. var oldByte = newByte;
  15154. newByte = stream.getByte();
  15155. var code = oldByte << 8 | newByte;
  15156. if (code === 0xFF51) {
  15157. stream.skip(4);
  15158. var Xsiz = stream.getInt32() >>> 0;
  15159. var Ysiz = stream.getInt32() >>> 0;
  15160. var XOsiz = stream.getInt32() >>> 0;
  15161. var YOsiz = stream.getInt32() >>> 0;
  15162. stream.skip(16);
  15163. var Csiz = stream.getUint16();
  15164. this.width = Xsiz - XOsiz;
  15165. this.height = Ysiz - YOsiz;
  15166. this.componentsCount = Csiz;
  15167. this.bitsPerComponent = 8;
  15168. return;
  15169. }
  15170. }
  15171. error('JPX Error: No size marker found in JPX stream');
  15172. },
  15173. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15174. var context = {};
  15175. var doNotRecover = false;
  15176. try {
  15177. var position = start;
  15178. while (position + 1 < end) {
  15179. var code = readUint16(data, position);
  15180. position += 2;
  15181. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15182. switch (code) {
  15183. case 0xFF4F:
  15184. context.mainHeader = true;
  15185. break;
  15186. case 0xFFD9:
  15187. break;
  15188. case 0xFF51:
  15189. length = readUint16(data, position);
  15190. var siz = {};
  15191. siz.Xsiz = readUint32(data, position + 4);
  15192. siz.Ysiz = readUint32(data, position + 8);
  15193. siz.XOsiz = readUint32(data, position + 12);
  15194. siz.YOsiz = readUint32(data, position + 16);
  15195. siz.XTsiz = readUint32(data, position + 20);
  15196. siz.YTsiz = readUint32(data, position + 24);
  15197. siz.XTOsiz = readUint32(data, position + 28);
  15198. siz.YTOsiz = readUint32(data, position + 32);
  15199. var componentsCount = readUint16(data, position + 36);
  15200. siz.Csiz = componentsCount;
  15201. var components = [];
  15202. j = position + 38;
  15203. for (var i = 0; i < componentsCount; i++) {
  15204. var component = {
  15205. precision: (data[j] & 0x7F) + 1,
  15206. isSigned: !!(data[j] & 0x80),
  15207. XRsiz: data[j + 1],
  15208. YRsiz: data[j + 1]
  15209. };
  15210. calculateComponentDimensions(component, siz);
  15211. components.push(component);
  15212. }
  15213. context.SIZ = siz;
  15214. context.components = components;
  15215. calculateTileGrids(context, components);
  15216. context.QCC = [];
  15217. context.COC = [];
  15218. break;
  15219. case 0xFF5C:
  15220. length = readUint16(data, position);
  15221. var qcd = {};
  15222. j = position + 2;
  15223. sqcd = data[j++];
  15224. switch (sqcd & 0x1F) {
  15225. case 0:
  15226. spqcdSize = 8;
  15227. scalarExpounded = true;
  15228. break;
  15229. case 1:
  15230. spqcdSize = 16;
  15231. scalarExpounded = false;
  15232. break;
  15233. case 2:
  15234. spqcdSize = 16;
  15235. scalarExpounded = true;
  15236. break;
  15237. default:
  15238. throw new Error('Invalid SQcd value ' + sqcd);
  15239. }
  15240. qcd.noQuantization = spqcdSize === 8;
  15241. qcd.scalarExpounded = scalarExpounded;
  15242. qcd.guardBits = sqcd >> 5;
  15243. spqcds = [];
  15244. while (j < length + position) {
  15245. var spqcd = {};
  15246. if (spqcdSize === 8) {
  15247. spqcd.epsilon = data[j++] >> 3;
  15248. spqcd.mu = 0;
  15249. } else {
  15250. spqcd.epsilon = data[j] >> 3;
  15251. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15252. j += 2;
  15253. }
  15254. spqcds.push(spqcd);
  15255. }
  15256. qcd.SPqcds = spqcds;
  15257. if (context.mainHeader) {
  15258. context.QCD = qcd;
  15259. } else {
  15260. context.currentTile.QCD = qcd;
  15261. context.currentTile.QCC = [];
  15262. }
  15263. break;
  15264. case 0xFF5D:
  15265. length = readUint16(data, position);
  15266. var qcc = {};
  15267. j = position + 2;
  15268. var cqcc;
  15269. if (context.SIZ.Csiz < 257) {
  15270. cqcc = data[j++];
  15271. } else {
  15272. cqcc = readUint16(data, j);
  15273. j += 2;
  15274. }
  15275. sqcd = data[j++];
  15276. switch (sqcd & 0x1F) {
  15277. case 0:
  15278. spqcdSize = 8;
  15279. scalarExpounded = true;
  15280. break;
  15281. case 1:
  15282. spqcdSize = 16;
  15283. scalarExpounded = false;
  15284. break;
  15285. case 2:
  15286. spqcdSize = 16;
  15287. scalarExpounded = true;
  15288. break;
  15289. default:
  15290. throw new Error('Invalid SQcd value ' + sqcd);
  15291. }
  15292. qcc.noQuantization = spqcdSize === 8;
  15293. qcc.scalarExpounded = scalarExpounded;
  15294. qcc.guardBits = sqcd >> 5;
  15295. spqcds = [];
  15296. while (j < length + position) {
  15297. spqcd = {};
  15298. if (spqcdSize === 8) {
  15299. spqcd.epsilon = data[j++] >> 3;
  15300. spqcd.mu = 0;
  15301. } else {
  15302. spqcd.epsilon = data[j] >> 3;
  15303. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15304. j += 2;
  15305. }
  15306. spqcds.push(spqcd);
  15307. }
  15308. qcc.SPqcds = spqcds;
  15309. if (context.mainHeader) {
  15310. context.QCC[cqcc] = qcc;
  15311. } else {
  15312. context.currentTile.QCC[cqcc] = qcc;
  15313. }
  15314. break;
  15315. case 0xFF52:
  15316. length = readUint16(data, position);
  15317. var cod = {};
  15318. j = position + 2;
  15319. var scod = data[j++];
  15320. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15321. cod.sopMarkerUsed = !!(scod & 2);
  15322. cod.ephMarkerUsed = !!(scod & 4);
  15323. cod.progressionOrder = data[j++];
  15324. cod.layersCount = readUint16(data, j);
  15325. j += 2;
  15326. cod.multipleComponentTransform = data[j++];
  15327. cod.decompositionLevelsCount = data[j++];
  15328. cod.xcb = (data[j++] & 0xF) + 2;
  15329. cod.ycb = (data[j++] & 0xF) + 2;
  15330. var blockStyle = data[j++];
  15331. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15332. cod.resetContextProbabilities = !!(blockStyle & 2);
  15333. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15334. cod.verticalyStripe = !!(blockStyle & 8);
  15335. cod.predictableTermination = !!(blockStyle & 16);
  15336. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15337. cod.reversibleTransformation = data[j++];
  15338. if (cod.entropyCoderWithCustomPrecincts) {
  15339. var precinctsSizes = [];
  15340. while (j < length + position) {
  15341. var precinctsSize = data[j++];
  15342. precinctsSizes.push({
  15343. PPx: precinctsSize & 0xF,
  15344. PPy: precinctsSize >> 4
  15345. });
  15346. }
  15347. cod.precinctsSizes = precinctsSizes;
  15348. }
  15349. var unsupported = [];
  15350. if (cod.selectiveArithmeticCodingBypass) {
  15351. unsupported.push('selectiveArithmeticCodingBypass');
  15352. }
  15353. if (cod.resetContextProbabilities) {
  15354. unsupported.push('resetContextProbabilities');
  15355. }
  15356. if (cod.terminationOnEachCodingPass) {
  15357. unsupported.push('terminationOnEachCodingPass');
  15358. }
  15359. if (cod.verticalyStripe) {
  15360. unsupported.push('verticalyStripe');
  15361. }
  15362. if (cod.predictableTermination) {
  15363. unsupported.push('predictableTermination');
  15364. }
  15365. if (unsupported.length > 0) {
  15366. doNotRecover = true;
  15367. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15368. }
  15369. if (context.mainHeader) {
  15370. context.COD = cod;
  15371. } else {
  15372. context.currentTile.COD = cod;
  15373. context.currentTile.COC = [];
  15374. }
  15375. break;
  15376. case 0xFF90:
  15377. length = readUint16(data, position);
  15378. tile = {};
  15379. tile.index = readUint16(data, position + 2);
  15380. tile.length = readUint32(data, position + 4);
  15381. tile.dataEnd = tile.length + position - 2;
  15382. tile.partIndex = data[position + 8];
  15383. tile.partsCount = data[position + 9];
  15384. context.mainHeader = false;
  15385. if (tile.partIndex === 0) {
  15386. tile.COD = context.COD;
  15387. tile.COC = context.COC.slice(0);
  15388. tile.QCD = context.QCD;
  15389. tile.QCC = context.QCC.slice(0);
  15390. }
  15391. context.currentTile = tile;
  15392. break;
  15393. case 0xFF93:
  15394. tile = context.currentTile;
  15395. if (tile.partIndex === 0) {
  15396. initializeTile(context, tile.index);
  15397. buildPackets(context);
  15398. }
  15399. length = tile.dataEnd - position;
  15400. parseTilePackets(context, data, position, length);
  15401. break;
  15402. case 0xFF55:
  15403. case 0xFF57:
  15404. case 0xFF58:
  15405. case 0xFF64:
  15406. length = readUint16(data, position);
  15407. break;
  15408. case 0xFF53:
  15409. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15410. default:
  15411. throw new Error('Unknown codestream code: ' + code.toString(16));
  15412. }
  15413. position += length;
  15414. }
  15415. } catch (e) {
  15416. if (doNotRecover || this.failOnCorruptedImage) {
  15417. error('JPX Error: ' + e.message);
  15418. } else {
  15419. warn('JPX: Trying to recover from: ' + e.message);
  15420. }
  15421. }
  15422. this.tiles = transformComponents(context);
  15423. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15424. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15425. this.componentsCount = context.SIZ.Csiz;
  15426. }
  15427. };
  15428. function calculateComponentDimensions(component, siz) {
  15429. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15430. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15431. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15432. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15433. component.width = component.x1 - component.x0;
  15434. component.height = component.y1 - component.y0;
  15435. }
  15436. function calculateTileGrids(context, components) {
  15437. var siz = context.SIZ;
  15438. var tile, tiles = [];
  15439. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15440. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15441. for (var q = 0; q < numYtiles; q++) {
  15442. for (var p = 0; p < numXtiles; p++) {
  15443. tile = {};
  15444. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15445. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15446. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15447. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15448. tile.width = tile.tx1 - tile.tx0;
  15449. tile.height = tile.ty1 - tile.ty0;
  15450. tile.components = [];
  15451. tiles.push(tile);
  15452. }
  15453. }
  15454. context.tiles = tiles;
  15455. var componentsCount = siz.Csiz;
  15456. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15457. var component = components[i];
  15458. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15459. var tileComponent = {};
  15460. tile = tiles[j];
  15461. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15462. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15463. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15464. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15465. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15466. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15467. tile.components[i] = tileComponent;
  15468. }
  15469. }
  15470. }
  15471. function getBlocksDimensions(context, component, r) {
  15472. var codOrCoc = component.codingStyleParameters;
  15473. var result = {};
  15474. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15475. result.PPx = 15;
  15476. result.PPy = 15;
  15477. } else {
  15478. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15479. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15480. }
  15481. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15482. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15483. return result;
  15484. }
  15485. function buildPrecincts(context, resolution, dimensions) {
  15486. var precinctWidth = 1 << dimensions.PPx;
  15487. var precinctHeight = 1 << dimensions.PPy;
  15488. var isZeroRes = resolution.resLevel === 0;
  15489. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15490. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15491. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15492. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15493. var numprecincts = numprecinctswide * numprecinctshigh;
  15494. resolution.precinctParameters = {
  15495. precinctWidth: precinctWidth,
  15496. precinctHeight: precinctHeight,
  15497. numprecinctswide: numprecinctswide,
  15498. numprecinctshigh: numprecinctshigh,
  15499. numprecincts: numprecincts,
  15500. precinctWidthInSubband: precinctWidthInSubband,
  15501. precinctHeightInSubband: precinctHeightInSubband
  15502. };
  15503. }
  15504. function buildCodeblocks(context, subband, dimensions) {
  15505. var xcb_ = dimensions.xcb_;
  15506. var ycb_ = dimensions.ycb_;
  15507. var codeblockWidth = 1 << xcb_;
  15508. var codeblockHeight = 1 << ycb_;
  15509. var cbx0 = subband.tbx0 >> xcb_;
  15510. var cby0 = subband.tby0 >> ycb_;
  15511. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15512. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15513. var precinctParameters = subband.resolution.precinctParameters;
  15514. var codeblocks = [];
  15515. var precincts = [];
  15516. var i, j, codeblock, precinctNumber;
  15517. for (j = cby0; j < cby1; j++) {
  15518. for (i = cbx0; i < cbx1; i++) {
  15519. codeblock = {
  15520. cbx: i,
  15521. cby: j,
  15522. tbx0: codeblockWidth * i,
  15523. tby0: codeblockHeight * j,
  15524. tbx1: codeblockWidth * (i + 1),
  15525. tby1: codeblockHeight * (j + 1)
  15526. };
  15527. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15528. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15529. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15530. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15531. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15532. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15533. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15534. codeblock.precinctNumber = precinctNumber;
  15535. codeblock.subbandType = subband.type;
  15536. codeblock.Lblock = 3;
  15537. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15538. continue;
  15539. }
  15540. codeblocks.push(codeblock);
  15541. var precinct = precincts[precinctNumber];
  15542. if (precinct !== undefined) {
  15543. if (i < precinct.cbxMin) {
  15544. precinct.cbxMin = i;
  15545. } else if (i > precinct.cbxMax) {
  15546. precinct.cbxMax = i;
  15547. }
  15548. if (j < precinct.cbyMin) {
  15549. precinct.cbxMin = j;
  15550. } else if (j > precinct.cbyMax) {
  15551. precinct.cbyMax = j;
  15552. }
  15553. } else {
  15554. precincts[precinctNumber] = precinct = {
  15555. cbxMin: i,
  15556. cbyMin: j,
  15557. cbxMax: i,
  15558. cbyMax: j
  15559. };
  15560. }
  15561. codeblock.precinct = precinct;
  15562. }
  15563. }
  15564. subband.codeblockParameters = {
  15565. codeblockWidth: xcb_,
  15566. codeblockHeight: ycb_,
  15567. numcodeblockwide: cbx1 - cbx0 + 1,
  15568. numcodeblockhigh: cby1 - cby0 + 1
  15569. };
  15570. subband.codeblocks = codeblocks;
  15571. subband.precincts = precincts;
  15572. }
  15573. function createPacket(resolution, precinctNumber, layerNumber) {
  15574. var precinctCodeblocks = [];
  15575. var subbands = resolution.subbands;
  15576. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15577. var subband = subbands[i];
  15578. var codeblocks = subband.codeblocks;
  15579. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15580. var codeblock = codeblocks[j];
  15581. if (codeblock.precinctNumber !== precinctNumber) {
  15582. continue;
  15583. }
  15584. precinctCodeblocks.push(codeblock);
  15585. }
  15586. }
  15587. return {
  15588. layerNumber: layerNumber,
  15589. codeblocks: precinctCodeblocks
  15590. };
  15591. }
  15592. function LayerResolutionComponentPositionIterator(context) {
  15593. var siz = context.SIZ;
  15594. var tileIndex = context.currentTile.index;
  15595. var tile = context.tiles[tileIndex];
  15596. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15597. var componentsCount = siz.Csiz;
  15598. var maxDecompositionLevelsCount = 0;
  15599. for (var q = 0; q < componentsCount; q++) {
  15600. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15601. }
  15602. var l = 0, r = 0, i = 0, k = 0;
  15603. this.nextPacket = function JpxImage_nextPacket() {
  15604. for (; l < layersCount; l++) {
  15605. for (; r <= maxDecompositionLevelsCount; r++) {
  15606. for (; i < componentsCount; i++) {
  15607. var component = tile.components[i];
  15608. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15609. continue;
  15610. }
  15611. var resolution = component.resolutions[r];
  15612. var numprecincts = resolution.precinctParameters.numprecincts;
  15613. for (; k < numprecincts;) {
  15614. var packet = createPacket(resolution, k, l);
  15615. k++;
  15616. return packet;
  15617. }
  15618. k = 0;
  15619. }
  15620. i = 0;
  15621. }
  15622. r = 0;
  15623. }
  15624. error('JPX Error: Out of packets');
  15625. };
  15626. }
  15627. function ResolutionLayerComponentPositionIterator(context) {
  15628. var siz = context.SIZ;
  15629. var tileIndex = context.currentTile.index;
  15630. var tile = context.tiles[tileIndex];
  15631. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15632. var componentsCount = siz.Csiz;
  15633. var maxDecompositionLevelsCount = 0;
  15634. for (var q = 0; q < componentsCount; q++) {
  15635. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15636. }
  15637. var r = 0, l = 0, i = 0, k = 0;
  15638. this.nextPacket = function JpxImage_nextPacket() {
  15639. for (; r <= maxDecompositionLevelsCount; r++) {
  15640. for (; l < layersCount; l++) {
  15641. for (; i < componentsCount; i++) {
  15642. var component = tile.components[i];
  15643. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15644. continue;
  15645. }
  15646. var resolution = component.resolutions[r];
  15647. var numprecincts = resolution.precinctParameters.numprecincts;
  15648. for (; k < numprecincts;) {
  15649. var packet = createPacket(resolution, k, l);
  15650. k++;
  15651. return packet;
  15652. }
  15653. k = 0;
  15654. }
  15655. i = 0;
  15656. }
  15657. l = 0;
  15658. }
  15659. error('JPX Error: Out of packets');
  15660. };
  15661. }
  15662. function ResolutionPositionComponentLayerIterator(context) {
  15663. var siz = context.SIZ;
  15664. var tileIndex = context.currentTile.index;
  15665. var tile = context.tiles[tileIndex];
  15666. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15667. var componentsCount = siz.Csiz;
  15668. var l, r, c, p;
  15669. var maxDecompositionLevelsCount = 0;
  15670. for (c = 0; c < componentsCount; c++) {
  15671. var component = tile.components[c];
  15672. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15673. }
  15674. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15675. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15676. var maxNumPrecincts = 0;
  15677. for (c = 0; c < componentsCount; ++c) {
  15678. var resolutions = tile.components[c].resolutions;
  15679. if (r < resolutions.length) {
  15680. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15681. }
  15682. }
  15683. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15684. }
  15685. l = 0;
  15686. r = 0;
  15687. c = 0;
  15688. p = 0;
  15689. this.nextPacket = function JpxImage_nextPacket() {
  15690. for (; r <= maxDecompositionLevelsCount; r++) {
  15691. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15692. for (; c < componentsCount; c++) {
  15693. var component = tile.components[c];
  15694. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15695. continue;
  15696. }
  15697. var resolution = component.resolutions[r];
  15698. var numprecincts = resolution.precinctParameters.numprecincts;
  15699. if (p >= numprecincts) {
  15700. continue;
  15701. }
  15702. for (; l < layersCount;) {
  15703. var packet = createPacket(resolution, p, l);
  15704. l++;
  15705. return packet;
  15706. }
  15707. l = 0;
  15708. }
  15709. c = 0;
  15710. }
  15711. p = 0;
  15712. }
  15713. error('JPX Error: Out of packets');
  15714. };
  15715. }
  15716. function PositionComponentResolutionLayerIterator(context) {
  15717. var siz = context.SIZ;
  15718. var tileIndex = context.currentTile.index;
  15719. var tile = context.tiles[tileIndex];
  15720. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15721. var componentsCount = siz.Csiz;
  15722. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15723. var precinctsIterationSizes = precinctsSizes;
  15724. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15725. this.nextPacket = function JpxImage_nextPacket() {
  15726. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15727. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15728. for (; c < componentsCount; c++) {
  15729. var component = tile.components[c];
  15730. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15731. for (; r <= decompositionLevelsCount; r++) {
  15732. var resolution = component.resolutions[r];
  15733. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15734. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15735. if (k === null) {
  15736. continue;
  15737. }
  15738. for (; l < layersCount;) {
  15739. var packet = createPacket(resolution, k, l);
  15740. l++;
  15741. return packet;
  15742. }
  15743. l = 0;
  15744. }
  15745. r = 0;
  15746. }
  15747. c = 0;
  15748. }
  15749. px = 0;
  15750. }
  15751. error('JPX Error: Out of packets');
  15752. };
  15753. }
  15754. function ComponentPositionResolutionLayerIterator(context) {
  15755. var siz = context.SIZ;
  15756. var tileIndex = context.currentTile.index;
  15757. var tile = context.tiles[tileIndex];
  15758. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15759. var componentsCount = siz.Csiz;
  15760. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15761. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15762. this.nextPacket = function JpxImage_nextPacket() {
  15763. for (; c < componentsCount; ++c) {
  15764. var component = tile.components[c];
  15765. var precinctsIterationSizes = precinctsSizes.components[c];
  15766. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15767. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15768. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15769. for (; r <= decompositionLevelsCount; r++) {
  15770. var resolution = component.resolutions[r];
  15771. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15772. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15773. if (k === null) {
  15774. continue;
  15775. }
  15776. for (; l < layersCount;) {
  15777. var packet = createPacket(resolution, k, l);
  15778. l++;
  15779. return packet;
  15780. }
  15781. l = 0;
  15782. }
  15783. r = 0;
  15784. }
  15785. px = 0;
  15786. }
  15787. py = 0;
  15788. }
  15789. error('JPX Error: Out of packets');
  15790. };
  15791. }
  15792. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15793. var posX = pxIndex * precinctIterationSizes.minWidth;
  15794. var posY = pyIndex * precinctIterationSizes.minHeight;
  15795. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15796. return null;
  15797. }
  15798. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15799. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15800. }
  15801. function getPrecinctSizesInImageScale(tile) {
  15802. var componentsCount = tile.components.length;
  15803. var minWidth = Number.MAX_VALUE;
  15804. var minHeight = Number.MAX_VALUE;
  15805. var maxNumWide = 0;
  15806. var maxNumHigh = 0;
  15807. var sizePerComponent = new Array(componentsCount);
  15808. for (var c = 0; c < componentsCount; c++) {
  15809. var component = tile.components[c];
  15810. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15811. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15812. var minWidthCurrentComponent = Number.MAX_VALUE;
  15813. var minHeightCurrentComponent = Number.MAX_VALUE;
  15814. var maxNumWideCurrentComponent = 0;
  15815. var maxNumHighCurrentComponent = 0;
  15816. var scale = 1;
  15817. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15818. var resolution = component.resolutions[r];
  15819. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15820. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15821. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15822. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15823. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15824. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15825. sizePerResolution[r] = {
  15826. width: widthCurrentResolution,
  15827. height: heightCurrentResolution
  15828. };
  15829. scale <<= 1;
  15830. }
  15831. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15832. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15833. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15834. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15835. sizePerComponent[c] = {
  15836. resolutions: sizePerResolution,
  15837. minWidth: minWidthCurrentComponent,
  15838. minHeight: minHeightCurrentComponent,
  15839. maxNumWide: maxNumWideCurrentComponent,
  15840. maxNumHigh: maxNumHighCurrentComponent
  15841. };
  15842. }
  15843. return {
  15844. components: sizePerComponent,
  15845. minWidth: minWidth,
  15846. minHeight: minHeight,
  15847. maxNumWide: maxNumWide,
  15848. maxNumHigh: maxNumHigh
  15849. };
  15850. }
  15851. function buildPackets(context) {
  15852. var siz = context.SIZ;
  15853. var tileIndex = context.currentTile.index;
  15854. var tile = context.tiles[tileIndex];
  15855. var componentsCount = siz.Csiz;
  15856. for (var c = 0; c < componentsCount; c++) {
  15857. var component = tile.components[c];
  15858. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15859. var resolutions = [];
  15860. var subbands = [];
  15861. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15862. var blocksDimensions = getBlocksDimensions(context, component, r);
  15863. var resolution = {};
  15864. var scale = 1 << decompositionLevelsCount - r;
  15865. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15866. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15867. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15868. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15869. resolution.resLevel = r;
  15870. buildPrecincts(context, resolution, blocksDimensions);
  15871. resolutions.push(resolution);
  15872. var subband;
  15873. if (r === 0) {
  15874. subband = {};
  15875. subband.type = 'LL';
  15876. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15877. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15878. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15879. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15880. subband.resolution = resolution;
  15881. buildCodeblocks(context, subband, blocksDimensions);
  15882. subbands.push(subband);
  15883. resolution.subbands = [subband];
  15884. } else {
  15885. var bscale = 1 << decompositionLevelsCount - r + 1;
  15886. var resolutionSubbands = [];
  15887. subband = {};
  15888. subband.type = 'HL';
  15889. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15890. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  15891. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15892. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  15893. subband.resolution = resolution;
  15894. buildCodeblocks(context, subband, blocksDimensions);
  15895. subbands.push(subband);
  15896. resolutionSubbands.push(subband);
  15897. subband = {};
  15898. subband.type = 'LH';
  15899. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  15900. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15901. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  15902. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15903. subband.resolution = resolution;
  15904. buildCodeblocks(context, subband, blocksDimensions);
  15905. subbands.push(subband);
  15906. resolutionSubbands.push(subband);
  15907. subband = {};
  15908. subband.type = 'HH';
  15909. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15910. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15911. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15912. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15913. subband.resolution = resolution;
  15914. buildCodeblocks(context, subband, blocksDimensions);
  15915. subbands.push(subband);
  15916. resolutionSubbands.push(subband);
  15917. resolution.subbands = resolutionSubbands;
  15918. }
  15919. }
  15920. component.resolutions = resolutions;
  15921. component.subbands = subbands;
  15922. }
  15923. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  15924. switch (progressionOrder) {
  15925. case 0:
  15926. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  15927. break;
  15928. case 1:
  15929. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  15930. break;
  15931. case 2:
  15932. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  15933. break;
  15934. case 3:
  15935. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  15936. break;
  15937. case 4:
  15938. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  15939. break;
  15940. default:
  15941. error('JPX Error: Unsupported progression order ' + progressionOrder);
  15942. }
  15943. }
  15944. function parseTilePackets(context, data, offset, dataLength) {
  15945. var position = 0;
  15946. var buffer, bufferSize = 0, skipNextBit = false;
  15947. function readBits(count) {
  15948. while (bufferSize < count) {
  15949. var b = data[offset + position];
  15950. position++;
  15951. if (skipNextBit) {
  15952. buffer = buffer << 7 | b;
  15953. bufferSize += 7;
  15954. skipNextBit = false;
  15955. } else {
  15956. buffer = buffer << 8 | b;
  15957. bufferSize += 8;
  15958. }
  15959. if (b === 0xFF) {
  15960. skipNextBit = true;
  15961. }
  15962. }
  15963. bufferSize -= count;
  15964. return buffer >>> bufferSize & (1 << count) - 1;
  15965. }
  15966. function skipMarkerIfEqual(value) {
  15967. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  15968. skipBytes(1);
  15969. return true;
  15970. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  15971. skipBytes(2);
  15972. return true;
  15973. }
  15974. return false;
  15975. }
  15976. function skipBytes(count) {
  15977. position += count;
  15978. }
  15979. function alignToByte() {
  15980. bufferSize = 0;
  15981. if (skipNextBit) {
  15982. position++;
  15983. skipNextBit = false;
  15984. }
  15985. }
  15986. function readCodingpasses() {
  15987. if (readBits(1) === 0) {
  15988. return 1;
  15989. }
  15990. if (readBits(1) === 0) {
  15991. return 2;
  15992. }
  15993. var value = readBits(2);
  15994. if (value < 3) {
  15995. return value + 3;
  15996. }
  15997. value = readBits(5);
  15998. if (value < 31) {
  15999. return value + 6;
  16000. }
  16001. value = readBits(7);
  16002. return value + 37;
  16003. }
  16004. var tileIndex = context.currentTile.index;
  16005. var tile = context.tiles[tileIndex];
  16006. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16007. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16008. var packetsIterator = tile.packetsIterator;
  16009. while (position < dataLength) {
  16010. alignToByte();
  16011. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16012. skipBytes(4);
  16013. }
  16014. var packet = packetsIterator.nextPacket();
  16015. if (!readBits(1)) {
  16016. continue;
  16017. }
  16018. var layerNumber = packet.layerNumber;
  16019. var queue = [], codeblock;
  16020. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16021. codeblock = packet.codeblocks[i];
  16022. var precinct = codeblock.precinct;
  16023. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16024. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16025. var codeblockIncluded = false;
  16026. var firstTimeInclusion = false;
  16027. var valueReady;
  16028. if (codeblock['included'] !== undefined) {
  16029. codeblockIncluded = !!readBits(1);
  16030. } else {
  16031. precinct = codeblock.precinct;
  16032. var inclusionTree, zeroBitPlanesTree;
  16033. if (precinct['inclusionTree'] !== undefined) {
  16034. inclusionTree = precinct.inclusionTree;
  16035. } else {
  16036. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16037. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16038. inclusionTree = new InclusionTree(width, height, layerNumber);
  16039. zeroBitPlanesTree = new TagTree(width, height);
  16040. precinct.inclusionTree = inclusionTree;
  16041. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16042. }
  16043. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16044. while (true) {
  16045. if (readBits(1)) {
  16046. valueReady = !inclusionTree.nextLevel();
  16047. if (valueReady) {
  16048. codeblock.included = true;
  16049. codeblockIncluded = firstTimeInclusion = true;
  16050. break;
  16051. }
  16052. } else {
  16053. inclusionTree.incrementValue(layerNumber);
  16054. break;
  16055. }
  16056. }
  16057. }
  16058. }
  16059. if (!codeblockIncluded) {
  16060. continue;
  16061. }
  16062. if (firstTimeInclusion) {
  16063. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16064. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16065. while (true) {
  16066. if (readBits(1)) {
  16067. valueReady = !zeroBitPlanesTree.nextLevel();
  16068. if (valueReady) {
  16069. break;
  16070. }
  16071. } else {
  16072. zeroBitPlanesTree.incrementValue();
  16073. }
  16074. }
  16075. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16076. }
  16077. var codingpasses = readCodingpasses();
  16078. while (readBits(1)) {
  16079. codeblock.Lblock++;
  16080. }
  16081. var codingpassesLog2 = log2(codingpasses);
  16082. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16083. var codedDataLength = readBits(bits);
  16084. queue.push({
  16085. codeblock: codeblock,
  16086. codingpasses: codingpasses,
  16087. dataLength: codedDataLength
  16088. });
  16089. }
  16090. alignToByte();
  16091. if (ephMarkerUsed) {
  16092. skipMarkerIfEqual(0x92);
  16093. }
  16094. while (queue.length > 0) {
  16095. var packetItem = queue.shift();
  16096. codeblock = packetItem.codeblock;
  16097. if (codeblock['data'] === undefined) {
  16098. codeblock.data = [];
  16099. }
  16100. codeblock.data.push({
  16101. data: data,
  16102. start: offset + position,
  16103. end: offset + position + packetItem.dataLength,
  16104. codingpasses: packetItem.codingpasses
  16105. });
  16106. position += packetItem.dataLength;
  16107. }
  16108. }
  16109. return position;
  16110. }
  16111. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16112. var x0 = subband.tbx0;
  16113. var y0 = subband.tby0;
  16114. var width = subband.tbx1 - subband.tbx0;
  16115. var codeblocks = subband.codeblocks;
  16116. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16117. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16118. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16119. var codeblock = codeblocks[i];
  16120. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16121. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16122. if (blockWidth === 0 || blockHeight === 0) {
  16123. continue;
  16124. }
  16125. if (codeblock['data'] === undefined) {
  16126. continue;
  16127. }
  16128. var bitModel, currentCodingpassType;
  16129. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16130. currentCodingpassType = 2;
  16131. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16132. var j, jj, dataItem;
  16133. for (j = 0, jj = data.length; j < jj; j++) {
  16134. dataItem = data[j];
  16135. totalLength += dataItem.end - dataItem.start;
  16136. codingpasses += dataItem.codingpasses;
  16137. }
  16138. var encodedData = new Uint8Array(totalLength);
  16139. var position = 0;
  16140. for (j = 0, jj = data.length; j < jj; j++) {
  16141. dataItem = data[j];
  16142. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16143. encodedData.set(chunk, position);
  16144. position += chunk.length;
  16145. }
  16146. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16147. bitModel.setDecoder(decoder);
  16148. for (j = 0; j < codingpasses; j++) {
  16149. switch (currentCodingpassType) {
  16150. case 0:
  16151. bitModel.runSignificancePropagationPass();
  16152. break;
  16153. case 1:
  16154. bitModel.runMagnitudeRefinementPass();
  16155. break;
  16156. case 2:
  16157. bitModel.runCleanupPass();
  16158. if (segmentationSymbolUsed) {
  16159. bitModel.checkSegmentationSymbol();
  16160. }
  16161. break;
  16162. }
  16163. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16164. }
  16165. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16166. var sign = bitModel.coefficentsSign;
  16167. var magnitude = bitModel.coefficentsMagnitude;
  16168. var bitsDecoded = bitModel.bitsDecoded;
  16169. var magnitudeCorrection = reversible ? 0 : 0.5;
  16170. var k, n, nb;
  16171. position = 0;
  16172. var interleave = subband.type !== 'LL';
  16173. for (j = 0; j < blockHeight; j++) {
  16174. var row = offset / width | 0;
  16175. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16176. for (k = 0; k < blockWidth; k++) {
  16177. n = magnitude[position];
  16178. if (n !== 0) {
  16179. n = (n + magnitudeCorrection) * delta;
  16180. if (sign[position] !== 0) {
  16181. n = -n;
  16182. }
  16183. nb = bitsDecoded[position];
  16184. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16185. if (reversible && nb >= mb) {
  16186. coefficients[pos] = n;
  16187. } else {
  16188. coefficients[pos] = n * (1 << mb - nb);
  16189. }
  16190. }
  16191. offset++;
  16192. position++;
  16193. }
  16194. offset += width - blockWidth;
  16195. }
  16196. }
  16197. }
  16198. function transformTile(context, tile, c) {
  16199. var component = tile.components[c];
  16200. var codingStyleParameters = component.codingStyleParameters;
  16201. var quantizationParameters = component.quantizationParameters;
  16202. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16203. var spqcds = quantizationParameters.SPqcds;
  16204. var scalarExpounded = quantizationParameters.scalarExpounded;
  16205. var guardBits = quantizationParameters.guardBits;
  16206. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16207. var precision = context.components[c].precision;
  16208. var reversible = codingStyleParameters.reversibleTransformation;
  16209. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16210. var subbandCoefficients = [];
  16211. var b = 0;
  16212. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16213. var resolution = component.resolutions[i];
  16214. var width = resolution.trx1 - resolution.trx0;
  16215. var height = resolution.try1 - resolution.try0;
  16216. var coefficients = new Float32Array(width * height);
  16217. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16218. var mu, epsilon;
  16219. if (!scalarExpounded) {
  16220. mu = spqcds[0].mu;
  16221. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16222. } else {
  16223. mu = spqcds[b].mu;
  16224. epsilon = spqcds[b].epsilon;
  16225. b++;
  16226. }
  16227. var subband = resolution.subbands[j];
  16228. var gainLog2 = SubbandsGainLog2[subband.type];
  16229. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16230. var mb = guardBits + epsilon - 1;
  16231. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16232. }
  16233. subbandCoefficients.push({
  16234. width: width,
  16235. height: height,
  16236. items: coefficients
  16237. });
  16238. }
  16239. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16240. return {
  16241. left: component.tcx0,
  16242. top: component.tcy0,
  16243. width: result.width,
  16244. height: result.height,
  16245. items: result.items
  16246. };
  16247. }
  16248. function transformComponents(context) {
  16249. var siz = context.SIZ;
  16250. var components = context.components;
  16251. var componentsCount = siz.Csiz;
  16252. var resultImages = [];
  16253. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16254. var tile = context.tiles[i];
  16255. var transformedTiles = [];
  16256. var c;
  16257. for (c = 0; c < componentsCount; c++) {
  16258. transformedTiles[c] = transformTile(context, tile, c);
  16259. }
  16260. var tile0 = transformedTiles[0];
  16261. var out = new Uint8Array(tile0.items.length * componentsCount);
  16262. var result = {
  16263. left: tile0.left,
  16264. top: tile0.top,
  16265. width: tile0.width,
  16266. height: tile0.height,
  16267. items: out
  16268. };
  16269. var shift, offset, max, min, maxK;
  16270. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16271. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16272. var fourComponents = componentsCount === 4;
  16273. var y0items = transformedTiles[0].items;
  16274. var y1items = transformedTiles[1].items;
  16275. var y2items = transformedTiles[2].items;
  16276. var y3items = fourComponents ? transformedTiles[3].items : null;
  16277. shift = components[0].precision - 8;
  16278. offset = (128 << shift) + 0.5;
  16279. max = 255 * (1 << shift);
  16280. maxK = max * 0.5;
  16281. min = -maxK;
  16282. var component0 = tile.components[0];
  16283. var alpha01 = componentsCount - 3;
  16284. jj = y0items.length;
  16285. if (!component0.codingStyleParameters.reversibleTransformation) {
  16286. for (j = 0; j < jj; j++, pos += alpha01) {
  16287. y0 = y0items[j] + offset;
  16288. y1 = y1items[j];
  16289. y2 = y2items[j];
  16290. r = y0 + 1.402 * y2;
  16291. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16292. b = y0 + 1.772 * y1;
  16293. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16294. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16295. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16296. }
  16297. } else {
  16298. for (j = 0; j < jj; j++, pos += alpha01) {
  16299. y0 = y0items[j] + offset;
  16300. y1 = y1items[j];
  16301. y2 = y2items[j];
  16302. g = y0 - (y2 + y1 >> 2);
  16303. r = g + y2;
  16304. b = g + y1;
  16305. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16306. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16307. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16308. }
  16309. }
  16310. if (fourComponents) {
  16311. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16312. k = y3items[j];
  16313. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16314. }
  16315. }
  16316. } else {
  16317. for (c = 0; c < componentsCount; c++) {
  16318. var items = transformedTiles[c].items;
  16319. shift = components[c].precision - 8;
  16320. offset = (128 << shift) + 0.5;
  16321. max = 127.5 * (1 << shift);
  16322. min = -max;
  16323. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16324. val = items[j];
  16325. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16326. pos += componentsCount;
  16327. }
  16328. }
  16329. }
  16330. resultImages.push(result);
  16331. }
  16332. return resultImages;
  16333. }
  16334. function initializeTile(context, tileIndex) {
  16335. var siz = context.SIZ;
  16336. var componentsCount = siz.Csiz;
  16337. var tile = context.tiles[tileIndex];
  16338. for (var c = 0; c < componentsCount; c++) {
  16339. var component = tile.components[c];
  16340. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16341. component.quantizationParameters = qcdOrQcc;
  16342. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16343. component.codingStyleParameters = codOrCoc;
  16344. }
  16345. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16346. }
  16347. var TagTree = function TagTreeClosure() {
  16348. function TagTree(width, height) {
  16349. var levelsLength = log2(Math.max(width, height)) + 1;
  16350. this.levels = [];
  16351. for (var i = 0; i < levelsLength; i++) {
  16352. var level = {
  16353. width: width,
  16354. height: height,
  16355. items: []
  16356. };
  16357. this.levels.push(level);
  16358. width = Math.ceil(width / 2);
  16359. height = Math.ceil(height / 2);
  16360. }
  16361. }
  16362. TagTree.prototype = {
  16363. reset: function TagTree_reset(i, j) {
  16364. var currentLevel = 0, value = 0, level;
  16365. while (currentLevel < this.levels.length) {
  16366. level = this.levels[currentLevel];
  16367. var index = i + j * level.width;
  16368. if (level.items[index] !== undefined) {
  16369. value = level.items[index];
  16370. break;
  16371. }
  16372. level.index = index;
  16373. i >>= 1;
  16374. j >>= 1;
  16375. currentLevel++;
  16376. }
  16377. currentLevel--;
  16378. level = this.levels[currentLevel];
  16379. level.items[level.index] = value;
  16380. this.currentLevel = currentLevel;
  16381. delete this.value;
  16382. },
  16383. incrementValue: function TagTree_incrementValue() {
  16384. var level = this.levels[this.currentLevel];
  16385. level.items[level.index]++;
  16386. },
  16387. nextLevel: function TagTree_nextLevel() {
  16388. var currentLevel = this.currentLevel;
  16389. var level = this.levels[currentLevel];
  16390. var value = level.items[level.index];
  16391. currentLevel--;
  16392. if (currentLevel < 0) {
  16393. this.value = value;
  16394. return false;
  16395. }
  16396. this.currentLevel = currentLevel;
  16397. level = this.levels[currentLevel];
  16398. level.items[level.index] = value;
  16399. return true;
  16400. }
  16401. };
  16402. return TagTree;
  16403. }();
  16404. var InclusionTree = function InclusionTreeClosure() {
  16405. function InclusionTree(width, height, defaultValue) {
  16406. var levelsLength = log2(Math.max(width, height)) + 1;
  16407. this.levels = [];
  16408. for (var i = 0; i < levelsLength; i++) {
  16409. var items = new Uint8Array(width * height);
  16410. for (var j = 0, jj = items.length; j < jj; j++) {
  16411. items[j] = defaultValue;
  16412. }
  16413. var level = {
  16414. width: width,
  16415. height: height,
  16416. items: items
  16417. };
  16418. this.levels.push(level);
  16419. width = Math.ceil(width / 2);
  16420. height = Math.ceil(height / 2);
  16421. }
  16422. }
  16423. InclusionTree.prototype = {
  16424. reset: function InclusionTree_reset(i, j, stopValue) {
  16425. var currentLevel = 0;
  16426. while (currentLevel < this.levels.length) {
  16427. var level = this.levels[currentLevel];
  16428. var index = i + j * level.width;
  16429. level.index = index;
  16430. var value = level.items[index];
  16431. if (value === 0xFF) {
  16432. break;
  16433. }
  16434. if (value > stopValue) {
  16435. this.currentLevel = currentLevel;
  16436. this.propagateValues();
  16437. return false;
  16438. }
  16439. i >>= 1;
  16440. j >>= 1;
  16441. currentLevel++;
  16442. }
  16443. this.currentLevel = currentLevel - 1;
  16444. return true;
  16445. },
  16446. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16447. var level = this.levels[this.currentLevel];
  16448. level.items[level.index] = stopValue + 1;
  16449. this.propagateValues();
  16450. },
  16451. propagateValues: function InclusionTree_propagateValues() {
  16452. var levelIndex = this.currentLevel;
  16453. var level = this.levels[levelIndex];
  16454. var currentValue = level.items[level.index];
  16455. while (--levelIndex >= 0) {
  16456. level = this.levels[levelIndex];
  16457. level.items[level.index] = currentValue;
  16458. }
  16459. },
  16460. nextLevel: function InclusionTree_nextLevel() {
  16461. var currentLevel = this.currentLevel;
  16462. var level = this.levels[currentLevel];
  16463. var value = level.items[level.index];
  16464. level.items[level.index] = 0xFF;
  16465. currentLevel--;
  16466. if (currentLevel < 0) {
  16467. return false;
  16468. }
  16469. this.currentLevel = currentLevel;
  16470. level = this.levels[currentLevel];
  16471. level.items[level.index] = value;
  16472. return true;
  16473. }
  16474. };
  16475. return InclusionTree;
  16476. }();
  16477. var BitModel = function BitModelClosure() {
  16478. var UNIFORM_CONTEXT = 17;
  16479. var RUNLENGTH_CONTEXT = 18;
  16480. var LLAndLHContextsLabel = new Uint8Array([
  16481. 0,
  16482. 5,
  16483. 8,
  16484. 0,
  16485. 3,
  16486. 7,
  16487. 8,
  16488. 0,
  16489. 4,
  16490. 7,
  16491. 8,
  16492. 0,
  16493. 0,
  16494. 0,
  16495. 0,
  16496. 0,
  16497. 1,
  16498. 6,
  16499. 8,
  16500. 0,
  16501. 3,
  16502. 7,
  16503. 8,
  16504. 0,
  16505. 4,
  16506. 7,
  16507. 8,
  16508. 0,
  16509. 0,
  16510. 0,
  16511. 0,
  16512. 0,
  16513. 2,
  16514. 6,
  16515. 8,
  16516. 0,
  16517. 3,
  16518. 7,
  16519. 8,
  16520. 0,
  16521. 4,
  16522. 7,
  16523. 8,
  16524. 0,
  16525. 0,
  16526. 0,
  16527. 0,
  16528. 0,
  16529. 2,
  16530. 6,
  16531. 8,
  16532. 0,
  16533. 3,
  16534. 7,
  16535. 8,
  16536. 0,
  16537. 4,
  16538. 7,
  16539. 8,
  16540. 0,
  16541. 0,
  16542. 0,
  16543. 0,
  16544. 0,
  16545. 2,
  16546. 6,
  16547. 8,
  16548. 0,
  16549. 3,
  16550. 7,
  16551. 8,
  16552. 0,
  16553. 4,
  16554. 7,
  16555. 8
  16556. ]);
  16557. var HLContextLabel = new Uint8Array([
  16558. 0,
  16559. 3,
  16560. 4,
  16561. 0,
  16562. 5,
  16563. 7,
  16564. 7,
  16565. 0,
  16566. 8,
  16567. 8,
  16568. 8,
  16569. 0,
  16570. 0,
  16571. 0,
  16572. 0,
  16573. 0,
  16574. 1,
  16575. 3,
  16576. 4,
  16577. 0,
  16578. 6,
  16579. 7,
  16580. 7,
  16581. 0,
  16582. 8,
  16583. 8,
  16584. 8,
  16585. 0,
  16586. 0,
  16587. 0,
  16588. 0,
  16589. 0,
  16590. 2,
  16591. 3,
  16592. 4,
  16593. 0,
  16594. 6,
  16595. 7,
  16596. 7,
  16597. 0,
  16598. 8,
  16599. 8,
  16600. 8,
  16601. 0,
  16602. 0,
  16603. 0,
  16604. 0,
  16605. 0,
  16606. 2,
  16607. 3,
  16608. 4,
  16609. 0,
  16610. 6,
  16611. 7,
  16612. 7,
  16613. 0,
  16614. 8,
  16615. 8,
  16616. 8,
  16617. 0,
  16618. 0,
  16619. 0,
  16620. 0,
  16621. 0,
  16622. 2,
  16623. 3,
  16624. 4,
  16625. 0,
  16626. 6,
  16627. 7,
  16628. 7,
  16629. 0,
  16630. 8,
  16631. 8,
  16632. 8
  16633. ]);
  16634. var HHContextLabel = new Uint8Array([
  16635. 0,
  16636. 1,
  16637. 2,
  16638. 0,
  16639. 1,
  16640. 2,
  16641. 2,
  16642. 0,
  16643. 2,
  16644. 2,
  16645. 2,
  16646. 0,
  16647. 0,
  16648. 0,
  16649. 0,
  16650. 0,
  16651. 3,
  16652. 4,
  16653. 5,
  16654. 0,
  16655. 4,
  16656. 5,
  16657. 5,
  16658. 0,
  16659. 5,
  16660. 5,
  16661. 5,
  16662. 0,
  16663. 0,
  16664. 0,
  16665. 0,
  16666. 0,
  16667. 6,
  16668. 7,
  16669. 7,
  16670. 0,
  16671. 7,
  16672. 7,
  16673. 7,
  16674. 0,
  16675. 7,
  16676. 7,
  16677. 7,
  16678. 0,
  16679. 0,
  16680. 0,
  16681. 0,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 8,
  16688. 8,
  16689. 8,
  16690. 0,
  16691. 8,
  16692. 8,
  16693. 8,
  16694. 0,
  16695. 0,
  16696. 0,
  16697. 0,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 8,
  16704. 8,
  16705. 8,
  16706. 0,
  16707. 8,
  16708. 8,
  16709. 8
  16710. ]);
  16711. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16712. this.width = width;
  16713. this.height = height;
  16714. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16715. var coefficientCount = width * height;
  16716. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16717. this.coefficentsSign = new Uint8Array(coefficientCount);
  16718. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16719. this.processingFlags = new Uint8Array(coefficientCount);
  16720. var bitsDecoded = new Uint8Array(coefficientCount);
  16721. if (zeroBitPlanes !== 0) {
  16722. for (var i = 0; i < coefficientCount; i++) {
  16723. bitsDecoded[i] = zeroBitPlanes;
  16724. }
  16725. }
  16726. this.bitsDecoded = bitsDecoded;
  16727. this.reset();
  16728. }
  16729. BitModel.prototype = {
  16730. setDecoder: function BitModel_setDecoder(decoder) {
  16731. this.decoder = decoder;
  16732. },
  16733. reset: function BitModel_reset() {
  16734. this.contexts = new Int8Array(19);
  16735. this.contexts[0] = 4 << 1 | 0;
  16736. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16737. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16738. },
  16739. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16740. var neighborsSignificance = this.neighborsSignificance;
  16741. var width = this.width, height = this.height;
  16742. var left = column > 0;
  16743. var right = column + 1 < width;
  16744. var i;
  16745. if (row > 0) {
  16746. i = index - width;
  16747. if (left) {
  16748. neighborsSignificance[i - 1] += 0x10;
  16749. }
  16750. if (right) {
  16751. neighborsSignificance[i + 1] += 0x10;
  16752. }
  16753. neighborsSignificance[i] += 0x04;
  16754. }
  16755. if (row + 1 < height) {
  16756. i = index + width;
  16757. if (left) {
  16758. neighborsSignificance[i - 1] += 0x10;
  16759. }
  16760. if (right) {
  16761. neighborsSignificance[i + 1] += 0x10;
  16762. }
  16763. neighborsSignificance[i] += 0x04;
  16764. }
  16765. if (left) {
  16766. neighborsSignificance[index - 1] += 0x01;
  16767. }
  16768. if (right) {
  16769. neighborsSignificance[index + 1] += 0x01;
  16770. }
  16771. neighborsSignificance[index] |= 0x80;
  16772. },
  16773. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16774. var decoder = this.decoder;
  16775. var width = this.width, height = this.height;
  16776. var coefficentsMagnitude = this.coefficentsMagnitude;
  16777. var coefficentsSign = this.coefficentsSign;
  16778. var neighborsSignificance = this.neighborsSignificance;
  16779. var processingFlags = this.processingFlags;
  16780. var contexts = this.contexts;
  16781. var labels = this.contextLabelTable;
  16782. var bitsDecoded = this.bitsDecoded;
  16783. var processedInverseMask = ~1;
  16784. var processedMask = 1;
  16785. var firstMagnitudeBitMask = 2;
  16786. for (var i0 = 0; i0 < height; i0 += 4) {
  16787. for (var j = 0; j < width; j++) {
  16788. var index = i0 * width + j;
  16789. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16790. var i = i0 + i1;
  16791. if (i >= height) {
  16792. break;
  16793. }
  16794. processingFlags[index] &= processedInverseMask;
  16795. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16796. continue;
  16797. }
  16798. var contextLabel = labels[neighborsSignificance[index]];
  16799. var decision = decoder.readBit(contexts, contextLabel);
  16800. if (decision) {
  16801. var sign = this.decodeSignBit(i, j, index);
  16802. coefficentsSign[index] = sign;
  16803. coefficentsMagnitude[index] = 1;
  16804. this.setNeighborsSignificance(i, j, index);
  16805. processingFlags[index] |= firstMagnitudeBitMask;
  16806. }
  16807. bitsDecoded[index]++;
  16808. processingFlags[index] |= processedMask;
  16809. }
  16810. }
  16811. }
  16812. },
  16813. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16814. var width = this.width, height = this.height;
  16815. var coefficentsMagnitude = this.coefficentsMagnitude;
  16816. var coefficentsSign = this.coefficentsSign;
  16817. var contribution, sign0, sign1, significance1;
  16818. var contextLabel, decoded;
  16819. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16820. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16821. sign1 = coefficentsSign[index + 1];
  16822. if (significance1) {
  16823. sign0 = coefficentsSign[index - 1];
  16824. contribution = 1 - sign1 - sign0;
  16825. } else {
  16826. contribution = 1 - sign1 - sign1;
  16827. }
  16828. } else if (significance1) {
  16829. sign0 = coefficentsSign[index - 1];
  16830. contribution = 1 - sign0 - sign0;
  16831. } else {
  16832. contribution = 0;
  16833. }
  16834. var horizontalContribution = 3 * contribution;
  16835. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16836. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16837. sign1 = coefficentsSign[index + width];
  16838. if (significance1) {
  16839. sign0 = coefficentsSign[index - width];
  16840. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16841. } else {
  16842. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16843. }
  16844. } else if (significance1) {
  16845. sign0 = coefficentsSign[index - width];
  16846. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16847. } else {
  16848. contribution = horizontalContribution;
  16849. }
  16850. if (contribution >= 0) {
  16851. contextLabel = 9 + contribution;
  16852. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16853. } else {
  16854. contextLabel = 9 - contribution;
  16855. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16856. }
  16857. return decoded;
  16858. },
  16859. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16860. var decoder = this.decoder;
  16861. var width = this.width, height = this.height;
  16862. var coefficentsMagnitude = this.coefficentsMagnitude;
  16863. var neighborsSignificance = this.neighborsSignificance;
  16864. var contexts = this.contexts;
  16865. var bitsDecoded = this.bitsDecoded;
  16866. var processingFlags = this.processingFlags;
  16867. var processedMask = 1;
  16868. var firstMagnitudeBitMask = 2;
  16869. var length = width * height;
  16870. var width4 = width * 4;
  16871. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16872. indexNext = Math.min(length, index0 + width4);
  16873. for (var j = 0; j < width; j++) {
  16874. for (var index = index0 + j; index < indexNext; index += width) {
  16875. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16876. continue;
  16877. }
  16878. var contextLabel = 16;
  16879. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16880. processingFlags[index] ^= firstMagnitudeBitMask;
  16881. var significance = neighborsSignificance[index] & 127;
  16882. contextLabel = significance === 0 ? 15 : 14;
  16883. }
  16884. var bit = decoder.readBit(contexts, contextLabel);
  16885. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16886. bitsDecoded[index]++;
  16887. processingFlags[index] |= processedMask;
  16888. }
  16889. }
  16890. }
  16891. },
  16892. runCleanupPass: function BitModel_runCleanupPass() {
  16893. var decoder = this.decoder;
  16894. var width = this.width, height = this.height;
  16895. var neighborsSignificance = this.neighborsSignificance;
  16896. var coefficentsMagnitude = this.coefficentsMagnitude;
  16897. var coefficentsSign = this.coefficentsSign;
  16898. var contexts = this.contexts;
  16899. var labels = this.contextLabelTable;
  16900. var bitsDecoded = this.bitsDecoded;
  16901. var processingFlags = this.processingFlags;
  16902. var processedMask = 1;
  16903. var firstMagnitudeBitMask = 2;
  16904. var oneRowDown = width;
  16905. var twoRowsDown = width * 2;
  16906. var threeRowsDown = width * 3;
  16907. var iNext;
  16908. for (var i0 = 0; i0 < height; i0 = iNext) {
  16909. iNext = Math.min(i0 + 4, height);
  16910. var indexBase = i0 * width;
  16911. var checkAllEmpty = i0 + 3 < height;
  16912. for (var j = 0; j < width; j++) {
  16913. var index0 = indexBase + j;
  16914. 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;
  16915. var i1 = 0, index = index0;
  16916. var i = i0, sign;
  16917. if (allEmpty) {
  16918. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  16919. if (!hasSignificantCoefficent) {
  16920. bitsDecoded[index0]++;
  16921. bitsDecoded[index0 + oneRowDown]++;
  16922. bitsDecoded[index0 + twoRowsDown]++;
  16923. bitsDecoded[index0 + threeRowsDown]++;
  16924. continue;
  16925. }
  16926. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  16927. if (i1 !== 0) {
  16928. i = i0 + i1;
  16929. index += i1 * width;
  16930. }
  16931. sign = this.decodeSignBit(i, j, index);
  16932. coefficentsSign[index] = sign;
  16933. coefficentsMagnitude[index] = 1;
  16934. this.setNeighborsSignificance(i, j, index);
  16935. processingFlags[index] |= firstMagnitudeBitMask;
  16936. index = index0;
  16937. for (var i2 = i0; i2 <= i; i2++, index += width) {
  16938. bitsDecoded[index]++;
  16939. }
  16940. i1++;
  16941. }
  16942. for (i = i0 + i1; i < iNext; i++, index += width) {
  16943. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16944. continue;
  16945. }
  16946. var contextLabel = labels[neighborsSignificance[index]];
  16947. var decision = decoder.readBit(contexts, contextLabel);
  16948. if (decision === 1) {
  16949. sign = this.decodeSignBit(i, j, index);
  16950. coefficentsSign[index] = sign;
  16951. coefficentsMagnitude[index] = 1;
  16952. this.setNeighborsSignificance(i, j, index);
  16953. processingFlags[index] |= firstMagnitudeBitMask;
  16954. }
  16955. bitsDecoded[index]++;
  16956. }
  16957. }
  16958. }
  16959. },
  16960. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  16961. var decoder = this.decoder;
  16962. var contexts = this.contexts;
  16963. 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);
  16964. if (symbol !== 0xA) {
  16965. error('JPX Error: Invalid segmentation symbol');
  16966. }
  16967. }
  16968. };
  16969. return BitModel;
  16970. }();
  16971. var Transform = function TransformClosure() {
  16972. function Transform() {
  16973. }
  16974. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  16975. var ll = subbands[0];
  16976. for (var i = 1, ii = subbands.length; i < ii; i++) {
  16977. ll = this.iterate(ll, subbands[i], u0, v0);
  16978. }
  16979. return ll;
  16980. };
  16981. Transform.prototype.extend = function extend(buffer, offset, size) {
  16982. var i1 = offset - 1, j1 = offset + 1;
  16983. var i2 = offset + size - 2, j2 = offset + size;
  16984. buffer[i1--] = buffer[j1++];
  16985. buffer[j2++] = buffer[i2--];
  16986. buffer[i1--] = buffer[j1++];
  16987. buffer[j2++] = buffer[i2--];
  16988. buffer[i1--] = buffer[j1++];
  16989. buffer[j2++] = buffer[i2--];
  16990. buffer[i1] = buffer[j1];
  16991. buffer[j2] = buffer[i2];
  16992. };
  16993. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  16994. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  16995. var width = hl_lh_hh.width;
  16996. var height = hl_lh_hh.height;
  16997. var items = hl_lh_hh.items;
  16998. var i, j, k, l, u, v;
  16999. for (k = 0, i = 0; i < llHeight; i++) {
  17000. l = i * 2 * width;
  17001. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17002. items[l] = llItems[k];
  17003. }
  17004. }
  17005. llItems = ll.items = null;
  17006. var bufferPadding = 4;
  17007. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17008. if (width === 1) {
  17009. if ((u0 & 1) !== 0) {
  17010. for (v = 0, k = 0; v < height; v++, k += width) {
  17011. items[k] *= 0.5;
  17012. }
  17013. }
  17014. } else {
  17015. for (v = 0, k = 0; v < height; v++, k += width) {
  17016. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17017. this.extend(rowBuffer, bufferPadding, width);
  17018. this.filter(rowBuffer, bufferPadding, width);
  17019. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17020. }
  17021. }
  17022. var numBuffers = 16;
  17023. var colBuffers = [];
  17024. for (i = 0; i < numBuffers; i++) {
  17025. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17026. }
  17027. var b, currentBuffer = 0;
  17028. ll = bufferPadding + height;
  17029. if (height === 1) {
  17030. if ((v0 & 1) !== 0) {
  17031. for (u = 0; u < width; u++) {
  17032. items[u] *= 0.5;
  17033. }
  17034. }
  17035. } else {
  17036. for (u = 0; u < width; u++) {
  17037. if (currentBuffer === 0) {
  17038. numBuffers = Math.min(width - u, numBuffers);
  17039. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17040. for (b = 0; b < numBuffers; b++) {
  17041. colBuffers[b][l] = items[k + b];
  17042. }
  17043. }
  17044. currentBuffer = numBuffers;
  17045. }
  17046. currentBuffer--;
  17047. var buffer = colBuffers[currentBuffer];
  17048. this.extend(buffer, bufferPadding, height);
  17049. this.filter(buffer, bufferPadding, height);
  17050. if (currentBuffer === 0) {
  17051. k = u - numBuffers + 1;
  17052. for (l = bufferPadding; l < ll; k += width, l++) {
  17053. for (b = 0; b < numBuffers; b++) {
  17054. items[k + b] = colBuffers[b][l];
  17055. }
  17056. }
  17057. }
  17058. }
  17059. }
  17060. return {
  17061. width: width,
  17062. height: height,
  17063. items: items
  17064. };
  17065. };
  17066. return Transform;
  17067. }();
  17068. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17069. function IrreversibleTransform() {
  17070. Transform.call(this);
  17071. }
  17072. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17073. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17074. var len = length >> 1;
  17075. offset = offset | 0;
  17076. var j, n, current, next;
  17077. var alpha = -1.586134342059924;
  17078. var beta = -0.052980118572961;
  17079. var gamma = 0.882911075530934;
  17080. var delta = 0.443506852043971;
  17081. var K = 1.230174104914001;
  17082. var K_ = 1 / K;
  17083. j = offset - 3;
  17084. for (n = len + 4; n--; j += 2) {
  17085. x[j] *= K_;
  17086. }
  17087. j = offset - 2;
  17088. current = delta * x[j - 1];
  17089. for (n = len + 3; n--; j += 2) {
  17090. next = delta * x[j + 1];
  17091. x[j] = K * x[j] - current - next;
  17092. if (n--) {
  17093. j += 2;
  17094. current = delta * x[j + 1];
  17095. x[j] = K * x[j] - current - next;
  17096. } else {
  17097. break;
  17098. }
  17099. }
  17100. j = offset - 1;
  17101. current = gamma * x[j - 1];
  17102. for (n = len + 2; n--; j += 2) {
  17103. next = gamma * x[j + 1];
  17104. x[j] -= current + next;
  17105. if (n--) {
  17106. j += 2;
  17107. current = gamma * x[j + 1];
  17108. x[j] -= current + next;
  17109. } else {
  17110. break;
  17111. }
  17112. }
  17113. j = offset;
  17114. current = beta * x[j - 1];
  17115. for (n = len + 1; n--; j += 2) {
  17116. next = beta * x[j + 1];
  17117. x[j] -= current + next;
  17118. if (n--) {
  17119. j += 2;
  17120. current = beta * x[j + 1];
  17121. x[j] -= current + next;
  17122. } else {
  17123. break;
  17124. }
  17125. }
  17126. if (len !== 0) {
  17127. j = offset + 1;
  17128. current = alpha * x[j - 1];
  17129. for (n = len; n--; j += 2) {
  17130. next = alpha * x[j + 1];
  17131. x[j] -= current + next;
  17132. if (n--) {
  17133. j += 2;
  17134. current = alpha * x[j + 1];
  17135. x[j] -= current + next;
  17136. } else {
  17137. break;
  17138. }
  17139. }
  17140. }
  17141. };
  17142. return IrreversibleTransform;
  17143. }();
  17144. var ReversibleTransform = function ReversibleTransformClosure() {
  17145. function ReversibleTransform() {
  17146. Transform.call(this);
  17147. }
  17148. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17149. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17150. var len = length >> 1;
  17151. offset = offset | 0;
  17152. var j, n;
  17153. for (j = offset, n = len + 1; n--; j += 2) {
  17154. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17155. }
  17156. for (j = offset + 1, n = len; n--; j += 2) {
  17157. x[j] += x[j - 1] + x[j + 1] >> 1;
  17158. }
  17159. };
  17160. return ReversibleTransform;
  17161. }();
  17162. return JpxImage;
  17163. }();
  17164. exports.JpxImage = JpxImage;
  17165. }));
  17166. (function (root, factory) {
  17167. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17168. }(this, function (exports, sharedUtil) {
  17169. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17170. var getMetrics = getLookupTableFactory(function (t) {
  17171. t['Courier'] = 600;
  17172. t['Courier-Bold'] = 600;
  17173. t['Courier-BoldOblique'] = 600;
  17174. t['Courier-Oblique'] = 600;
  17175. t['Helvetica'] = getLookupTableFactory(function (t) {
  17176. t['space'] = 278;
  17177. t['exclam'] = 278;
  17178. t['quotedbl'] = 355;
  17179. t['numbersign'] = 556;
  17180. t['dollar'] = 556;
  17181. t['percent'] = 889;
  17182. t['ampersand'] = 667;
  17183. t['quoteright'] = 222;
  17184. t['parenleft'] = 333;
  17185. t['parenright'] = 333;
  17186. t['asterisk'] = 389;
  17187. t['plus'] = 584;
  17188. t['comma'] = 278;
  17189. t['hyphen'] = 333;
  17190. t['period'] = 278;
  17191. t['slash'] = 278;
  17192. t['zero'] = 556;
  17193. t['one'] = 556;
  17194. t['two'] = 556;
  17195. t['three'] = 556;
  17196. t['four'] = 556;
  17197. t['five'] = 556;
  17198. t['six'] = 556;
  17199. t['seven'] = 556;
  17200. t['eight'] = 556;
  17201. t['nine'] = 556;
  17202. t['colon'] = 278;
  17203. t['semicolon'] = 278;
  17204. t['less'] = 584;
  17205. t['equal'] = 584;
  17206. t['greater'] = 584;
  17207. t['question'] = 556;
  17208. t['at'] = 1015;
  17209. t['A'] = 667;
  17210. t['B'] = 667;
  17211. t['C'] = 722;
  17212. t['D'] = 722;
  17213. t['E'] = 667;
  17214. t['F'] = 611;
  17215. t['G'] = 778;
  17216. t['H'] = 722;
  17217. t['I'] = 278;
  17218. t['J'] = 500;
  17219. t['K'] = 667;
  17220. t['L'] = 556;
  17221. t['M'] = 833;
  17222. t['N'] = 722;
  17223. t['O'] = 778;
  17224. t['P'] = 667;
  17225. t['Q'] = 778;
  17226. t['R'] = 722;
  17227. t['S'] = 667;
  17228. t['T'] = 611;
  17229. t['U'] = 722;
  17230. t['V'] = 667;
  17231. t['W'] = 944;
  17232. t['X'] = 667;
  17233. t['Y'] = 667;
  17234. t['Z'] = 611;
  17235. t['bracketleft'] = 278;
  17236. t['backslash'] = 278;
  17237. t['bracketright'] = 278;
  17238. t['asciicircum'] = 469;
  17239. t['underscore'] = 556;
  17240. t['quoteleft'] = 222;
  17241. t['a'] = 556;
  17242. t['b'] = 556;
  17243. t['c'] = 500;
  17244. t['d'] = 556;
  17245. t['e'] = 556;
  17246. t['f'] = 278;
  17247. t['g'] = 556;
  17248. t['h'] = 556;
  17249. t['i'] = 222;
  17250. t['j'] = 222;
  17251. t['k'] = 500;
  17252. t['l'] = 222;
  17253. t['m'] = 833;
  17254. t['n'] = 556;
  17255. t['o'] = 556;
  17256. t['p'] = 556;
  17257. t['q'] = 556;
  17258. t['r'] = 333;
  17259. t['s'] = 500;
  17260. t['t'] = 278;
  17261. t['u'] = 556;
  17262. t['v'] = 500;
  17263. t['w'] = 722;
  17264. t['x'] = 500;
  17265. t['y'] = 500;
  17266. t['z'] = 500;
  17267. t['braceleft'] = 334;
  17268. t['bar'] = 260;
  17269. t['braceright'] = 334;
  17270. t['asciitilde'] = 584;
  17271. t['exclamdown'] = 333;
  17272. t['cent'] = 556;
  17273. t['sterling'] = 556;
  17274. t['fraction'] = 167;
  17275. t['yen'] = 556;
  17276. t['florin'] = 556;
  17277. t['section'] = 556;
  17278. t['currency'] = 556;
  17279. t['quotesingle'] = 191;
  17280. t['quotedblleft'] = 333;
  17281. t['guillemotleft'] = 556;
  17282. t['guilsinglleft'] = 333;
  17283. t['guilsinglright'] = 333;
  17284. t['fi'] = 500;
  17285. t['fl'] = 500;
  17286. t['endash'] = 556;
  17287. t['dagger'] = 556;
  17288. t['daggerdbl'] = 556;
  17289. t['periodcentered'] = 278;
  17290. t['paragraph'] = 537;
  17291. t['bullet'] = 350;
  17292. t['quotesinglbase'] = 222;
  17293. t['quotedblbase'] = 333;
  17294. t['quotedblright'] = 333;
  17295. t['guillemotright'] = 556;
  17296. t['ellipsis'] = 1000;
  17297. t['perthousand'] = 1000;
  17298. t['questiondown'] = 611;
  17299. t['grave'] = 333;
  17300. t['acute'] = 333;
  17301. t['circumflex'] = 333;
  17302. t['tilde'] = 333;
  17303. t['macron'] = 333;
  17304. t['breve'] = 333;
  17305. t['dotaccent'] = 333;
  17306. t['dieresis'] = 333;
  17307. t['ring'] = 333;
  17308. t['cedilla'] = 333;
  17309. t['hungarumlaut'] = 333;
  17310. t['ogonek'] = 333;
  17311. t['caron'] = 333;
  17312. t['emdash'] = 1000;
  17313. t['AE'] = 1000;
  17314. t['ordfeminine'] = 370;
  17315. t['Lslash'] = 556;
  17316. t['Oslash'] = 778;
  17317. t['OE'] = 1000;
  17318. t['ordmasculine'] = 365;
  17319. t['ae'] = 889;
  17320. t['dotlessi'] = 278;
  17321. t['lslash'] = 222;
  17322. t['oslash'] = 611;
  17323. t['oe'] = 944;
  17324. t['germandbls'] = 611;
  17325. t['Idieresis'] = 278;
  17326. t['eacute'] = 556;
  17327. t['abreve'] = 556;
  17328. t['uhungarumlaut'] = 556;
  17329. t['ecaron'] = 556;
  17330. t['Ydieresis'] = 667;
  17331. t['divide'] = 584;
  17332. t['Yacute'] = 667;
  17333. t['Acircumflex'] = 667;
  17334. t['aacute'] = 556;
  17335. t['Ucircumflex'] = 722;
  17336. t['yacute'] = 500;
  17337. t['scommaaccent'] = 500;
  17338. t['ecircumflex'] = 556;
  17339. t['Uring'] = 722;
  17340. t['Udieresis'] = 722;
  17341. t['aogonek'] = 556;
  17342. t['Uacute'] = 722;
  17343. t['uogonek'] = 556;
  17344. t['Edieresis'] = 667;
  17345. t['Dcroat'] = 722;
  17346. t['commaaccent'] = 250;
  17347. t['copyright'] = 737;
  17348. t['Emacron'] = 667;
  17349. t['ccaron'] = 500;
  17350. t['aring'] = 556;
  17351. t['Ncommaaccent'] = 722;
  17352. t['lacute'] = 222;
  17353. t['agrave'] = 556;
  17354. t['Tcommaaccent'] = 611;
  17355. t['Cacute'] = 722;
  17356. t['atilde'] = 556;
  17357. t['Edotaccent'] = 667;
  17358. t['scaron'] = 500;
  17359. t['scedilla'] = 500;
  17360. t['iacute'] = 278;
  17361. t['lozenge'] = 471;
  17362. t['Rcaron'] = 722;
  17363. t['Gcommaaccent'] = 778;
  17364. t['ucircumflex'] = 556;
  17365. t['acircumflex'] = 556;
  17366. t['Amacron'] = 667;
  17367. t['rcaron'] = 333;
  17368. t['ccedilla'] = 500;
  17369. t['Zdotaccent'] = 611;
  17370. t['Thorn'] = 667;
  17371. t['Omacron'] = 778;
  17372. t['Racute'] = 722;
  17373. t['Sacute'] = 667;
  17374. t['dcaron'] = 643;
  17375. t['Umacron'] = 722;
  17376. t['uring'] = 556;
  17377. t['threesuperior'] = 333;
  17378. t['Ograve'] = 778;
  17379. t['Agrave'] = 667;
  17380. t['Abreve'] = 667;
  17381. t['multiply'] = 584;
  17382. t['uacute'] = 556;
  17383. t['Tcaron'] = 611;
  17384. t['partialdiff'] = 476;
  17385. t['ydieresis'] = 500;
  17386. t['Nacute'] = 722;
  17387. t['icircumflex'] = 278;
  17388. t['Ecircumflex'] = 667;
  17389. t['adieresis'] = 556;
  17390. t['edieresis'] = 556;
  17391. t['cacute'] = 500;
  17392. t['nacute'] = 556;
  17393. t['umacron'] = 556;
  17394. t['Ncaron'] = 722;
  17395. t['Iacute'] = 278;
  17396. t['plusminus'] = 584;
  17397. t['brokenbar'] = 260;
  17398. t['registered'] = 737;
  17399. t['Gbreve'] = 778;
  17400. t['Idotaccent'] = 278;
  17401. t['summation'] = 600;
  17402. t['Egrave'] = 667;
  17403. t['racute'] = 333;
  17404. t['omacron'] = 556;
  17405. t['Zacute'] = 611;
  17406. t['Zcaron'] = 611;
  17407. t['greaterequal'] = 549;
  17408. t['Eth'] = 722;
  17409. t['Ccedilla'] = 722;
  17410. t['lcommaaccent'] = 222;
  17411. t['tcaron'] = 317;
  17412. t['eogonek'] = 556;
  17413. t['Uogonek'] = 722;
  17414. t['Aacute'] = 667;
  17415. t['Adieresis'] = 667;
  17416. t['egrave'] = 556;
  17417. t['zacute'] = 500;
  17418. t['iogonek'] = 222;
  17419. t['Oacute'] = 778;
  17420. t['oacute'] = 556;
  17421. t['amacron'] = 556;
  17422. t['sacute'] = 500;
  17423. t['idieresis'] = 278;
  17424. t['Ocircumflex'] = 778;
  17425. t['Ugrave'] = 722;
  17426. t['Delta'] = 612;
  17427. t['thorn'] = 556;
  17428. t['twosuperior'] = 333;
  17429. t['Odieresis'] = 778;
  17430. t['mu'] = 556;
  17431. t['igrave'] = 278;
  17432. t['ohungarumlaut'] = 556;
  17433. t['Eogonek'] = 667;
  17434. t['dcroat'] = 556;
  17435. t['threequarters'] = 834;
  17436. t['Scedilla'] = 667;
  17437. t['lcaron'] = 299;
  17438. t['Kcommaaccent'] = 667;
  17439. t['Lacute'] = 556;
  17440. t['trademark'] = 1000;
  17441. t['edotaccent'] = 556;
  17442. t['Igrave'] = 278;
  17443. t['Imacron'] = 278;
  17444. t['Lcaron'] = 556;
  17445. t['onehalf'] = 834;
  17446. t['lessequal'] = 549;
  17447. t['ocircumflex'] = 556;
  17448. t['ntilde'] = 556;
  17449. t['Uhungarumlaut'] = 722;
  17450. t['Eacute'] = 667;
  17451. t['emacron'] = 556;
  17452. t['gbreve'] = 556;
  17453. t['onequarter'] = 834;
  17454. t['Scaron'] = 667;
  17455. t['Scommaaccent'] = 667;
  17456. t['Ohungarumlaut'] = 778;
  17457. t['degree'] = 400;
  17458. t['ograve'] = 556;
  17459. t['Ccaron'] = 722;
  17460. t['ugrave'] = 556;
  17461. t['radical'] = 453;
  17462. t['Dcaron'] = 722;
  17463. t['rcommaaccent'] = 333;
  17464. t['Ntilde'] = 722;
  17465. t['otilde'] = 556;
  17466. t['Rcommaaccent'] = 722;
  17467. t['Lcommaaccent'] = 556;
  17468. t['Atilde'] = 667;
  17469. t['Aogonek'] = 667;
  17470. t['Aring'] = 667;
  17471. t['Otilde'] = 778;
  17472. t['zdotaccent'] = 500;
  17473. t['Ecaron'] = 667;
  17474. t['Iogonek'] = 278;
  17475. t['kcommaaccent'] = 500;
  17476. t['minus'] = 584;
  17477. t['Icircumflex'] = 278;
  17478. t['ncaron'] = 556;
  17479. t['tcommaaccent'] = 278;
  17480. t['logicalnot'] = 584;
  17481. t['odieresis'] = 556;
  17482. t['udieresis'] = 556;
  17483. t['notequal'] = 549;
  17484. t['gcommaaccent'] = 556;
  17485. t['eth'] = 556;
  17486. t['zcaron'] = 500;
  17487. t['ncommaaccent'] = 556;
  17488. t['onesuperior'] = 333;
  17489. t['imacron'] = 278;
  17490. t['Euro'] = 556;
  17491. });
  17492. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17493. t['space'] = 278;
  17494. t['exclam'] = 333;
  17495. t['quotedbl'] = 474;
  17496. t['numbersign'] = 556;
  17497. t['dollar'] = 556;
  17498. t['percent'] = 889;
  17499. t['ampersand'] = 722;
  17500. t['quoteright'] = 278;
  17501. t['parenleft'] = 333;
  17502. t['parenright'] = 333;
  17503. t['asterisk'] = 389;
  17504. t['plus'] = 584;
  17505. t['comma'] = 278;
  17506. t['hyphen'] = 333;
  17507. t['period'] = 278;
  17508. t['slash'] = 278;
  17509. t['zero'] = 556;
  17510. t['one'] = 556;
  17511. t['two'] = 556;
  17512. t['three'] = 556;
  17513. t['four'] = 556;
  17514. t['five'] = 556;
  17515. t['six'] = 556;
  17516. t['seven'] = 556;
  17517. t['eight'] = 556;
  17518. t['nine'] = 556;
  17519. t['colon'] = 333;
  17520. t['semicolon'] = 333;
  17521. t['less'] = 584;
  17522. t['equal'] = 584;
  17523. t['greater'] = 584;
  17524. t['question'] = 611;
  17525. t['at'] = 975;
  17526. t['A'] = 722;
  17527. t['B'] = 722;
  17528. t['C'] = 722;
  17529. t['D'] = 722;
  17530. t['E'] = 667;
  17531. t['F'] = 611;
  17532. t['G'] = 778;
  17533. t['H'] = 722;
  17534. t['I'] = 278;
  17535. t['J'] = 556;
  17536. t['K'] = 722;
  17537. t['L'] = 611;
  17538. t['M'] = 833;
  17539. t['N'] = 722;
  17540. t['O'] = 778;
  17541. t['P'] = 667;
  17542. t['Q'] = 778;
  17543. t['R'] = 722;
  17544. t['S'] = 667;
  17545. t['T'] = 611;
  17546. t['U'] = 722;
  17547. t['V'] = 667;
  17548. t['W'] = 944;
  17549. t['X'] = 667;
  17550. t['Y'] = 667;
  17551. t['Z'] = 611;
  17552. t['bracketleft'] = 333;
  17553. t['backslash'] = 278;
  17554. t['bracketright'] = 333;
  17555. t['asciicircum'] = 584;
  17556. t['underscore'] = 556;
  17557. t['quoteleft'] = 278;
  17558. t['a'] = 556;
  17559. t['b'] = 611;
  17560. t['c'] = 556;
  17561. t['d'] = 611;
  17562. t['e'] = 556;
  17563. t['f'] = 333;
  17564. t['g'] = 611;
  17565. t['h'] = 611;
  17566. t['i'] = 278;
  17567. t['j'] = 278;
  17568. t['k'] = 556;
  17569. t['l'] = 278;
  17570. t['m'] = 889;
  17571. t['n'] = 611;
  17572. t['o'] = 611;
  17573. t['p'] = 611;
  17574. t['q'] = 611;
  17575. t['r'] = 389;
  17576. t['s'] = 556;
  17577. t['t'] = 333;
  17578. t['u'] = 611;
  17579. t['v'] = 556;
  17580. t['w'] = 778;
  17581. t['x'] = 556;
  17582. t['y'] = 556;
  17583. t['z'] = 500;
  17584. t['braceleft'] = 389;
  17585. t['bar'] = 280;
  17586. t['braceright'] = 389;
  17587. t['asciitilde'] = 584;
  17588. t['exclamdown'] = 333;
  17589. t['cent'] = 556;
  17590. t['sterling'] = 556;
  17591. t['fraction'] = 167;
  17592. t['yen'] = 556;
  17593. t['florin'] = 556;
  17594. t['section'] = 556;
  17595. t['currency'] = 556;
  17596. t['quotesingle'] = 238;
  17597. t['quotedblleft'] = 500;
  17598. t['guillemotleft'] = 556;
  17599. t['guilsinglleft'] = 333;
  17600. t['guilsinglright'] = 333;
  17601. t['fi'] = 611;
  17602. t['fl'] = 611;
  17603. t['endash'] = 556;
  17604. t['dagger'] = 556;
  17605. t['daggerdbl'] = 556;
  17606. t['periodcentered'] = 278;
  17607. t['paragraph'] = 556;
  17608. t['bullet'] = 350;
  17609. t['quotesinglbase'] = 278;
  17610. t['quotedblbase'] = 500;
  17611. t['quotedblright'] = 500;
  17612. t['guillemotright'] = 556;
  17613. t['ellipsis'] = 1000;
  17614. t['perthousand'] = 1000;
  17615. t['questiondown'] = 611;
  17616. t['grave'] = 333;
  17617. t['acute'] = 333;
  17618. t['circumflex'] = 333;
  17619. t['tilde'] = 333;
  17620. t['macron'] = 333;
  17621. t['breve'] = 333;
  17622. t['dotaccent'] = 333;
  17623. t['dieresis'] = 333;
  17624. t['ring'] = 333;
  17625. t['cedilla'] = 333;
  17626. t['hungarumlaut'] = 333;
  17627. t['ogonek'] = 333;
  17628. t['caron'] = 333;
  17629. t['emdash'] = 1000;
  17630. t['AE'] = 1000;
  17631. t['ordfeminine'] = 370;
  17632. t['Lslash'] = 611;
  17633. t['Oslash'] = 778;
  17634. t['OE'] = 1000;
  17635. t['ordmasculine'] = 365;
  17636. t['ae'] = 889;
  17637. t['dotlessi'] = 278;
  17638. t['lslash'] = 278;
  17639. t['oslash'] = 611;
  17640. t['oe'] = 944;
  17641. t['germandbls'] = 611;
  17642. t['Idieresis'] = 278;
  17643. t['eacute'] = 556;
  17644. t['abreve'] = 556;
  17645. t['uhungarumlaut'] = 611;
  17646. t['ecaron'] = 556;
  17647. t['Ydieresis'] = 667;
  17648. t['divide'] = 584;
  17649. t['Yacute'] = 667;
  17650. t['Acircumflex'] = 722;
  17651. t['aacute'] = 556;
  17652. t['Ucircumflex'] = 722;
  17653. t['yacute'] = 556;
  17654. t['scommaaccent'] = 556;
  17655. t['ecircumflex'] = 556;
  17656. t['Uring'] = 722;
  17657. t['Udieresis'] = 722;
  17658. t['aogonek'] = 556;
  17659. t['Uacute'] = 722;
  17660. t['uogonek'] = 611;
  17661. t['Edieresis'] = 667;
  17662. t['Dcroat'] = 722;
  17663. t['commaaccent'] = 250;
  17664. t['copyright'] = 737;
  17665. t['Emacron'] = 667;
  17666. t['ccaron'] = 556;
  17667. t['aring'] = 556;
  17668. t['Ncommaaccent'] = 722;
  17669. t['lacute'] = 278;
  17670. t['agrave'] = 556;
  17671. t['Tcommaaccent'] = 611;
  17672. t['Cacute'] = 722;
  17673. t['atilde'] = 556;
  17674. t['Edotaccent'] = 667;
  17675. t['scaron'] = 556;
  17676. t['scedilla'] = 556;
  17677. t['iacute'] = 278;
  17678. t['lozenge'] = 494;
  17679. t['Rcaron'] = 722;
  17680. t['Gcommaaccent'] = 778;
  17681. t['ucircumflex'] = 611;
  17682. t['acircumflex'] = 556;
  17683. t['Amacron'] = 722;
  17684. t['rcaron'] = 389;
  17685. t['ccedilla'] = 556;
  17686. t['Zdotaccent'] = 611;
  17687. t['Thorn'] = 667;
  17688. t['Omacron'] = 778;
  17689. t['Racute'] = 722;
  17690. t['Sacute'] = 667;
  17691. t['dcaron'] = 743;
  17692. t['Umacron'] = 722;
  17693. t['uring'] = 611;
  17694. t['threesuperior'] = 333;
  17695. t['Ograve'] = 778;
  17696. t['Agrave'] = 722;
  17697. t['Abreve'] = 722;
  17698. t['multiply'] = 584;
  17699. t['uacute'] = 611;
  17700. t['Tcaron'] = 611;
  17701. t['partialdiff'] = 494;
  17702. t['ydieresis'] = 556;
  17703. t['Nacute'] = 722;
  17704. t['icircumflex'] = 278;
  17705. t['Ecircumflex'] = 667;
  17706. t['adieresis'] = 556;
  17707. t['edieresis'] = 556;
  17708. t['cacute'] = 556;
  17709. t['nacute'] = 611;
  17710. t['umacron'] = 611;
  17711. t['Ncaron'] = 722;
  17712. t['Iacute'] = 278;
  17713. t['plusminus'] = 584;
  17714. t['brokenbar'] = 280;
  17715. t['registered'] = 737;
  17716. t['Gbreve'] = 778;
  17717. t['Idotaccent'] = 278;
  17718. t['summation'] = 600;
  17719. t['Egrave'] = 667;
  17720. t['racute'] = 389;
  17721. t['omacron'] = 611;
  17722. t['Zacute'] = 611;
  17723. t['Zcaron'] = 611;
  17724. t['greaterequal'] = 549;
  17725. t['Eth'] = 722;
  17726. t['Ccedilla'] = 722;
  17727. t['lcommaaccent'] = 278;
  17728. t['tcaron'] = 389;
  17729. t['eogonek'] = 556;
  17730. t['Uogonek'] = 722;
  17731. t['Aacute'] = 722;
  17732. t['Adieresis'] = 722;
  17733. t['egrave'] = 556;
  17734. t['zacute'] = 500;
  17735. t['iogonek'] = 278;
  17736. t['Oacute'] = 778;
  17737. t['oacute'] = 611;
  17738. t['amacron'] = 556;
  17739. t['sacute'] = 556;
  17740. t['idieresis'] = 278;
  17741. t['Ocircumflex'] = 778;
  17742. t['Ugrave'] = 722;
  17743. t['Delta'] = 612;
  17744. t['thorn'] = 611;
  17745. t['twosuperior'] = 333;
  17746. t['Odieresis'] = 778;
  17747. t['mu'] = 611;
  17748. t['igrave'] = 278;
  17749. t['ohungarumlaut'] = 611;
  17750. t['Eogonek'] = 667;
  17751. t['dcroat'] = 611;
  17752. t['threequarters'] = 834;
  17753. t['Scedilla'] = 667;
  17754. t['lcaron'] = 400;
  17755. t['Kcommaaccent'] = 722;
  17756. t['Lacute'] = 611;
  17757. t['trademark'] = 1000;
  17758. t['edotaccent'] = 556;
  17759. t['Igrave'] = 278;
  17760. t['Imacron'] = 278;
  17761. t['Lcaron'] = 611;
  17762. t['onehalf'] = 834;
  17763. t['lessequal'] = 549;
  17764. t['ocircumflex'] = 611;
  17765. t['ntilde'] = 611;
  17766. t['Uhungarumlaut'] = 722;
  17767. t['Eacute'] = 667;
  17768. t['emacron'] = 556;
  17769. t['gbreve'] = 611;
  17770. t['onequarter'] = 834;
  17771. t['Scaron'] = 667;
  17772. t['Scommaaccent'] = 667;
  17773. t['Ohungarumlaut'] = 778;
  17774. t['degree'] = 400;
  17775. t['ograve'] = 611;
  17776. t['Ccaron'] = 722;
  17777. t['ugrave'] = 611;
  17778. t['radical'] = 549;
  17779. t['Dcaron'] = 722;
  17780. t['rcommaaccent'] = 389;
  17781. t['Ntilde'] = 722;
  17782. t['otilde'] = 611;
  17783. t['Rcommaaccent'] = 722;
  17784. t['Lcommaaccent'] = 611;
  17785. t['Atilde'] = 722;
  17786. t['Aogonek'] = 722;
  17787. t['Aring'] = 722;
  17788. t['Otilde'] = 778;
  17789. t['zdotaccent'] = 500;
  17790. t['Ecaron'] = 667;
  17791. t['Iogonek'] = 278;
  17792. t['kcommaaccent'] = 556;
  17793. t['minus'] = 584;
  17794. t['Icircumflex'] = 278;
  17795. t['ncaron'] = 611;
  17796. t['tcommaaccent'] = 333;
  17797. t['logicalnot'] = 584;
  17798. t['odieresis'] = 611;
  17799. t['udieresis'] = 611;
  17800. t['notequal'] = 549;
  17801. t['gcommaaccent'] = 611;
  17802. t['eth'] = 611;
  17803. t['zcaron'] = 500;
  17804. t['ncommaaccent'] = 611;
  17805. t['onesuperior'] = 333;
  17806. t['imacron'] = 278;
  17807. t['Euro'] = 556;
  17808. });
  17809. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17810. t['space'] = 278;
  17811. t['exclam'] = 333;
  17812. t['quotedbl'] = 474;
  17813. t['numbersign'] = 556;
  17814. t['dollar'] = 556;
  17815. t['percent'] = 889;
  17816. t['ampersand'] = 722;
  17817. t['quoteright'] = 278;
  17818. t['parenleft'] = 333;
  17819. t['parenright'] = 333;
  17820. t['asterisk'] = 389;
  17821. t['plus'] = 584;
  17822. t['comma'] = 278;
  17823. t['hyphen'] = 333;
  17824. t['period'] = 278;
  17825. t['slash'] = 278;
  17826. t['zero'] = 556;
  17827. t['one'] = 556;
  17828. t['two'] = 556;
  17829. t['three'] = 556;
  17830. t['four'] = 556;
  17831. t['five'] = 556;
  17832. t['six'] = 556;
  17833. t['seven'] = 556;
  17834. t['eight'] = 556;
  17835. t['nine'] = 556;
  17836. t['colon'] = 333;
  17837. t['semicolon'] = 333;
  17838. t['less'] = 584;
  17839. t['equal'] = 584;
  17840. t['greater'] = 584;
  17841. t['question'] = 611;
  17842. t['at'] = 975;
  17843. t['A'] = 722;
  17844. t['B'] = 722;
  17845. t['C'] = 722;
  17846. t['D'] = 722;
  17847. t['E'] = 667;
  17848. t['F'] = 611;
  17849. t['G'] = 778;
  17850. t['H'] = 722;
  17851. t['I'] = 278;
  17852. t['J'] = 556;
  17853. t['K'] = 722;
  17854. t['L'] = 611;
  17855. t['M'] = 833;
  17856. t['N'] = 722;
  17857. t['O'] = 778;
  17858. t['P'] = 667;
  17859. t['Q'] = 778;
  17860. t['R'] = 722;
  17861. t['S'] = 667;
  17862. t['T'] = 611;
  17863. t['U'] = 722;
  17864. t['V'] = 667;
  17865. t['W'] = 944;
  17866. t['X'] = 667;
  17867. t['Y'] = 667;
  17868. t['Z'] = 611;
  17869. t['bracketleft'] = 333;
  17870. t['backslash'] = 278;
  17871. t['bracketright'] = 333;
  17872. t['asciicircum'] = 584;
  17873. t['underscore'] = 556;
  17874. t['quoteleft'] = 278;
  17875. t['a'] = 556;
  17876. t['b'] = 611;
  17877. t['c'] = 556;
  17878. t['d'] = 611;
  17879. t['e'] = 556;
  17880. t['f'] = 333;
  17881. t['g'] = 611;
  17882. t['h'] = 611;
  17883. t['i'] = 278;
  17884. t['j'] = 278;
  17885. t['k'] = 556;
  17886. t['l'] = 278;
  17887. t['m'] = 889;
  17888. t['n'] = 611;
  17889. t['o'] = 611;
  17890. t['p'] = 611;
  17891. t['q'] = 611;
  17892. t['r'] = 389;
  17893. t['s'] = 556;
  17894. t['t'] = 333;
  17895. t['u'] = 611;
  17896. t['v'] = 556;
  17897. t['w'] = 778;
  17898. t['x'] = 556;
  17899. t['y'] = 556;
  17900. t['z'] = 500;
  17901. t['braceleft'] = 389;
  17902. t['bar'] = 280;
  17903. t['braceright'] = 389;
  17904. t['asciitilde'] = 584;
  17905. t['exclamdown'] = 333;
  17906. t['cent'] = 556;
  17907. t['sterling'] = 556;
  17908. t['fraction'] = 167;
  17909. t['yen'] = 556;
  17910. t['florin'] = 556;
  17911. t['section'] = 556;
  17912. t['currency'] = 556;
  17913. t['quotesingle'] = 238;
  17914. t['quotedblleft'] = 500;
  17915. t['guillemotleft'] = 556;
  17916. t['guilsinglleft'] = 333;
  17917. t['guilsinglright'] = 333;
  17918. t['fi'] = 611;
  17919. t['fl'] = 611;
  17920. t['endash'] = 556;
  17921. t['dagger'] = 556;
  17922. t['daggerdbl'] = 556;
  17923. t['periodcentered'] = 278;
  17924. t['paragraph'] = 556;
  17925. t['bullet'] = 350;
  17926. t['quotesinglbase'] = 278;
  17927. t['quotedblbase'] = 500;
  17928. t['quotedblright'] = 500;
  17929. t['guillemotright'] = 556;
  17930. t['ellipsis'] = 1000;
  17931. t['perthousand'] = 1000;
  17932. t['questiondown'] = 611;
  17933. t['grave'] = 333;
  17934. t['acute'] = 333;
  17935. t['circumflex'] = 333;
  17936. t['tilde'] = 333;
  17937. t['macron'] = 333;
  17938. t['breve'] = 333;
  17939. t['dotaccent'] = 333;
  17940. t['dieresis'] = 333;
  17941. t['ring'] = 333;
  17942. t['cedilla'] = 333;
  17943. t['hungarumlaut'] = 333;
  17944. t['ogonek'] = 333;
  17945. t['caron'] = 333;
  17946. t['emdash'] = 1000;
  17947. t['AE'] = 1000;
  17948. t['ordfeminine'] = 370;
  17949. t['Lslash'] = 611;
  17950. t['Oslash'] = 778;
  17951. t['OE'] = 1000;
  17952. t['ordmasculine'] = 365;
  17953. t['ae'] = 889;
  17954. t['dotlessi'] = 278;
  17955. t['lslash'] = 278;
  17956. t['oslash'] = 611;
  17957. t['oe'] = 944;
  17958. t['germandbls'] = 611;
  17959. t['Idieresis'] = 278;
  17960. t['eacute'] = 556;
  17961. t['abreve'] = 556;
  17962. t['uhungarumlaut'] = 611;
  17963. t['ecaron'] = 556;
  17964. t['Ydieresis'] = 667;
  17965. t['divide'] = 584;
  17966. t['Yacute'] = 667;
  17967. t['Acircumflex'] = 722;
  17968. t['aacute'] = 556;
  17969. t['Ucircumflex'] = 722;
  17970. t['yacute'] = 556;
  17971. t['scommaaccent'] = 556;
  17972. t['ecircumflex'] = 556;
  17973. t['Uring'] = 722;
  17974. t['Udieresis'] = 722;
  17975. t['aogonek'] = 556;
  17976. t['Uacute'] = 722;
  17977. t['uogonek'] = 611;
  17978. t['Edieresis'] = 667;
  17979. t['Dcroat'] = 722;
  17980. t['commaaccent'] = 250;
  17981. t['copyright'] = 737;
  17982. t['Emacron'] = 667;
  17983. t['ccaron'] = 556;
  17984. t['aring'] = 556;
  17985. t['Ncommaaccent'] = 722;
  17986. t['lacute'] = 278;
  17987. t['agrave'] = 556;
  17988. t['Tcommaaccent'] = 611;
  17989. t['Cacute'] = 722;
  17990. t['atilde'] = 556;
  17991. t['Edotaccent'] = 667;
  17992. t['scaron'] = 556;
  17993. t['scedilla'] = 556;
  17994. t['iacute'] = 278;
  17995. t['lozenge'] = 494;
  17996. t['Rcaron'] = 722;
  17997. t['Gcommaaccent'] = 778;
  17998. t['ucircumflex'] = 611;
  17999. t['acircumflex'] = 556;
  18000. t['Amacron'] = 722;
  18001. t['rcaron'] = 389;
  18002. t['ccedilla'] = 556;
  18003. t['Zdotaccent'] = 611;
  18004. t['Thorn'] = 667;
  18005. t['Omacron'] = 778;
  18006. t['Racute'] = 722;
  18007. t['Sacute'] = 667;
  18008. t['dcaron'] = 743;
  18009. t['Umacron'] = 722;
  18010. t['uring'] = 611;
  18011. t['threesuperior'] = 333;
  18012. t['Ograve'] = 778;
  18013. t['Agrave'] = 722;
  18014. t['Abreve'] = 722;
  18015. t['multiply'] = 584;
  18016. t['uacute'] = 611;
  18017. t['Tcaron'] = 611;
  18018. t['partialdiff'] = 494;
  18019. t['ydieresis'] = 556;
  18020. t['Nacute'] = 722;
  18021. t['icircumflex'] = 278;
  18022. t['Ecircumflex'] = 667;
  18023. t['adieresis'] = 556;
  18024. t['edieresis'] = 556;
  18025. t['cacute'] = 556;
  18026. t['nacute'] = 611;
  18027. t['umacron'] = 611;
  18028. t['Ncaron'] = 722;
  18029. t['Iacute'] = 278;
  18030. t['plusminus'] = 584;
  18031. t['brokenbar'] = 280;
  18032. t['registered'] = 737;
  18033. t['Gbreve'] = 778;
  18034. t['Idotaccent'] = 278;
  18035. t['summation'] = 600;
  18036. t['Egrave'] = 667;
  18037. t['racute'] = 389;
  18038. t['omacron'] = 611;
  18039. t['Zacute'] = 611;
  18040. t['Zcaron'] = 611;
  18041. t['greaterequal'] = 549;
  18042. t['Eth'] = 722;
  18043. t['Ccedilla'] = 722;
  18044. t['lcommaaccent'] = 278;
  18045. t['tcaron'] = 389;
  18046. t['eogonek'] = 556;
  18047. t['Uogonek'] = 722;
  18048. t['Aacute'] = 722;
  18049. t['Adieresis'] = 722;
  18050. t['egrave'] = 556;
  18051. t['zacute'] = 500;
  18052. t['iogonek'] = 278;
  18053. t['Oacute'] = 778;
  18054. t['oacute'] = 611;
  18055. t['amacron'] = 556;
  18056. t['sacute'] = 556;
  18057. t['idieresis'] = 278;
  18058. t['Ocircumflex'] = 778;
  18059. t['Ugrave'] = 722;
  18060. t['Delta'] = 612;
  18061. t['thorn'] = 611;
  18062. t['twosuperior'] = 333;
  18063. t['Odieresis'] = 778;
  18064. t['mu'] = 611;
  18065. t['igrave'] = 278;
  18066. t['ohungarumlaut'] = 611;
  18067. t['Eogonek'] = 667;
  18068. t['dcroat'] = 611;
  18069. t['threequarters'] = 834;
  18070. t['Scedilla'] = 667;
  18071. t['lcaron'] = 400;
  18072. t['Kcommaaccent'] = 722;
  18073. t['Lacute'] = 611;
  18074. t['trademark'] = 1000;
  18075. t['edotaccent'] = 556;
  18076. t['Igrave'] = 278;
  18077. t['Imacron'] = 278;
  18078. t['Lcaron'] = 611;
  18079. t['onehalf'] = 834;
  18080. t['lessequal'] = 549;
  18081. t['ocircumflex'] = 611;
  18082. t['ntilde'] = 611;
  18083. t['Uhungarumlaut'] = 722;
  18084. t['Eacute'] = 667;
  18085. t['emacron'] = 556;
  18086. t['gbreve'] = 611;
  18087. t['onequarter'] = 834;
  18088. t['Scaron'] = 667;
  18089. t['Scommaaccent'] = 667;
  18090. t['Ohungarumlaut'] = 778;
  18091. t['degree'] = 400;
  18092. t['ograve'] = 611;
  18093. t['Ccaron'] = 722;
  18094. t['ugrave'] = 611;
  18095. t['radical'] = 549;
  18096. t['Dcaron'] = 722;
  18097. t['rcommaaccent'] = 389;
  18098. t['Ntilde'] = 722;
  18099. t['otilde'] = 611;
  18100. t['Rcommaaccent'] = 722;
  18101. t['Lcommaaccent'] = 611;
  18102. t['Atilde'] = 722;
  18103. t['Aogonek'] = 722;
  18104. t['Aring'] = 722;
  18105. t['Otilde'] = 778;
  18106. t['zdotaccent'] = 500;
  18107. t['Ecaron'] = 667;
  18108. t['Iogonek'] = 278;
  18109. t['kcommaaccent'] = 556;
  18110. t['minus'] = 584;
  18111. t['Icircumflex'] = 278;
  18112. t['ncaron'] = 611;
  18113. t['tcommaaccent'] = 333;
  18114. t['logicalnot'] = 584;
  18115. t['odieresis'] = 611;
  18116. t['udieresis'] = 611;
  18117. t['notequal'] = 549;
  18118. t['gcommaaccent'] = 611;
  18119. t['eth'] = 611;
  18120. t['zcaron'] = 500;
  18121. t['ncommaaccent'] = 611;
  18122. t['onesuperior'] = 333;
  18123. t['imacron'] = 278;
  18124. t['Euro'] = 556;
  18125. });
  18126. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18127. t['space'] = 278;
  18128. t['exclam'] = 278;
  18129. t['quotedbl'] = 355;
  18130. t['numbersign'] = 556;
  18131. t['dollar'] = 556;
  18132. t['percent'] = 889;
  18133. t['ampersand'] = 667;
  18134. t['quoteright'] = 222;
  18135. t['parenleft'] = 333;
  18136. t['parenright'] = 333;
  18137. t['asterisk'] = 389;
  18138. t['plus'] = 584;
  18139. t['comma'] = 278;
  18140. t['hyphen'] = 333;
  18141. t['period'] = 278;
  18142. t['slash'] = 278;
  18143. t['zero'] = 556;
  18144. t['one'] = 556;
  18145. t['two'] = 556;
  18146. t['three'] = 556;
  18147. t['four'] = 556;
  18148. t['five'] = 556;
  18149. t['six'] = 556;
  18150. t['seven'] = 556;
  18151. t['eight'] = 556;
  18152. t['nine'] = 556;
  18153. t['colon'] = 278;
  18154. t['semicolon'] = 278;
  18155. t['less'] = 584;
  18156. t['equal'] = 584;
  18157. t['greater'] = 584;
  18158. t['question'] = 556;
  18159. t['at'] = 1015;
  18160. t['A'] = 667;
  18161. t['B'] = 667;
  18162. t['C'] = 722;
  18163. t['D'] = 722;
  18164. t['E'] = 667;
  18165. t['F'] = 611;
  18166. t['G'] = 778;
  18167. t['H'] = 722;
  18168. t['I'] = 278;
  18169. t['J'] = 500;
  18170. t['K'] = 667;
  18171. t['L'] = 556;
  18172. t['M'] = 833;
  18173. t['N'] = 722;
  18174. t['O'] = 778;
  18175. t['P'] = 667;
  18176. t['Q'] = 778;
  18177. t['R'] = 722;
  18178. t['S'] = 667;
  18179. t['T'] = 611;
  18180. t['U'] = 722;
  18181. t['V'] = 667;
  18182. t['W'] = 944;
  18183. t['X'] = 667;
  18184. t['Y'] = 667;
  18185. t['Z'] = 611;
  18186. t['bracketleft'] = 278;
  18187. t['backslash'] = 278;
  18188. t['bracketright'] = 278;
  18189. t['asciicircum'] = 469;
  18190. t['underscore'] = 556;
  18191. t['quoteleft'] = 222;
  18192. t['a'] = 556;
  18193. t['b'] = 556;
  18194. t['c'] = 500;
  18195. t['d'] = 556;
  18196. t['e'] = 556;
  18197. t['f'] = 278;
  18198. t['g'] = 556;
  18199. t['h'] = 556;
  18200. t['i'] = 222;
  18201. t['j'] = 222;
  18202. t['k'] = 500;
  18203. t['l'] = 222;
  18204. t['m'] = 833;
  18205. t['n'] = 556;
  18206. t['o'] = 556;
  18207. t['p'] = 556;
  18208. t['q'] = 556;
  18209. t['r'] = 333;
  18210. t['s'] = 500;
  18211. t['t'] = 278;
  18212. t['u'] = 556;
  18213. t['v'] = 500;
  18214. t['w'] = 722;
  18215. t['x'] = 500;
  18216. t['y'] = 500;
  18217. t['z'] = 500;
  18218. t['braceleft'] = 334;
  18219. t['bar'] = 260;
  18220. t['braceright'] = 334;
  18221. t['asciitilde'] = 584;
  18222. t['exclamdown'] = 333;
  18223. t['cent'] = 556;
  18224. t['sterling'] = 556;
  18225. t['fraction'] = 167;
  18226. t['yen'] = 556;
  18227. t['florin'] = 556;
  18228. t['section'] = 556;
  18229. t['currency'] = 556;
  18230. t['quotesingle'] = 191;
  18231. t['quotedblleft'] = 333;
  18232. t['guillemotleft'] = 556;
  18233. t['guilsinglleft'] = 333;
  18234. t['guilsinglright'] = 333;
  18235. t['fi'] = 500;
  18236. t['fl'] = 500;
  18237. t['endash'] = 556;
  18238. t['dagger'] = 556;
  18239. t['daggerdbl'] = 556;
  18240. t['periodcentered'] = 278;
  18241. t['paragraph'] = 537;
  18242. t['bullet'] = 350;
  18243. t['quotesinglbase'] = 222;
  18244. t['quotedblbase'] = 333;
  18245. t['quotedblright'] = 333;
  18246. t['guillemotright'] = 556;
  18247. t['ellipsis'] = 1000;
  18248. t['perthousand'] = 1000;
  18249. t['questiondown'] = 611;
  18250. t['grave'] = 333;
  18251. t['acute'] = 333;
  18252. t['circumflex'] = 333;
  18253. t['tilde'] = 333;
  18254. t['macron'] = 333;
  18255. t['breve'] = 333;
  18256. t['dotaccent'] = 333;
  18257. t['dieresis'] = 333;
  18258. t['ring'] = 333;
  18259. t['cedilla'] = 333;
  18260. t['hungarumlaut'] = 333;
  18261. t['ogonek'] = 333;
  18262. t['caron'] = 333;
  18263. t['emdash'] = 1000;
  18264. t['AE'] = 1000;
  18265. t['ordfeminine'] = 370;
  18266. t['Lslash'] = 556;
  18267. t['Oslash'] = 778;
  18268. t['OE'] = 1000;
  18269. t['ordmasculine'] = 365;
  18270. t['ae'] = 889;
  18271. t['dotlessi'] = 278;
  18272. t['lslash'] = 222;
  18273. t['oslash'] = 611;
  18274. t['oe'] = 944;
  18275. t['germandbls'] = 611;
  18276. t['Idieresis'] = 278;
  18277. t['eacute'] = 556;
  18278. t['abreve'] = 556;
  18279. t['uhungarumlaut'] = 556;
  18280. t['ecaron'] = 556;
  18281. t['Ydieresis'] = 667;
  18282. t['divide'] = 584;
  18283. t['Yacute'] = 667;
  18284. t['Acircumflex'] = 667;
  18285. t['aacute'] = 556;
  18286. t['Ucircumflex'] = 722;
  18287. t['yacute'] = 500;
  18288. t['scommaaccent'] = 500;
  18289. t['ecircumflex'] = 556;
  18290. t['Uring'] = 722;
  18291. t['Udieresis'] = 722;
  18292. t['aogonek'] = 556;
  18293. t['Uacute'] = 722;
  18294. t['uogonek'] = 556;
  18295. t['Edieresis'] = 667;
  18296. t['Dcroat'] = 722;
  18297. t['commaaccent'] = 250;
  18298. t['copyright'] = 737;
  18299. t['Emacron'] = 667;
  18300. t['ccaron'] = 500;
  18301. t['aring'] = 556;
  18302. t['Ncommaaccent'] = 722;
  18303. t['lacute'] = 222;
  18304. t['agrave'] = 556;
  18305. t['Tcommaaccent'] = 611;
  18306. t['Cacute'] = 722;
  18307. t['atilde'] = 556;
  18308. t['Edotaccent'] = 667;
  18309. t['scaron'] = 500;
  18310. t['scedilla'] = 500;
  18311. t['iacute'] = 278;
  18312. t['lozenge'] = 471;
  18313. t['Rcaron'] = 722;
  18314. t['Gcommaaccent'] = 778;
  18315. t['ucircumflex'] = 556;
  18316. t['acircumflex'] = 556;
  18317. t['Amacron'] = 667;
  18318. t['rcaron'] = 333;
  18319. t['ccedilla'] = 500;
  18320. t['Zdotaccent'] = 611;
  18321. t['Thorn'] = 667;
  18322. t['Omacron'] = 778;
  18323. t['Racute'] = 722;
  18324. t['Sacute'] = 667;
  18325. t['dcaron'] = 643;
  18326. t['Umacron'] = 722;
  18327. t['uring'] = 556;
  18328. t['threesuperior'] = 333;
  18329. t['Ograve'] = 778;
  18330. t['Agrave'] = 667;
  18331. t['Abreve'] = 667;
  18332. t['multiply'] = 584;
  18333. t['uacute'] = 556;
  18334. t['Tcaron'] = 611;
  18335. t['partialdiff'] = 476;
  18336. t['ydieresis'] = 500;
  18337. t['Nacute'] = 722;
  18338. t['icircumflex'] = 278;
  18339. t['Ecircumflex'] = 667;
  18340. t['adieresis'] = 556;
  18341. t['edieresis'] = 556;
  18342. t['cacute'] = 500;
  18343. t['nacute'] = 556;
  18344. t['umacron'] = 556;
  18345. t['Ncaron'] = 722;
  18346. t['Iacute'] = 278;
  18347. t['plusminus'] = 584;
  18348. t['brokenbar'] = 260;
  18349. t['registered'] = 737;
  18350. t['Gbreve'] = 778;
  18351. t['Idotaccent'] = 278;
  18352. t['summation'] = 600;
  18353. t['Egrave'] = 667;
  18354. t['racute'] = 333;
  18355. t['omacron'] = 556;
  18356. t['Zacute'] = 611;
  18357. t['Zcaron'] = 611;
  18358. t['greaterequal'] = 549;
  18359. t['Eth'] = 722;
  18360. t['Ccedilla'] = 722;
  18361. t['lcommaaccent'] = 222;
  18362. t['tcaron'] = 317;
  18363. t['eogonek'] = 556;
  18364. t['Uogonek'] = 722;
  18365. t['Aacute'] = 667;
  18366. t['Adieresis'] = 667;
  18367. t['egrave'] = 556;
  18368. t['zacute'] = 500;
  18369. t['iogonek'] = 222;
  18370. t['Oacute'] = 778;
  18371. t['oacute'] = 556;
  18372. t['amacron'] = 556;
  18373. t['sacute'] = 500;
  18374. t['idieresis'] = 278;
  18375. t['Ocircumflex'] = 778;
  18376. t['Ugrave'] = 722;
  18377. t['Delta'] = 612;
  18378. t['thorn'] = 556;
  18379. t['twosuperior'] = 333;
  18380. t['Odieresis'] = 778;
  18381. t['mu'] = 556;
  18382. t['igrave'] = 278;
  18383. t['ohungarumlaut'] = 556;
  18384. t['Eogonek'] = 667;
  18385. t['dcroat'] = 556;
  18386. t['threequarters'] = 834;
  18387. t['Scedilla'] = 667;
  18388. t['lcaron'] = 299;
  18389. t['Kcommaaccent'] = 667;
  18390. t['Lacute'] = 556;
  18391. t['trademark'] = 1000;
  18392. t['edotaccent'] = 556;
  18393. t['Igrave'] = 278;
  18394. t['Imacron'] = 278;
  18395. t['Lcaron'] = 556;
  18396. t['onehalf'] = 834;
  18397. t['lessequal'] = 549;
  18398. t['ocircumflex'] = 556;
  18399. t['ntilde'] = 556;
  18400. t['Uhungarumlaut'] = 722;
  18401. t['Eacute'] = 667;
  18402. t['emacron'] = 556;
  18403. t['gbreve'] = 556;
  18404. t['onequarter'] = 834;
  18405. t['Scaron'] = 667;
  18406. t['Scommaaccent'] = 667;
  18407. t['Ohungarumlaut'] = 778;
  18408. t['degree'] = 400;
  18409. t['ograve'] = 556;
  18410. t['Ccaron'] = 722;
  18411. t['ugrave'] = 556;
  18412. t['radical'] = 453;
  18413. t['Dcaron'] = 722;
  18414. t['rcommaaccent'] = 333;
  18415. t['Ntilde'] = 722;
  18416. t['otilde'] = 556;
  18417. t['Rcommaaccent'] = 722;
  18418. t['Lcommaaccent'] = 556;
  18419. t['Atilde'] = 667;
  18420. t['Aogonek'] = 667;
  18421. t['Aring'] = 667;
  18422. t['Otilde'] = 778;
  18423. t['zdotaccent'] = 500;
  18424. t['Ecaron'] = 667;
  18425. t['Iogonek'] = 278;
  18426. t['kcommaaccent'] = 500;
  18427. t['minus'] = 584;
  18428. t['Icircumflex'] = 278;
  18429. t['ncaron'] = 556;
  18430. t['tcommaaccent'] = 278;
  18431. t['logicalnot'] = 584;
  18432. t['odieresis'] = 556;
  18433. t['udieresis'] = 556;
  18434. t['notequal'] = 549;
  18435. t['gcommaaccent'] = 556;
  18436. t['eth'] = 556;
  18437. t['zcaron'] = 500;
  18438. t['ncommaaccent'] = 556;
  18439. t['onesuperior'] = 333;
  18440. t['imacron'] = 278;
  18441. t['Euro'] = 556;
  18442. });
  18443. t['Symbol'] = getLookupTableFactory(function (t) {
  18444. t['space'] = 250;
  18445. t['exclam'] = 333;
  18446. t['universal'] = 713;
  18447. t['numbersign'] = 500;
  18448. t['existential'] = 549;
  18449. t['percent'] = 833;
  18450. t['ampersand'] = 778;
  18451. t['suchthat'] = 439;
  18452. t['parenleft'] = 333;
  18453. t['parenright'] = 333;
  18454. t['asteriskmath'] = 500;
  18455. t['plus'] = 549;
  18456. t['comma'] = 250;
  18457. t['minus'] = 549;
  18458. t['period'] = 250;
  18459. t['slash'] = 278;
  18460. t['zero'] = 500;
  18461. t['one'] = 500;
  18462. t['two'] = 500;
  18463. t['three'] = 500;
  18464. t['four'] = 500;
  18465. t['five'] = 500;
  18466. t['six'] = 500;
  18467. t['seven'] = 500;
  18468. t['eight'] = 500;
  18469. t['nine'] = 500;
  18470. t['colon'] = 278;
  18471. t['semicolon'] = 278;
  18472. t['less'] = 549;
  18473. t['equal'] = 549;
  18474. t['greater'] = 549;
  18475. t['question'] = 444;
  18476. t['congruent'] = 549;
  18477. t['Alpha'] = 722;
  18478. t['Beta'] = 667;
  18479. t['Chi'] = 722;
  18480. t['Delta'] = 612;
  18481. t['Epsilon'] = 611;
  18482. t['Phi'] = 763;
  18483. t['Gamma'] = 603;
  18484. t['Eta'] = 722;
  18485. t['Iota'] = 333;
  18486. t['theta1'] = 631;
  18487. t['Kappa'] = 722;
  18488. t['Lambda'] = 686;
  18489. t['Mu'] = 889;
  18490. t['Nu'] = 722;
  18491. t['Omicron'] = 722;
  18492. t['Pi'] = 768;
  18493. t['Theta'] = 741;
  18494. t['Rho'] = 556;
  18495. t['Sigma'] = 592;
  18496. t['Tau'] = 611;
  18497. t['Upsilon'] = 690;
  18498. t['sigma1'] = 439;
  18499. t['Omega'] = 768;
  18500. t['Xi'] = 645;
  18501. t['Psi'] = 795;
  18502. t['Zeta'] = 611;
  18503. t['bracketleft'] = 333;
  18504. t['therefore'] = 863;
  18505. t['bracketright'] = 333;
  18506. t['perpendicular'] = 658;
  18507. t['underscore'] = 500;
  18508. t['radicalex'] = 500;
  18509. t['alpha'] = 631;
  18510. t['beta'] = 549;
  18511. t['chi'] = 549;
  18512. t['delta'] = 494;
  18513. t['epsilon'] = 439;
  18514. t['phi'] = 521;
  18515. t['gamma'] = 411;
  18516. t['eta'] = 603;
  18517. t['iota'] = 329;
  18518. t['phi1'] = 603;
  18519. t['kappa'] = 549;
  18520. t['lambda'] = 549;
  18521. t['mu'] = 576;
  18522. t['nu'] = 521;
  18523. t['omicron'] = 549;
  18524. t['pi'] = 549;
  18525. t['theta'] = 521;
  18526. t['rho'] = 549;
  18527. t['sigma'] = 603;
  18528. t['tau'] = 439;
  18529. t['upsilon'] = 576;
  18530. t['omega1'] = 713;
  18531. t['omega'] = 686;
  18532. t['xi'] = 493;
  18533. t['psi'] = 686;
  18534. t['zeta'] = 494;
  18535. t['braceleft'] = 480;
  18536. t['bar'] = 200;
  18537. t['braceright'] = 480;
  18538. t['similar'] = 549;
  18539. t['Euro'] = 750;
  18540. t['Upsilon1'] = 620;
  18541. t['minute'] = 247;
  18542. t['lessequal'] = 549;
  18543. t['fraction'] = 167;
  18544. t['infinity'] = 713;
  18545. t['florin'] = 500;
  18546. t['club'] = 753;
  18547. t['diamond'] = 753;
  18548. t['heart'] = 753;
  18549. t['spade'] = 753;
  18550. t['arrowboth'] = 1042;
  18551. t['arrowleft'] = 987;
  18552. t['arrowup'] = 603;
  18553. t['arrowright'] = 987;
  18554. t['arrowdown'] = 603;
  18555. t['degree'] = 400;
  18556. t['plusminus'] = 549;
  18557. t['second'] = 411;
  18558. t['greaterequal'] = 549;
  18559. t['multiply'] = 549;
  18560. t['proportional'] = 713;
  18561. t['partialdiff'] = 494;
  18562. t['bullet'] = 460;
  18563. t['divide'] = 549;
  18564. t['notequal'] = 549;
  18565. t['equivalence'] = 549;
  18566. t['approxequal'] = 549;
  18567. t['ellipsis'] = 1000;
  18568. t['arrowvertex'] = 603;
  18569. t['arrowhorizex'] = 1000;
  18570. t['carriagereturn'] = 658;
  18571. t['aleph'] = 823;
  18572. t['Ifraktur'] = 686;
  18573. t['Rfraktur'] = 795;
  18574. t['weierstrass'] = 987;
  18575. t['circlemultiply'] = 768;
  18576. t['circleplus'] = 768;
  18577. t['emptyset'] = 823;
  18578. t['intersection'] = 768;
  18579. t['union'] = 768;
  18580. t['propersuperset'] = 713;
  18581. t['reflexsuperset'] = 713;
  18582. t['notsubset'] = 713;
  18583. t['propersubset'] = 713;
  18584. t['reflexsubset'] = 713;
  18585. t['element'] = 713;
  18586. t['notelement'] = 713;
  18587. t['angle'] = 768;
  18588. t['gradient'] = 713;
  18589. t['registerserif'] = 790;
  18590. t['copyrightserif'] = 790;
  18591. t['trademarkserif'] = 890;
  18592. t['product'] = 823;
  18593. t['radical'] = 549;
  18594. t['dotmath'] = 250;
  18595. t['logicalnot'] = 713;
  18596. t['logicaland'] = 603;
  18597. t['logicalor'] = 603;
  18598. t['arrowdblboth'] = 1042;
  18599. t['arrowdblleft'] = 987;
  18600. t['arrowdblup'] = 603;
  18601. t['arrowdblright'] = 987;
  18602. t['arrowdbldown'] = 603;
  18603. t['lozenge'] = 494;
  18604. t['angleleft'] = 329;
  18605. t['registersans'] = 790;
  18606. t['copyrightsans'] = 790;
  18607. t['trademarksans'] = 786;
  18608. t['summation'] = 713;
  18609. t['parenlefttp'] = 384;
  18610. t['parenleftex'] = 384;
  18611. t['parenleftbt'] = 384;
  18612. t['bracketlefttp'] = 384;
  18613. t['bracketleftex'] = 384;
  18614. t['bracketleftbt'] = 384;
  18615. t['bracelefttp'] = 494;
  18616. t['braceleftmid'] = 494;
  18617. t['braceleftbt'] = 494;
  18618. t['braceex'] = 494;
  18619. t['angleright'] = 329;
  18620. t['integral'] = 274;
  18621. t['integraltp'] = 686;
  18622. t['integralex'] = 686;
  18623. t['integralbt'] = 686;
  18624. t['parenrighttp'] = 384;
  18625. t['parenrightex'] = 384;
  18626. t['parenrightbt'] = 384;
  18627. t['bracketrighttp'] = 384;
  18628. t['bracketrightex'] = 384;
  18629. t['bracketrightbt'] = 384;
  18630. t['bracerighttp'] = 494;
  18631. t['bracerightmid'] = 494;
  18632. t['bracerightbt'] = 494;
  18633. t['apple'] = 790;
  18634. });
  18635. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18636. t['space'] = 250;
  18637. t['exclam'] = 333;
  18638. t['quotedbl'] = 408;
  18639. t['numbersign'] = 500;
  18640. t['dollar'] = 500;
  18641. t['percent'] = 833;
  18642. t['ampersand'] = 778;
  18643. t['quoteright'] = 333;
  18644. t['parenleft'] = 333;
  18645. t['parenright'] = 333;
  18646. t['asterisk'] = 500;
  18647. t['plus'] = 564;
  18648. t['comma'] = 250;
  18649. t['hyphen'] = 333;
  18650. t['period'] = 250;
  18651. t['slash'] = 278;
  18652. t['zero'] = 500;
  18653. t['one'] = 500;
  18654. t['two'] = 500;
  18655. t['three'] = 500;
  18656. t['four'] = 500;
  18657. t['five'] = 500;
  18658. t['six'] = 500;
  18659. t['seven'] = 500;
  18660. t['eight'] = 500;
  18661. t['nine'] = 500;
  18662. t['colon'] = 278;
  18663. t['semicolon'] = 278;
  18664. t['less'] = 564;
  18665. t['equal'] = 564;
  18666. t['greater'] = 564;
  18667. t['question'] = 444;
  18668. t['at'] = 921;
  18669. t['A'] = 722;
  18670. t['B'] = 667;
  18671. t['C'] = 667;
  18672. t['D'] = 722;
  18673. t['E'] = 611;
  18674. t['F'] = 556;
  18675. t['G'] = 722;
  18676. t['H'] = 722;
  18677. t['I'] = 333;
  18678. t['J'] = 389;
  18679. t['K'] = 722;
  18680. t['L'] = 611;
  18681. t['M'] = 889;
  18682. t['N'] = 722;
  18683. t['O'] = 722;
  18684. t['P'] = 556;
  18685. t['Q'] = 722;
  18686. t['R'] = 667;
  18687. t['S'] = 556;
  18688. t['T'] = 611;
  18689. t['U'] = 722;
  18690. t['V'] = 722;
  18691. t['W'] = 944;
  18692. t['X'] = 722;
  18693. t['Y'] = 722;
  18694. t['Z'] = 611;
  18695. t['bracketleft'] = 333;
  18696. t['backslash'] = 278;
  18697. t['bracketright'] = 333;
  18698. t['asciicircum'] = 469;
  18699. t['underscore'] = 500;
  18700. t['quoteleft'] = 333;
  18701. t['a'] = 444;
  18702. t['b'] = 500;
  18703. t['c'] = 444;
  18704. t['d'] = 500;
  18705. t['e'] = 444;
  18706. t['f'] = 333;
  18707. t['g'] = 500;
  18708. t['h'] = 500;
  18709. t['i'] = 278;
  18710. t['j'] = 278;
  18711. t['k'] = 500;
  18712. t['l'] = 278;
  18713. t['m'] = 778;
  18714. t['n'] = 500;
  18715. t['o'] = 500;
  18716. t['p'] = 500;
  18717. t['q'] = 500;
  18718. t['r'] = 333;
  18719. t['s'] = 389;
  18720. t['t'] = 278;
  18721. t['u'] = 500;
  18722. t['v'] = 500;
  18723. t['w'] = 722;
  18724. t['x'] = 500;
  18725. t['y'] = 500;
  18726. t['z'] = 444;
  18727. t['braceleft'] = 480;
  18728. t['bar'] = 200;
  18729. t['braceright'] = 480;
  18730. t['asciitilde'] = 541;
  18731. t['exclamdown'] = 333;
  18732. t['cent'] = 500;
  18733. t['sterling'] = 500;
  18734. t['fraction'] = 167;
  18735. t['yen'] = 500;
  18736. t['florin'] = 500;
  18737. t['section'] = 500;
  18738. t['currency'] = 500;
  18739. t['quotesingle'] = 180;
  18740. t['quotedblleft'] = 444;
  18741. t['guillemotleft'] = 500;
  18742. t['guilsinglleft'] = 333;
  18743. t['guilsinglright'] = 333;
  18744. t['fi'] = 556;
  18745. t['fl'] = 556;
  18746. t['endash'] = 500;
  18747. t['dagger'] = 500;
  18748. t['daggerdbl'] = 500;
  18749. t['periodcentered'] = 250;
  18750. t['paragraph'] = 453;
  18751. t['bullet'] = 350;
  18752. t['quotesinglbase'] = 333;
  18753. t['quotedblbase'] = 444;
  18754. t['quotedblright'] = 444;
  18755. t['guillemotright'] = 500;
  18756. t['ellipsis'] = 1000;
  18757. t['perthousand'] = 1000;
  18758. t['questiondown'] = 444;
  18759. t['grave'] = 333;
  18760. t['acute'] = 333;
  18761. t['circumflex'] = 333;
  18762. t['tilde'] = 333;
  18763. t['macron'] = 333;
  18764. t['breve'] = 333;
  18765. t['dotaccent'] = 333;
  18766. t['dieresis'] = 333;
  18767. t['ring'] = 333;
  18768. t['cedilla'] = 333;
  18769. t['hungarumlaut'] = 333;
  18770. t['ogonek'] = 333;
  18771. t['caron'] = 333;
  18772. t['emdash'] = 1000;
  18773. t['AE'] = 889;
  18774. t['ordfeminine'] = 276;
  18775. t['Lslash'] = 611;
  18776. t['Oslash'] = 722;
  18777. t['OE'] = 889;
  18778. t['ordmasculine'] = 310;
  18779. t['ae'] = 667;
  18780. t['dotlessi'] = 278;
  18781. t['lslash'] = 278;
  18782. t['oslash'] = 500;
  18783. t['oe'] = 722;
  18784. t['germandbls'] = 500;
  18785. t['Idieresis'] = 333;
  18786. t['eacute'] = 444;
  18787. t['abreve'] = 444;
  18788. t['uhungarumlaut'] = 500;
  18789. t['ecaron'] = 444;
  18790. t['Ydieresis'] = 722;
  18791. t['divide'] = 564;
  18792. t['Yacute'] = 722;
  18793. t['Acircumflex'] = 722;
  18794. t['aacute'] = 444;
  18795. t['Ucircumflex'] = 722;
  18796. t['yacute'] = 500;
  18797. t['scommaaccent'] = 389;
  18798. t['ecircumflex'] = 444;
  18799. t['Uring'] = 722;
  18800. t['Udieresis'] = 722;
  18801. t['aogonek'] = 444;
  18802. t['Uacute'] = 722;
  18803. t['uogonek'] = 500;
  18804. t['Edieresis'] = 611;
  18805. t['Dcroat'] = 722;
  18806. t['commaaccent'] = 250;
  18807. t['copyright'] = 760;
  18808. t['Emacron'] = 611;
  18809. t['ccaron'] = 444;
  18810. t['aring'] = 444;
  18811. t['Ncommaaccent'] = 722;
  18812. t['lacute'] = 278;
  18813. t['agrave'] = 444;
  18814. t['Tcommaaccent'] = 611;
  18815. t['Cacute'] = 667;
  18816. t['atilde'] = 444;
  18817. t['Edotaccent'] = 611;
  18818. t['scaron'] = 389;
  18819. t['scedilla'] = 389;
  18820. t['iacute'] = 278;
  18821. t['lozenge'] = 471;
  18822. t['Rcaron'] = 667;
  18823. t['Gcommaaccent'] = 722;
  18824. t['ucircumflex'] = 500;
  18825. t['acircumflex'] = 444;
  18826. t['Amacron'] = 722;
  18827. t['rcaron'] = 333;
  18828. t['ccedilla'] = 444;
  18829. t['Zdotaccent'] = 611;
  18830. t['Thorn'] = 556;
  18831. t['Omacron'] = 722;
  18832. t['Racute'] = 667;
  18833. t['Sacute'] = 556;
  18834. t['dcaron'] = 588;
  18835. t['Umacron'] = 722;
  18836. t['uring'] = 500;
  18837. t['threesuperior'] = 300;
  18838. t['Ograve'] = 722;
  18839. t['Agrave'] = 722;
  18840. t['Abreve'] = 722;
  18841. t['multiply'] = 564;
  18842. t['uacute'] = 500;
  18843. t['Tcaron'] = 611;
  18844. t['partialdiff'] = 476;
  18845. t['ydieresis'] = 500;
  18846. t['Nacute'] = 722;
  18847. t['icircumflex'] = 278;
  18848. t['Ecircumflex'] = 611;
  18849. t['adieresis'] = 444;
  18850. t['edieresis'] = 444;
  18851. t['cacute'] = 444;
  18852. t['nacute'] = 500;
  18853. t['umacron'] = 500;
  18854. t['Ncaron'] = 722;
  18855. t['Iacute'] = 333;
  18856. t['plusminus'] = 564;
  18857. t['brokenbar'] = 200;
  18858. t['registered'] = 760;
  18859. t['Gbreve'] = 722;
  18860. t['Idotaccent'] = 333;
  18861. t['summation'] = 600;
  18862. t['Egrave'] = 611;
  18863. t['racute'] = 333;
  18864. t['omacron'] = 500;
  18865. t['Zacute'] = 611;
  18866. t['Zcaron'] = 611;
  18867. t['greaterequal'] = 549;
  18868. t['Eth'] = 722;
  18869. t['Ccedilla'] = 667;
  18870. t['lcommaaccent'] = 278;
  18871. t['tcaron'] = 326;
  18872. t['eogonek'] = 444;
  18873. t['Uogonek'] = 722;
  18874. t['Aacute'] = 722;
  18875. t['Adieresis'] = 722;
  18876. t['egrave'] = 444;
  18877. t['zacute'] = 444;
  18878. t['iogonek'] = 278;
  18879. t['Oacute'] = 722;
  18880. t['oacute'] = 500;
  18881. t['amacron'] = 444;
  18882. t['sacute'] = 389;
  18883. t['idieresis'] = 278;
  18884. t['Ocircumflex'] = 722;
  18885. t['Ugrave'] = 722;
  18886. t['Delta'] = 612;
  18887. t['thorn'] = 500;
  18888. t['twosuperior'] = 300;
  18889. t['Odieresis'] = 722;
  18890. t['mu'] = 500;
  18891. t['igrave'] = 278;
  18892. t['ohungarumlaut'] = 500;
  18893. t['Eogonek'] = 611;
  18894. t['dcroat'] = 500;
  18895. t['threequarters'] = 750;
  18896. t['Scedilla'] = 556;
  18897. t['lcaron'] = 344;
  18898. t['Kcommaaccent'] = 722;
  18899. t['Lacute'] = 611;
  18900. t['trademark'] = 980;
  18901. t['edotaccent'] = 444;
  18902. t['Igrave'] = 333;
  18903. t['Imacron'] = 333;
  18904. t['Lcaron'] = 611;
  18905. t['onehalf'] = 750;
  18906. t['lessequal'] = 549;
  18907. t['ocircumflex'] = 500;
  18908. t['ntilde'] = 500;
  18909. t['Uhungarumlaut'] = 722;
  18910. t['Eacute'] = 611;
  18911. t['emacron'] = 444;
  18912. t['gbreve'] = 500;
  18913. t['onequarter'] = 750;
  18914. t['Scaron'] = 556;
  18915. t['Scommaaccent'] = 556;
  18916. t['Ohungarumlaut'] = 722;
  18917. t['degree'] = 400;
  18918. t['ograve'] = 500;
  18919. t['Ccaron'] = 667;
  18920. t['ugrave'] = 500;
  18921. t['radical'] = 453;
  18922. t['Dcaron'] = 722;
  18923. t['rcommaaccent'] = 333;
  18924. t['Ntilde'] = 722;
  18925. t['otilde'] = 500;
  18926. t['Rcommaaccent'] = 667;
  18927. t['Lcommaaccent'] = 611;
  18928. t['Atilde'] = 722;
  18929. t['Aogonek'] = 722;
  18930. t['Aring'] = 722;
  18931. t['Otilde'] = 722;
  18932. t['zdotaccent'] = 444;
  18933. t['Ecaron'] = 611;
  18934. t['Iogonek'] = 333;
  18935. t['kcommaaccent'] = 500;
  18936. t['minus'] = 564;
  18937. t['Icircumflex'] = 333;
  18938. t['ncaron'] = 500;
  18939. t['tcommaaccent'] = 278;
  18940. t['logicalnot'] = 564;
  18941. t['odieresis'] = 500;
  18942. t['udieresis'] = 500;
  18943. t['notequal'] = 549;
  18944. t['gcommaaccent'] = 500;
  18945. t['eth'] = 500;
  18946. t['zcaron'] = 444;
  18947. t['ncommaaccent'] = 500;
  18948. t['onesuperior'] = 300;
  18949. t['imacron'] = 278;
  18950. t['Euro'] = 500;
  18951. });
  18952. t['Times-Bold'] = getLookupTableFactory(function (t) {
  18953. t['space'] = 250;
  18954. t['exclam'] = 333;
  18955. t['quotedbl'] = 555;
  18956. t['numbersign'] = 500;
  18957. t['dollar'] = 500;
  18958. t['percent'] = 1000;
  18959. t['ampersand'] = 833;
  18960. t['quoteright'] = 333;
  18961. t['parenleft'] = 333;
  18962. t['parenright'] = 333;
  18963. t['asterisk'] = 500;
  18964. t['plus'] = 570;
  18965. t['comma'] = 250;
  18966. t['hyphen'] = 333;
  18967. t['period'] = 250;
  18968. t['slash'] = 278;
  18969. t['zero'] = 500;
  18970. t['one'] = 500;
  18971. t['two'] = 500;
  18972. t['three'] = 500;
  18973. t['four'] = 500;
  18974. t['five'] = 500;
  18975. t['six'] = 500;
  18976. t['seven'] = 500;
  18977. t['eight'] = 500;
  18978. t['nine'] = 500;
  18979. t['colon'] = 333;
  18980. t['semicolon'] = 333;
  18981. t['less'] = 570;
  18982. t['equal'] = 570;
  18983. t['greater'] = 570;
  18984. t['question'] = 500;
  18985. t['at'] = 930;
  18986. t['A'] = 722;
  18987. t['B'] = 667;
  18988. t['C'] = 722;
  18989. t['D'] = 722;
  18990. t['E'] = 667;
  18991. t['F'] = 611;
  18992. t['G'] = 778;
  18993. t['H'] = 778;
  18994. t['I'] = 389;
  18995. t['J'] = 500;
  18996. t['K'] = 778;
  18997. t['L'] = 667;
  18998. t['M'] = 944;
  18999. t['N'] = 722;
  19000. t['O'] = 778;
  19001. t['P'] = 611;
  19002. t['Q'] = 778;
  19003. t['R'] = 722;
  19004. t['S'] = 556;
  19005. t['T'] = 667;
  19006. t['U'] = 722;
  19007. t['V'] = 722;
  19008. t['W'] = 1000;
  19009. t['X'] = 722;
  19010. t['Y'] = 722;
  19011. t['Z'] = 667;
  19012. t['bracketleft'] = 333;
  19013. t['backslash'] = 278;
  19014. t['bracketright'] = 333;
  19015. t['asciicircum'] = 581;
  19016. t['underscore'] = 500;
  19017. t['quoteleft'] = 333;
  19018. t['a'] = 500;
  19019. t['b'] = 556;
  19020. t['c'] = 444;
  19021. t['d'] = 556;
  19022. t['e'] = 444;
  19023. t['f'] = 333;
  19024. t['g'] = 500;
  19025. t['h'] = 556;
  19026. t['i'] = 278;
  19027. t['j'] = 333;
  19028. t['k'] = 556;
  19029. t['l'] = 278;
  19030. t['m'] = 833;
  19031. t['n'] = 556;
  19032. t['o'] = 500;
  19033. t['p'] = 556;
  19034. t['q'] = 556;
  19035. t['r'] = 444;
  19036. t['s'] = 389;
  19037. t['t'] = 333;
  19038. t['u'] = 556;
  19039. t['v'] = 500;
  19040. t['w'] = 722;
  19041. t['x'] = 500;
  19042. t['y'] = 500;
  19043. t['z'] = 444;
  19044. t['braceleft'] = 394;
  19045. t['bar'] = 220;
  19046. t['braceright'] = 394;
  19047. t['asciitilde'] = 520;
  19048. t['exclamdown'] = 333;
  19049. t['cent'] = 500;
  19050. t['sterling'] = 500;
  19051. t['fraction'] = 167;
  19052. t['yen'] = 500;
  19053. t['florin'] = 500;
  19054. t['section'] = 500;
  19055. t['currency'] = 500;
  19056. t['quotesingle'] = 278;
  19057. t['quotedblleft'] = 500;
  19058. t['guillemotleft'] = 500;
  19059. t['guilsinglleft'] = 333;
  19060. t['guilsinglright'] = 333;
  19061. t['fi'] = 556;
  19062. t['fl'] = 556;
  19063. t['endash'] = 500;
  19064. t['dagger'] = 500;
  19065. t['daggerdbl'] = 500;
  19066. t['periodcentered'] = 250;
  19067. t['paragraph'] = 540;
  19068. t['bullet'] = 350;
  19069. t['quotesinglbase'] = 333;
  19070. t['quotedblbase'] = 500;
  19071. t['quotedblright'] = 500;
  19072. t['guillemotright'] = 500;
  19073. t['ellipsis'] = 1000;
  19074. t['perthousand'] = 1000;
  19075. t['questiondown'] = 500;
  19076. t['grave'] = 333;
  19077. t['acute'] = 333;
  19078. t['circumflex'] = 333;
  19079. t['tilde'] = 333;
  19080. t['macron'] = 333;
  19081. t['breve'] = 333;
  19082. t['dotaccent'] = 333;
  19083. t['dieresis'] = 333;
  19084. t['ring'] = 333;
  19085. t['cedilla'] = 333;
  19086. t['hungarumlaut'] = 333;
  19087. t['ogonek'] = 333;
  19088. t['caron'] = 333;
  19089. t['emdash'] = 1000;
  19090. t['AE'] = 1000;
  19091. t['ordfeminine'] = 300;
  19092. t['Lslash'] = 667;
  19093. t['Oslash'] = 778;
  19094. t['OE'] = 1000;
  19095. t['ordmasculine'] = 330;
  19096. t['ae'] = 722;
  19097. t['dotlessi'] = 278;
  19098. t['lslash'] = 278;
  19099. t['oslash'] = 500;
  19100. t['oe'] = 722;
  19101. t['germandbls'] = 556;
  19102. t['Idieresis'] = 389;
  19103. t['eacute'] = 444;
  19104. t['abreve'] = 500;
  19105. t['uhungarumlaut'] = 556;
  19106. t['ecaron'] = 444;
  19107. t['Ydieresis'] = 722;
  19108. t['divide'] = 570;
  19109. t['Yacute'] = 722;
  19110. t['Acircumflex'] = 722;
  19111. t['aacute'] = 500;
  19112. t['Ucircumflex'] = 722;
  19113. t['yacute'] = 500;
  19114. t['scommaaccent'] = 389;
  19115. t['ecircumflex'] = 444;
  19116. t['Uring'] = 722;
  19117. t['Udieresis'] = 722;
  19118. t['aogonek'] = 500;
  19119. t['Uacute'] = 722;
  19120. t['uogonek'] = 556;
  19121. t['Edieresis'] = 667;
  19122. t['Dcroat'] = 722;
  19123. t['commaaccent'] = 250;
  19124. t['copyright'] = 747;
  19125. t['Emacron'] = 667;
  19126. t['ccaron'] = 444;
  19127. t['aring'] = 500;
  19128. t['Ncommaaccent'] = 722;
  19129. t['lacute'] = 278;
  19130. t['agrave'] = 500;
  19131. t['Tcommaaccent'] = 667;
  19132. t['Cacute'] = 722;
  19133. t['atilde'] = 500;
  19134. t['Edotaccent'] = 667;
  19135. t['scaron'] = 389;
  19136. t['scedilla'] = 389;
  19137. t['iacute'] = 278;
  19138. t['lozenge'] = 494;
  19139. t['Rcaron'] = 722;
  19140. t['Gcommaaccent'] = 778;
  19141. t['ucircumflex'] = 556;
  19142. t['acircumflex'] = 500;
  19143. t['Amacron'] = 722;
  19144. t['rcaron'] = 444;
  19145. t['ccedilla'] = 444;
  19146. t['Zdotaccent'] = 667;
  19147. t['Thorn'] = 611;
  19148. t['Omacron'] = 778;
  19149. t['Racute'] = 722;
  19150. t['Sacute'] = 556;
  19151. t['dcaron'] = 672;
  19152. t['Umacron'] = 722;
  19153. t['uring'] = 556;
  19154. t['threesuperior'] = 300;
  19155. t['Ograve'] = 778;
  19156. t['Agrave'] = 722;
  19157. t['Abreve'] = 722;
  19158. t['multiply'] = 570;
  19159. t['uacute'] = 556;
  19160. t['Tcaron'] = 667;
  19161. t['partialdiff'] = 494;
  19162. t['ydieresis'] = 500;
  19163. t['Nacute'] = 722;
  19164. t['icircumflex'] = 278;
  19165. t['Ecircumflex'] = 667;
  19166. t['adieresis'] = 500;
  19167. t['edieresis'] = 444;
  19168. t['cacute'] = 444;
  19169. t['nacute'] = 556;
  19170. t['umacron'] = 556;
  19171. t['Ncaron'] = 722;
  19172. t['Iacute'] = 389;
  19173. t['plusminus'] = 570;
  19174. t['brokenbar'] = 220;
  19175. t['registered'] = 747;
  19176. t['Gbreve'] = 778;
  19177. t['Idotaccent'] = 389;
  19178. t['summation'] = 600;
  19179. t['Egrave'] = 667;
  19180. t['racute'] = 444;
  19181. t['omacron'] = 500;
  19182. t['Zacute'] = 667;
  19183. t['Zcaron'] = 667;
  19184. t['greaterequal'] = 549;
  19185. t['Eth'] = 722;
  19186. t['Ccedilla'] = 722;
  19187. t['lcommaaccent'] = 278;
  19188. t['tcaron'] = 416;
  19189. t['eogonek'] = 444;
  19190. t['Uogonek'] = 722;
  19191. t['Aacute'] = 722;
  19192. t['Adieresis'] = 722;
  19193. t['egrave'] = 444;
  19194. t['zacute'] = 444;
  19195. t['iogonek'] = 278;
  19196. t['Oacute'] = 778;
  19197. t['oacute'] = 500;
  19198. t['amacron'] = 500;
  19199. t['sacute'] = 389;
  19200. t['idieresis'] = 278;
  19201. t['Ocircumflex'] = 778;
  19202. t['Ugrave'] = 722;
  19203. t['Delta'] = 612;
  19204. t['thorn'] = 556;
  19205. t['twosuperior'] = 300;
  19206. t['Odieresis'] = 778;
  19207. t['mu'] = 556;
  19208. t['igrave'] = 278;
  19209. t['ohungarumlaut'] = 500;
  19210. t['Eogonek'] = 667;
  19211. t['dcroat'] = 556;
  19212. t['threequarters'] = 750;
  19213. t['Scedilla'] = 556;
  19214. t['lcaron'] = 394;
  19215. t['Kcommaaccent'] = 778;
  19216. t['Lacute'] = 667;
  19217. t['trademark'] = 1000;
  19218. t['edotaccent'] = 444;
  19219. t['Igrave'] = 389;
  19220. t['Imacron'] = 389;
  19221. t['Lcaron'] = 667;
  19222. t['onehalf'] = 750;
  19223. t['lessequal'] = 549;
  19224. t['ocircumflex'] = 500;
  19225. t['ntilde'] = 556;
  19226. t['Uhungarumlaut'] = 722;
  19227. t['Eacute'] = 667;
  19228. t['emacron'] = 444;
  19229. t['gbreve'] = 500;
  19230. t['onequarter'] = 750;
  19231. t['Scaron'] = 556;
  19232. t['Scommaaccent'] = 556;
  19233. t['Ohungarumlaut'] = 778;
  19234. t['degree'] = 400;
  19235. t['ograve'] = 500;
  19236. t['Ccaron'] = 722;
  19237. t['ugrave'] = 556;
  19238. t['radical'] = 549;
  19239. t['Dcaron'] = 722;
  19240. t['rcommaaccent'] = 444;
  19241. t['Ntilde'] = 722;
  19242. t['otilde'] = 500;
  19243. t['Rcommaaccent'] = 722;
  19244. t['Lcommaaccent'] = 667;
  19245. t['Atilde'] = 722;
  19246. t['Aogonek'] = 722;
  19247. t['Aring'] = 722;
  19248. t['Otilde'] = 778;
  19249. t['zdotaccent'] = 444;
  19250. t['Ecaron'] = 667;
  19251. t['Iogonek'] = 389;
  19252. t['kcommaaccent'] = 556;
  19253. t['minus'] = 570;
  19254. t['Icircumflex'] = 389;
  19255. t['ncaron'] = 556;
  19256. t['tcommaaccent'] = 333;
  19257. t['logicalnot'] = 570;
  19258. t['odieresis'] = 500;
  19259. t['udieresis'] = 556;
  19260. t['notequal'] = 549;
  19261. t['gcommaaccent'] = 500;
  19262. t['eth'] = 500;
  19263. t['zcaron'] = 444;
  19264. t['ncommaaccent'] = 556;
  19265. t['onesuperior'] = 300;
  19266. t['imacron'] = 278;
  19267. t['Euro'] = 500;
  19268. });
  19269. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19270. t['space'] = 250;
  19271. t['exclam'] = 389;
  19272. t['quotedbl'] = 555;
  19273. t['numbersign'] = 500;
  19274. t['dollar'] = 500;
  19275. t['percent'] = 833;
  19276. t['ampersand'] = 778;
  19277. t['quoteright'] = 333;
  19278. t['parenleft'] = 333;
  19279. t['parenright'] = 333;
  19280. t['asterisk'] = 500;
  19281. t['plus'] = 570;
  19282. t['comma'] = 250;
  19283. t['hyphen'] = 333;
  19284. t['period'] = 250;
  19285. t['slash'] = 278;
  19286. t['zero'] = 500;
  19287. t['one'] = 500;
  19288. t['two'] = 500;
  19289. t['three'] = 500;
  19290. t['four'] = 500;
  19291. t['five'] = 500;
  19292. t['six'] = 500;
  19293. t['seven'] = 500;
  19294. t['eight'] = 500;
  19295. t['nine'] = 500;
  19296. t['colon'] = 333;
  19297. t['semicolon'] = 333;
  19298. t['less'] = 570;
  19299. t['equal'] = 570;
  19300. t['greater'] = 570;
  19301. t['question'] = 500;
  19302. t['at'] = 832;
  19303. t['A'] = 667;
  19304. t['B'] = 667;
  19305. t['C'] = 667;
  19306. t['D'] = 722;
  19307. t['E'] = 667;
  19308. t['F'] = 667;
  19309. t['G'] = 722;
  19310. t['H'] = 778;
  19311. t['I'] = 389;
  19312. t['J'] = 500;
  19313. t['K'] = 667;
  19314. t['L'] = 611;
  19315. t['M'] = 889;
  19316. t['N'] = 722;
  19317. t['O'] = 722;
  19318. t['P'] = 611;
  19319. t['Q'] = 722;
  19320. t['R'] = 667;
  19321. t['S'] = 556;
  19322. t['T'] = 611;
  19323. t['U'] = 722;
  19324. t['V'] = 667;
  19325. t['W'] = 889;
  19326. t['X'] = 667;
  19327. t['Y'] = 611;
  19328. t['Z'] = 611;
  19329. t['bracketleft'] = 333;
  19330. t['backslash'] = 278;
  19331. t['bracketright'] = 333;
  19332. t['asciicircum'] = 570;
  19333. t['underscore'] = 500;
  19334. t['quoteleft'] = 333;
  19335. t['a'] = 500;
  19336. t['b'] = 500;
  19337. t['c'] = 444;
  19338. t['d'] = 500;
  19339. t['e'] = 444;
  19340. t['f'] = 333;
  19341. t['g'] = 500;
  19342. t['h'] = 556;
  19343. t['i'] = 278;
  19344. t['j'] = 278;
  19345. t['k'] = 500;
  19346. t['l'] = 278;
  19347. t['m'] = 778;
  19348. t['n'] = 556;
  19349. t['o'] = 500;
  19350. t['p'] = 500;
  19351. t['q'] = 500;
  19352. t['r'] = 389;
  19353. t['s'] = 389;
  19354. t['t'] = 278;
  19355. t['u'] = 556;
  19356. t['v'] = 444;
  19357. t['w'] = 667;
  19358. t['x'] = 500;
  19359. t['y'] = 444;
  19360. t['z'] = 389;
  19361. t['braceleft'] = 348;
  19362. t['bar'] = 220;
  19363. t['braceright'] = 348;
  19364. t['asciitilde'] = 570;
  19365. t['exclamdown'] = 389;
  19366. t['cent'] = 500;
  19367. t['sterling'] = 500;
  19368. t['fraction'] = 167;
  19369. t['yen'] = 500;
  19370. t['florin'] = 500;
  19371. t['section'] = 500;
  19372. t['currency'] = 500;
  19373. t['quotesingle'] = 278;
  19374. t['quotedblleft'] = 500;
  19375. t['guillemotleft'] = 500;
  19376. t['guilsinglleft'] = 333;
  19377. t['guilsinglright'] = 333;
  19378. t['fi'] = 556;
  19379. t['fl'] = 556;
  19380. t['endash'] = 500;
  19381. t['dagger'] = 500;
  19382. t['daggerdbl'] = 500;
  19383. t['periodcentered'] = 250;
  19384. t['paragraph'] = 500;
  19385. t['bullet'] = 350;
  19386. t['quotesinglbase'] = 333;
  19387. t['quotedblbase'] = 500;
  19388. t['quotedblright'] = 500;
  19389. t['guillemotright'] = 500;
  19390. t['ellipsis'] = 1000;
  19391. t['perthousand'] = 1000;
  19392. t['questiondown'] = 500;
  19393. t['grave'] = 333;
  19394. t['acute'] = 333;
  19395. t['circumflex'] = 333;
  19396. t['tilde'] = 333;
  19397. t['macron'] = 333;
  19398. t['breve'] = 333;
  19399. t['dotaccent'] = 333;
  19400. t['dieresis'] = 333;
  19401. t['ring'] = 333;
  19402. t['cedilla'] = 333;
  19403. t['hungarumlaut'] = 333;
  19404. t['ogonek'] = 333;
  19405. t['caron'] = 333;
  19406. t['emdash'] = 1000;
  19407. t['AE'] = 944;
  19408. t['ordfeminine'] = 266;
  19409. t['Lslash'] = 611;
  19410. t['Oslash'] = 722;
  19411. t['OE'] = 944;
  19412. t['ordmasculine'] = 300;
  19413. t['ae'] = 722;
  19414. t['dotlessi'] = 278;
  19415. t['lslash'] = 278;
  19416. t['oslash'] = 500;
  19417. t['oe'] = 722;
  19418. t['germandbls'] = 500;
  19419. t['Idieresis'] = 389;
  19420. t['eacute'] = 444;
  19421. t['abreve'] = 500;
  19422. t['uhungarumlaut'] = 556;
  19423. t['ecaron'] = 444;
  19424. t['Ydieresis'] = 611;
  19425. t['divide'] = 570;
  19426. t['Yacute'] = 611;
  19427. t['Acircumflex'] = 667;
  19428. t['aacute'] = 500;
  19429. t['Ucircumflex'] = 722;
  19430. t['yacute'] = 444;
  19431. t['scommaaccent'] = 389;
  19432. t['ecircumflex'] = 444;
  19433. t['Uring'] = 722;
  19434. t['Udieresis'] = 722;
  19435. t['aogonek'] = 500;
  19436. t['Uacute'] = 722;
  19437. t['uogonek'] = 556;
  19438. t['Edieresis'] = 667;
  19439. t['Dcroat'] = 722;
  19440. t['commaaccent'] = 250;
  19441. t['copyright'] = 747;
  19442. t['Emacron'] = 667;
  19443. t['ccaron'] = 444;
  19444. t['aring'] = 500;
  19445. t['Ncommaaccent'] = 722;
  19446. t['lacute'] = 278;
  19447. t['agrave'] = 500;
  19448. t['Tcommaaccent'] = 611;
  19449. t['Cacute'] = 667;
  19450. t['atilde'] = 500;
  19451. t['Edotaccent'] = 667;
  19452. t['scaron'] = 389;
  19453. t['scedilla'] = 389;
  19454. t['iacute'] = 278;
  19455. t['lozenge'] = 494;
  19456. t['Rcaron'] = 667;
  19457. t['Gcommaaccent'] = 722;
  19458. t['ucircumflex'] = 556;
  19459. t['acircumflex'] = 500;
  19460. t['Amacron'] = 667;
  19461. t['rcaron'] = 389;
  19462. t['ccedilla'] = 444;
  19463. t['Zdotaccent'] = 611;
  19464. t['Thorn'] = 611;
  19465. t['Omacron'] = 722;
  19466. t['Racute'] = 667;
  19467. t['Sacute'] = 556;
  19468. t['dcaron'] = 608;
  19469. t['Umacron'] = 722;
  19470. t['uring'] = 556;
  19471. t['threesuperior'] = 300;
  19472. t['Ograve'] = 722;
  19473. t['Agrave'] = 667;
  19474. t['Abreve'] = 667;
  19475. t['multiply'] = 570;
  19476. t['uacute'] = 556;
  19477. t['Tcaron'] = 611;
  19478. t['partialdiff'] = 494;
  19479. t['ydieresis'] = 444;
  19480. t['Nacute'] = 722;
  19481. t['icircumflex'] = 278;
  19482. t['Ecircumflex'] = 667;
  19483. t['adieresis'] = 500;
  19484. t['edieresis'] = 444;
  19485. t['cacute'] = 444;
  19486. t['nacute'] = 556;
  19487. t['umacron'] = 556;
  19488. t['Ncaron'] = 722;
  19489. t['Iacute'] = 389;
  19490. t['plusminus'] = 570;
  19491. t['brokenbar'] = 220;
  19492. t['registered'] = 747;
  19493. t['Gbreve'] = 722;
  19494. t['Idotaccent'] = 389;
  19495. t['summation'] = 600;
  19496. t['Egrave'] = 667;
  19497. t['racute'] = 389;
  19498. t['omacron'] = 500;
  19499. t['Zacute'] = 611;
  19500. t['Zcaron'] = 611;
  19501. t['greaterequal'] = 549;
  19502. t['Eth'] = 722;
  19503. t['Ccedilla'] = 667;
  19504. t['lcommaaccent'] = 278;
  19505. t['tcaron'] = 366;
  19506. t['eogonek'] = 444;
  19507. t['Uogonek'] = 722;
  19508. t['Aacute'] = 667;
  19509. t['Adieresis'] = 667;
  19510. t['egrave'] = 444;
  19511. t['zacute'] = 389;
  19512. t['iogonek'] = 278;
  19513. t['Oacute'] = 722;
  19514. t['oacute'] = 500;
  19515. t['amacron'] = 500;
  19516. t['sacute'] = 389;
  19517. t['idieresis'] = 278;
  19518. t['Ocircumflex'] = 722;
  19519. t['Ugrave'] = 722;
  19520. t['Delta'] = 612;
  19521. t['thorn'] = 500;
  19522. t['twosuperior'] = 300;
  19523. t['Odieresis'] = 722;
  19524. t['mu'] = 576;
  19525. t['igrave'] = 278;
  19526. t['ohungarumlaut'] = 500;
  19527. t['Eogonek'] = 667;
  19528. t['dcroat'] = 500;
  19529. t['threequarters'] = 750;
  19530. t['Scedilla'] = 556;
  19531. t['lcaron'] = 382;
  19532. t['Kcommaaccent'] = 667;
  19533. t['Lacute'] = 611;
  19534. t['trademark'] = 1000;
  19535. t['edotaccent'] = 444;
  19536. t['Igrave'] = 389;
  19537. t['Imacron'] = 389;
  19538. t['Lcaron'] = 611;
  19539. t['onehalf'] = 750;
  19540. t['lessequal'] = 549;
  19541. t['ocircumflex'] = 500;
  19542. t['ntilde'] = 556;
  19543. t['Uhungarumlaut'] = 722;
  19544. t['Eacute'] = 667;
  19545. t['emacron'] = 444;
  19546. t['gbreve'] = 500;
  19547. t['onequarter'] = 750;
  19548. t['Scaron'] = 556;
  19549. t['Scommaaccent'] = 556;
  19550. t['Ohungarumlaut'] = 722;
  19551. t['degree'] = 400;
  19552. t['ograve'] = 500;
  19553. t['Ccaron'] = 667;
  19554. t['ugrave'] = 556;
  19555. t['radical'] = 549;
  19556. t['Dcaron'] = 722;
  19557. t['rcommaaccent'] = 389;
  19558. t['Ntilde'] = 722;
  19559. t['otilde'] = 500;
  19560. t['Rcommaaccent'] = 667;
  19561. t['Lcommaaccent'] = 611;
  19562. t['Atilde'] = 667;
  19563. t['Aogonek'] = 667;
  19564. t['Aring'] = 667;
  19565. t['Otilde'] = 722;
  19566. t['zdotaccent'] = 389;
  19567. t['Ecaron'] = 667;
  19568. t['Iogonek'] = 389;
  19569. t['kcommaaccent'] = 500;
  19570. t['minus'] = 606;
  19571. t['Icircumflex'] = 389;
  19572. t['ncaron'] = 556;
  19573. t['tcommaaccent'] = 278;
  19574. t['logicalnot'] = 606;
  19575. t['odieresis'] = 500;
  19576. t['udieresis'] = 556;
  19577. t['notequal'] = 549;
  19578. t['gcommaaccent'] = 500;
  19579. t['eth'] = 500;
  19580. t['zcaron'] = 389;
  19581. t['ncommaaccent'] = 556;
  19582. t['onesuperior'] = 300;
  19583. t['imacron'] = 278;
  19584. t['Euro'] = 500;
  19585. });
  19586. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19587. t['space'] = 250;
  19588. t['exclam'] = 333;
  19589. t['quotedbl'] = 420;
  19590. t['numbersign'] = 500;
  19591. t['dollar'] = 500;
  19592. t['percent'] = 833;
  19593. t['ampersand'] = 778;
  19594. t['quoteright'] = 333;
  19595. t['parenleft'] = 333;
  19596. t['parenright'] = 333;
  19597. t['asterisk'] = 500;
  19598. t['plus'] = 675;
  19599. t['comma'] = 250;
  19600. t['hyphen'] = 333;
  19601. t['period'] = 250;
  19602. t['slash'] = 278;
  19603. t['zero'] = 500;
  19604. t['one'] = 500;
  19605. t['two'] = 500;
  19606. t['three'] = 500;
  19607. t['four'] = 500;
  19608. t['five'] = 500;
  19609. t['six'] = 500;
  19610. t['seven'] = 500;
  19611. t['eight'] = 500;
  19612. t['nine'] = 500;
  19613. t['colon'] = 333;
  19614. t['semicolon'] = 333;
  19615. t['less'] = 675;
  19616. t['equal'] = 675;
  19617. t['greater'] = 675;
  19618. t['question'] = 500;
  19619. t['at'] = 920;
  19620. t['A'] = 611;
  19621. t['B'] = 611;
  19622. t['C'] = 667;
  19623. t['D'] = 722;
  19624. t['E'] = 611;
  19625. t['F'] = 611;
  19626. t['G'] = 722;
  19627. t['H'] = 722;
  19628. t['I'] = 333;
  19629. t['J'] = 444;
  19630. t['K'] = 667;
  19631. t['L'] = 556;
  19632. t['M'] = 833;
  19633. t['N'] = 667;
  19634. t['O'] = 722;
  19635. t['P'] = 611;
  19636. t['Q'] = 722;
  19637. t['R'] = 611;
  19638. t['S'] = 500;
  19639. t['T'] = 556;
  19640. t['U'] = 722;
  19641. t['V'] = 611;
  19642. t['W'] = 833;
  19643. t['X'] = 611;
  19644. t['Y'] = 556;
  19645. t['Z'] = 556;
  19646. t['bracketleft'] = 389;
  19647. t['backslash'] = 278;
  19648. t['bracketright'] = 389;
  19649. t['asciicircum'] = 422;
  19650. t['underscore'] = 500;
  19651. t['quoteleft'] = 333;
  19652. t['a'] = 500;
  19653. t['b'] = 500;
  19654. t['c'] = 444;
  19655. t['d'] = 500;
  19656. t['e'] = 444;
  19657. t['f'] = 278;
  19658. t['g'] = 500;
  19659. t['h'] = 500;
  19660. t['i'] = 278;
  19661. t['j'] = 278;
  19662. t['k'] = 444;
  19663. t['l'] = 278;
  19664. t['m'] = 722;
  19665. t['n'] = 500;
  19666. t['o'] = 500;
  19667. t['p'] = 500;
  19668. t['q'] = 500;
  19669. t['r'] = 389;
  19670. t['s'] = 389;
  19671. t['t'] = 278;
  19672. t['u'] = 500;
  19673. t['v'] = 444;
  19674. t['w'] = 667;
  19675. t['x'] = 444;
  19676. t['y'] = 444;
  19677. t['z'] = 389;
  19678. t['braceleft'] = 400;
  19679. t['bar'] = 275;
  19680. t['braceright'] = 400;
  19681. t['asciitilde'] = 541;
  19682. t['exclamdown'] = 389;
  19683. t['cent'] = 500;
  19684. t['sterling'] = 500;
  19685. t['fraction'] = 167;
  19686. t['yen'] = 500;
  19687. t['florin'] = 500;
  19688. t['section'] = 500;
  19689. t['currency'] = 500;
  19690. t['quotesingle'] = 214;
  19691. t['quotedblleft'] = 556;
  19692. t['guillemotleft'] = 500;
  19693. t['guilsinglleft'] = 333;
  19694. t['guilsinglright'] = 333;
  19695. t['fi'] = 500;
  19696. t['fl'] = 500;
  19697. t['endash'] = 500;
  19698. t['dagger'] = 500;
  19699. t['daggerdbl'] = 500;
  19700. t['periodcentered'] = 250;
  19701. t['paragraph'] = 523;
  19702. t['bullet'] = 350;
  19703. t['quotesinglbase'] = 333;
  19704. t['quotedblbase'] = 556;
  19705. t['quotedblright'] = 556;
  19706. t['guillemotright'] = 500;
  19707. t['ellipsis'] = 889;
  19708. t['perthousand'] = 1000;
  19709. t['questiondown'] = 500;
  19710. t['grave'] = 333;
  19711. t['acute'] = 333;
  19712. t['circumflex'] = 333;
  19713. t['tilde'] = 333;
  19714. t['macron'] = 333;
  19715. t['breve'] = 333;
  19716. t['dotaccent'] = 333;
  19717. t['dieresis'] = 333;
  19718. t['ring'] = 333;
  19719. t['cedilla'] = 333;
  19720. t['hungarumlaut'] = 333;
  19721. t['ogonek'] = 333;
  19722. t['caron'] = 333;
  19723. t['emdash'] = 889;
  19724. t['AE'] = 889;
  19725. t['ordfeminine'] = 276;
  19726. t['Lslash'] = 556;
  19727. t['Oslash'] = 722;
  19728. t['OE'] = 944;
  19729. t['ordmasculine'] = 310;
  19730. t['ae'] = 667;
  19731. t['dotlessi'] = 278;
  19732. t['lslash'] = 278;
  19733. t['oslash'] = 500;
  19734. t['oe'] = 667;
  19735. t['germandbls'] = 500;
  19736. t['Idieresis'] = 333;
  19737. t['eacute'] = 444;
  19738. t['abreve'] = 500;
  19739. t['uhungarumlaut'] = 500;
  19740. t['ecaron'] = 444;
  19741. t['Ydieresis'] = 556;
  19742. t['divide'] = 675;
  19743. t['Yacute'] = 556;
  19744. t['Acircumflex'] = 611;
  19745. t['aacute'] = 500;
  19746. t['Ucircumflex'] = 722;
  19747. t['yacute'] = 444;
  19748. t['scommaaccent'] = 389;
  19749. t['ecircumflex'] = 444;
  19750. t['Uring'] = 722;
  19751. t['Udieresis'] = 722;
  19752. t['aogonek'] = 500;
  19753. t['Uacute'] = 722;
  19754. t['uogonek'] = 500;
  19755. t['Edieresis'] = 611;
  19756. t['Dcroat'] = 722;
  19757. t['commaaccent'] = 250;
  19758. t['copyright'] = 760;
  19759. t['Emacron'] = 611;
  19760. t['ccaron'] = 444;
  19761. t['aring'] = 500;
  19762. t['Ncommaaccent'] = 667;
  19763. t['lacute'] = 278;
  19764. t['agrave'] = 500;
  19765. t['Tcommaaccent'] = 556;
  19766. t['Cacute'] = 667;
  19767. t['atilde'] = 500;
  19768. t['Edotaccent'] = 611;
  19769. t['scaron'] = 389;
  19770. t['scedilla'] = 389;
  19771. t['iacute'] = 278;
  19772. t['lozenge'] = 471;
  19773. t['Rcaron'] = 611;
  19774. t['Gcommaaccent'] = 722;
  19775. t['ucircumflex'] = 500;
  19776. t['acircumflex'] = 500;
  19777. t['Amacron'] = 611;
  19778. t['rcaron'] = 389;
  19779. t['ccedilla'] = 444;
  19780. t['Zdotaccent'] = 556;
  19781. t['Thorn'] = 611;
  19782. t['Omacron'] = 722;
  19783. t['Racute'] = 611;
  19784. t['Sacute'] = 500;
  19785. t['dcaron'] = 544;
  19786. t['Umacron'] = 722;
  19787. t['uring'] = 500;
  19788. t['threesuperior'] = 300;
  19789. t['Ograve'] = 722;
  19790. t['Agrave'] = 611;
  19791. t['Abreve'] = 611;
  19792. t['multiply'] = 675;
  19793. t['uacute'] = 500;
  19794. t['Tcaron'] = 556;
  19795. t['partialdiff'] = 476;
  19796. t['ydieresis'] = 444;
  19797. t['Nacute'] = 667;
  19798. t['icircumflex'] = 278;
  19799. t['Ecircumflex'] = 611;
  19800. t['adieresis'] = 500;
  19801. t['edieresis'] = 444;
  19802. t['cacute'] = 444;
  19803. t['nacute'] = 500;
  19804. t['umacron'] = 500;
  19805. t['Ncaron'] = 667;
  19806. t['Iacute'] = 333;
  19807. t['plusminus'] = 675;
  19808. t['brokenbar'] = 275;
  19809. t['registered'] = 760;
  19810. t['Gbreve'] = 722;
  19811. t['Idotaccent'] = 333;
  19812. t['summation'] = 600;
  19813. t['Egrave'] = 611;
  19814. t['racute'] = 389;
  19815. t['omacron'] = 500;
  19816. t['Zacute'] = 556;
  19817. t['Zcaron'] = 556;
  19818. t['greaterequal'] = 549;
  19819. t['Eth'] = 722;
  19820. t['Ccedilla'] = 667;
  19821. t['lcommaaccent'] = 278;
  19822. t['tcaron'] = 300;
  19823. t['eogonek'] = 444;
  19824. t['Uogonek'] = 722;
  19825. t['Aacute'] = 611;
  19826. t['Adieresis'] = 611;
  19827. t['egrave'] = 444;
  19828. t['zacute'] = 389;
  19829. t['iogonek'] = 278;
  19830. t['Oacute'] = 722;
  19831. t['oacute'] = 500;
  19832. t['amacron'] = 500;
  19833. t['sacute'] = 389;
  19834. t['idieresis'] = 278;
  19835. t['Ocircumflex'] = 722;
  19836. t['Ugrave'] = 722;
  19837. t['Delta'] = 612;
  19838. t['thorn'] = 500;
  19839. t['twosuperior'] = 300;
  19840. t['Odieresis'] = 722;
  19841. t['mu'] = 500;
  19842. t['igrave'] = 278;
  19843. t['ohungarumlaut'] = 500;
  19844. t['Eogonek'] = 611;
  19845. t['dcroat'] = 500;
  19846. t['threequarters'] = 750;
  19847. t['Scedilla'] = 500;
  19848. t['lcaron'] = 300;
  19849. t['Kcommaaccent'] = 667;
  19850. t['Lacute'] = 556;
  19851. t['trademark'] = 980;
  19852. t['edotaccent'] = 444;
  19853. t['Igrave'] = 333;
  19854. t['Imacron'] = 333;
  19855. t['Lcaron'] = 611;
  19856. t['onehalf'] = 750;
  19857. t['lessequal'] = 549;
  19858. t['ocircumflex'] = 500;
  19859. t['ntilde'] = 500;
  19860. t['Uhungarumlaut'] = 722;
  19861. t['Eacute'] = 611;
  19862. t['emacron'] = 444;
  19863. t['gbreve'] = 500;
  19864. t['onequarter'] = 750;
  19865. t['Scaron'] = 500;
  19866. t['Scommaaccent'] = 500;
  19867. t['Ohungarumlaut'] = 722;
  19868. t['degree'] = 400;
  19869. t['ograve'] = 500;
  19870. t['Ccaron'] = 667;
  19871. t['ugrave'] = 500;
  19872. t['radical'] = 453;
  19873. t['Dcaron'] = 722;
  19874. t['rcommaaccent'] = 389;
  19875. t['Ntilde'] = 667;
  19876. t['otilde'] = 500;
  19877. t['Rcommaaccent'] = 611;
  19878. t['Lcommaaccent'] = 556;
  19879. t['Atilde'] = 611;
  19880. t['Aogonek'] = 611;
  19881. t['Aring'] = 611;
  19882. t['Otilde'] = 722;
  19883. t['zdotaccent'] = 389;
  19884. t['Ecaron'] = 611;
  19885. t['Iogonek'] = 333;
  19886. t['kcommaaccent'] = 444;
  19887. t['minus'] = 675;
  19888. t['Icircumflex'] = 333;
  19889. t['ncaron'] = 500;
  19890. t['tcommaaccent'] = 278;
  19891. t['logicalnot'] = 675;
  19892. t['odieresis'] = 500;
  19893. t['udieresis'] = 500;
  19894. t['notequal'] = 549;
  19895. t['gcommaaccent'] = 500;
  19896. t['eth'] = 500;
  19897. t['zcaron'] = 389;
  19898. t['ncommaaccent'] = 500;
  19899. t['onesuperior'] = 300;
  19900. t['imacron'] = 278;
  19901. t['Euro'] = 500;
  19902. });
  19903. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  19904. t['space'] = 278;
  19905. t['a1'] = 974;
  19906. t['a2'] = 961;
  19907. t['a202'] = 974;
  19908. t['a3'] = 980;
  19909. t['a4'] = 719;
  19910. t['a5'] = 789;
  19911. t['a119'] = 790;
  19912. t['a118'] = 791;
  19913. t['a117'] = 690;
  19914. t['a11'] = 960;
  19915. t['a12'] = 939;
  19916. t['a13'] = 549;
  19917. t['a14'] = 855;
  19918. t['a15'] = 911;
  19919. t['a16'] = 933;
  19920. t['a105'] = 911;
  19921. t['a17'] = 945;
  19922. t['a18'] = 974;
  19923. t['a19'] = 755;
  19924. t['a20'] = 846;
  19925. t['a21'] = 762;
  19926. t['a22'] = 761;
  19927. t['a23'] = 571;
  19928. t['a24'] = 677;
  19929. t['a25'] = 763;
  19930. t['a26'] = 760;
  19931. t['a27'] = 759;
  19932. t['a28'] = 754;
  19933. t['a6'] = 494;
  19934. t['a7'] = 552;
  19935. t['a8'] = 537;
  19936. t['a9'] = 577;
  19937. t['a10'] = 692;
  19938. t['a29'] = 786;
  19939. t['a30'] = 788;
  19940. t['a31'] = 788;
  19941. t['a32'] = 790;
  19942. t['a33'] = 793;
  19943. t['a34'] = 794;
  19944. t['a35'] = 816;
  19945. t['a36'] = 823;
  19946. t['a37'] = 789;
  19947. t['a38'] = 841;
  19948. t['a39'] = 823;
  19949. t['a40'] = 833;
  19950. t['a41'] = 816;
  19951. t['a42'] = 831;
  19952. t['a43'] = 923;
  19953. t['a44'] = 744;
  19954. t['a45'] = 723;
  19955. t['a46'] = 749;
  19956. t['a47'] = 790;
  19957. t['a48'] = 792;
  19958. t['a49'] = 695;
  19959. t['a50'] = 776;
  19960. t['a51'] = 768;
  19961. t['a52'] = 792;
  19962. t['a53'] = 759;
  19963. t['a54'] = 707;
  19964. t['a55'] = 708;
  19965. t['a56'] = 682;
  19966. t['a57'] = 701;
  19967. t['a58'] = 826;
  19968. t['a59'] = 815;
  19969. t['a60'] = 789;
  19970. t['a61'] = 789;
  19971. t['a62'] = 707;
  19972. t['a63'] = 687;
  19973. t['a64'] = 696;
  19974. t['a65'] = 689;
  19975. t['a66'] = 786;
  19976. t['a67'] = 787;
  19977. t['a68'] = 713;
  19978. t['a69'] = 791;
  19979. t['a70'] = 785;
  19980. t['a71'] = 791;
  19981. t['a72'] = 873;
  19982. t['a73'] = 761;
  19983. t['a74'] = 762;
  19984. t['a203'] = 762;
  19985. t['a75'] = 759;
  19986. t['a204'] = 759;
  19987. t['a76'] = 892;
  19988. t['a77'] = 892;
  19989. t['a78'] = 788;
  19990. t['a79'] = 784;
  19991. t['a81'] = 438;
  19992. t['a82'] = 138;
  19993. t['a83'] = 277;
  19994. t['a84'] = 415;
  19995. t['a97'] = 392;
  19996. t['a98'] = 392;
  19997. t['a99'] = 668;
  19998. t['a100'] = 668;
  19999. t['a89'] = 390;
  20000. t['a90'] = 390;
  20001. t['a93'] = 317;
  20002. t['a94'] = 317;
  20003. t['a91'] = 276;
  20004. t['a92'] = 276;
  20005. t['a205'] = 509;
  20006. t['a85'] = 509;
  20007. t['a206'] = 410;
  20008. t['a86'] = 410;
  20009. t['a87'] = 234;
  20010. t['a88'] = 234;
  20011. t['a95'] = 334;
  20012. t['a96'] = 334;
  20013. t['a101'] = 732;
  20014. t['a102'] = 544;
  20015. t['a103'] = 544;
  20016. t['a104'] = 910;
  20017. t['a106'] = 667;
  20018. t['a107'] = 760;
  20019. t['a108'] = 760;
  20020. t['a112'] = 776;
  20021. t['a111'] = 595;
  20022. t['a110'] = 694;
  20023. t['a109'] = 626;
  20024. t['a120'] = 788;
  20025. t['a121'] = 788;
  20026. t['a122'] = 788;
  20027. t['a123'] = 788;
  20028. t['a124'] = 788;
  20029. t['a125'] = 788;
  20030. t['a126'] = 788;
  20031. t['a127'] = 788;
  20032. t['a128'] = 788;
  20033. t['a129'] = 788;
  20034. t['a130'] = 788;
  20035. t['a131'] = 788;
  20036. t['a132'] = 788;
  20037. t['a133'] = 788;
  20038. t['a134'] = 788;
  20039. t['a135'] = 788;
  20040. t['a136'] = 788;
  20041. t['a137'] = 788;
  20042. t['a138'] = 788;
  20043. t['a139'] = 788;
  20044. t['a140'] = 788;
  20045. t['a141'] = 788;
  20046. t['a142'] = 788;
  20047. t['a143'] = 788;
  20048. t['a144'] = 788;
  20049. t['a145'] = 788;
  20050. t['a146'] = 788;
  20051. t['a147'] = 788;
  20052. t['a148'] = 788;
  20053. t['a149'] = 788;
  20054. t['a150'] = 788;
  20055. t['a151'] = 788;
  20056. t['a152'] = 788;
  20057. t['a153'] = 788;
  20058. t['a154'] = 788;
  20059. t['a155'] = 788;
  20060. t['a156'] = 788;
  20061. t['a157'] = 788;
  20062. t['a158'] = 788;
  20063. t['a159'] = 788;
  20064. t['a160'] = 894;
  20065. t['a161'] = 838;
  20066. t['a163'] = 1016;
  20067. t['a164'] = 458;
  20068. t['a196'] = 748;
  20069. t['a165'] = 924;
  20070. t['a192'] = 748;
  20071. t['a166'] = 918;
  20072. t['a167'] = 927;
  20073. t['a168'] = 928;
  20074. t['a169'] = 928;
  20075. t['a170'] = 834;
  20076. t['a171'] = 873;
  20077. t['a172'] = 828;
  20078. t['a173'] = 924;
  20079. t['a162'] = 924;
  20080. t['a174'] = 917;
  20081. t['a175'] = 930;
  20082. t['a176'] = 931;
  20083. t['a177'] = 463;
  20084. t['a178'] = 883;
  20085. t['a179'] = 836;
  20086. t['a193'] = 836;
  20087. t['a180'] = 867;
  20088. t['a199'] = 867;
  20089. t['a181'] = 696;
  20090. t['a200'] = 696;
  20091. t['a182'] = 874;
  20092. t['a201'] = 874;
  20093. t['a183'] = 760;
  20094. t['a184'] = 946;
  20095. t['a197'] = 771;
  20096. t['a185'] = 865;
  20097. t['a194'] = 771;
  20098. t['a198'] = 888;
  20099. t['a186'] = 967;
  20100. t['a195'] = 888;
  20101. t['a187'] = 831;
  20102. t['a188'] = 873;
  20103. t['a189'] = 927;
  20104. t['a190'] = 970;
  20105. t['a191'] = 918;
  20106. });
  20107. });
  20108. exports.getMetrics = getMetrics;
  20109. }));
  20110. (function (root, factory) {
  20111. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20112. }(this, function (exports, sharedUtil) {
  20113. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20114. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20115. var MASK_HIGH = 0xffff0000;
  20116. var MASK_LOW = 0xffff;
  20117. function MurmurHash3_64(seed) {
  20118. var SEED = 0xc3d2e1f0;
  20119. this.h1 = seed ? seed & 0xffffffff : SEED;
  20120. this.h2 = seed ? seed & 0xffffffff : SEED;
  20121. }
  20122. var alwaysUseUint32ArrayView = false;
  20123. try {
  20124. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20125. } catch (e) {
  20126. alwaysUseUint32ArrayView = true;
  20127. }
  20128. MurmurHash3_64.prototype = {
  20129. update: function MurmurHash3_64_update(input) {
  20130. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20131. var i;
  20132. if (typeof input === 'string') {
  20133. var data = new Uint8Array(input.length * 2);
  20134. var length = 0;
  20135. for (i = 0; i < input.length; i++) {
  20136. var code = input.charCodeAt(i);
  20137. if (code <= 0xff) {
  20138. data[length++] = code;
  20139. } else {
  20140. data[length++] = code >>> 8;
  20141. data[length++] = code & 0xff;
  20142. }
  20143. }
  20144. } else if (input instanceof Uint8Array) {
  20145. data = input;
  20146. length = data.length;
  20147. } else if (typeof input === 'object' && 'length' in input) {
  20148. data = input;
  20149. length = data.length;
  20150. useUint32ArrayView = true;
  20151. } else {
  20152. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20153. }
  20154. var blockCounts = length >> 2;
  20155. var tailLength = length - blockCounts * 4;
  20156. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20157. var k1 = 0;
  20158. var k2 = 0;
  20159. var h1 = this.h1;
  20160. var h2 = this.h2;
  20161. var C1 = 0xcc9e2d51;
  20162. var C2 = 0x1b873593;
  20163. var C1_LOW = C1 & MASK_LOW;
  20164. var C2_LOW = C2 & MASK_LOW;
  20165. for (i = 0; i < blockCounts; i++) {
  20166. if (i & 1) {
  20167. k1 = dataUint32[i];
  20168. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20169. k1 = k1 << 15 | k1 >>> 17;
  20170. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20171. h1 ^= k1;
  20172. h1 = h1 << 13 | h1 >>> 19;
  20173. h1 = h1 * 5 + 0xe6546b64;
  20174. } else {
  20175. k2 = dataUint32[i];
  20176. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20177. k2 = k2 << 15 | k2 >>> 17;
  20178. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20179. h2 ^= k2;
  20180. h2 = h2 << 13 | h2 >>> 19;
  20181. h2 = h2 * 5 + 0xe6546b64;
  20182. }
  20183. }
  20184. k1 = 0;
  20185. switch (tailLength) {
  20186. case 3:
  20187. k1 ^= data[blockCounts * 4 + 2] << 16;
  20188. case 2:
  20189. k1 ^= data[blockCounts * 4 + 1] << 8;
  20190. case 1:
  20191. k1 ^= data[blockCounts * 4];
  20192. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20193. k1 = k1 << 15 | k1 >>> 17;
  20194. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20195. if (blockCounts & 1) {
  20196. h1 ^= k1;
  20197. } else {
  20198. h2 ^= k1;
  20199. }
  20200. }
  20201. this.h1 = h1;
  20202. this.h2 = h2;
  20203. return this;
  20204. },
  20205. hexdigest: function MurmurHash3_64_hexdigest() {
  20206. var h1 = this.h1;
  20207. var h2 = this.h2;
  20208. h1 ^= h2 >>> 1;
  20209. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20210. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20211. h1 ^= h2 >>> 1;
  20212. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20213. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20214. h1 ^= h2 >>> 1;
  20215. for (var i = 0, arr = [
  20216. h1,
  20217. h2
  20218. ], str = ''; i < arr.length; i++) {
  20219. var hex = (arr[i] >>> 0).toString(16);
  20220. while (hex.length < 8) {
  20221. hex = '0' + hex;
  20222. }
  20223. str += hex;
  20224. }
  20225. return str;
  20226. }
  20227. };
  20228. return MurmurHash3_64;
  20229. }();
  20230. exports.MurmurHash3_64 = MurmurHash3_64;
  20231. }));
  20232. (function (root, factory) {
  20233. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20234. }(this, function (exports, sharedUtil) {
  20235. var isArray = sharedUtil.isArray;
  20236. var Name = function NameClosure() {
  20237. function Name(name) {
  20238. this.name = name;
  20239. }
  20240. Name.prototype = {};
  20241. var nameCache = Object.create(null);
  20242. Name.get = function Name_get(name) {
  20243. var nameValue = nameCache[name];
  20244. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20245. };
  20246. return Name;
  20247. }();
  20248. var Cmd = function CmdClosure() {
  20249. function Cmd(cmd) {
  20250. this.cmd = cmd;
  20251. }
  20252. Cmd.prototype = {};
  20253. var cmdCache = Object.create(null);
  20254. Cmd.get = function Cmd_get(cmd) {
  20255. var cmdValue = cmdCache[cmd];
  20256. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20257. };
  20258. return Cmd;
  20259. }();
  20260. var Dict = function DictClosure() {
  20261. var nonSerializable = function nonSerializableClosure() {
  20262. return nonSerializable;
  20263. };
  20264. function Dict(xref) {
  20265. this.map = Object.create(null);
  20266. this.xref = xref;
  20267. this.objId = null;
  20268. this.suppressEncryption = false;
  20269. this.__nonSerializable__ = nonSerializable;
  20270. }
  20271. Dict.prototype = {
  20272. assignXref: function Dict_assignXref(newXref) {
  20273. this.xref = newXref;
  20274. },
  20275. get: function Dict_get(key1, key2, key3) {
  20276. var value;
  20277. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20278. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20279. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20280. }
  20281. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20282. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20283. }
  20284. value = this.map[key3] || null;
  20285. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20286. },
  20287. getAsync: function Dict_getAsync(key1, key2, key3) {
  20288. var value;
  20289. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20290. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20291. if (xref) {
  20292. return xref.fetchIfRefAsync(value, suppressEncryption);
  20293. }
  20294. return Promise.resolve(value);
  20295. }
  20296. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20297. if (xref) {
  20298. return xref.fetchIfRefAsync(value, suppressEncryption);
  20299. }
  20300. return Promise.resolve(value);
  20301. }
  20302. value = this.map[key3] || null;
  20303. if (xref) {
  20304. return xref.fetchIfRefAsync(value, suppressEncryption);
  20305. }
  20306. return Promise.resolve(value);
  20307. },
  20308. getArray: function Dict_getArray(key1, key2, key3) {
  20309. var value = this.get(key1, key2, key3);
  20310. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20311. if (!isArray(value) || !xref) {
  20312. return value;
  20313. }
  20314. value = value.slice();
  20315. for (var i = 0, ii = value.length; i < ii; i++) {
  20316. if (!isRef(value[i])) {
  20317. continue;
  20318. }
  20319. value[i] = xref.fetch(value[i], suppressEncryption);
  20320. }
  20321. return value;
  20322. },
  20323. getRaw: function Dict_getRaw(key) {
  20324. return this.map[key];
  20325. },
  20326. getKeys: function Dict_getKeys() {
  20327. return Object.keys(this.map);
  20328. },
  20329. set: function Dict_set(key, value) {
  20330. this.map[key] = value;
  20331. },
  20332. has: function Dict_has(key) {
  20333. return key in this.map;
  20334. },
  20335. forEach: function Dict_forEach(callback) {
  20336. for (var key in this.map) {
  20337. callback(key, this.get(key));
  20338. }
  20339. }
  20340. };
  20341. Dict.empty = new Dict(null);
  20342. Dict.merge = function Dict_merge(xref, dictArray) {
  20343. var mergedDict = new Dict(xref);
  20344. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20345. var dict = dictArray[i];
  20346. if (!isDict(dict)) {
  20347. continue;
  20348. }
  20349. for (var keyName in dict.map) {
  20350. if (mergedDict.map[keyName]) {
  20351. continue;
  20352. }
  20353. mergedDict.map[keyName] = dict.map[keyName];
  20354. }
  20355. }
  20356. return mergedDict;
  20357. };
  20358. return Dict;
  20359. }();
  20360. var Ref = function RefClosure() {
  20361. function Ref(num, gen) {
  20362. this.num = num;
  20363. this.gen = gen;
  20364. }
  20365. Ref.prototype = {
  20366. toString: function Ref_toString() {
  20367. var str = this.num + 'R';
  20368. if (this.gen !== 0) {
  20369. str += this.gen;
  20370. }
  20371. return str;
  20372. }
  20373. };
  20374. return Ref;
  20375. }();
  20376. var RefSet = function RefSetClosure() {
  20377. function RefSet() {
  20378. this.dict = Object.create(null);
  20379. }
  20380. RefSet.prototype = {
  20381. has: function RefSet_has(ref) {
  20382. return ref.toString() in this.dict;
  20383. },
  20384. put: function RefSet_put(ref) {
  20385. this.dict[ref.toString()] = true;
  20386. },
  20387. remove: function RefSet_remove(ref) {
  20388. delete this.dict[ref.toString()];
  20389. }
  20390. };
  20391. return RefSet;
  20392. }();
  20393. var RefSetCache = function RefSetCacheClosure() {
  20394. function RefSetCache() {
  20395. this.dict = Object.create(null);
  20396. }
  20397. RefSetCache.prototype = {
  20398. get: function RefSetCache_get(ref) {
  20399. return this.dict[ref.toString()];
  20400. },
  20401. has: function RefSetCache_has(ref) {
  20402. return ref.toString() in this.dict;
  20403. },
  20404. put: function RefSetCache_put(ref, obj) {
  20405. this.dict[ref.toString()] = obj;
  20406. },
  20407. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20408. this.dict[ref.toString()] = this.get(aliasRef);
  20409. },
  20410. forEach: function RefSetCache_forEach(fn, thisArg) {
  20411. for (var i in this.dict) {
  20412. fn.call(thisArg, this.dict[i]);
  20413. }
  20414. },
  20415. clear: function RefSetCache_clear() {
  20416. this.dict = Object.create(null);
  20417. }
  20418. };
  20419. return RefSetCache;
  20420. }();
  20421. function isName(v, name) {
  20422. return v instanceof Name && (name === undefined || v.name === name);
  20423. }
  20424. function isCmd(v, cmd) {
  20425. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20426. }
  20427. function isDict(v, type) {
  20428. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20429. }
  20430. function isRef(v) {
  20431. return v instanceof Ref;
  20432. }
  20433. function isRefsEqual(v1, v2) {
  20434. return v1.num === v2.num && v1.gen === v2.gen;
  20435. }
  20436. function isStream(v) {
  20437. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20438. }
  20439. exports.Cmd = Cmd;
  20440. exports.Dict = Dict;
  20441. exports.Name = Name;
  20442. exports.Ref = Ref;
  20443. exports.RefSet = RefSet;
  20444. exports.RefSetCache = RefSetCache;
  20445. exports.isCmd = isCmd;
  20446. exports.isDict = isDict;
  20447. exports.isName = isName;
  20448. exports.isRef = isRef;
  20449. exports.isRefsEqual = isRefsEqual;
  20450. exports.isStream = isStream;
  20451. }));
  20452. (function (root, factory) {
  20453. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20454. }(this, function (exports, sharedUtil) {
  20455. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20456. var getStdFontMap = getLookupTableFactory(function (t) {
  20457. t['ArialNarrow'] = 'Helvetica';
  20458. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20459. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20460. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20461. t['ArialBlack'] = 'Helvetica';
  20462. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20463. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20464. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20465. t['Arial-Black'] = 'Helvetica';
  20466. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20467. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20468. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20469. t['Arial'] = 'Helvetica';
  20470. t['Arial-Bold'] = 'Helvetica-Bold';
  20471. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20472. t['Arial-Italic'] = 'Helvetica-Oblique';
  20473. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20474. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20475. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20476. t['ArialMT'] = 'Helvetica';
  20477. t['Courier-Bold'] = 'Courier-Bold';
  20478. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20479. t['Courier-Italic'] = 'Courier-Oblique';
  20480. t['CourierNew'] = 'Courier';
  20481. t['CourierNew-Bold'] = 'Courier-Bold';
  20482. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20483. t['CourierNew-Italic'] = 'Courier-Oblique';
  20484. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20485. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20486. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20487. t['CourierNewPSMT'] = 'Courier';
  20488. t['Helvetica'] = 'Helvetica';
  20489. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20490. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20491. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20492. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20493. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20494. t['Symbol-Bold'] = 'Symbol';
  20495. t['Symbol-BoldItalic'] = 'Symbol';
  20496. t['Symbol-Italic'] = 'Symbol';
  20497. t['TimesNewRoman'] = 'Times-Roman';
  20498. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20499. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20500. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20501. t['TimesNewRomanPS'] = 'Times-Roman';
  20502. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20503. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20504. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20505. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20506. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20507. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20508. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20509. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20510. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20511. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20512. });
  20513. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20514. t['CenturyGothic'] = 'Helvetica';
  20515. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20516. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20517. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20518. t['ComicSansMS'] = 'Comic Sans MS';
  20519. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20520. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20521. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20522. t['LucidaConsole'] = 'Courier';
  20523. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20524. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20525. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20526. t['MS-Gothic'] = 'MS Gothic';
  20527. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20528. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20529. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20530. t['MS-Mincho'] = 'MS Mincho';
  20531. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20532. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20533. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20534. t['MS-PGothic'] = 'MS PGothic';
  20535. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20536. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20537. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20538. t['MS-PMincho'] = 'MS PMincho';
  20539. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20540. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20541. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20542. t['NuptialScript'] = 'Times-Italic';
  20543. t['Wingdings'] = 'ZapfDingbats';
  20544. });
  20545. var getSerifFonts = getLookupTableFactory(function (t) {
  20546. t['Adobe Jenson'] = true;
  20547. t['Adobe Text'] = true;
  20548. t['Albertus'] = true;
  20549. t['Aldus'] = true;
  20550. t['Alexandria'] = true;
  20551. t['Algerian'] = true;
  20552. t['American Typewriter'] = true;
  20553. t['Antiqua'] = true;
  20554. t['Apex'] = true;
  20555. t['Arno'] = true;
  20556. t['Aster'] = true;
  20557. t['Aurora'] = true;
  20558. t['Baskerville'] = true;
  20559. t['Bell'] = true;
  20560. t['Bembo'] = true;
  20561. t['Bembo Schoolbook'] = true;
  20562. t['Benguiat'] = true;
  20563. t['Berkeley Old Style'] = true;
  20564. t['Bernhard Modern'] = true;
  20565. t['Berthold City'] = true;
  20566. t['Bodoni'] = true;
  20567. t['Bauer Bodoni'] = true;
  20568. t['Book Antiqua'] = true;
  20569. t['Bookman'] = true;
  20570. t['Bordeaux Roman'] = true;
  20571. t['Californian FB'] = true;
  20572. t['Calisto'] = true;
  20573. t['Calvert'] = true;
  20574. t['Capitals'] = true;
  20575. t['Cambria'] = true;
  20576. t['Cartier'] = true;
  20577. t['Caslon'] = true;
  20578. t['Catull'] = true;
  20579. t['Centaur'] = true;
  20580. t['Century Old Style'] = true;
  20581. t['Century Schoolbook'] = true;
  20582. t['Chaparral'] = true;
  20583. t['Charis SIL'] = true;
  20584. t['Cheltenham'] = true;
  20585. t['Cholla Slab'] = true;
  20586. t['Clarendon'] = true;
  20587. t['Clearface'] = true;
  20588. t['Cochin'] = true;
  20589. t['Colonna'] = true;
  20590. t['Computer Modern'] = true;
  20591. t['Concrete Roman'] = true;
  20592. t['Constantia'] = true;
  20593. t['Cooper Black'] = true;
  20594. t['Corona'] = true;
  20595. t['Ecotype'] = true;
  20596. t['Egyptienne'] = true;
  20597. t['Elephant'] = true;
  20598. t['Excelsior'] = true;
  20599. t['Fairfield'] = true;
  20600. t['FF Scala'] = true;
  20601. t['Folkard'] = true;
  20602. t['Footlight'] = true;
  20603. t['FreeSerif'] = true;
  20604. t['Friz Quadrata'] = true;
  20605. t['Garamond'] = true;
  20606. t['Gentium'] = true;
  20607. t['Georgia'] = true;
  20608. t['Gloucester'] = true;
  20609. t['Goudy Old Style'] = true;
  20610. t['Goudy Schoolbook'] = true;
  20611. t['Goudy Pro Font'] = true;
  20612. t['Granjon'] = true;
  20613. t['Guardian Egyptian'] = true;
  20614. t['Heather'] = true;
  20615. t['Hercules'] = true;
  20616. t['High Tower Text'] = true;
  20617. t['Hiroshige'] = true;
  20618. t['Hoefler Text'] = true;
  20619. t['Humana Serif'] = true;
  20620. t['Imprint'] = true;
  20621. t['Ionic No. 5'] = true;
  20622. t['Janson'] = true;
  20623. t['Joanna'] = true;
  20624. t['Korinna'] = true;
  20625. t['Lexicon'] = true;
  20626. t['Liberation Serif'] = true;
  20627. t['Linux Libertine'] = true;
  20628. t['Literaturnaya'] = true;
  20629. t['Lucida'] = true;
  20630. t['Lucida Bright'] = true;
  20631. t['Melior'] = true;
  20632. t['Memphis'] = true;
  20633. t['Miller'] = true;
  20634. t['Minion'] = true;
  20635. t['Modern'] = true;
  20636. t['Mona Lisa'] = true;
  20637. t['Mrs Eaves'] = true;
  20638. t['MS Serif'] = true;
  20639. t['Museo Slab'] = true;
  20640. t['New York'] = true;
  20641. t['Nimbus Roman'] = true;
  20642. t['NPS Rawlinson Roadway'] = true;
  20643. t['NuptialScript'] = true;
  20644. t['Palatino'] = true;
  20645. t['Perpetua'] = true;
  20646. t['Plantin'] = true;
  20647. t['Plantin Schoolbook'] = true;
  20648. t['Playbill'] = true;
  20649. t['Poor Richard'] = true;
  20650. t['Rawlinson Roadway'] = true;
  20651. t['Renault'] = true;
  20652. t['Requiem'] = true;
  20653. t['Rockwell'] = true;
  20654. t['Roman'] = true;
  20655. t['Rotis Serif'] = true;
  20656. t['Sabon'] = true;
  20657. t['Scala'] = true;
  20658. t['Seagull'] = true;
  20659. t['Sistina'] = true;
  20660. t['Souvenir'] = true;
  20661. t['STIX'] = true;
  20662. t['Stone Informal'] = true;
  20663. t['Stone Serif'] = true;
  20664. t['Sylfaen'] = true;
  20665. t['Times'] = true;
  20666. t['Trajan'] = true;
  20667. t['Trinité'] = true;
  20668. t['Trump Mediaeval'] = true;
  20669. t['Utopia'] = true;
  20670. t['Vale Type'] = true;
  20671. t['Bitstream Vera'] = true;
  20672. t['Vera Serif'] = true;
  20673. t['Versailles'] = true;
  20674. t['Wanted'] = true;
  20675. t['Weiss'] = true;
  20676. t['Wide Latin'] = true;
  20677. t['Windsor'] = true;
  20678. t['XITS'] = true;
  20679. });
  20680. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20681. t['Dingbats'] = true;
  20682. t['Symbol'] = true;
  20683. t['ZapfDingbats'] = true;
  20684. });
  20685. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20686. t[2] = 10;
  20687. t[3] = 32;
  20688. t[4] = 33;
  20689. t[5] = 34;
  20690. t[6] = 35;
  20691. t[7] = 36;
  20692. t[8] = 37;
  20693. t[9] = 38;
  20694. t[10] = 39;
  20695. t[11] = 40;
  20696. t[12] = 41;
  20697. t[13] = 42;
  20698. t[14] = 43;
  20699. t[15] = 44;
  20700. t[16] = 45;
  20701. t[17] = 46;
  20702. t[18] = 47;
  20703. t[19] = 48;
  20704. t[20] = 49;
  20705. t[21] = 50;
  20706. t[22] = 51;
  20707. t[23] = 52;
  20708. t[24] = 53;
  20709. t[25] = 54;
  20710. t[26] = 55;
  20711. t[27] = 56;
  20712. t[28] = 57;
  20713. t[29] = 58;
  20714. t[30] = 894;
  20715. t[31] = 60;
  20716. t[32] = 61;
  20717. t[33] = 62;
  20718. t[34] = 63;
  20719. t[35] = 64;
  20720. t[36] = 65;
  20721. t[37] = 66;
  20722. t[38] = 67;
  20723. t[39] = 68;
  20724. t[40] = 69;
  20725. t[41] = 70;
  20726. t[42] = 71;
  20727. t[43] = 72;
  20728. t[44] = 73;
  20729. t[45] = 74;
  20730. t[46] = 75;
  20731. t[47] = 76;
  20732. t[48] = 77;
  20733. t[49] = 78;
  20734. t[50] = 79;
  20735. t[51] = 80;
  20736. t[52] = 81;
  20737. t[53] = 82;
  20738. t[54] = 83;
  20739. t[55] = 84;
  20740. t[56] = 85;
  20741. t[57] = 86;
  20742. t[58] = 87;
  20743. t[59] = 88;
  20744. t[60] = 89;
  20745. t[61] = 90;
  20746. t[62] = 91;
  20747. t[63] = 92;
  20748. t[64] = 93;
  20749. t[65] = 94;
  20750. t[66] = 95;
  20751. t[67] = 96;
  20752. t[68] = 97;
  20753. t[69] = 98;
  20754. t[70] = 99;
  20755. t[71] = 100;
  20756. t[72] = 101;
  20757. t[73] = 102;
  20758. t[74] = 103;
  20759. t[75] = 104;
  20760. t[76] = 105;
  20761. t[77] = 106;
  20762. t[78] = 107;
  20763. t[79] = 108;
  20764. t[80] = 109;
  20765. t[81] = 110;
  20766. t[82] = 111;
  20767. t[83] = 112;
  20768. t[84] = 113;
  20769. t[85] = 114;
  20770. t[86] = 115;
  20771. t[87] = 116;
  20772. t[88] = 117;
  20773. t[89] = 118;
  20774. t[90] = 119;
  20775. t[91] = 120;
  20776. t[92] = 121;
  20777. t[93] = 122;
  20778. t[94] = 123;
  20779. t[95] = 124;
  20780. t[96] = 125;
  20781. t[97] = 126;
  20782. t[98] = 196;
  20783. t[99] = 197;
  20784. t[100] = 199;
  20785. t[101] = 201;
  20786. t[102] = 209;
  20787. t[103] = 214;
  20788. t[104] = 220;
  20789. t[105] = 225;
  20790. t[106] = 224;
  20791. t[107] = 226;
  20792. t[108] = 228;
  20793. t[109] = 227;
  20794. t[110] = 229;
  20795. t[111] = 231;
  20796. t[112] = 233;
  20797. t[113] = 232;
  20798. t[114] = 234;
  20799. t[115] = 235;
  20800. t[116] = 237;
  20801. t[117] = 236;
  20802. t[118] = 238;
  20803. t[119] = 239;
  20804. t[120] = 241;
  20805. t[121] = 243;
  20806. t[122] = 242;
  20807. t[123] = 244;
  20808. t[124] = 246;
  20809. t[125] = 245;
  20810. t[126] = 250;
  20811. t[127] = 249;
  20812. t[128] = 251;
  20813. t[129] = 252;
  20814. t[130] = 8224;
  20815. t[131] = 176;
  20816. t[132] = 162;
  20817. t[133] = 163;
  20818. t[134] = 167;
  20819. t[135] = 8226;
  20820. t[136] = 182;
  20821. t[137] = 223;
  20822. t[138] = 174;
  20823. t[139] = 169;
  20824. t[140] = 8482;
  20825. t[141] = 180;
  20826. t[142] = 168;
  20827. t[143] = 8800;
  20828. t[144] = 198;
  20829. t[145] = 216;
  20830. t[146] = 8734;
  20831. t[147] = 177;
  20832. t[148] = 8804;
  20833. t[149] = 8805;
  20834. t[150] = 165;
  20835. t[151] = 181;
  20836. t[152] = 8706;
  20837. t[153] = 8721;
  20838. t[154] = 8719;
  20839. t[156] = 8747;
  20840. t[157] = 170;
  20841. t[158] = 186;
  20842. t[159] = 8486;
  20843. t[160] = 230;
  20844. t[161] = 248;
  20845. t[162] = 191;
  20846. t[163] = 161;
  20847. t[164] = 172;
  20848. t[165] = 8730;
  20849. t[166] = 402;
  20850. t[167] = 8776;
  20851. t[168] = 8710;
  20852. t[169] = 171;
  20853. t[170] = 187;
  20854. t[171] = 8230;
  20855. t[210] = 218;
  20856. t[223] = 711;
  20857. t[224] = 321;
  20858. t[225] = 322;
  20859. t[227] = 353;
  20860. t[229] = 382;
  20861. t[234] = 253;
  20862. t[252] = 263;
  20863. t[253] = 268;
  20864. t[254] = 269;
  20865. t[258] = 258;
  20866. t[260] = 260;
  20867. t[261] = 261;
  20868. t[265] = 280;
  20869. t[266] = 281;
  20870. t[268] = 283;
  20871. t[269] = 313;
  20872. t[275] = 323;
  20873. t[276] = 324;
  20874. t[278] = 328;
  20875. t[284] = 345;
  20876. t[285] = 346;
  20877. t[286] = 347;
  20878. t[292] = 367;
  20879. t[295] = 377;
  20880. t[296] = 378;
  20881. t[298] = 380;
  20882. t[305] = 963;
  20883. t[306] = 964;
  20884. t[307] = 966;
  20885. t[308] = 8215;
  20886. t[309] = 8252;
  20887. t[310] = 8319;
  20888. t[311] = 8359;
  20889. t[312] = 8592;
  20890. t[313] = 8593;
  20891. t[337] = 9552;
  20892. t[493] = 1039;
  20893. t[494] = 1040;
  20894. t[705] = 1524;
  20895. t[706] = 8362;
  20896. t[710] = 64288;
  20897. t[711] = 64298;
  20898. t[759] = 1617;
  20899. t[761] = 1776;
  20900. t[763] = 1778;
  20901. t[775] = 1652;
  20902. t[777] = 1764;
  20903. t[778] = 1780;
  20904. t[779] = 1781;
  20905. t[780] = 1782;
  20906. t[782] = 771;
  20907. t[783] = 64726;
  20908. t[786] = 8363;
  20909. t[788] = 8532;
  20910. t[790] = 768;
  20911. t[791] = 769;
  20912. t[792] = 768;
  20913. t[795] = 803;
  20914. t[797] = 64336;
  20915. t[798] = 64337;
  20916. t[799] = 64342;
  20917. t[800] = 64343;
  20918. t[801] = 64344;
  20919. t[802] = 64345;
  20920. t[803] = 64362;
  20921. t[804] = 64363;
  20922. t[805] = 64364;
  20923. t[2424] = 7821;
  20924. t[2425] = 7822;
  20925. t[2426] = 7823;
  20926. t[2427] = 7824;
  20927. t[2428] = 7825;
  20928. t[2429] = 7826;
  20929. t[2430] = 7827;
  20930. t[2433] = 7682;
  20931. t[2678] = 8045;
  20932. t[2679] = 8046;
  20933. t[2830] = 1552;
  20934. t[2838] = 686;
  20935. t[2840] = 751;
  20936. t[2842] = 753;
  20937. t[2843] = 754;
  20938. t[2844] = 755;
  20939. t[2846] = 757;
  20940. t[2856] = 767;
  20941. t[2857] = 848;
  20942. t[2858] = 849;
  20943. t[2862] = 853;
  20944. t[2863] = 854;
  20945. t[2864] = 855;
  20946. t[2865] = 861;
  20947. t[2866] = 862;
  20948. t[2906] = 7460;
  20949. t[2908] = 7462;
  20950. t[2909] = 7463;
  20951. t[2910] = 7464;
  20952. t[2912] = 7466;
  20953. t[2913] = 7467;
  20954. t[2914] = 7468;
  20955. t[2916] = 7470;
  20956. t[2917] = 7471;
  20957. t[2918] = 7472;
  20958. t[2920] = 7474;
  20959. t[2921] = 7475;
  20960. t[2922] = 7476;
  20961. t[2924] = 7478;
  20962. t[2925] = 7479;
  20963. t[2926] = 7480;
  20964. t[2928] = 7482;
  20965. t[2929] = 7483;
  20966. t[2930] = 7484;
  20967. t[2932] = 7486;
  20968. t[2933] = 7487;
  20969. t[2934] = 7488;
  20970. t[2936] = 7490;
  20971. t[2937] = 7491;
  20972. t[2938] = 7492;
  20973. t[2940] = 7494;
  20974. t[2941] = 7495;
  20975. t[2942] = 7496;
  20976. t[2944] = 7498;
  20977. t[2946] = 7500;
  20978. t[2948] = 7502;
  20979. t[2950] = 7504;
  20980. t[2951] = 7505;
  20981. t[2952] = 7506;
  20982. t[2954] = 7508;
  20983. t[2955] = 7509;
  20984. t[2956] = 7510;
  20985. t[2958] = 7512;
  20986. t[2959] = 7513;
  20987. t[2960] = 7514;
  20988. t[2962] = 7516;
  20989. t[2963] = 7517;
  20990. t[2964] = 7518;
  20991. t[2966] = 7520;
  20992. t[2967] = 7521;
  20993. t[2968] = 7522;
  20994. t[2970] = 7524;
  20995. t[2971] = 7525;
  20996. t[2972] = 7526;
  20997. t[2974] = 7528;
  20998. t[2975] = 7529;
  20999. t[2976] = 7530;
  21000. t[2978] = 1537;
  21001. t[2979] = 1538;
  21002. t[2980] = 1539;
  21003. t[2982] = 1549;
  21004. t[2983] = 1551;
  21005. t[2984] = 1552;
  21006. t[2986] = 1554;
  21007. t[2987] = 1555;
  21008. t[2988] = 1556;
  21009. t[2990] = 1623;
  21010. t[2991] = 1624;
  21011. t[2995] = 1775;
  21012. t[2999] = 1791;
  21013. t[3002] = 64290;
  21014. t[3003] = 64291;
  21015. t[3004] = 64292;
  21016. t[3006] = 64294;
  21017. t[3007] = 64295;
  21018. t[3008] = 64296;
  21019. t[3011] = 1900;
  21020. t[3014] = 8223;
  21021. t[3015] = 8244;
  21022. t[3017] = 7532;
  21023. t[3018] = 7533;
  21024. t[3019] = 7534;
  21025. t[3075] = 7590;
  21026. t[3076] = 7591;
  21027. t[3079] = 7594;
  21028. t[3080] = 7595;
  21029. t[3083] = 7598;
  21030. t[3084] = 7599;
  21031. t[3087] = 7602;
  21032. t[3088] = 7603;
  21033. t[3091] = 7606;
  21034. t[3092] = 7607;
  21035. t[3095] = 7610;
  21036. t[3096] = 7611;
  21037. t[3099] = 7614;
  21038. t[3100] = 7615;
  21039. t[3103] = 7618;
  21040. t[3104] = 7619;
  21041. t[3107] = 8337;
  21042. t[3108] = 8338;
  21043. t[3116] = 1884;
  21044. t[3119] = 1885;
  21045. t[3120] = 1885;
  21046. t[3123] = 1886;
  21047. t[3124] = 1886;
  21048. t[3127] = 1887;
  21049. t[3128] = 1887;
  21050. t[3131] = 1888;
  21051. t[3132] = 1888;
  21052. t[3135] = 1889;
  21053. t[3136] = 1889;
  21054. t[3139] = 1890;
  21055. t[3140] = 1890;
  21056. t[3143] = 1891;
  21057. t[3144] = 1891;
  21058. t[3147] = 1892;
  21059. t[3148] = 1892;
  21060. t[3153] = 580;
  21061. t[3154] = 581;
  21062. t[3157] = 584;
  21063. t[3158] = 585;
  21064. t[3161] = 588;
  21065. t[3162] = 589;
  21066. t[3165] = 891;
  21067. t[3166] = 892;
  21068. t[3169] = 1274;
  21069. t[3170] = 1275;
  21070. t[3173] = 1278;
  21071. t[3174] = 1279;
  21072. t[3181] = 7622;
  21073. t[3182] = 7623;
  21074. t[3282] = 11799;
  21075. t[3316] = 578;
  21076. t[3379] = 42785;
  21077. t[3393] = 1159;
  21078. t[3416] = 8377;
  21079. });
  21080. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21081. t[227] = 322;
  21082. t[264] = 261;
  21083. t[291] = 346;
  21084. });
  21085. exports.getStdFontMap = getStdFontMap;
  21086. exports.getNonStdFontMap = getNonStdFontMap;
  21087. exports.getSerifFonts = getSerifFonts;
  21088. exports.getSymbolsFonts = getSymbolsFonts;
  21089. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21090. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21091. }));
  21092. (function (root, factory) {
  21093. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21094. }(this, function (exports, sharedUtil) {
  21095. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21096. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21097. t[63721] = 0x00A9;
  21098. t[63193] = 0x00A9;
  21099. t[63720] = 0x00AE;
  21100. t[63194] = 0x00AE;
  21101. t[63722] = 0x2122;
  21102. t[63195] = 0x2122;
  21103. t[63729] = 0x23A7;
  21104. t[63730] = 0x23A8;
  21105. t[63731] = 0x23A9;
  21106. t[63740] = 0x23AB;
  21107. t[63741] = 0x23AC;
  21108. t[63742] = 0x23AD;
  21109. t[63726] = 0x23A1;
  21110. t[63727] = 0x23A2;
  21111. t[63728] = 0x23A3;
  21112. t[63737] = 0x23A4;
  21113. t[63738] = 0x23A5;
  21114. t[63739] = 0x23A6;
  21115. t[63723] = 0x239B;
  21116. t[63724] = 0x239C;
  21117. t[63725] = 0x239D;
  21118. t[63734] = 0x239E;
  21119. t[63735] = 0x239F;
  21120. t[63736] = 0x23A0;
  21121. });
  21122. function mapSpecialUnicodeValues(code) {
  21123. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21124. return 0;
  21125. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21126. return getSpecialPUASymbols()[code] || code;
  21127. }
  21128. return code;
  21129. }
  21130. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21131. var unicode = glyphsUnicodeMap[name];
  21132. if (unicode !== undefined) {
  21133. return unicode;
  21134. }
  21135. if (!name) {
  21136. return -1;
  21137. }
  21138. if (name[0] === 'u') {
  21139. var nameLen = name.length, hexStr;
  21140. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21141. hexStr = name.substr(3);
  21142. } else if (nameLen >= 5 && nameLen <= 7) {
  21143. hexStr = name.substr(1);
  21144. } else {
  21145. return -1;
  21146. }
  21147. if (hexStr === hexStr.toUpperCase()) {
  21148. unicode = parseInt(hexStr, 16);
  21149. if (unicode >= 0) {
  21150. return unicode;
  21151. }
  21152. }
  21153. }
  21154. return -1;
  21155. }
  21156. var UnicodeRanges = [
  21157. {
  21158. 'begin': 0x0000,
  21159. 'end': 0x007F
  21160. },
  21161. {
  21162. 'begin': 0x0080,
  21163. 'end': 0x00FF
  21164. },
  21165. {
  21166. 'begin': 0x0100,
  21167. 'end': 0x017F
  21168. },
  21169. {
  21170. 'begin': 0x0180,
  21171. 'end': 0x024F
  21172. },
  21173. {
  21174. 'begin': 0x0250,
  21175. 'end': 0x02AF
  21176. },
  21177. {
  21178. 'begin': 0x02B0,
  21179. 'end': 0x02FF
  21180. },
  21181. {
  21182. 'begin': 0x0300,
  21183. 'end': 0x036F
  21184. },
  21185. {
  21186. 'begin': 0x0370,
  21187. 'end': 0x03FF
  21188. },
  21189. {
  21190. 'begin': 0x2C80,
  21191. 'end': 0x2CFF
  21192. },
  21193. {
  21194. 'begin': 0x0400,
  21195. 'end': 0x04FF
  21196. },
  21197. {
  21198. 'begin': 0x0530,
  21199. 'end': 0x058F
  21200. },
  21201. {
  21202. 'begin': 0x0590,
  21203. 'end': 0x05FF
  21204. },
  21205. {
  21206. 'begin': 0xA500,
  21207. 'end': 0xA63F
  21208. },
  21209. {
  21210. 'begin': 0x0600,
  21211. 'end': 0x06FF
  21212. },
  21213. {
  21214. 'begin': 0x07C0,
  21215. 'end': 0x07FF
  21216. },
  21217. {
  21218. 'begin': 0x0900,
  21219. 'end': 0x097F
  21220. },
  21221. {
  21222. 'begin': 0x0980,
  21223. 'end': 0x09FF
  21224. },
  21225. {
  21226. 'begin': 0x0A00,
  21227. 'end': 0x0A7F
  21228. },
  21229. {
  21230. 'begin': 0x0A80,
  21231. 'end': 0x0AFF
  21232. },
  21233. {
  21234. 'begin': 0x0B00,
  21235. 'end': 0x0B7F
  21236. },
  21237. {
  21238. 'begin': 0x0B80,
  21239. 'end': 0x0BFF
  21240. },
  21241. {
  21242. 'begin': 0x0C00,
  21243. 'end': 0x0C7F
  21244. },
  21245. {
  21246. 'begin': 0x0C80,
  21247. 'end': 0x0CFF
  21248. },
  21249. {
  21250. 'begin': 0x0D00,
  21251. 'end': 0x0D7F
  21252. },
  21253. {
  21254. 'begin': 0x0E00,
  21255. 'end': 0x0E7F
  21256. },
  21257. {
  21258. 'begin': 0x0E80,
  21259. 'end': 0x0EFF
  21260. },
  21261. {
  21262. 'begin': 0x10A0,
  21263. 'end': 0x10FF
  21264. },
  21265. {
  21266. 'begin': 0x1B00,
  21267. 'end': 0x1B7F
  21268. },
  21269. {
  21270. 'begin': 0x1100,
  21271. 'end': 0x11FF
  21272. },
  21273. {
  21274. 'begin': 0x1E00,
  21275. 'end': 0x1EFF
  21276. },
  21277. {
  21278. 'begin': 0x1F00,
  21279. 'end': 0x1FFF
  21280. },
  21281. {
  21282. 'begin': 0x2000,
  21283. 'end': 0x206F
  21284. },
  21285. {
  21286. 'begin': 0x2070,
  21287. 'end': 0x209F
  21288. },
  21289. {
  21290. 'begin': 0x20A0,
  21291. 'end': 0x20CF
  21292. },
  21293. {
  21294. 'begin': 0x20D0,
  21295. 'end': 0x20FF
  21296. },
  21297. {
  21298. 'begin': 0x2100,
  21299. 'end': 0x214F
  21300. },
  21301. {
  21302. 'begin': 0x2150,
  21303. 'end': 0x218F
  21304. },
  21305. {
  21306. 'begin': 0x2190,
  21307. 'end': 0x21FF
  21308. },
  21309. {
  21310. 'begin': 0x2200,
  21311. 'end': 0x22FF
  21312. },
  21313. {
  21314. 'begin': 0x2300,
  21315. 'end': 0x23FF
  21316. },
  21317. {
  21318. 'begin': 0x2400,
  21319. 'end': 0x243F
  21320. },
  21321. {
  21322. 'begin': 0x2440,
  21323. 'end': 0x245F
  21324. },
  21325. {
  21326. 'begin': 0x2460,
  21327. 'end': 0x24FF
  21328. },
  21329. {
  21330. 'begin': 0x2500,
  21331. 'end': 0x257F
  21332. },
  21333. {
  21334. 'begin': 0x2580,
  21335. 'end': 0x259F
  21336. },
  21337. {
  21338. 'begin': 0x25A0,
  21339. 'end': 0x25FF
  21340. },
  21341. {
  21342. 'begin': 0x2600,
  21343. 'end': 0x26FF
  21344. },
  21345. {
  21346. 'begin': 0x2700,
  21347. 'end': 0x27BF
  21348. },
  21349. {
  21350. 'begin': 0x3000,
  21351. 'end': 0x303F
  21352. },
  21353. {
  21354. 'begin': 0x3040,
  21355. 'end': 0x309F
  21356. },
  21357. {
  21358. 'begin': 0x30A0,
  21359. 'end': 0x30FF
  21360. },
  21361. {
  21362. 'begin': 0x3100,
  21363. 'end': 0x312F
  21364. },
  21365. {
  21366. 'begin': 0x3130,
  21367. 'end': 0x318F
  21368. },
  21369. {
  21370. 'begin': 0xA840,
  21371. 'end': 0xA87F
  21372. },
  21373. {
  21374. 'begin': 0x3200,
  21375. 'end': 0x32FF
  21376. },
  21377. {
  21378. 'begin': 0x3300,
  21379. 'end': 0x33FF
  21380. },
  21381. {
  21382. 'begin': 0xAC00,
  21383. 'end': 0xD7AF
  21384. },
  21385. {
  21386. 'begin': 0xD800,
  21387. 'end': 0xDFFF
  21388. },
  21389. {
  21390. 'begin': 0x10900,
  21391. 'end': 0x1091F
  21392. },
  21393. {
  21394. 'begin': 0x4E00,
  21395. 'end': 0x9FFF
  21396. },
  21397. {
  21398. 'begin': 0xE000,
  21399. 'end': 0xF8FF
  21400. },
  21401. {
  21402. 'begin': 0x31C0,
  21403. 'end': 0x31EF
  21404. },
  21405. {
  21406. 'begin': 0xFB00,
  21407. 'end': 0xFB4F
  21408. },
  21409. {
  21410. 'begin': 0xFB50,
  21411. 'end': 0xFDFF
  21412. },
  21413. {
  21414. 'begin': 0xFE20,
  21415. 'end': 0xFE2F
  21416. },
  21417. {
  21418. 'begin': 0xFE10,
  21419. 'end': 0xFE1F
  21420. },
  21421. {
  21422. 'begin': 0xFE50,
  21423. 'end': 0xFE6F
  21424. },
  21425. {
  21426. 'begin': 0xFE70,
  21427. 'end': 0xFEFF
  21428. },
  21429. {
  21430. 'begin': 0xFF00,
  21431. 'end': 0xFFEF
  21432. },
  21433. {
  21434. 'begin': 0xFFF0,
  21435. 'end': 0xFFFF
  21436. },
  21437. {
  21438. 'begin': 0x0F00,
  21439. 'end': 0x0FFF
  21440. },
  21441. {
  21442. 'begin': 0x0700,
  21443. 'end': 0x074F
  21444. },
  21445. {
  21446. 'begin': 0x0780,
  21447. 'end': 0x07BF
  21448. },
  21449. {
  21450. 'begin': 0x0D80,
  21451. 'end': 0x0DFF
  21452. },
  21453. {
  21454. 'begin': 0x1000,
  21455. 'end': 0x109F
  21456. },
  21457. {
  21458. 'begin': 0x1200,
  21459. 'end': 0x137F
  21460. },
  21461. {
  21462. 'begin': 0x13A0,
  21463. 'end': 0x13FF
  21464. },
  21465. {
  21466. 'begin': 0x1400,
  21467. 'end': 0x167F
  21468. },
  21469. {
  21470. 'begin': 0x1680,
  21471. 'end': 0x169F
  21472. },
  21473. {
  21474. 'begin': 0x16A0,
  21475. 'end': 0x16FF
  21476. },
  21477. {
  21478. 'begin': 0x1780,
  21479. 'end': 0x17FF
  21480. },
  21481. {
  21482. 'begin': 0x1800,
  21483. 'end': 0x18AF
  21484. },
  21485. {
  21486. 'begin': 0x2800,
  21487. 'end': 0x28FF
  21488. },
  21489. {
  21490. 'begin': 0xA000,
  21491. 'end': 0xA48F
  21492. },
  21493. {
  21494. 'begin': 0x1700,
  21495. 'end': 0x171F
  21496. },
  21497. {
  21498. 'begin': 0x10300,
  21499. 'end': 0x1032F
  21500. },
  21501. {
  21502. 'begin': 0x10330,
  21503. 'end': 0x1034F
  21504. },
  21505. {
  21506. 'begin': 0x10400,
  21507. 'end': 0x1044F
  21508. },
  21509. {
  21510. 'begin': 0x1D000,
  21511. 'end': 0x1D0FF
  21512. },
  21513. {
  21514. 'begin': 0x1D400,
  21515. 'end': 0x1D7FF
  21516. },
  21517. {
  21518. 'begin': 0xFF000,
  21519. 'end': 0xFFFFD
  21520. },
  21521. {
  21522. 'begin': 0xFE00,
  21523. 'end': 0xFE0F
  21524. },
  21525. {
  21526. 'begin': 0xE0000,
  21527. 'end': 0xE007F
  21528. },
  21529. {
  21530. 'begin': 0x1900,
  21531. 'end': 0x194F
  21532. },
  21533. {
  21534. 'begin': 0x1950,
  21535. 'end': 0x197F
  21536. },
  21537. {
  21538. 'begin': 0x1980,
  21539. 'end': 0x19DF
  21540. },
  21541. {
  21542. 'begin': 0x1A00,
  21543. 'end': 0x1A1F
  21544. },
  21545. {
  21546. 'begin': 0x2C00,
  21547. 'end': 0x2C5F
  21548. },
  21549. {
  21550. 'begin': 0x2D30,
  21551. 'end': 0x2D7F
  21552. },
  21553. {
  21554. 'begin': 0x4DC0,
  21555. 'end': 0x4DFF
  21556. },
  21557. {
  21558. 'begin': 0xA800,
  21559. 'end': 0xA82F
  21560. },
  21561. {
  21562. 'begin': 0x10000,
  21563. 'end': 0x1007F
  21564. },
  21565. {
  21566. 'begin': 0x10140,
  21567. 'end': 0x1018F
  21568. },
  21569. {
  21570. 'begin': 0x10380,
  21571. 'end': 0x1039F
  21572. },
  21573. {
  21574. 'begin': 0x103A0,
  21575. 'end': 0x103DF
  21576. },
  21577. {
  21578. 'begin': 0x10450,
  21579. 'end': 0x1047F
  21580. },
  21581. {
  21582. 'begin': 0x10480,
  21583. 'end': 0x104AF
  21584. },
  21585. {
  21586. 'begin': 0x10800,
  21587. 'end': 0x1083F
  21588. },
  21589. {
  21590. 'begin': 0x10A00,
  21591. 'end': 0x10A5F
  21592. },
  21593. {
  21594. 'begin': 0x1D300,
  21595. 'end': 0x1D35F
  21596. },
  21597. {
  21598. 'begin': 0x12000,
  21599. 'end': 0x123FF
  21600. },
  21601. {
  21602. 'begin': 0x1D360,
  21603. 'end': 0x1D37F
  21604. },
  21605. {
  21606. 'begin': 0x1B80,
  21607. 'end': 0x1BBF
  21608. },
  21609. {
  21610. 'begin': 0x1C00,
  21611. 'end': 0x1C4F
  21612. },
  21613. {
  21614. 'begin': 0x1C50,
  21615. 'end': 0x1C7F
  21616. },
  21617. {
  21618. 'begin': 0xA880,
  21619. 'end': 0xA8DF
  21620. },
  21621. {
  21622. 'begin': 0xA900,
  21623. 'end': 0xA92F
  21624. },
  21625. {
  21626. 'begin': 0xA930,
  21627. 'end': 0xA95F
  21628. },
  21629. {
  21630. 'begin': 0xAA00,
  21631. 'end': 0xAA5F
  21632. },
  21633. {
  21634. 'begin': 0x10190,
  21635. 'end': 0x101CF
  21636. },
  21637. {
  21638. 'begin': 0x101D0,
  21639. 'end': 0x101FF
  21640. },
  21641. {
  21642. 'begin': 0x102A0,
  21643. 'end': 0x102DF
  21644. },
  21645. {
  21646. 'begin': 0x1F030,
  21647. 'end': 0x1F09F
  21648. }
  21649. ];
  21650. function getUnicodeRangeFor(value) {
  21651. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21652. var range = UnicodeRanges[i];
  21653. if (value >= range.begin && value < range.end) {
  21654. return i;
  21655. }
  21656. }
  21657. return -1;
  21658. }
  21659. function isRTLRangeFor(value) {
  21660. var range = UnicodeRanges[13];
  21661. if (value >= range.begin && value < range.end) {
  21662. return true;
  21663. }
  21664. range = UnicodeRanges[11];
  21665. if (value >= range.begin && value < range.end) {
  21666. return true;
  21667. }
  21668. return false;
  21669. }
  21670. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21671. t['\u00A8'] = '\u0020\u0308';
  21672. t['\u00AF'] = '\u0020\u0304';
  21673. t['\u00B4'] = '\u0020\u0301';
  21674. t['\u00B5'] = '\u03BC';
  21675. t['\u00B8'] = '\u0020\u0327';
  21676. t['\u0132'] = '\u0049\u004A';
  21677. t['\u0133'] = '\u0069\u006A';
  21678. t['\u013F'] = '\u004C\u00B7';
  21679. t['\u0140'] = '\u006C\u00B7';
  21680. t['\u0149'] = '\u02BC\u006E';
  21681. t['\u017F'] = '\u0073';
  21682. t['\u01C4'] = '\u0044\u017D';
  21683. t['\u01C5'] = '\u0044\u017E';
  21684. t['\u01C6'] = '\u0064\u017E';
  21685. t['\u01C7'] = '\u004C\u004A';
  21686. t['\u01C8'] = '\u004C\u006A';
  21687. t['\u01C9'] = '\u006C\u006A';
  21688. t['\u01CA'] = '\u004E\u004A';
  21689. t['\u01CB'] = '\u004E\u006A';
  21690. t['\u01CC'] = '\u006E\u006A';
  21691. t['\u01F1'] = '\u0044\u005A';
  21692. t['\u01F2'] = '\u0044\u007A';
  21693. t['\u01F3'] = '\u0064\u007A';
  21694. t['\u02D8'] = '\u0020\u0306';
  21695. t['\u02D9'] = '\u0020\u0307';
  21696. t['\u02DA'] = '\u0020\u030A';
  21697. t['\u02DB'] = '\u0020\u0328';
  21698. t['\u02DC'] = '\u0020\u0303';
  21699. t['\u02DD'] = '\u0020\u030B';
  21700. t['\u037A'] = '\u0020\u0345';
  21701. t['\u0384'] = '\u0020\u0301';
  21702. t['\u03D0'] = '\u03B2';
  21703. t['\u03D1'] = '\u03B8';
  21704. t['\u03D2'] = '\u03A5';
  21705. t['\u03D5'] = '\u03C6';
  21706. t['\u03D6'] = '\u03C0';
  21707. t['\u03F0'] = '\u03BA';
  21708. t['\u03F1'] = '\u03C1';
  21709. t['\u03F2'] = '\u03C2';
  21710. t['\u03F4'] = '\u0398';
  21711. t['\u03F5'] = '\u03B5';
  21712. t['\u03F9'] = '\u03A3';
  21713. t['\u0587'] = '\u0565\u0582';
  21714. t['\u0675'] = '\u0627\u0674';
  21715. t['\u0676'] = '\u0648\u0674';
  21716. t['\u0677'] = '\u06C7\u0674';
  21717. t['\u0678'] = '\u064A\u0674';
  21718. t['\u0E33'] = '\u0E4D\u0E32';
  21719. t['\u0EB3'] = '\u0ECD\u0EB2';
  21720. t['\u0EDC'] = '\u0EAB\u0E99';
  21721. t['\u0EDD'] = '\u0EAB\u0EA1';
  21722. t['\u0F77'] = '\u0FB2\u0F81';
  21723. t['\u0F79'] = '\u0FB3\u0F81';
  21724. t['\u1E9A'] = '\u0061\u02BE';
  21725. t['\u1FBD'] = '\u0020\u0313';
  21726. t['\u1FBF'] = '\u0020\u0313';
  21727. t['\u1FC0'] = '\u0020\u0342';
  21728. t['\u1FFE'] = '\u0020\u0314';
  21729. t['\u2002'] = '\u0020';
  21730. t['\u2003'] = '\u0020';
  21731. t['\u2004'] = '\u0020';
  21732. t['\u2005'] = '\u0020';
  21733. t['\u2006'] = '\u0020';
  21734. t['\u2008'] = '\u0020';
  21735. t['\u2009'] = '\u0020';
  21736. t['\u200A'] = '\u0020';
  21737. t['\u2017'] = '\u0020\u0333';
  21738. t['\u2024'] = '\u002E';
  21739. t['\u2025'] = '\u002E\u002E';
  21740. t['\u2026'] = '\u002E\u002E\u002E';
  21741. t['\u2033'] = '\u2032\u2032';
  21742. t['\u2034'] = '\u2032\u2032\u2032';
  21743. t['\u2036'] = '\u2035\u2035';
  21744. t['\u2037'] = '\u2035\u2035\u2035';
  21745. t['\u203C'] = '\u0021\u0021';
  21746. t['\u203E'] = '\u0020\u0305';
  21747. t['\u2047'] = '\u003F\u003F';
  21748. t['\u2048'] = '\u003F\u0021';
  21749. t['\u2049'] = '\u0021\u003F';
  21750. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21751. t['\u205F'] = '\u0020';
  21752. t['\u20A8'] = '\u0052\u0073';
  21753. t['\u2100'] = '\u0061\u002F\u0063';
  21754. t['\u2101'] = '\u0061\u002F\u0073';
  21755. t['\u2103'] = '\u00B0\u0043';
  21756. t['\u2105'] = '\u0063\u002F\u006F';
  21757. t['\u2106'] = '\u0063\u002F\u0075';
  21758. t['\u2107'] = '\u0190';
  21759. t['\u2109'] = '\u00B0\u0046';
  21760. t['\u2116'] = '\u004E\u006F';
  21761. t['\u2121'] = '\u0054\u0045\u004C';
  21762. t['\u2135'] = '\u05D0';
  21763. t['\u2136'] = '\u05D1';
  21764. t['\u2137'] = '\u05D2';
  21765. t['\u2138'] = '\u05D3';
  21766. t['\u213B'] = '\u0046\u0041\u0058';
  21767. t['\u2160'] = '\u0049';
  21768. t['\u2161'] = '\u0049\u0049';
  21769. t['\u2162'] = '\u0049\u0049\u0049';
  21770. t['\u2163'] = '\u0049\u0056';
  21771. t['\u2164'] = '\u0056';
  21772. t['\u2165'] = '\u0056\u0049';
  21773. t['\u2166'] = '\u0056\u0049\u0049';
  21774. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21775. t['\u2168'] = '\u0049\u0058';
  21776. t['\u2169'] = '\u0058';
  21777. t['\u216A'] = '\u0058\u0049';
  21778. t['\u216B'] = '\u0058\u0049\u0049';
  21779. t['\u216C'] = '\u004C';
  21780. t['\u216D'] = '\u0043';
  21781. t['\u216E'] = '\u0044';
  21782. t['\u216F'] = '\u004D';
  21783. t['\u2170'] = '\u0069';
  21784. t['\u2171'] = '\u0069\u0069';
  21785. t['\u2172'] = '\u0069\u0069\u0069';
  21786. t['\u2173'] = '\u0069\u0076';
  21787. t['\u2174'] = '\u0076';
  21788. t['\u2175'] = '\u0076\u0069';
  21789. t['\u2176'] = '\u0076\u0069\u0069';
  21790. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21791. t['\u2178'] = '\u0069\u0078';
  21792. t['\u2179'] = '\u0078';
  21793. t['\u217A'] = '\u0078\u0069';
  21794. t['\u217B'] = '\u0078\u0069\u0069';
  21795. t['\u217C'] = '\u006C';
  21796. t['\u217D'] = '\u0063';
  21797. t['\u217E'] = '\u0064';
  21798. t['\u217F'] = '\u006D';
  21799. t['\u222C'] = '\u222B\u222B';
  21800. t['\u222D'] = '\u222B\u222B\u222B';
  21801. t['\u222F'] = '\u222E\u222E';
  21802. t['\u2230'] = '\u222E\u222E\u222E';
  21803. t['\u2474'] = '\u0028\u0031\u0029';
  21804. t['\u2475'] = '\u0028\u0032\u0029';
  21805. t['\u2476'] = '\u0028\u0033\u0029';
  21806. t['\u2477'] = '\u0028\u0034\u0029';
  21807. t['\u2478'] = '\u0028\u0035\u0029';
  21808. t['\u2479'] = '\u0028\u0036\u0029';
  21809. t['\u247A'] = '\u0028\u0037\u0029';
  21810. t['\u247B'] = '\u0028\u0038\u0029';
  21811. t['\u247C'] = '\u0028\u0039\u0029';
  21812. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21813. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21814. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21815. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21816. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21817. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21818. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21819. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21820. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21821. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21822. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21823. t['\u2488'] = '\u0031\u002E';
  21824. t['\u2489'] = '\u0032\u002E';
  21825. t['\u248A'] = '\u0033\u002E';
  21826. t['\u248B'] = '\u0034\u002E';
  21827. t['\u248C'] = '\u0035\u002E';
  21828. t['\u248D'] = '\u0036\u002E';
  21829. t['\u248E'] = '\u0037\u002E';
  21830. t['\u248F'] = '\u0038\u002E';
  21831. t['\u2490'] = '\u0039\u002E';
  21832. t['\u2491'] = '\u0031\u0030\u002E';
  21833. t['\u2492'] = '\u0031\u0031\u002E';
  21834. t['\u2493'] = '\u0031\u0032\u002E';
  21835. t['\u2494'] = '\u0031\u0033\u002E';
  21836. t['\u2495'] = '\u0031\u0034\u002E';
  21837. t['\u2496'] = '\u0031\u0035\u002E';
  21838. t['\u2497'] = '\u0031\u0036\u002E';
  21839. t['\u2498'] = '\u0031\u0037\u002E';
  21840. t['\u2499'] = '\u0031\u0038\u002E';
  21841. t['\u249A'] = '\u0031\u0039\u002E';
  21842. t['\u249B'] = '\u0032\u0030\u002E';
  21843. t['\u249C'] = '\u0028\u0061\u0029';
  21844. t['\u249D'] = '\u0028\u0062\u0029';
  21845. t['\u249E'] = '\u0028\u0063\u0029';
  21846. t['\u249F'] = '\u0028\u0064\u0029';
  21847. t['\u24A0'] = '\u0028\u0065\u0029';
  21848. t['\u24A1'] = '\u0028\u0066\u0029';
  21849. t['\u24A2'] = '\u0028\u0067\u0029';
  21850. t['\u24A3'] = '\u0028\u0068\u0029';
  21851. t['\u24A4'] = '\u0028\u0069\u0029';
  21852. t['\u24A5'] = '\u0028\u006A\u0029';
  21853. t['\u24A6'] = '\u0028\u006B\u0029';
  21854. t['\u24A7'] = '\u0028\u006C\u0029';
  21855. t['\u24A8'] = '\u0028\u006D\u0029';
  21856. t['\u24A9'] = '\u0028\u006E\u0029';
  21857. t['\u24AA'] = '\u0028\u006F\u0029';
  21858. t['\u24AB'] = '\u0028\u0070\u0029';
  21859. t['\u24AC'] = '\u0028\u0071\u0029';
  21860. t['\u24AD'] = '\u0028\u0072\u0029';
  21861. t['\u24AE'] = '\u0028\u0073\u0029';
  21862. t['\u24AF'] = '\u0028\u0074\u0029';
  21863. t['\u24B0'] = '\u0028\u0075\u0029';
  21864. t['\u24B1'] = '\u0028\u0076\u0029';
  21865. t['\u24B2'] = '\u0028\u0077\u0029';
  21866. t['\u24B3'] = '\u0028\u0078\u0029';
  21867. t['\u24B4'] = '\u0028\u0079\u0029';
  21868. t['\u24B5'] = '\u0028\u007A\u0029';
  21869. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21870. t['\u2A74'] = '\u003A\u003A\u003D';
  21871. t['\u2A75'] = '\u003D\u003D';
  21872. t['\u2A76'] = '\u003D\u003D\u003D';
  21873. t['\u2E9F'] = '\u6BCD';
  21874. t['\u2EF3'] = '\u9F9F';
  21875. t['\u2F00'] = '\u4E00';
  21876. t['\u2F01'] = '\u4E28';
  21877. t['\u2F02'] = '\u4E36';
  21878. t['\u2F03'] = '\u4E3F';
  21879. t['\u2F04'] = '\u4E59';
  21880. t['\u2F05'] = '\u4E85';
  21881. t['\u2F06'] = '\u4E8C';
  21882. t['\u2F07'] = '\u4EA0';
  21883. t['\u2F08'] = '\u4EBA';
  21884. t['\u2F09'] = '\u513F';
  21885. t['\u2F0A'] = '\u5165';
  21886. t['\u2F0B'] = '\u516B';
  21887. t['\u2F0C'] = '\u5182';
  21888. t['\u2F0D'] = '\u5196';
  21889. t['\u2F0E'] = '\u51AB';
  21890. t['\u2F0F'] = '\u51E0';
  21891. t['\u2F10'] = '\u51F5';
  21892. t['\u2F11'] = '\u5200';
  21893. t['\u2F12'] = '\u529B';
  21894. t['\u2F13'] = '\u52F9';
  21895. t['\u2F14'] = '\u5315';
  21896. t['\u2F15'] = '\u531A';
  21897. t['\u2F16'] = '\u5338';
  21898. t['\u2F17'] = '\u5341';
  21899. t['\u2F18'] = '\u535C';
  21900. t['\u2F19'] = '\u5369';
  21901. t['\u2F1A'] = '\u5382';
  21902. t['\u2F1B'] = '\u53B6';
  21903. t['\u2F1C'] = '\u53C8';
  21904. t['\u2F1D'] = '\u53E3';
  21905. t['\u2F1E'] = '\u56D7';
  21906. t['\u2F1F'] = '\u571F';
  21907. t['\u2F20'] = '\u58EB';
  21908. t['\u2F21'] = '\u5902';
  21909. t['\u2F22'] = '\u590A';
  21910. t['\u2F23'] = '\u5915';
  21911. t['\u2F24'] = '\u5927';
  21912. t['\u2F25'] = '\u5973';
  21913. t['\u2F26'] = '\u5B50';
  21914. t['\u2F27'] = '\u5B80';
  21915. t['\u2F28'] = '\u5BF8';
  21916. t['\u2F29'] = '\u5C0F';
  21917. t['\u2F2A'] = '\u5C22';
  21918. t['\u2F2B'] = '\u5C38';
  21919. t['\u2F2C'] = '\u5C6E';
  21920. t['\u2F2D'] = '\u5C71';
  21921. t['\u2F2E'] = '\u5DDB';
  21922. t['\u2F2F'] = '\u5DE5';
  21923. t['\u2F30'] = '\u5DF1';
  21924. t['\u2F31'] = '\u5DFE';
  21925. t['\u2F32'] = '\u5E72';
  21926. t['\u2F33'] = '\u5E7A';
  21927. t['\u2F34'] = '\u5E7F';
  21928. t['\u2F35'] = '\u5EF4';
  21929. t['\u2F36'] = '\u5EFE';
  21930. t['\u2F37'] = '\u5F0B';
  21931. t['\u2F38'] = '\u5F13';
  21932. t['\u2F39'] = '\u5F50';
  21933. t['\u2F3A'] = '\u5F61';
  21934. t['\u2F3B'] = '\u5F73';
  21935. t['\u2F3C'] = '\u5FC3';
  21936. t['\u2F3D'] = '\u6208';
  21937. t['\u2F3E'] = '\u6236';
  21938. t['\u2F3F'] = '\u624B';
  21939. t['\u2F40'] = '\u652F';
  21940. t['\u2F41'] = '\u6534';
  21941. t['\u2F42'] = '\u6587';
  21942. t['\u2F43'] = '\u6597';
  21943. t['\u2F44'] = '\u65A4';
  21944. t['\u2F45'] = '\u65B9';
  21945. t['\u2F46'] = '\u65E0';
  21946. t['\u2F47'] = '\u65E5';
  21947. t['\u2F48'] = '\u66F0';
  21948. t['\u2F49'] = '\u6708';
  21949. t['\u2F4A'] = '\u6728';
  21950. t['\u2F4B'] = '\u6B20';
  21951. t['\u2F4C'] = '\u6B62';
  21952. t['\u2F4D'] = '\u6B79';
  21953. t['\u2F4E'] = '\u6BB3';
  21954. t['\u2F4F'] = '\u6BCB';
  21955. t['\u2F50'] = '\u6BD4';
  21956. t['\u2F51'] = '\u6BDB';
  21957. t['\u2F52'] = '\u6C0F';
  21958. t['\u2F53'] = '\u6C14';
  21959. t['\u2F54'] = '\u6C34';
  21960. t['\u2F55'] = '\u706B';
  21961. t['\u2F56'] = '\u722A';
  21962. t['\u2F57'] = '\u7236';
  21963. t['\u2F58'] = '\u723B';
  21964. t['\u2F59'] = '\u723F';
  21965. t['\u2F5A'] = '\u7247';
  21966. t['\u2F5B'] = '\u7259';
  21967. t['\u2F5C'] = '\u725B';
  21968. t['\u2F5D'] = '\u72AC';
  21969. t['\u2F5E'] = '\u7384';
  21970. t['\u2F5F'] = '\u7389';
  21971. t['\u2F60'] = '\u74DC';
  21972. t['\u2F61'] = '\u74E6';
  21973. t['\u2F62'] = '\u7518';
  21974. t['\u2F63'] = '\u751F';
  21975. t['\u2F64'] = '\u7528';
  21976. t['\u2F65'] = '\u7530';
  21977. t['\u2F66'] = '\u758B';
  21978. t['\u2F67'] = '\u7592';
  21979. t['\u2F68'] = '\u7676';
  21980. t['\u2F69'] = '\u767D';
  21981. t['\u2F6A'] = '\u76AE';
  21982. t['\u2F6B'] = '\u76BF';
  21983. t['\u2F6C'] = '\u76EE';
  21984. t['\u2F6D'] = '\u77DB';
  21985. t['\u2F6E'] = '\u77E2';
  21986. t['\u2F6F'] = '\u77F3';
  21987. t['\u2F70'] = '\u793A';
  21988. t['\u2F71'] = '\u79B8';
  21989. t['\u2F72'] = '\u79BE';
  21990. t['\u2F73'] = '\u7A74';
  21991. t['\u2F74'] = '\u7ACB';
  21992. t['\u2F75'] = '\u7AF9';
  21993. t['\u2F76'] = '\u7C73';
  21994. t['\u2F77'] = '\u7CF8';
  21995. t['\u2F78'] = '\u7F36';
  21996. t['\u2F79'] = '\u7F51';
  21997. t['\u2F7A'] = '\u7F8A';
  21998. t['\u2F7B'] = '\u7FBD';
  21999. t['\u2F7C'] = '\u8001';
  22000. t['\u2F7D'] = '\u800C';
  22001. t['\u2F7E'] = '\u8012';
  22002. t['\u2F7F'] = '\u8033';
  22003. t['\u2F80'] = '\u807F';
  22004. t['\u2F81'] = '\u8089';
  22005. t['\u2F82'] = '\u81E3';
  22006. t['\u2F83'] = '\u81EA';
  22007. t['\u2F84'] = '\u81F3';
  22008. t['\u2F85'] = '\u81FC';
  22009. t['\u2F86'] = '\u820C';
  22010. t['\u2F87'] = '\u821B';
  22011. t['\u2F88'] = '\u821F';
  22012. t['\u2F89'] = '\u826E';
  22013. t['\u2F8A'] = '\u8272';
  22014. t['\u2F8B'] = '\u8278';
  22015. t['\u2F8C'] = '\u864D';
  22016. t['\u2F8D'] = '\u866B';
  22017. t['\u2F8E'] = '\u8840';
  22018. t['\u2F8F'] = '\u884C';
  22019. t['\u2F90'] = '\u8863';
  22020. t['\u2F91'] = '\u897E';
  22021. t['\u2F92'] = '\u898B';
  22022. t['\u2F93'] = '\u89D2';
  22023. t['\u2F94'] = '\u8A00';
  22024. t['\u2F95'] = '\u8C37';
  22025. t['\u2F96'] = '\u8C46';
  22026. t['\u2F97'] = '\u8C55';
  22027. t['\u2F98'] = '\u8C78';
  22028. t['\u2F99'] = '\u8C9D';
  22029. t['\u2F9A'] = '\u8D64';
  22030. t['\u2F9B'] = '\u8D70';
  22031. t['\u2F9C'] = '\u8DB3';
  22032. t['\u2F9D'] = '\u8EAB';
  22033. t['\u2F9E'] = '\u8ECA';
  22034. t['\u2F9F'] = '\u8F9B';
  22035. t['\u2FA0'] = '\u8FB0';
  22036. t['\u2FA1'] = '\u8FB5';
  22037. t['\u2FA2'] = '\u9091';
  22038. t['\u2FA3'] = '\u9149';
  22039. t['\u2FA4'] = '\u91C6';
  22040. t['\u2FA5'] = '\u91CC';
  22041. t['\u2FA6'] = '\u91D1';
  22042. t['\u2FA7'] = '\u9577';
  22043. t['\u2FA8'] = '\u9580';
  22044. t['\u2FA9'] = '\u961C';
  22045. t['\u2FAA'] = '\u96B6';
  22046. t['\u2FAB'] = '\u96B9';
  22047. t['\u2FAC'] = '\u96E8';
  22048. t['\u2FAD'] = '\u9751';
  22049. t['\u2FAE'] = '\u975E';
  22050. t['\u2FAF'] = '\u9762';
  22051. t['\u2FB0'] = '\u9769';
  22052. t['\u2FB1'] = '\u97CB';
  22053. t['\u2FB2'] = '\u97ED';
  22054. t['\u2FB3'] = '\u97F3';
  22055. t['\u2FB4'] = '\u9801';
  22056. t['\u2FB5'] = '\u98A8';
  22057. t['\u2FB6'] = '\u98DB';
  22058. t['\u2FB7'] = '\u98DF';
  22059. t['\u2FB8'] = '\u9996';
  22060. t['\u2FB9'] = '\u9999';
  22061. t['\u2FBA'] = '\u99AC';
  22062. t['\u2FBB'] = '\u9AA8';
  22063. t['\u2FBC'] = '\u9AD8';
  22064. t['\u2FBD'] = '\u9ADF';
  22065. t['\u2FBE'] = '\u9B25';
  22066. t['\u2FBF'] = '\u9B2F';
  22067. t['\u2FC0'] = '\u9B32';
  22068. t['\u2FC1'] = '\u9B3C';
  22069. t['\u2FC2'] = '\u9B5A';
  22070. t['\u2FC3'] = '\u9CE5';
  22071. t['\u2FC4'] = '\u9E75';
  22072. t['\u2FC5'] = '\u9E7F';
  22073. t['\u2FC6'] = '\u9EA5';
  22074. t['\u2FC7'] = '\u9EBB';
  22075. t['\u2FC8'] = '\u9EC3';
  22076. t['\u2FC9'] = '\u9ECD';
  22077. t['\u2FCA'] = '\u9ED1';
  22078. t['\u2FCB'] = '\u9EF9';
  22079. t['\u2FCC'] = '\u9EFD';
  22080. t['\u2FCD'] = '\u9F0E';
  22081. t['\u2FCE'] = '\u9F13';
  22082. t['\u2FCF'] = '\u9F20';
  22083. t['\u2FD0'] = '\u9F3B';
  22084. t['\u2FD1'] = '\u9F4A';
  22085. t['\u2FD2'] = '\u9F52';
  22086. t['\u2FD3'] = '\u9F8D';
  22087. t['\u2FD4'] = '\u9F9C';
  22088. t['\u2FD5'] = '\u9FA0';
  22089. t['\u3036'] = '\u3012';
  22090. t['\u3038'] = '\u5341';
  22091. t['\u3039'] = '\u5344';
  22092. t['\u303A'] = '\u5345';
  22093. t['\u309B'] = '\u0020\u3099';
  22094. t['\u309C'] = '\u0020\u309A';
  22095. t['\u3131'] = '\u1100';
  22096. t['\u3132'] = '\u1101';
  22097. t['\u3133'] = '\u11AA';
  22098. t['\u3134'] = '\u1102';
  22099. t['\u3135'] = '\u11AC';
  22100. t['\u3136'] = '\u11AD';
  22101. t['\u3137'] = '\u1103';
  22102. t['\u3138'] = '\u1104';
  22103. t['\u3139'] = '\u1105';
  22104. t['\u313A'] = '\u11B0';
  22105. t['\u313B'] = '\u11B1';
  22106. t['\u313C'] = '\u11B2';
  22107. t['\u313D'] = '\u11B3';
  22108. t['\u313E'] = '\u11B4';
  22109. t['\u313F'] = '\u11B5';
  22110. t['\u3140'] = '\u111A';
  22111. t['\u3141'] = '\u1106';
  22112. t['\u3142'] = '\u1107';
  22113. t['\u3143'] = '\u1108';
  22114. t['\u3144'] = '\u1121';
  22115. t['\u3145'] = '\u1109';
  22116. t['\u3146'] = '\u110A';
  22117. t['\u3147'] = '\u110B';
  22118. t['\u3148'] = '\u110C';
  22119. t['\u3149'] = '\u110D';
  22120. t['\u314A'] = '\u110E';
  22121. t['\u314B'] = '\u110F';
  22122. t['\u314C'] = '\u1110';
  22123. t['\u314D'] = '\u1111';
  22124. t['\u314E'] = '\u1112';
  22125. t['\u314F'] = '\u1161';
  22126. t['\u3150'] = '\u1162';
  22127. t['\u3151'] = '\u1163';
  22128. t['\u3152'] = '\u1164';
  22129. t['\u3153'] = '\u1165';
  22130. t['\u3154'] = '\u1166';
  22131. t['\u3155'] = '\u1167';
  22132. t['\u3156'] = '\u1168';
  22133. t['\u3157'] = '\u1169';
  22134. t['\u3158'] = '\u116A';
  22135. t['\u3159'] = '\u116B';
  22136. t['\u315A'] = '\u116C';
  22137. t['\u315B'] = '\u116D';
  22138. t['\u315C'] = '\u116E';
  22139. t['\u315D'] = '\u116F';
  22140. t['\u315E'] = '\u1170';
  22141. t['\u315F'] = '\u1171';
  22142. t['\u3160'] = '\u1172';
  22143. t['\u3161'] = '\u1173';
  22144. t['\u3162'] = '\u1174';
  22145. t['\u3163'] = '\u1175';
  22146. t['\u3164'] = '\u1160';
  22147. t['\u3165'] = '\u1114';
  22148. t['\u3166'] = '\u1115';
  22149. t['\u3167'] = '\u11C7';
  22150. t['\u3168'] = '\u11C8';
  22151. t['\u3169'] = '\u11CC';
  22152. t['\u316A'] = '\u11CE';
  22153. t['\u316B'] = '\u11D3';
  22154. t['\u316C'] = '\u11D7';
  22155. t['\u316D'] = '\u11D9';
  22156. t['\u316E'] = '\u111C';
  22157. t['\u316F'] = '\u11DD';
  22158. t['\u3170'] = '\u11DF';
  22159. t['\u3171'] = '\u111D';
  22160. t['\u3172'] = '\u111E';
  22161. t['\u3173'] = '\u1120';
  22162. t['\u3174'] = '\u1122';
  22163. t['\u3175'] = '\u1123';
  22164. t['\u3176'] = '\u1127';
  22165. t['\u3177'] = '\u1129';
  22166. t['\u3178'] = '\u112B';
  22167. t['\u3179'] = '\u112C';
  22168. t['\u317A'] = '\u112D';
  22169. t['\u317B'] = '\u112E';
  22170. t['\u317C'] = '\u112F';
  22171. t['\u317D'] = '\u1132';
  22172. t['\u317E'] = '\u1136';
  22173. t['\u317F'] = '\u1140';
  22174. t['\u3180'] = '\u1147';
  22175. t['\u3181'] = '\u114C';
  22176. t['\u3182'] = '\u11F1';
  22177. t['\u3183'] = '\u11F2';
  22178. t['\u3184'] = '\u1157';
  22179. t['\u3185'] = '\u1158';
  22180. t['\u3186'] = '\u1159';
  22181. t['\u3187'] = '\u1184';
  22182. t['\u3188'] = '\u1185';
  22183. t['\u3189'] = '\u1188';
  22184. t['\u318A'] = '\u1191';
  22185. t['\u318B'] = '\u1192';
  22186. t['\u318C'] = '\u1194';
  22187. t['\u318D'] = '\u119E';
  22188. t['\u318E'] = '\u11A1';
  22189. t['\u3200'] = '\u0028\u1100\u0029';
  22190. t['\u3201'] = '\u0028\u1102\u0029';
  22191. t['\u3202'] = '\u0028\u1103\u0029';
  22192. t['\u3203'] = '\u0028\u1105\u0029';
  22193. t['\u3204'] = '\u0028\u1106\u0029';
  22194. t['\u3205'] = '\u0028\u1107\u0029';
  22195. t['\u3206'] = '\u0028\u1109\u0029';
  22196. t['\u3207'] = '\u0028\u110B\u0029';
  22197. t['\u3208'] = '\u0028\u110C\u0029';
  22198. t['\u3209'] = '\u0028\u110E\u0029';
  22199. t['\u320A'] = '\u0028\u110F\u0029';
  22200. t['\u320B'] = '\u0028\u1110\u0029';
  22201. t['\u320C'] = '\u0028\u1111\u0029';
  22202. t['\u320D'] = '\u0028\u1112\u0029';
  22203. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22204. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22205. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22206. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22207. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22208. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22209. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22210. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22211. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22212. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22213. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22214. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22215. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22216. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22217. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22218. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22219. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22220. t['\u3220'] = '\u0028\u4E00\u0029';
  22221. t['\u3221'] = '\u0028\u4E8C\u0029';
  22222. t['\u3222'] = '\u0028\u4E09\u0029';
  22223. t['\u3223'] = '\u0028\u56DB\u0029';
  22224. t['\u3224'] = '\u0028\u4E94\u0029';
  22225. t['\u3225'] = '\u0028\u516D\u0029';
  22226. t['\u3226'] = '\u0028\u4E03\u0029';
  22227. t['\u3227'] = '\u0028\u516B\u0029';
  22228. t['\u3228'] = '\u0028\u4E5D\u0029';
  22229. t['\u3229'] = '\u0028\u5341\u0029';
  22230. t['\u322A'] = '\u0028\u6708\u0029';
  22231. t['\u322B'] = '\u0028\u706B\u0029';
  22232. t['\u322C'] = '\u0028\u6C34\u0029';
  22233. t['\u322D'] = '\u0028\u6728\u0029';
  22234. t['\u322E'] = '\u0028\u91D1\u0029';
  22235. t['\u322F'] = '\u0028\u571F\u0029';
  22236. t['\u3230'] = '\u0028\u65E5\u0029';
  22237. t['\u3231'] = '\u0028\u682A\u0029';
  22238. t['\u3232'] = '\u0028\u6709\u0029';
  22239. t['\u3233'] = '\u0028\u793E\u0029';
  22240. t['\u3234'] = '\u0028\u540D\u0029';
  22241. t['\u3235'] = '\u0028\u7279\u0029';
  22242. t['\u3236'] = '\u0028\u8CA1\u0029';
  22243. t['\u3237'] = '\u0028\u795D\u0029';
  22244. t['\u3238'] = '\u0028\u52B4\u0029';
  22245. t['\u3239'] = '\u0028\u4EE3\u0029';
  22246. t['\u323A'] = '\u0028\u547C\u0029';
  22247. t['\u323B'] = '\u0028\u5B66\u0029';
  22248. t['\u323C'] = '\u0028\u76E3\u0029';
  22249. t['\u323D'] = '\u0028\u4F01\u0029';
  22250. t['\u323E'] = '\u0028\u8CC7\u0029';
  22251. t['\u323F'] = '\u0028\u5354\u0029';
  22252. t['\u3240'] = '\u0028\u796D\u0029';
  22253. t['\u3241'] = '\u0028\u4F11\u0029';
  22254. t['\u3242'] = '\u0028\u81EA\u0029';
  22255. t['\u3243'] = '\u0028\u81F3\u0029';
  22256. t['\u32C0'] = '\u0031\u6708';
  22257. t['\u32C1'] = '\u0032\u6708';
  22258. t['\u32C2'] = '\u0033\u6708';
  22259. t['\u32C3'] = '\u0034\u6708';
  22260. t['\u32C4'] = '\u0035\u6708';
  22261. t['\u32C5'] = '\u0036\u6708';
  22262. t['\u32C6'] = '\u0037\u6708';
  22263. t['\u32C7'] = '\u0038\u6708';
  22264. t['\u32C8'] = '\u0039\u6708';
  22265. t['\u32C9'] = '\u0031\u0030\u6708';
  22266. t['\u32CA'] = '\u0031\u0031\u6708';
  22267. t['\u32CB'] = '\u0031\u0032\u6708';
  22268. t['\u3358'] = '\u0030\u70B9';
  22269. t['\u3359'] = '\u0031\u70B9';
  22270. t['\u335A'] = '\u0032\u70B9';
  22271. t['\u335B'] = '\u0033\u70B9';
  22272. t['\u335C'] = '\u0034\u70B9';
  22273. t['\u335D'] = '\u0035\u70B9';
  22274. t['\u335E'] = '\u0036\u70B9';
  22275. t['\u335F'] = '\u0037\u70B9';
  22276. t['\u3360'] = '\u0038\u70B9';
  22277. t['\u3361'] = '\u0039\u70B9';
  22278. t['\u3362'] = '\u0031\u0030\u70B9';
  22279. t['\u3363'] = '\u0031\u0031\u70B9';
  22280. t['\u3364'] = '\u0031\u0032\u70B9';
  22281. t['\u3365'] = '\u0031\u0033\u70B9';
  22282. t['\u3366'] = '\u0031\u0034\u70B9';
  22283. t['\u3367'] = '\u0031\u0035\u70B9';
  22284. t['\u3368'] = '\u0031\u0036\u70B9';
  22285. t['\u3369'] = '\u0031\u0037\u70B9';
  22286. t['\u336A'] = '\u0031\u0038\u70B9';
  22287. t['\u336B'] = '\u0031\u0039\u70B9';
  22288. t['\u336C'] = '\u0032\u0030\u70B9';
  22289. t['\u336D'] = '\u0032\u0031\u70B9';
  22290. t['\u336E'] = '\u0032\u0032\u70B9';
  22291. t['\u336F'] = '\u0032\u0033\u70B9';
  22292. t['\u3370'] = '\u0032\u0034\u70B9';
  22293. t['\u33E0'] = '\u0031\u65E5';
  22294. t['\u33E1'] = '\u0032\u65E5';
  22295. t['\u33E2'] = '\u0033\u65E5';
  22296. t['\u33E3'] = '\u0034\u65E5';
  22297. t['\u33E4'] = '\u0035\u65E5';
  22298. t['\u33E5'] = '\u0036\u65E5';
  22299. t['\u33E6'] = '\u0037\u65E5';
  22300. t['\u33E7'] = '\u0038\u65E5';
  22301. t['\u33E8'] = '\u0039\u65E5';
  22302. t['\u33E9'] = '\u0031\u0030\u65E5';
  22303. t['\u33EA'] = '\u0031\u0031\u65E5';
  22304. t['\u33EB'] = '\u0031\u0032\u65E5';
  22305. t['\u33EC'] = '\u0031\u0033\u65E5';
  22306. t['\u33ED'] = '\u0031\u0034\u65E5';
  22307. t['\u33EE'] = '\u0031\u0035\u65E5';
  22308. t['\u33EF'] = '\u0031\u0036\u65E5';
  22309. t['\u33F0'] = '\u0031\u0037\u65E5';
  22310. t['\u33F1'] = '\u0031\u0038\u65E5';
  22311. t['\u33F2'] = '\u0031\u0039\u65E5';
  22312. t['\u33F3'] = '\u0032\u0030\u65E5';
  22313. t['\u33F4'] = '\u0032\u0031\u65E5';
  22314. t['\u33F5'] = '\u0032\u0032\u65E5';
  22315. t['\u33F6'] = '\u0032\u0033\u65E5';
  22316. t['\u33F7'] = '\u0032\u0034\u65E5';
  22317. t['\u33F8'] = '\u0032\u0035\u65E5';
  22318. t['\u33F9'] = '\u0032\u0036\u65E5';
  22319. t['\u33FA'] = '\u0032\u0037\u65E5';
  22320. t['\u33FB'] = '\u0032\u0038\u65E5';
  22321. t['\u33FC'] = '\u0032\u0039\u65E5';
  22322. t['\u33FD'] = '\u0033\u0030\u65E5';
  22323. t['\u33FE'] = '\u0033\u0031\u65E5';
  22324. t['\uFB00'] = '\u0066\u0066';
  22325. t['\uFB01'] = '\u0066\u0069';
  22326. t['\uFB02'] = '\u0066\u006C';
  22327. t['\uFB03'] = '\u0066\u0066\u0069';
  22328. t['\uFB04'] = '\u0066\u0066\u006C';
  22329. t['\uFB05'] = '\u017F\u0074';
  22330. t['\uFB06'] = '\u0073\u0074';
  22331. t['\uFB13'] = '\u0574\u0576';
  22332. t['\uFB14'] = '\u0574\u0565';
  22333. t['\uFB15'] = '\u0574\u056B';
  22334. t['\uFB16'] = '\u057E\u0576';
  22335. t['\uFB17'] = '\u0574\u056D';
  22336. t['\uFB4F'] = '\u05D0\u05DC';
  22337. t['\uFB50'] = '\u0671';
  22338. t['\uFB51'] = '\u0671';
  22339. t['\uFB52'] = '\u067B';
  22340. t['\uFB53'] = '\u067B';
  22341. t['\uFB54'] = '\u067B';
  22342. t['\uFB55'] = '\u067B';
  22343. t['\uFB56'] = '\u067E';
  22344. t['\uFB57'] = '\u067E';
  22345. t['\uFB58'] = '\u067E';
  22346. t['\uFB59'] = '\u067E';
  22347. t['\uFB5A'] = '\u0680';
  22348. t['\uFB5B'] = '\u0680';
  22349. t['\uFB5C'] = '\u0680';
  22350. t['\uFB5D'] = '\u0680';
  22351. t['\uFB5E'] = '\u067A';
  22352. t['\uFB5F'] = '\u067A';
  22353. t['\uFB60'] = '\u067A';
  22354. t['\uFB61'] = '\u067A';
  22355. t['\uFB62'] = '\u067F';
  22356. t['\uFB63'] = '\u067F';
  22357. t['\uFB64'] = '\u067F';
  22358. t['\uFB65'] = '\u067F';
  22359. t['\uFB66'] = '\u0679';
  22360. t['\uFB67'] = '\u0679';
  22361. t['\uFB68'] = '\u0679';
  22362. t['\uFB69'] = '\u0679';
  22363. t['\uFB6A'] = '\u06A4';
  22364. t['\uFB6B'] = '\u06A4';
  22365. t['\uFB6C'] = '\u06A4';
  22366. t['\uFB6D'] = '\u06A4';
  22367. t['\uFB6E'] = '\u06A6';
  22368. t['\uFB6F'] = '\u06A6';
  22369. t['\uFB70'] = '\u06A6';
  22370. t['\uFB71'] = '\u06A6';
  22371. t['\uFB72'] = '\u0684';
  22372. t['\uFB73'] = '\u0684';
  22373. t['\uFB74'] = '\u0684';
  22374. t['\uFB75'] = '\u0684';
  22375. t['\uFB76'] = '\u0683';
  22376. t['\uFB77'] = '\u0683';
  22377. t['\uFB78'] = '\u0683';
  22378. t['\uFB79'] = '\u0683';
  22379. t['\uFB7A'] = '\u0686';
  22380. t['\uFB7B'] = '\u0686';
  22381. t['\uFB7C'] = '\u0686';
  22382. t['\uFB7D'] = '\u0686';
  22383. t['\uFB7E'] = '\u0687';
  22384. t['\uFB7F'] = '\u0687';
  22385. t['\uFB80'] = '\u0687';
  22386. t['\uFB81'] = '\u0687';
  22387. t['\uFB82'] = '\u068D';
  22388. t['\uFB83'] = '\u068D';
  22389. t['\uFB84'] = '\u068C';
  22390. t['\uFB85'] = '\u068C';
  22391. t['\uFB86'] = '\u068E';
  22392. t['\uFB87'] = '\u068E';
  22393. t['\uFB88'] = '\u0688';
  22394. t['\uFB89'] = '\u0688';
  22395. t['\uFB8A'] = '\u0698';
  22396. t['\uFB8B'] = '\u0698';
  22397. t['\uFB8C'] = '\u0691';
  22398. t['\uFB8D'] = '\u0691';
  22399. t['\uFB8E'] = '\u06A9';
  22400. t['\uFB8F'] = '\u06A9';
  22401. t['\uFB90'] = '\u06A9';
  22402. t['\uFB91'] = '\u06A9';
  22403. t['\uFB92'] = '\u06AF';
  22404. t['\uFB93'] = '\u06AF';
  22405. t['\uFB94'] = '\u06AF';
  22406. t['\uFB95'] = '\u06AF';
  22407. t['\uFB96'] = '\u06B3';
  22408. t['\uFB97'] = '\u06B3';
  22409. t['\uFB98'] = '\u06B3';
  22410. t['\uFB99'] = '\u06B3';
  22411. t['\uFB9A'] = '\u06B1';
  22412. t['\uFB9B'] = '\u06B1';
  22413. t['\uFB9C'] = '\u06B1';
  22414. t['\uFB9D'] = '\u06B1';
  22415. t['\uFB9E'] = '\u06BA';
  22416. t['\uFB9F'] = '\u06BA';
  22417. t['\uFBA0'] = '\u06BB';
  22418. t['\uFBA1'] = '\u06BB';
  22419. t['\uFBA2'] = '\u06BB';
  22420. t['\uFBA3'] = '\u06BB';
  22421. t['\uFBA4'] = '\u06C0';
  22422. t['\uFBA5'] = '\u06C0';
  22423. t['\uFBA6'] = '\u06C1';
  22424. t['\uFBA7'] = '\u06C1';
  22425. t['\uFBA8'] = '\u06C1';
  22426. t['\uFBA9'] = '\u06C1';
  22427. t['\uFBAA'] = '\u06BE';
  22428. t['\uFBAB'] = '\u06BE';
  22429. t['\uFBAC'] = '\u06BE';
  22430. t['\uFBAD'] = '\u06BE';
  22431. t['\uFBAE'] = '\u06D2';
  22432. t['\uFBAF'] = '\u06D2';
  22433. t['\uFBB0'] = '\u06D3';
  22434. t['\uFBB1'] = '\u06D3';
  22435. t['\uFBD3'] = '\u06AD';
  22436. t['\uFBD4'] = '\u06AD';
  22437. t['\uFBD5'] = '\u06AD';
  22438. t['\uFBD6'] = '\u06AD';
  22439. t['\uFBD7'] = '\u06C7';
  22440. t['\uFBD8'] = '\u06C7';
  22441. t['\uFBD9'] = '\u06C6';
  22442. t['\uFBDA'] = '\u06C6';
  22443. t['\uFBDB'] = '\u06C8';
  22444. t['\uFBDC'] = '\u06C8';
  22445. t['\uFBDD'] = '\u0677';
  22446. t['\uFBDE'] = '\u06CB';
  22447. t['\uFBDF'] = '\u06CB';
  22448. t['\uFBE0'] = '\u06C5';
  22449. t['\uFBE1'] = '\u06C5';
  22450. t['\uFBE2'] = '\u06C9';
  22451. t['\uFBE3'] = '\u06C9';
  22452. t['\uFBE4'] = '\u06D0';
  22453. t['\uFBE5'] = '\u06D0';
  22454. t['\uFBE6'] = '\u06D0';
  22455. t['\uFBE7'] = '\u06D0';
  22456. t['\uFBE8'] = '\u0649';
  22457. t['\uFBE9'] = '\u0649';
  22458. t['\uFBEA'] = '\u0626\u0627';
  22459. t['\uFBEB'] = '\u0626\u0627';
  22460. t['\uFBEC'] = '\u0626\u06D5';
  22461. t['\uFBED'] = '\u0626\u06D5';
  22462. t['\uFBEE'] = '\u0626\u0648';
  22463. t['\uFBEF'] = '\u0626\u0648';
  22464. t['\uFBF0'] = '\u0626\u06C7';
  22465. t['\uFBF1'] = '\u0626\u06C7';
  22466. t['\uFBF2'] = '\u0626\u06C6';
  22467. t['\uFBF3'] = '\u0626\u06C6';
  22468. t['\uFBF4'] = '\u0626\u06C8';
  22469. t['\uFBF5'] = '\u0626\u06C8';
  22470. t['\uFBF6'] = '\u0626\u06D0';
  22471. t['\uFBF7'] = '\u0626\u06D0';
  22472. t['\uFBF8'] = '\u0626\u06D0';
  22473. t['\uFBF9'] = '\u0626\u0649';
  22474. t['\uFBFA'] = '\u0626\u0649';
  22475. t['\uFBFB'] = '\u0626\u0649';
  22476. t['\uFBFC'] = '\u06CC';
  22477. t['\uFBFD'] = '\u06CC';
  22478. t['\uFBFE'] = '\u06CC';
  22479. t['\uFBFF'] = '\u06CC';
  22480. t['\uFC00'] = '\u0626\u062C';
  22481. t['\uFC01'] = '\u0626\u062D';
  22482. t['\uFC02'] = '\u0626\u0645';
  22483. t['\uFC03'] = '\u0626\u0649';
  22484. t['\uFC04'] = '\u0626\u064A';
  22485. t['\uFC05'] = '\u0628\u062C';
  22486. t['\uFC06'] = '\u0628\u062D';
  22487. t['\uFC07'] = '\u0628\u062E';
  22488. t['\uFC08'] = '\u0628\u0645';
  22489. t['\uFC09'] = '\u0628\u0649';
  22490. t['\uFC0A'] = '\u0628\u064A';
  22491. t['\uFC0B'] = '\u062A\u062C';
  22492. t['\uFC0C'] = '\u062A\u062D';
  22493. t['\uFC0D'] = '\u062A\u062E';
  22494. t['\uFC0E'] = '\u062A\u0645';
  22495. t['\uFC0F'] = '\u062A\u0649';
  22496. t['\uFC10'] = '\u062A\u064A';
  22497. t['\uFC11'] = '\u062B\u062C';
  22498. t['\uFC12'] = '\u062B\u0645';
  22499. t['\uFC13'] = '\u062B\u0649';
  22500. t['\uFC14'] = '\u062B\u064A';
  22501. t['\uFC15'] = '\u062C\u062D';
  22502. t['\uFC16'] = '\u062C\u0645';
  22503. t['\uFC17'] = '\u062D\u062C';
  22504. t['\uFC18'] = '\u062D\u0645';
  22505. t['\uFC19'] = '\u062E\u062C';
  22506. t['\uFC1A'] = '\u062E\u062D';
  22507. t['\uFC1B'] = '\u062E\u0645';
  22508. t['\uFC1C'] = '\u0633\u062C';
  22509. t['\uFC1D'] = '\u0633\u062D';
  22510. t['\uFC1E'] = '\u0633\u062E';
  22511. t['\uFC1F'] = '\u0633\u0645';
  22512. t['\uFC20'] = '\u0635\u062D';
  22513. t['\uFC21'] = '\u0635\u0645';
  22514. t['\uFC22'] = '\u0636\u062C';
  22515. t['\uFC23'] = '\u0636\u062D';
  22516. t['\uFC24'] = '\u0636\u062E';
  22517. t['\uFC25'] = '\u0636\u0645';
  22518. t['\uFC26'] = '\u0637\u062D';
  22519. t['\uFC27'] = '\u0637\u0645';
  22520. t['\uFC28'] = '\u0638\u0645';
  22521. t['\uFC29'] = '\u0639\u062C';
  22522. t['\uFC2A'] = '\u0639\u0645';
  22523. t['\uFC2B'] = '\u063A\u062C';
  22524. t['\uFC2C'] = '\u063A\u0645';
  22525. t['\uFC2D'] = '\u0641\u062C';
  22526. t['\uFC2E'] = '\u0641\u062D';
  22527. t['\uFC2F'] = '\u0641\u062E';
  22528. t['\uFC30'] = '\u0641\u0645';
  22529. t['\uFC31'] = '\u0641\u0649';
  22530. t['\uFC32'] = '\u0641\u064A';
  22531. t['\uFC33'] = '\u0642\u062D';
  22532. t['\uFC34'] = '\u0642\u0645';
  22533. t['\uFC35'] = '\u0642\u0649';
  22534. t['\uFC36'] = '\u0642\u064A';
  22535. t['\uFC37'] = '\u0643\u0627';
  22536. t['\uFC38'] = '\u0643\u062C';
  22537. t['\uFC39'] = '\u0643\u062D';
  22538. t['\uFC3A'] = '\u0643\u062E';
  22539. t['\uFC3B'] = '\u0643\u0644';
  22540. t['\uFC3C'] = '\u0643\u0645';
  22541. t['\uFC3D'] = '\u0643\u0649';
  22542. t['\uFC3E'] = '\u0643\u064A';
  22543. t['\uFC3F'] = '\u0644\u062C';
  22544. t['\uFC40'] = '\u0644\u062D';
  22545. t['\uFC41'] = '\u0644\u062E';
  22546. t['\uFC42'] = '\u0644\u0645';
  22547. t['\uFC43'] = '\u0644\u0649';
  22548. t['\uFC44'] = '\u0644\u064A';
  22549. t['\uFC45'] = '\u0645\u062C';
  22550. t['\uFC46'] = '\u0645\u062D';
  22551. t['\uFC47'] = '\u0645\u062E';
  22552. t['\uFC48'] = '\u0645\u0645';
  22553. t['\uFC49'] = '\u0645\u0649';
  22554. t['\uFC4A'] = '\u0645\u064A';
  22555. t['\uFC4B'] = '\u0646\u062C';
  22556. t['\uFC4C'] = '\u0646\u062D';
  22557. t['\uFC4D'] = '\u0646\u062E';
  22558. t['\uFC4E'] = '\u0646\u0645';
  22559. t['\uFC4F'] = '\u0646\u0649';
  22560. t['\uFC50'] = '\u0646\u064A';
  22561. t['\uFC51'] = '\u0647\u062C';
  22562. t['\uFC52'] = '\u0647\u0645';
  22563. t['\uFC53'] = '\u0647\u0649';
  22564. t['\uFC54'] = '\u0647\u064A';
  22565. t['\uFC55'] = '\u064A\u062C';
  22566. t['\uFC56'] = '\u064A\u062D';
  22567. t['\uFC57'] = '\u064A\u062E';
  22568. t['\uFC58'] = '\u064A\u0645';
  22569. t['\uFC59'] = '\u064A\u0649';
  22570. t['\uFC5A'] = '\u064A\u064A';
  22571. t['\uFC5B'] = '\u0630\u0670';
  22572. t['\uFC5C'] = '\u0631\u0670';
  22573. t['\uFC5D'] = '\u0649\u0670';
  22574. t['\uFC5E'] = '\u0020\u064C\u0651';
  22575. t['\uFC5F'] = '\u0020\u064D\u0651';
  22576. t['\uFC60'] = '\u0020\u064E\u0651';
  22577. t['\uFC61'] = '\u0020\u064F\u0651';
  22578. t['\uFC62'] = '\u0020\u0650\u0651';
  22579. t['\uFC63'] = '\u0020\u0651\u0670';
  22580. t['\uFC64'] = '\u0626\u0631';
  22581. t['\uFC65'] = '\u0626\u0632';
  22582. t['\uFC66'] = '\u0626\u0645';
  22583. t['\uFC67'] = '\u0626\u0646';
  22584. t['\uFC68'] = '\u0626\u0649';
  22585. t['\uFC69'] = '\u0626\u064A';
  22586. t['\uFC6A'] = '\u0628\u0631';
  22587. t['\uFC6B'] = '\u0628\u0632';
  22588. t['\uFC6C'] = '\u0628\u0645';
  22589. t['\uFC6D'] = '\u0628\u0646';
  22590. t['\uFC6E'] = '\u0628\u0649';
  22591. t['\uFC6F'] = '\u0628\u064A';
  22592. t['\uFC70'] = '\u062A\u0631';
  22593. t['\uFC71'] = '\u062A\u0632';
  22594. t['\uFC72'] = '\u062A\u0645';
  22595. t['\uFC73'] = '\u062A\u0646';
  22596. t['\uFC74'] = '\u062A\u0649';
  22597. t['\uFC75'] = '\u062A\u064A';
  22598. t['\uFC76'] = '\u062B\u0631';
  22599. t['\uFC77'] = '\u062B\u0632';
  22600. t['\uFC78'] = '\u062B\u0645';
  22601. t['\uFC79'] = '\u062B\u0646';
  22602. t['\uFC7A'] = '\u062B\u0649';
  22603. t['\uFC7B'] = '\u062B\u064A';
  22604. t['\uFC7C'] = '\u0641\u0649';
  22605. t['\uFC7D'] = '\u0641\u064A';
  22606. t['\uFC7E'] = '\u0642\u0649';
  22607. t['\uFC7F'] = '\u0642\u064A';
  22608. t['\uFC80'] = '\u0643\u0627';
  22609. t['\uFC81'] = '\u0643\u0644';
  22610. t['\uFC82'] = '\u0643\u0645';
  22611. t['\uFC83'] = '\u0643\u0649';
  22612. t['\uFC84'] = '\u0643\u064A';
  22613. t['\uFC85'] = '\u0644\u0645';
  22614. t['\uFC86'] = '\u0644\u0649';
  22615. t['\uFC87'] = '\u0644\u064A';
  22616. t['\uFC88'] = '\u0645\u0627';
  22617. t['\uFC89'] = '\u0645\u0645';
  22618. t['\uFC8A'] = '\u0646\u0631';
  22619. t['\uFC8B'] = '\u0646\u0632';
  22620. t['\uFC8C'] = '\u0646\u0645';
  22621. t['\uFC8D'] = '\u0646\u0646';
  22622. t['\uFC8E'] = '\u0646\u0649';
  22623. t['\uFC8F'] = '\u0646\u064A';
  22624. t['\uFC90'] = '\u0649\u0670';
  22625. t['\uFC91'] = '\u064A\u0631';
  22626. t['\uFC92'] = '\u064A\u0632';
  22627. t['\uFC93'] = '\u064A\u0645';
  22628. t['\uFC94'] = '\u064A\u0646';
  22629. t['\uFC95'] = '\u064A\u0649';
  22630. t['\uFC96'] = '\u064A\u064A';
  22631. t['\uFC97'] = '\u0626\u062C';
  22632. t['\uFC98'] = '\u0626\u062D';
  22633. t['\uFC99'] = '\u0626\u062E';
  22634. t['\uFC9A'] = '\u0626\u0645';
  22635. t['\uFC9B'] = '\u0626\u0647';
  22636. t['\uFC9C'] = '\u0628\u062C';
  22637. t['\uFC9D'] = '\u0628\u062D';
  22638. t['\uFC9E'] = '\u0628\u062E';
  22639. t['\uFC9F'] = '\u0628\u0645';
  22640. t['\uFCA0'] = '\u0628\u0647';
  22641. t['\uFCA1'] = '\u062A\u062C';
  22642. t['\uFCA2'] = '\u062A\u062D';
  22643. t['\uFCA3'] = '\u062A\u062E';
  22644. t['\uFCA4'] = '\u062A\u0645';
  22645. t['\uFCA5'] = '\u062A\u0647';
  22646. t['\uFCA6'] = '\u062B\u0645';
  22647. t['\uFCA7'] = '\u062C\u062D';
  22648. t['\uFCA8'] = '\u062C\u0645';
  22649. t['\uFCA9'] = '\u062D\u062C';
  22650. t['\uFCAA'] = '\u062D\u0645';
  22651. t['\uFCAB'] = '\u062E\u062C';
  22652. t['\uFCAC'] = '\u062E\u0645';
  22653. t['\uFCAD'] = '\u0633\u062C';
  22654. t['\uFCAE'] = '\u0633\u062D';
  22655. t['\uFCAF'] = '\u0633\u062E';
  22656. t['\uFCB0'] = '\u0633\u0645';
  22657. t['\uFCB1'] = '\u0635\u062D';
  22658. t['\uFCB2'] = '\u0635\u062E';
  22659. t['\uFCB3'] = '\u0635\u0645';
  22660. t['\uFCB4'] = '\u0636\u062C';
  22661. t['\uFCB5'] = '\u0636\u062D';
  22662. t['\uFCB6'] = '\u0636\u062E';
  22663. t['\uFCB7'] = '\u0636\u0645';
  22664. t['\uFCB8'] = '\u0637\u062D';
  22665. t['\uFCB9'] = '\u0638\u0645';
  22666. t['\uFCBA'] = '\u0639\u062C';
  22667. t['\uFCBB'] = '\u0639\u0645';
  22668. t['\uFCBC'] = '\u063A\u062C';
  22669. t['\uFCBD'] = '\u063A\u0645';
  22670. t['\uFCBE'] = '\u0641\u062C';
  22671. t['\uFCBF'] = '\u0641\u062D';
  22672. t['\uFCC0'] = '\u0641\u062E';
  22673. t['\uFCC1'] = '\u0641\u0645';
  22674. t['\uFCC2'] = '\u0642\u062D';
  22675. t['\uFCC3'] = '\u0642\u0645';
  22676. t['\uFCC4'] = '\u0643\u062C';
  22677. t['\uFCC5'] = '\u0643\u062D';
  22678. t['\uFCC6'] = '\u0643\u062E';
  22679. t['\uFCC7'] = '\u0643\u0644';
  22680. t['\uFCC8'] = '\u0643\u0645';
  22681. t['\uFCC9'] = '\u0644\u062C';
  22682. t['\uFCCA'] = '\u0644\u062D';
  22683. t['\uFCCB'] = '\u0644\u062E';
  22684. t['\uFCCC'] = '\u0644\u0645';
  22685. t['\uFCCD'] = '\u0644\u0647';
  22686. t['\uFCCE'] = '\u0645\u062C';
  22687. t['\uFCCF'] = '\u0645\u062D';
  22688. t['\uFCD0'] = '\u0645\u062E';
  22689. t['\uFCD1'] = '\u0645\u0645';
  22690. t['\uFCD2'] = '\u0646\u062C';
  22691. t['\uFCD3'] = '\u0646\u062D';
  22692. t['\uFCD4'] = '\u0646\u062E';
  22693. t['\uFCD5'] = '\u0646\u0645';
  22694. t['\uFCD6'] = '\u0646\u0647';
  22695. t['\uFCD7'] = '\u0647\u062C';
  22696. t['\uFCD8'] = '\u0647\u0645';
  22697. t['\uFCD9'] = '\u0647\u0670';
  22698. t['\uFCDA'] = '\u064A\u062C';
  22699. t['\uFCDB'] = '\u064A\u062D';
  22700. t['\uFCDC'] = '\u064A\u062E';
  22701. t['\uFCDD'] = '\u064A\u0645';
  22702. t['\uFCDE'] = '\u064A\u0647';
  22703. t['\uFCDF'] = '\u0626\u0645';
  22704. t['\uFCE0'] = '\u0626\u0647';
  22705. t['\uFCE1'] = '\u0628\u0645';
  22706. t['\uFCE2'] = '\u0628\u0647';
  22707. t['\uFCE3'] = '\u062A\u0645';
  22708. t['\uFCE4'] = '\u062A\u0647';
  22709. t['\uFCE5'] = '\u062B\u0645';
  22710. t['\uFCE6'] = '\u062B\u0647';
  22711. t['\uFCE7'] = '\u0633\u0645';
  22712. t['\uFCE8'] = '\u0633\u0647';
  22713. t['\uFCE9'] = '\u0634\u0645';
  22714. t['\uFCEA'] = '\u0634\u0647';
  22715. t['\uFCEB'] = '\u0643\u0644';
  22716. t['\uFCEC'] = '\u0643\u0645';
  22717. t['\uFCED'] = '\u0644\u0645';
  22718. t['\uFCEE'] = '\u0646\u0645';
  22719. t['\uFCEF'] = '\u0646\u0647';
  22720. t['\uFCF0'] = '\u064A\u0645';
  22721. t['\uFCF1'] = '\u064A\u0647';
  22722. t['\uFCF2'] = '\u0640\u064E\u0651';
  22723. t['\uFCF3'] = '\u0640\u064F\u0651';
  22724. t['\uFCF4'] = '\u0640\u0650\u0651';
  22725. t['\uFCF5'] = '\u0637\u0649';
  22726. t['\uFCF6'] = '\u0637\u064A';
  22727. t['\uFCF7'] = '\u0639\u0649';
  22728. t['\uFCF8'] = '\u0639\u064A';
  22729. t['\uFCF9'] = '\u063A\u0649';
  22730. t['\uFCFA'] = '\u063A\u064A';
  22731. t['\uFCFB'] = '\u0633\u0649';
  22732. t['\uFCFC'] = '\u0633\u064A';
  22733. t['\uFCFD'] = '\u0634\u0649';
  22734. t['\uFCFE'] = '\u0634\u064A';
  22735. t['\uFCFF'] = '\u062D\u0649';
  22736. t['\uFD00'] = '\u062D\u064A';
  22737. t['\uFD01'] = '\u062C\u0649';
  22738. t['\uFD02'] = '\u062C\u064A';
  22739. t['\uFD03'] = '\u062E\u0649';
  22740. t['\uFD04'] = '\u062E\u064A';
  22741. t['\uFD05'] = '\u0635\u0649';
  22742. t['\uFD06'] = '\u0635\u064A';
  22743. t['\uFD07'] = '\u0636\u0649';
  22744. t['\uFD08'] = '\u0636\u064A';
  22745. t['\uFD09'] = '\u0634\u062C';
  22746. t['\uFD0A'] = '\u0634\u062D';
  22747. t['\uFD0B'] = '\u0634\u062E';
  22748. t['\uFD0C'] = '\u0634\u0645';
  22749. t['\uFD0D'] = '\u0634\u0631';
  22750. t['\uFD0E'] = '\u0633\u0631';
  22751. t['\uFD0F'] = '\u0635\u0631';
  22752. t['\uFD10'] = '\u0636\u0631';
  22753. t['\uFD11'] = '\u0637\u0649';
  22754. t['\uFD12'] = '\u0637\u064A';
  22755. t['\uFD13'] = '\u0639\u0649';
  22756. t['\uFD14'] = '\u0639\u064A';
  22757. t['\uFD15'] = '\u063A\u0649';
  22758. t['\uFD16'] = '\u063A\u064A';
  22759. t['\uFD17'] = '\u0633\u0649';
  22760. t['\uFD18'] = '\u0633\u064A';
  22761. t['\uFD19'] = '\u0634\u0649';
  22762. t['\uFD1A'] = '\u0634\u064A';
  22763. t['\uFD1B'] = '\u062D\u0649';
  22764. t['\uFD1C'] = '\u062D\u064A';
  22765. t['\uFD1D'] = '\u062C\u0649';
  22766. t['\uFD1E'] = '\u062C\u064A';
  22767. t['\uFD1F'] = '\u062E\u0649';
  22768. t['\uFD20'] = '\u062E\u064A';
  22769. t['\uFD21'] = '\u0635\u0649';
  22770. t['\uFD22'] = '\u0635\u064A';
  22771. t['\uFD23'] = '\u0636\u0649';
  22772. t['\uFD24'] = '\u0636\u064A';
  22773. t['\uFD25'] = '\u0634\u062C';
  22774. t['\uFD26'] = '\u0634\u062D';
  22775. t['\uFD27'] = '\u0634\u062E';
  22776. t['\uFD28'] = '\u0634\u0645';
  22777. t['\uFD29'] = '\u0634\u0631';
  22778. t['\uFD2A'] = '\u0633\u0631';
  22779. t['\uFD2B'] = '\u0635\u0631';
  22780. t['\uFD2C'] = '\u0636\u0631';
  22781. t['\uFD2D'] = '\u0634\u062C';
  22782. t['\uFD2E'] = '\u0634\u062D';
  22783. t['\uFD2F'] = '\u0634\u062E';
  22784. t['\uFD30'] = '\u0634\u0645';
  22785. t['\uFD31'] = '\u0633\u0647';
  22786. t['\uFD32'] = '\u0634\u0647';
  22787. t['\uFD33'] = '\u0637\u0645';
  22788. t['\uFD34'] = '\u0633\u062C';
  22789. t['\uFD35'] = '\u0633\u062D';
  22790. t['\uFD36'] = '\u0633\u062E';
  22791. t['\uFD37'] = '\u0634\u062C';
  22792. t['\uFD38'] = '\u0634\u062D';
  22793. t['\uFD39'] = '\u0634\u062E';
  22794. t['\uFD3A'] = '\u0637\u0645';
  22795. t['\uFD3B'] = '\u0638\u0645';
  22796. t['\uFD3C'] = '\u0627\u064B';
  22797. t['\uFD3D'] = '\u0627\u064B';
  22798. t['\uFD50'] = '\u062A\u062C\u0645';
  22799. t['\uFD51'] = '\u062A\u062D\u062C';
  22800. t['\uFD52'] = '\u062A\u062D\u062C';
  22801. t['\uFD53'] = '\u062A\u062D\u0645';
  22802. t['\uFD54'] = '\u062A\u062E\u0645';
  22803. t['\uFD55'] = '\u062A\u0645\u062C';
  22804. t['\uFD56'] = '\u062A\u0645\u062D';
  22805. t['\uFD57'] = '\u062A\u0645\u062E';
  22806. t['\uFD58'] = '\u062C\u0645\u062D';
  22807. t['\uFD59'] = '\u062C\u0645\u062D';
  22808. t['\uFD5A'] = '\u062D\u0645\u064A';
  22809. t['\uFD5B'] = '\u062D\u0645\u0649';
  22810. t['\uFD5C'] = '\u0633\u062D\u062C';
  22811. t['\uFD5D'] = '\u0633\u062C\u062D';
  22812. t['\uFD5E'] = '\u0633\u062C\u0649';
  22813. t['\uFD5F'] = '\u0633\u0645\u062D';
  22814. t['\uFD60'] = '\u0633\u0645\u062D';
  22815. t['\uFD61'] = '\u0633\u0645\u062C';
  22816. t['\uFD62'] = '\u0633\u0645\u0645';
  22817. t['\uFD63'] = '\u0633\u0645\u0645';
  22818. t['\uFD64'] = '\u0635\u062D\u062D';
  22819. t['\uFD65'] = '\u0635\u062D\u062D';
  22820. t['\uFD66'] = '\u0635\u0645\u0645';
  22821. t['\uFD67'] = '\u0634\u062D\u0645';
  22822. t['\uFD68'] = '\u0634\u062D\u0645';
  22823. t['\uFD69'] = '\u0634\u062C\u064A';
  22824. t['\uFD6A'] = '\u0634\u0645\u062E';
  22825. t['\uFD6B'] = '\u0634\u0645\u062E';
  22826. t['\uFD6C'] = '\u0634\u0645\u0645';
  22827. t['\uFD6D'] = '\u0634\u0645\u0645';
  22828. t['\uFD6E'] = '\u0636\u062D\u0649';
  22829. t['\uFD6F'] = '\u0636\u062E\u0645';
  22830. t['\uFD70'] = '\u0636\u062E\u0645';
  22831. t['\uFD71'] = '\u0637\u0645\u062D';
  22832. t['\uFD72'] = '\u0637\u0645\u062D';
  22833. t['\uFD73'] = '\u0637\u0645\u0645';
  22834. t['\uFD74'] = '\u0637\u0645\u064A';
  22835. t['\uFD75'] = '\u0639\u062C\u0645';
  22836. t['\uFD76'] = '\u0639\u0645\u0645';
  22837. t['\uFD77'] = '\u0639\u0645\u0645';
  22838. t['\uFD78'] = '\u0639\u0645\u0649';
  22839. t['\uFD79'] = '\u063A\u0645\u0645';
  22840. t['\uFD7A'] = '\u063A\u0645\u064A';
  22841. t['\uFD7B'] = '\u063A\u0645\u0649';
  22842. t['\uFD7C'] = '\u0641\u062E\u0645';
  22843. t['\uFD7D'] = '\u0641\u062E\u0645';
  22844. t['\uFD7E'] = '\u0642\u0645\u062D';
  22845. t['\uFD7F'] = '\u0642\u0645\u0645';
  22846. t['\uFD80'] = '\u0644\u062D\u0645';
  22847. t['\uFD81'] = '\u0644\u062D\u064A';
  22848. t['\uFD82'] = '\u0644\u062D\u0649';
  22849. t['\uFD83'] = '\u0644\u062C\u062C';
  22850. t['\uFD84'] = '\u0644\u062C\u062C';
  22851. t['\uFD85'] = '\u0644\u062E\u0645';
  22852. t['\uFD86'] = '\u0644\u062E\u0645';
  22853. t['\uFD87'] = '\u0644\u0645\u062D';
  22854. t['\uFD88'] = '\u0644\u0645\u062D';
  22855. t['\uFD89'] = '\u0645\u062D\u062C';
  22856. t['\uFD8A'] = '\u0645\u062D\u0645';
  22857. t['\uFD8B'] = '\u0645\u062D\u064A';
  22858. t['\uFD8C'] = '\u0645\u062C\u062D';
  22859. t['\uFD8D'] = '\u0645\u062C\u0645';
  22860. t['\uFD8E'] = '\u0645\u062E\u062C';
  22861. t['\uFD8F'] = '\u0645\u062E\u0645';
  22862. t['\uFD92'] = '\u0645\u062C\u062E';
  22863. t['\uFD93'] = '\u0647\u0645\u062C';
  22864. t['\uFD94'] = '\u0647\u0645\u0645';
  22865. t['\uFD95'] = '\u0646\u062D\u0645';
  22866. t['\uFD96'] = '\u0646\u062D\u0649';
  22867. t['\uFD97'] = '\u0646\u062C\u0645';
  22868. t['\uFD98'] = '\u0646\u062C\u0645';
  22869. t['\uFD99'] = '\u0646\u062C\u0649';
  22870. t['\uFD9A'] = '\u0646\u0645\u064A';
  22871. t['\uFD9B'] = '\u0646\u0645\u0649';
  22872. t['\uFD9C'] = '\u064A\u0645\u0645';
  22873. t['\uFD9D'] = '\u064A\u0645\u0645';
  22874. t['\uFD9E'] = '\u0628\u062E\u064A';
  22875. t['\uFD9F'] = '\u062A\u062C\u064A';
  22876. t['\uFDA0'] = '\u062A\u062C\u0649';
  22877. t['\uFDA1'] = '\u062A\u062E\u064A';
  22878. t['\uFDA2'] = '\u062A\u062E\u0649';
  22879. t['\uFDA3'] = '\u062A\u0645\u064A';
  22880. t['\uFDA4'] = '\u062A\u0645\u0649';
  22881. t['\uFDA5'] = '\u062C\u0645\u064A';
  22882. t['\uFDA6'] = '\u062C\u062D\u0649';
  22883. t['\uFDA7'] = '\u062C\u0645\u0649';
  22884. t['\uFDA8'] = '\u0633\u062E\u0649';
  22885. t['\uFDA9'] = '\u0635\u062D\u064A';
  22886. t['\uFDAA'] = '\u0634\u062D\u064A';
  22887. t['\uFDAB'] = '\u0636\u062D\u064A';
  22888. t['\uFDAC'] = '\u0644\u062C\u064A';
  22889. t['\uFDAD'] = '\u0644\u0645\u064A';
  22890. t['\uFDAE'] = '\u064A\u062D\u064A';
  22891. t['\uFDAF'] = '\u064A\u062C\u064A';
  22892. t['\uFDB0'] = '\u064A\u0645\u064A';
  22893. t['\uFDB1'] = '\u0645\u0645\u064A';
  22894. t['\uFDB2'] = '\u0642\u0645\u064A';
  22895. t['\uFDB3'] = '\u0646\u062D\u064A';
  22896. t['\uFDB4'] = '\u0642\u0645\u062D';
  22897. t['\uFDB5'] = '\u0644\u062D\u0645';
  22898. t['\uFDB6'] = '\u0639\u0645\u064A';
  22899. t['\uFDB7'] = '\u0643\u0645\u064A';
  22900. t['\uFDB8'] = '\u0646\u062C\u062D';
  22901. t['\uFDB9'] = '\u0645\u062E\u064A';
  22902. t['\uFDBA'] = '\u0644\u062C\u0645';
  22903. t['\uFDBB'] = '\u0643\u0645\u0645';
  22904. t['\uFDBC'] = '\u0644\u062C\u0645';
  22905. t['\uFDBD'] = '\u0646\u062C\u062D';
  22906. t['\uFDBE'] = '\u062C\u062D\u064A';
  22907. t['\uFDBF'] = '\u062D\u062C\u064A';
  22908. t['\uFDC0'] = '\u0645\u062C\u064A';
  22909. t['\uFDC1'] = '\u0641\u0645\u064A';
  22910. t['\uFDC2'] = '\u0628\u062D\u064A';
  22911. t['\uFDC3'] = '\u0643\u0645\u0645';
  22912. t['\uFDC4'] = '\u0639\u062C\u0645';
  22913. t['\uFDC5'] = '\u0635\u0645\u0645';
  22914. t['\uFDC6'] = '\u0633\u062E\u064A';
  22915. t['\uFDC7'] = '\u0646\u062C\u064A';
  22916. t['\uFE49'] = '\u203E';
  22917. t['\uFE4A'] = '\u203E';
  22918. t['\uFE4B'] = '\u203E';
  22919. t['\uFE4C'] = '\u203E';
  22920. t['\uFE4D'] = '\u005F';
  22921. t['\uFE4E'] = '\u005F';
  22922. t['\uFE4F'] = '\u005F';
  22923. t['\uFE80'] = '\u0621';
  22924. t['\uFE81'] = '\u0622';
  22925. t['\uFE82'] = '\u0622';
  22926. t['\uFE83'] = '\u0623';
  22927. t['\uFE84'] = '\u0623';
  22928. t['\uFE85'] = '\u0624';
  22929. t['\uFE86'] = '\u0624';
  22930. t['\uFE87'] = '\u0625';
  22931. t['\uFE88'] = '\u0625';
  22932. t['\uFE89'] = '\u0626';
  22933. t['\uFE8A'] = '\u0626';
  22934. t['\uFE8B'] = '\u0626';
  22935. t['\uFE8C'] = '\u0626';
  22936. t['\uFE8D'] = '\u0627';
  22937. t['\uFE8E'] = '\u0627';
  22938. t['\uFE8F'] = '\u0628';
  22939. t['\uFE90'] = '\u0628';
  22940. t['\uFE91'] = '\u0628';
  22941. t['\uFE92'] = '\u0628';
  22942. t['\uFE93'] = '\u0629';
  22943. t['\uFE94'] = '\u0629';
  22944. t['\uFE95'] = '\u062A';
  22945. t['\uFE96'] = '\u062A';
  22946. t['\uFE97'] = '\u062A';
  22947. t['\uFE98'] = '\u062A';
  22948. t['\uFE99'] = '\u062B';
  22949. t['\uFE9A'] = '\u062B';
  22950. t['\uFE9B'] = '\u062B';
  22951. t['\uFE9C'] = '\u062B';
  22952. t['\uFE9D'] = '\u062C';
  22953. t['\uFE9E'] = '\u062C';
  22954. t['\uFE9F'] = '\u062C';
  22955. t['\uFEA0'] = '\u062C';
  22956. t['\uFEA1'] = '\u062D';
  22957. t['\uFEA2'] = '\u062D';
  22958. t['\uFEA3'] = '\u062D';
  22959. t['\uFEA4'] = '\u062D';
  22960. t['\uFEA5'] = '\u062E';
  22961. t['\uFEA6'] = '\u062E';
  22962. t['\uFEA7'] = '\u062E';
  22963. t['\uFEA8'] = '\u062E';
  22964. t['\uFEA9'] = '\u062F';
  22965. t['\uFEAA'] = '\u062F';
  22966. t['\uFEAB'] = '\u0630';
  22967. t['\uFEAC'] = '\u0630';
  22968. t['\uFEAD'] = '\u0631';
  22969. t['\uFEAE'] = '\u0631';
  22970. t['\uFEAF'] = '\u0632';
  22971. t['\uFEB0'] = '\u0632';
  22972. t['\uFEB1'] = '\u0633';
  22973. t['\uFEB2'] = '\u0633';
  22974. t['\uFEB3'] = '\u0633';
  22975. t['\uFEB4'] = '\u0633';
  22976. t['\uFEB5'] = '\u0634';
  22977. t['\uFEB6'] = '\u0634';
  22978. t['\uFEB7'] = '\u0634';
  22979. t['\uFEB8'] = '\u0634';
  22980. t['\uFEB9'] = '\u0635';
  22981. t['\uFEBA'] = '\u0635';
  22982. t['\uFEBB'] = '\u0635';
  22983. t['\uFEBC'] = '\u0635';
  22984. t['\uFEBD'] = '\u0636';
  22985. t['\uFEBE'] = '\u0636';
  22986. t['\uFEBF'] = '\u0636';
  22987. t['\uFEC0'] = '\u0636';
  22988. t['\uFEC1'] = '\u0637';
  22989. t['\uFEC2'] = '\u0637';
  22990. t['\uFEC3'] = '\u0637';
  22991. t['\uFEC4'] = '\u0637';
  22992. t['\uFEC5'] = '\u0638';
  22993. t['\uFEC6'] = '\u0638';
  22994. t['\uFEC7'] = '\u0638';
  22995. t['\uFEC8'] = '\u0638';
  22996. t['\uFEC9'] = '\u0639';
  22997. t['\uFECA'] = '\u0639';
  22998. t['\uFECB'] = '\u0639';
  22999. t['\uFECC'] = '\u0639';
  23000. t['\uFECD'] = '\u063A';
  23001. t['\uFECE'] = '\u063A';
  23002. t['\uFECF'] = '\u063A';
  23003. t['\uFED0'] = '\u063A';
  23004. t['\uFED1'] = '\u0641';
  23005. t['\uFED2'] = '\u0641';
  23006. t['\uFED3'] = '\u0641';
  23007. t['\uFED4'] = '\u0641';
  23008. t['\uFED5'] = '\u0642';
  23009. t['\uFED6'] = '\u0642';
  23010. t['\uFED7'] = '\u0642';
  23011. t['\uFED8'] = '\u0642';
  23012. t['\uFED9'] = '\u0643';
  23013. t['\uFEDA'] = '\u0643';
  23014. t['\uFEDB'] = '\u0643';
  23015. t['\uFEDC'] = '\u0643';
  23016. t['\uFEDD'] = '\u0644';
  23017. t['\uFEDE'] = '\u0644';
  23018. t['\uFEDF'] = '\u0644';
  23019. t['\uFEE0'] = '\u0644';
  23020. t['\uFEE1'] = '\u0645';
  23021. t['\uFEE2'] = '\u0645';
  23022. t['\uFEE3'] = '\u0645';
  23023. t['\uFEE4'] = '\u0645';
  23024. t['\uFEE5'] = '\u0646';
  23025. t['\uFEE6'] = '\u0646';
  23026. t['\uFEE7'] = '\u0646';
  23027. t['\uFEE8'] = '\u0646';
  23028. t['\uFEE9'] = '\u0647';
  23029. t['\uFEEA'] = '\u0647';
  23030. t['\uFEEB'] = '\u0647';
  23031. t['\uFEEC'] = '\u0647';
  23032. t['\uFEED'] = '\u0648';
  23033. t['\uFEEE'] = '\u0648';
  23034. t['\uFEEF'] = '\u0649';
  23035. t['\uFEF0'] = '\u0649';
  23036. t['\uFEF1'] = '\u064A';
  23037. t['\uFEF2'] = '\u064A';
  23038. t['\uFEF3'] = '\u064A';
  23039. t['\uFEF4'] = '\u064A';
  23040. t['\uFEF5'] = '\u0644\u0622';
  23041. t['\uFEF6'] = '\u0644\u0622';
  23042. t['\uFEF7'] = '\u0644\u0623';
  23043. t['\uFEF8'] = '\u0644\u0623';
  23044. t['\uFEF9'] = '\u0644\u0625';
  23045. t['\uFEFA'] = '\u0644\u0625';
  23046. t['\uFEFB'] = '\u0644\u0627';
  23047. t['\uFEFC'] = '\u0644\u0627';
  23048. });
  23049. function reverseIfRtl(chars) {
  23050. var charsLength = chars.length;
  23051. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23052. return chars;
  23053. }
  23054. var s = '';
  23055. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23056. s += chars[ii];
  23057. }
  23058. return s;
  23059. }
  23060. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23061. exports.reverseIfRtl = reverseIfRtl;
  23062. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23063. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23064. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23065. }));
  23066. (function (root, factory) {
  23067. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  23068. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  23069. var Util = sharedUtil.Util;
  23070. var error = sharedUtil.error;
  23071. var info = sharedUtil.info;
  23072. var isInt = sharedUtil.isInt;
  23073. var isArray = sharedUtil.isArray;
  23074. var createObjectURL = sharedUtil.createObjectURL;
  23075. var shadow = sharedUtil.shadow;
  23076. var warn = sharedUtil.warn;
  23077. var isSpace = sharedUtil.isSpace;
  23078. var Dict = corePrimitives.Dict;
  23079. var isDict = corePrimitives.isDict;
  23080. var isStream = corePrimitives.isStream;
  23081. var Jbig2Image = coreJbig2.Jbig2Image;
  23082. var JpegImage = coreJpg.JpegImage;
  23083. var JpxImage = coreJpx.JpxImage;
  23084. var Stream = function StreamClosure() {
  23085. function Stream(arrayBuffer, start, length, dict) {
  23086. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  23087. this.start = start || 0;
  23088. this.pos = this.start;
  23089. this.end = start + length || this.bytes.length;
  23090. this.dict = dict;
  23091. }
  23092. Stream.prototype = {
  23093. get length() {
  23094. return this.end - this.start;
  23095. },
  23096. get isEmpty() {
  23097. return this.length === 0;
  23098. },
  23099. getByte: function Stream_getByte() {
  23100. if (this.pos >= this.end) {
  23101. return -1;
  23102. }
  23103. return this.bytes[this.pos++];
  23104. },
  23105. getUint16: function Stream_getUint16() {
  23106. var b0 = this.getByte();
  23107. var b1 = this.getByte();
  23108. if (b0 === -1 || b1 === -1) {
  23109. return -1;
  23110. }
  23111. return (b0 << 8) + b1;
  23112. },
  23113. getInt32: function Stream_getInt32() {
  23114. var b0 = this.getByte();
  23115. var b1 = this.getByte();
  23116. var b2 = this.getByte();
  23117. var b3 = this.getByte();
  23118. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  23119. },
  23120. getBytes: function Stream_getBytes(length) {
  23121. var bytes = this.bytes;
  23122. var pos = this.pos;
  23123. var strEnd = this.end;
  23124. if (!length) {
  23125. return bytes.subarray(pos, strEnd);
  23126. }
  23127. var end = pos + length;
  23128. if (end > strEnd) {
  23129. end = strEnd;
  23130. }
  23131. this.pos = end;
  23132. return bytes.subarray(pos, end);
  23133. },
  23134. peekByte: function Stream_peekByte() {
  23135. var peekedByte = this.getByte();
  23136. this.pos--;
  23137. return peekedByte;
  23138. },
  23139. peekBytes: function Stream_peekBytes(length) {
  23140. var bytes = this.getBytes(length);
  23141. this.pos -= bytes.length;
  23142. return bytes;
  23143. },
  23144. skip: function Stream_skip(n) {
  23145. if (!n) {
  23146. n = 1;
  23147. }
  23148. this.pos += n;
  23149. },
  23150. reset: function Stream_reset() {
  23151. this.pos = this.start;
  23152. },
  23153. moveStart: function Stream_moveStart() {
  23154. this.start = this.pos;
  23155. },
  23156. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  23157. return new Stream(this.bytes.buffer, start, length, dict);
  23158. },
  23159. isStream: true
  23160. };
  23161. return Stream;
  23162. }();
  23163. var StringStream = function StringStreamClosure() {
  23164. function StringStream(str) {
  23165. var length = str.length;
  23166. var bytes = new Uint8Array(length);
  23167. for (var n = 0; n < length; ++n) {
  23168. bytes[n] = str.charCodeAt(n);
  23169. }
  23170. Stream.call(this, bytes);
  23171. }
  23172. StringStream.prototype = Stream.prototype;
  23173. return StringStream;
  23174. }();
  23175. var DecodeStream = function DecodeStreamClosure() {
  23176. var emptyBuffer = new Uint8Array(0);
  23177. function DecodeStream(maybeMinBufferLength) {
  23178. this.pos = 0;
  23179. this.bufferLength = 0;
  23180. this.eof = false;
  23181. this.buffer = emptyBuffer;
  23182. this.minBufferLength = 512;
  23183. if (maybeMinBufferLength) {
  23184. while (this.minBufferLength < maybeMinBufferLength) {
  23185. this.minBufferLength *= 2;
  23186. }
  23187. }
  23188. }
  23189. DecodeStream.prototype = {
  23190. get isEmpty() {
  23191. while (!this.eof && this.bufferLength === 0) {
  23192. this.readBlock();
  23193. }
  23194. return this.bufferLength === 0;
  23195. },
  23196. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  23197. var buffer = this.buffer;
  23198. if (requested <= buffer.byteLength) {
  23199. return buffer;
  23200. }
  23201. var size = this.minBufferLength;
  23202. while (size < requested) {
  23203. size *= 2;
  23204. }
  23205. var buffer2 = new Uint8Array(size);
  23206. buffer2.set(buffer);
  23207. return this.buffer = buffer2;
  23208. },
  23209. getByte: function DecodeStream_getByte() {
  23210. var pos = this.pos;
  23211. while (this.bufferLength <= pos) {
  23212. if (this.eof) {
  23213. return -1;
  23214. }
  23215. this.readBlock();
  23216. }
  23217. return this.buffer[this.pos++];
  23218. },
  23219. getUint16: function DecodeStream_getUint16() {
  23220. var b0 = this.getByte();
  23221. var b1 = this.getByte();
  23222. if (b0 === -1 || b1 === -1) {
  23223. return -1;
  23224. }
  23225. return (b0 << 8) + b1;
  23226. },
  23227. getInt32: function DecodeStream_getInt32() {
  23228. var b0 = this.getByte();
  23229. var b1 = this.getByte();
  23230. var b2 = this.getByte();
  23231. var b3 = this.getByte();
  23232. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  23233. },
  23234. getBytes: function DecodeStream_getBytes(length) {
  23235. var end, pos = this.pos;
  23236. if (length) {
  23237. this.ensureBuffer(pos + length);
  23238. end = pos + length;
  23239. while (!this.eof && this.bufferLength < end) {
  23240. this.readBlock();
  23241. }
  23242. var bufEnd = this.bufferLength;
  23243. if (end > bufEnd) {
  23244. end = bufEnd;
  23245. }
  23246. } else {
  23247. while (!this.eof) {
  23248. this.readBlock();
  23249. }
  23250. end = this.bufferLength;
  23251. }
  23252. this.pos = end;
  23253. return this.buffer.subarray(pos, end);
  23254. },
  23255. peekByte: function DecodeStream_peekByte() {
  23256. var peekedByte = this.getByte();
  23257. this.pos--;
  23258. return peekedByte;
  23259. },
  23260. peekBytes: function DecodeStream_peekBytes(length) {
  23261. var bytes = this.getBytes(length);
  23262. this.pos -= bytes.length;
  23263. return bytes;
  23264. },
  23265. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  23266. var end = start + length;
  23267. while (this.bufferLength <= end && !this.eof) {
  23268. this.readBlock();
  23269. }
  23270. return new Stream(this.buffer, start, length, dict);
  23271. },
  23272. skip: function DecodeStream_skip(n) {
  23273. if (!n) {
  23274. n = 1;
  23275. }
  23276. this.pos += n;
  23277. },
  23278. reset: function DecodeStream_reset() {
  23279. this.pos = 0;
  23280. },
  23281. getBaseStreams: function DecodeStream_getBaseStreams() {
  23282. if (this.str && this.str.getBaseStreams) {
  23283. return this.str.getBaseStreams();
  23284. }
  23285. return [];
  23286. }
  23287. };
  23288. return DecodeStream;
  23289. }();
  23290. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  23291. function StreamsSequenceStream(streams) {
  23292. this.streams = streams;
  23293. DecodeStream.call(this, null);
  23294. }
  23295. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  23296. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  23297. var streams = this.streams;
  23298. if (streams.length === 0) {
  23299. this.eof = true;
  23300. return;
  23301. }
  23302. var stream = streams.shift();
  23303. var chunk = stream.getBytes();
  23304. var bufferLength = this.bufferLength;
  23305. var newLength = bufferLength + chunk.length;
  23306. var buffer = this.ensureBuffer(newLength);
  23307. buffer.set(chunk, bufferLength);
  23308. this.bufferLength = newLength;
  23309. };
  23310. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  23311. var baseStreams = [];
  23312. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  23313. var stream = this.streams[i];
  23314. if (stream.getBaseStreams) {
  23315. Util.appendToArray(baseStreams, stream.getBaseStreams());
  23316. }
  23317. }
  23318. return baseStreams;
  23319. };
  23320. return StreamsSequenceStream;
  23321. }();
  23322. var FlateStream = function FlateStreamClosure() {
  23323. var codeLenCodeMap = new Int32Array([
  23324. 16,
  23325. 17,
  23326. 18,
  23327. 0,
  23328. 8,
  23329. 7,
  23330. 9,
  23331. 6,
  23332. 10,
  23333. 5,
  23334. 11,
  23335. 4,
  23336. 12,
  23337. 3,
  23338. 13,
  23339. 2,
  23340. 14,
  23341. 1,
  23342. 15
  23343. ]);
  23344. var lengthDecode = new Int32Array([
  23345. 0x00003,
  23346. 0x00004,
  23347. 0x00005,
  23348. 0x00006,
  23349. 0x00007,
  23350. 0x00008,
  23351. 0x00009,
  23352. 0x0000a,
  23353. 0x1000b,
  23354. 0x1000d,
  23355. 0x1000f,
  23356. 0x10011,
  23357. 0x20013,
  23358. 0x20017,
  23359. 0x2001b,
  23360. 0x2001f,
  23361. 0x30023,
  23362. 0x3002b,
  23363. 0x30033,
  23364. 0x3003b,
  23365. 0x40043,
  23366. 0x40053,
  23367. 0x40063,
  23368. 0x40073,
  23369. 0x50083,
  23370. 0x500a3,
  23371. 0x500c3,
  23372. 0x500e3,
  23373. 0x00102,
  23374. 0x00102,
  23375. 0x00102
  23376. ]);
  23377. var distDecode = new Int32Array([
  23378. 0x00001,
  23379. 0x00002,
  23380. 0x00003,
  23381. 0x00004,
  23382. 0x10005,
  23383. 0x10007,
  23384. 0x20009,
  23385. 0x2000d,
  23386. 0x30011,
  23387. 0x30019,
  23388. 0x40021,
  23389. 0x40031,
  23390. 0x50041,
  23391. 0x50061,
  23392. 0x60081,
  23393. 0x600c1,
  23394. 0x70101,
  23395. 0x70181,
  23396. 0x80201,
  23397. 0x80301,
  23398. 0x90401,
  23399. 0x90601,
  23400. 0xa0801,
  23401. 0xa0c01,
  23402. 0xb1001,
  23403. 0xb1801,
  23404. 0xc2001,
  23405. 0xc3001,
  23406. 0xd4001,
  23407. 0xd6001
  23408. ]);
  23409. var fixedLitCodeTab = [
  23410. new Int32Array([
  23411. 0x70100,
  23412. 0x80050,
  23413. 0x80010,
  23414. 0x80118,
  23415. 0x70110,
  23416. 0x80070,
  23417. 0x80030,
  23418. 0x900c0,
  23419. 0x70108,
  23420. 0x80060,
  23421. 0x80020,
  23422. 0x900a0,
  23423. 0x80000,
  23424. 0x80080,
  23425. 0x80040,
  23426. 0x900e0,
  23427. 0x70104,
  23428. 0x80058,
  23429. 0x80018,
  23430. 0x90090,
  23431. 0x70114,
  23432. 0x80078,
  23433. 0x80038,
  23434. 0x900d0,
  23435. 0x7010c,
  23436. 0x80068,
  23437. 0x80028,
  23438. 0x900b0,
  23439. 0x80008,
  23440. 0x80088,
  23441. 0x80048,
  23442. 0x900f0,
  23443. 0x70102,
  23444. 0x80054,
  23445. 0x80014,
  23446. 0x8011c,
  23447. 0x70112,
  23448. 0x80074,
  23449. 0x80034,
  23450. 0x900c8,
  23451. 0x7010a,
  23452. 0x80064,
  23453. 0x80024,
  23454. 0x900a8,
  23455. 0x80004,
  23456. 0x80084,
  23457. 0x80044,
  23458. 0x900e8,
  23459. 0x70106,
  23460. 0x8005c,
  23461. 0x8001c,
  23462. 0x90098,
  23463. 0x70116,
  23464. 0x8007c,
  23465. 0x8003c,
  23466. 0x900d8,
  23467. 0x7010e,
  23468. 0x8006c,
  23469. 0x8002c,
  23470. 0x900b8,
  23471. 0x8000c,
  23472. 0x8008c,
  23473. 0x8004c,
  23474. 0x900f8,
  23475. 0x70101,
  23476. 0x80052,
  23477. 0x80012,
  23478. 0x8011a,
  23479. 0x70111,
  23480. 0x80072,
  23481. 0x80032,
  23482. 0x900c4,
  23483. 0x70109,
  23484. 0x80062,
  23485. 0x80022,
  23486. 0x900a4,
  23487. 0x80002,
  23488. 0x80082,
  23489. 0x80042,
  23490. 0x900e4,
  23491. 0x70105,
  23492. 0x8005a,
  23493. 0x8001a,
  23494. 0x90094,
  23495. 0x70115,
  23496. 0x8007a,
  23497. 0x8003a,
  23498. 0x900d4,
  23499. 0x7010d,
  23500. 0x8006a,
  23501. 0x8002a,
  23502. 0x900b4,
  23503. 0x8000a,
  23504. 0x8008a,
  23505. 0x8004a,
  23506. 0x900f4,
  23507. 0x70103,
  23508. 0x80056,
  23509. 0x80016,
  23510. 0x8011e,
  23511. 0x70113,
  23512. 0x80076,
  23513. 0x80036,
  23514. 0x900cc,
  23515. 0x7010b,
  23516. 0x80066,
  23517. 0x80026,
  23518. 0x900ac,
  23519. 0x80006,
  23520. 0x80086,
  23521. 0x80046,
  23522. 0x900ec,
  23523. 0x70107,
  23524. 0x8005e,
  23525. 0x8001e,
  23526. 0x9009c,
  23527. 0x70117,
  23528. 0x8007e,
  23529. 0x8003e,
  23530. 0x900dc,
  23531. 0x7010f,
  23532. 0x8006e,
  23533. 0x8002e,
  23534. 0x900bc,
  23535. 0x8000e,
  23536. 0x8008e,
  23537. 0x8004e,
  23538. 0x900fc,
  23539. 0x70100,
  23540. 0x80051,
  23541. 0x80011,
  23542. 0x80119,
  23543. 0x70110,
  23544. 0x80071,
  23545. 0x80031,
  23546. 0x900c2,
  23547. 0x70108,
  23548. 0x80061,
  23549. 0x80021,
  23550. 0x900a2,
  23551. 0x80001,
  23552. 0x80081,
  23553. 0x80041,
  23554. 0x900e2,
  23555. 0x70104,
  23556. 0x80059,
  23557. 0x80019,
  23558. 0x90092,
  23559. 0x70114,
  23560. 0x80079,
  23561. 0x80039,
  23562. 0x900d2,
  23563. 0x7010c,
  23564. 0x80069,
  23565. 0x80029,
  23566. 0x900b2,
  23567. 0x80009,
  23568. 0x80089,
  23569. 0x80049,
  23570. 0x900f2,
  23571. 0x70102,
  23572. 0x80055,
  23573. 0x80015,
  23574. 0x8011d,
  23575. 0x70112,
  23576. 0x80075,
  23577. 0x80035,
  23578. 0x900ca,
  23579. 0x7010a,
  23580. 0x80065,
  23581. 0x80025,
  23582. 0x900aa,
  23583. 0x80005,
  23584. 0x80085,
  23585. 0x80045,
  23586. 0x900ea,
  23587. 0x70106,
  23588. 0x8005d,
  23589. 0x8001d,
  23590. 0x9009a,
  23591. 0x70116,
  23592. 0x8007d,
  23593. 0x8003d,
  23594. 0x900da,
  23595. 0x7010e,
  23596. 0x8006d,
  23597. 0x8002d,
  23598. 0x900ba,
  23599. 0x8000d,
  23600. 0x8008d,
  23601. 0x8004d,
  23602. 0x900fa,
  23603. 0x70101,
  23604. 0x80053,
  23605. 0x80013,
  23606. 0x8011b,
  23607. 0x70111,
  23608. 0x80073,
  23609. 0x80033,
  23610. 0x900c6,
  23611. 0x70109,
  23612. 0x80063,
  23613. 0x80023,
  23614. 0x900a6,
  23615. 0x80003,
  23616. 0x80083,
  23617. 0x80043,
  23618. 0x900e6,
  23619. 0x70105,
  23620. 0x8005b,
  23621. 0x8001b,
  23622. 0x90096,
  23623. 0x70115,
  23624. 0x8007b,
  23625. 0x8003b,
  23626. 0x900d6,
  23627. 0x7010d,
  23628. 0x8006b,
  23629. 0x8002b,
  23630. 0x900b6,
  23631. 0x8000b,
  23632. 0x8008b,
  23633. 0x8004b,
  23634. 0x900f6,
  23635. 0x70103,
  23636. 0x80057,
  23637. 0x80017,
  23638. 0x8011f,
  23639. 0x70113,
  23640. 0x80077,
  23641. 0x80037,
  23642. 0x900ce,
  23643. 0x7010b,
  23644. 0x80067,
  23645. 0x80027,
  23646. 0x900ae,
  23647. 0x80007,
  23648. 0x80087,
  23649. 0x80047,
  23650. 0x900ee,
  23651. 0x70107,
  23652. 0x8005f,
  23653. 0x8001f,
  23654. 0x9009e,
  23655. 0x70117,
  23656. 0x8007f,
  23657. 0x8003f,
  23658. 0x900de,
  23659. 0x7010f,
  23660. 0x8006f,
  23661. 0x8002f,
  23662. 0x900be,
  23663. 0x8000f,
  23664. 0x8008f,
  23665. 0x8004f,
  23666. 0x900fe,
  23667. 0x70100,
  23668. 0x80050,
  23669. 0x80010,
  23670. 0x80118,
  23671. 0x70110,
  23672. 0x80070,
  23673. 0x80030,
  23674. 0x900c1,
  23675. 0x70108,
  23676. 0x80060,
  23677. 0x80020,
  23678. 0x900a1,
  23679. 0x80000,
  23680. 0x80080,
  23681. 0x80040,
  23682. 0x900e1,
  23683. 0x70104,
  23684. 0x80058,
  23685. 0x80018,
  23686. 0x90091,
  23687. 0x70114,
  23688. 0x80078,
  23689. 0x80038,
  23690. 0x900d1,
  23691. 0x7010c,
  23692. 0x80068,
  23693. 0x80028,
  23694. 0x900b1,
  23695. 0x80008,
  23696. 0x80088,
  23697. 0x80048,
  23698. 0x900f1,
  23699. 0x70102,
  23700. 0x80054,
  23701. 0x80014,
  23702. 0x8011c,
  23703. 0x70112,
  23704. 0x80074,
  23705. 0x80034,
  23706. 0x900c9,
  23707. 0x7010a,
  23708. 0x80064,
  23709. 0x80024,
  23710. 0x900a9,
  23711. 0x80004,
  23712. 0x80084,
  23713. 0x80044,
  23714. 0x900e9,
  23715. 0x70106,
  23716. 0x8005c,
  23717. 0x8001c,
  23718. 0x90099,
  23719. 0x70116,
  23720. 0x8007c,
  23721. 0x8003c,
  23722. 0x900d9,
  23723. 0x7010e,
  23724. 0x8006c,
  23725. 0x8002c,
  23726. 0x900b9,
  23727. 0x8000c,
  23728. 0x8008c,
  23729. 0x8004c,
  23730. 0x900f9,
  23731. 0x70101,
  23732. 0x80052,
  23733. 0x80012,
  23734. 0x8011a,
  23735. 0x70111,
  23736. 0x80072,
  23737. 0x80032,
  23738. 0x900c5,
  23739. 0x70109,
  23740. 0x80062,
  23741. 0x80022,
  23742. 0x900a5,
  23743. 0x80002,
  23744. 0x80082,
  23745. 0x80042,
  23746. 0x900e5,
  23747. 0x70105,
  23748. 0x8005a,
  23749. 0x8001a,
  23750. 0x90095,
  23751. 0x70115,
  23752. 0x8007a,
  23753. 0x8003a,
  23754. 0x900d5,
  23755. 0x7010d,
  23756. 0x8006a,
  23757. 0x8002a,
  23758. 0x900b5,
  23759. 0x8000a,
  23760. 0x8008a,
  23761. 0x8004a,
  23762. 0x900f5,
  23763. 0x70103,
  23764. 0x80056,
  23765. 0x80016,
  23766. 0x8011e,
  23767. 0x70113,
  23768. 0x80076,
  23769. 0x80036,
  23770. 0x900cd,
  23771. 0x7010b,
  23772. 0x80066,
  23773. 0x80026,
  23774. 0x900ad,
  23775. 0x80006,
  23776. 0x80086,
  23777. 0x80046,
  23778. 0x900ed,
  23779. 0x70107,
  23780. 0x8005e,
  23781. 0x8001e,
  23782. 0x9009d,
  23783. 0x70117,
  23784. 0x8007e,
  23785. 0x8003e,
  23786. 0x900dd,
  23787. 0x7010f,
  23788. 0x8006e,
  23789. 0x8002e,
  23790. 0x900bd,
  23791. 0x8000e,
  23792. 0x8008e,
  23793. 0x8004e,
  23794. 0x900fd,
  23795. 0x70100,
  23796. 0x80051,
  23797. 0x80011,
  23798. 0x80119,
  23799. 0x70110,
  23800. 0x80071,
  23801. 0x80031,
  23802. 0x900c3,
  23803. 0x70108,
  23804. 0x80061,
  23805. 0x80021,
  23806. 0x900a3,
  23807. 0x80001,
  23808. 0x80081,
  23809. 0x80041,
  23810. 0x900e3,
  23811. 0x70104,
  23812. 0x80059,
  23813. 0x80019,
  23814. 0x90093,
  23815. 0x70114,
  23816. 0x80079,
  23817. 0x80039,
  23818. 0x900d3,
  23819. 0x7010c,
  23820. 0x80069,
  23821. 0x80029,
  23822. 0x900b3,
  23823. 0x80009,
  23824. 0x80089,
  23825. 0x80049,
  23826. 0x900f3,
  23827. 0x70102,
  23828. 0x80055,
  23829. 0x80015,
  23830. 0x8011d,
  23831. 0x70112,
  23832. 0x80075,
  23833. 0x80035,
  23834. 0x900cb,
  23835. 0x7010a,
  23836. 0x80065,
  23837. 0x80025,
  23838. 0x900ab,
  23839. 0x80005,
  23840. 0x80085,
  23841. 0x80045,
  23842. 0x900eb,
  23843. 0x70106,
  23844. 0x8005d,
  23845. 0x8001d,
  23846. 0x9009b,
  23847. 0x70116,
  23848. 0x8007d,
  23849. 0x8003d,
  23850. 0x900db,
  23851. 0x7010e,
  23852. 0x8006d,
  23853. 0x8002d,
  23854. 0x900bb,
  23855. 0x8000d,
  23856. 0x8008d,
  23857. 0x8004d,
  23858. 0x900fb,
  23859. 0x70101,
  23860. 0x80053,
  23861. 0x80013,
  23862. 0x8011b,
  23863. 0x70111,
  23864. 0x80073,
  23865. 0x80033,
  23866. 0x900c7,
  23867. 0x70109,
  23868. 0x80063,
  23869. 0x80023,
  23870. 0x900a7,
  23871. 0x80003,
  23872. 0x80083,
  23873. 0x80043,
  23874. 0x900e7,
  23875. 0x70105,
  23876. 0x8005b,
  23877. 0x8001b,
  23878. 0x90097,
  23879. 0x70115,
  23880. 0x8007b,
  23881. 0x8003b,
  23882. 0x900d7,
  23883. 0x7010d,
  23884. 0x8006b,
  23885. 0x8002b,
  23886. 0x900b7,
  23887. 0x8000b,
  23888. 0x8008b,
  23889. 0x8004b,
  23890. 0x900f7,
  23891. 0x70103,
  23892. 0x80057,
  23893. 0x80017,
  23894. 0x8011f,
  23895. 0x70113,
  23896. 0x80077,
  23897. 0x80037,
  23898. 0x900cf,
  23899. 0x7010b,
  23900. 0x80067,
  23901. 0x80027,
  23902. 0x900af,
  23903. 0x80007,
  23904. 0x80087,
  23905. 0x80047,
  23906. 0x900ef,
  23907. 0x70107,
  23908. 0x8005f,
  23909. 0x8001f,
  23910. 0x9009f,
  23911. 0x70117,
  23912. 0x8007f,
  23913. 0x8003f,
  23914. 0x900df,
  23915. 0x7010f,
  23916. 0x8006f,
  23917. 0x8002f,
  23918. 0x900bf,
  23919. 0x8000f,
  23920. 0x8008f,
  23921. 0x8004f,
  23922. 0x900ff
  23923. ]),
  23924. 9
  23925. ];
  23926. var fixedDistCodeTab = [
  23927. new Int32Array([
  23928. 0x50000,
  23929. 0x50010,
  23930. 0x50008,
  23931. 0x50018,
  23932. 0x50004,
  23933. 0x50014,
  23934. 0x5000c,
  23935. 0x5001c,
  23936. 0x50002,
  23937. 0x50012,
  23938. 0x5000a,
  23939. 0x5001a,
  23940. 0x50006,
  23941. 0x50016,
  23942. 0x5000e,
  23943. 0x00000,
  23944. 0x50001,
  23945. 0x50011,
  23946. 0x50009,
  23947. 0x50019,
  23948. 0x50005,
  23949. 0x50015,
  23950. 0x5000d,
  23951. 0x5001d,
  23952. 0x50003,
  23953. 0x50013,
  23954. 0x5000b,
  23955. 0x5001b,
  23956. 0x50007,
  23957. 0x50017,
  23958. 0x5000f,
  23959. 0x00000
  23960. ]),
  23961. 5
  23962. ];
  23963. function FlateStream(str, maybeLength) {
  23964. this.str = str;
  23965. this.dict = str.dict;
  23966. var cmf = str.getByte();
  23967. var flg = str.getByte();
  23968. if (cmf === -1 || flg === -1) {
  23969. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  23970. }
  23971. if ((cmf & 0x0f) !== 0x08) {
  23972. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  23973. }
  23974. if (((cmf << 8) + flg) % 31 !== 0) {
  23975. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  23976. }
  23977. if (flg & 0x20) {
  23978. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  23979. }
  23980. this.codeSize = 0;
  23981. this.codeBuf = 0;
  23982. DecodeStream.call(this, maybeLength);
  23983. }
  23984. FlateStream.prototype = Object.create(DecodeStream.prototype);
  23985. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  23986. var str = this.str;
  23987. var codeSize = this.codeSize;
  23988. var codeBuf = this.codeBuf;
  23989. var b;
  23990. while (codeSize < bits) {
  23991. if ((b = str.getByte()) === -1) {
  23992. error('Bad encoding in flate stream');
  23993. }
  23994. codeBuf |= b << codeSize;
  23995. codeSize += 8;
  23996. }
  23997. b = codeBuf & (1 << bits) - 1;
  23998. this.codeBuf = codeBuf >> bits;
  23999. this.codeSize = codeSize -= bits;
  24000. return b;
  24001. };
  24002. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  24003. var str = this.str;
  24004. var codes = table[0];
  24005. var maxLen = table[1];
  24006. var codeSize = this.codeSize;
  24007. var codeBuf = this.codeBuf;
  24008. var b;
  24009. while (codeSize < maxLen) {
  24010. if ((b = str.getByte()) === -1) {
  24011. break;
  24012. }
  24013. codeBuf |= b << codeSize;
  24014. codeSize += 8;
  24015. }
  24016. var code = codes[codeBuf & (1 << maxLen) - 1];
  24017. var codeLen = code >> 16;
  24018. var codeVal = code & 0xffff;
  24019. if (codeLen < 1 || codeSize < codeLen) {
  24020. error('Bad encoding in flate stream');
  24021. }
  24022. this.codeBuf = codeBuf >> codeLen;
  24023. this.codeSize = codeSize - codeLen;
  24024. return codeVal;
  24025. };
  24026. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  24027. var n = lengths.length;
  24028. var maxLen = 0;
  24029. var i;
  24030. for (i = 0; i < n; ++i) {
  24031. if (lengths[i] > maxLen) {
  24032. maxLen = lengths[i];
  24033. }
  24034. }
  24035. var size = 1 << maxLen;
  24036. var codes = new Int32Array(size);
  24037. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  24038. for (var val = 0; val < n; ++val) {
  24039. if (lengths[val] === len) {
  24040. var code2 = 0;
  24041. var t = code;
  24042. for (i = 0; i < len; ++i) {
  24043. code2 = code2 << 1 | t & 1;
  24044. t >>= 1;
  24045. }
  24046. for (i = code2; i < size; i += skip) {
  24047. codes[i] = len << 16 | val;
  24048. }
  24049. ++code;
  24050. }
  24051. }
  24052. }
  24053. return [
  24054. codes,
  24055. maxLen
  24056. ];
  24057. };
  24058. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  24059. var buffer, len;
  24060. var str = this.str;
  24061. var hdr = this.getBits(3);
  24062. if (hdr & 1) {
  24063. this.eof = true;
  24064. }
  24065. hdr >>= 1;
  24066. if (hdr === 0) {
  24067. var b;
  24068. if ((b = str.getByte()) === -1) {
  24069. error('Bad block header in flate stream');
  24070. }
  24071. var blockLen = b;
  24072. if ((b = str.getByte()) === -1) {
  24073. error('Bad block header in flate stream');
  24074. }
  24075. blockLen |= b << 8;
  24076. if ((b = str.getByte()) === -1) {
  24077. error('Bad block header in flate stream');
  24078. }
  24079. var check = b;
  24080. if ((b = str.getByte()) === -1) {
  24081. error('Bad block header in flate stream');
  24082. }
  24083. check |= b << 8;
  24084. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  24085. error('Bad uncompressed block length in flate stream');
  24086. }
  24087. this.codeBuf = 0;
  24088. this.codeSize = 0;
  24089. var bufferLength = this.bufferLength;
  24090. buffer = this.ensureBuffer(bufferLength + blockLen);
  24091. var end = bufferLength + blockLen;
  24092. this.bufferLength = end;
  24093. if (blockLen === 0) {
  24094. if (str.peekByte() === -1) {
  24095. this.eof = true;
  24096. }
  24097. } else {
  24098. for (var n = bufferLength; n < end; ++n) {
  24099. if ((b = str.getByte()) === -1) {
  24100. this.eof = true;
  24101. break;
  24102. }
  24103. buffer[n] = b;
  24104. }
  24105. }
  24106. return;
  24107. }
  24108. var litCodeTable;
  24109. var distCodeTable;
  24110. if (hdr === 1) {
  24111. litCodeTable = fixedLitCodeTab;
  24112. distCodeTable = fixedDistCodeTab;
  24113. } else if (hdr === 2) {
  24114. var numLitCodes = this.getBits(5) + 257;
  24115. var numDistCodes = this.getBits(5) + 1;
  24116. var numCodeLenCodes = this.getBits(4) + 4;
  24117. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  24118. var i;
  24119. for (i = 0; i < numCodeLenCodes; ++i) {
  24120. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  24121. }
  24122. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  24123. len = 0;
  24124. i = 0;
  24125. var codes = numLitCodes + numDistCodes;
  24126. var codeLengths = new Uint8Array(codes);
  24127. var bitsLength, bitsOffset, what;
  24128. while (i < codes) {
  24129. var code = this.getCode(codeLenCodeTab);
  24130. if (code === 16) {
  24131. bitsLength = 2;
  24132. bitsOffset = 3;
  24133. what = len;
  24134. } else if (code === 17) {
  24135. bitsLength = 3;
  24136. bitsOffset = 3;
  24137. what = len = 0;
  24138. } else if (code === 18) {
  24139. bitsLength = 7;
  24140. bitsOffset = 11;
  24141. what = len = 0;
  24142. } else {
  24143. codeLengths[i++] = len = code;
  24144. continue;
  24145. }
  24146. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  24147. while (repeatLength-- > 0) {
  24148. codeLengths[i++] = what;
  24149. }
  24150. }
  24151. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  24152. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  24153. } else {
  24154. error('Unknown block type in flate stream');
  24155. }
  24156. buffer = this.buffer;
  24157. var limit = buffer ? buffer.length : 0;
  24158. var pos = this.bufferLength;
  24159. while (true) {
  24160. var code1 = this.getCode(litCodeTable);
  24161. if (code1 < 256) {
  24162. if (pos + 1 >= limit) {
  24163. buffer = this.ensureBuffer(pos + 1);
  24164. limit = buffer.length;
  24165. }
  24166. buffer[pos++] = code1;
  24167. continue;
  24168. }
  24169. if (code1 === 256) {
  24170. this.bufferLength = pos;
  24171. return;
  24172. }
  24173. code1 -= 257;
  24174. code1 = lengthDecode[code1];
  24175. var code2 = code1 >> 16;
  24176. if (code2 > 0) {
  24177. code2 = this.getBits(code2);
  24178. }
  24179. len = (code1 & 0xffff) + code2;
  24180. code1 = this.getCode(distCodeTable);
  24181. code1 = distDecode[code1];
  24182. code2 = code1 >> 16;
  24183. if (code2 > 0) {
  24184. code2 = this.getBits(code2);
  24185. }
  24186. var dist = (code1 & 0xffff) + code2;
  24187. if (pos + len >= limit) {
  24188. buffer = this.ensureBuffer(pos + len);
  24189. limit = buffer.length;
  24190. }
  24191. for (var k = 0; k < len; ++k, ++pos) {
  24192. buffer[pos] = buffer[pos - dist];
  24193. }
  24194. }
  24195. };
  24196. return FlateStream;
  24197. }();
  24198. var PredictorStream = function PredictorStreamClosure() {
  24199. function PredictorStream(str, maybeLength, params) {
  24200. if (!isDict(params)) {
  24201. return str;
  24202. }
  24203. var predictor = this.predictor = params.get('Predictor') || 1;
  24204. if (predictor <= 1) {
  24205. return str;
  24206. }
  24207. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  24208. error('Unsupported predictor: ' + predictor);
  24209. }
  24210. if (predictor === 2) {
  24211. this.readBlock = this.readBlockTiff;
  24212. } else {
  24213. this.readBlock = this.readBlockPng;
  24214. }
  24215. this.str = str;
  24216. this.dict = str.dict;
  24217. var colors = this.colors = params.get('Colors') || 1;
  24218. var bits = this.bits = params.get('BitsPerComponent') || 8;
  24219. var columns = this.columns = params.get('Columns') || 1;
  24220. this.pixBytes = colors * bits + 7 >> 3;
  24221. this.rowBytes = columns * colors * bits + 7 >> 3;
  24222. DecodeStream.call(this, maybeLength);
  24223. return this;
  24224. }
  24225. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  24226. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  24227. var rowBytes = this.rowBytes;
  24228. var bufferLength = this.bufferLength;
  24229. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  24230. var bits = this.bits;
  24231. var colors = this.colors;
  24232. var rawBytes = this.str.getBytes(rowBytes);
  24233. this.eof = !rawBytes.length;
  24234. if (this.eof) {
  24235. return;
  24236. }
  24237. var inbuf = 0, outbuf = 0;
  24238. var inbits = 0, outbits = 0;
  24239. var pos = bufferLength;
  24240. var i;
  24241. if (bits === 1) {
  24242. for (i = 0; i < rowBytes; ++i) {
  24243. var c = rawBytes[i];
  24244. inbuf = inbuf << 8 | c;
  24245. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  24246. inbuf &= 0xFFFF;
  24247. }
  24248. } else if (bits === 8) {
  24249. for (i = 0; i < colors; ++i) {
  24250. buffer[pos++] = rawBytes[i];
  24251. }
  24252. for (; i < rowBytes; ++i) {
  24253. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  24254. pos++;
  24255. }
  24256. } else {
  24257. var compArray = new Uint8Array(colors + 1);
  24258. var bitMask = (1 << bits) - 1;
  24259. var j = 0, k = bufferLength;
  24260. var columns = this.columns;
  24261. for (i = 0; i < columns; ++i) {
  24262. for (var kk = 0; kk < colors; ++kk) {
  24263. if (inbits < bits) {
  24264. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  24265. inbits += 8;
  24266. }
  24267. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  24268. inbits -= bits;
  24269. outbuf = outbuf << bits | compArray[kk];
  24270. outbits += bits;
  24271. if (outbits >= 8) {
  24272. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  24273. outbits -= 8;
  24274. }
  24275. }
  24276. }
  24277. if (outbits > 0) {
  24278. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  24279. }
  24280. }
  24281. this.bufferLength += rowBytes;
  24282. };
  24283. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  24284. var rowBytes = this.rowBytes;
  24285. var pixBytes = this.pixBytes;
  24286. var predictor = this.str.getByte();
  24287. var rawBytes = this.str.getBytes(rowBytes);
  24288. this.eof = !rawBytes.length;
  24289. if (this.eof) {
  24290. return;
  24291. }
  24292. var bufferLength = this.bufferLength;
  24293. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  24294. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  24295. if (prevRow.length === 0) {
  24296. prevRow = new Uint8Array(rowBytes);
  24297. }
  24298. var i, j = bufferLength, up, c;
  24299. switch (predictor) {
  24300. case 0:
  24301. for (i = 0; i < rowBytes; ++i) {
  24302. buffer[j++] = rawBytes[i];
  24303. }
  24304. break;
  24305. case 1:
  24306. for (i = 0; i < pixBytes; ++i) {
  24307. buffer[j++] = rawBytes[i];
  24308. }
  24309. for (; i < rowBytes; ++i) {
  24310. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  24311. j++;
  24312. }
  24313. break;
  24314. case 2:
  24315. for (i = 0; i < rowBytes; ++i) {
  24316. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  24317. }
  24318. break;
  24319. case 3:
  24320. for (i = 0; i < pixBytes; ++i) {
  24321. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  24322. }
  24323. for (; i < rowBytes; ++i) {
  24324. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  24325. j++;
  24326. }
  24327. break;
  24328. case 4:
  24329. for (i = 0; i < pixBytes; ++i) {
  24330. up = prevRow[i];
  24331. c = rawBytes[i];
  24332. buffer[j++] = up + c;
  24333. }
  24334. for (; i < rowBytes; ++i) {
  24335. up = prevRow[i];
  24336. var upLeft = prevRow[i - pixBytes];
  24337. var left = buffer[j - pixBytes];
  24338. var p = left + up - upLeft;
  24339. var pa = p - left;
  24340. if (pa < 0) {
  24341. pa = -pa;
  24342. }
  24343. var pb = p - up;
  24344. if (pb < 0) {
  24345. pb = -pb;
  24346. }
  24347. var pc = p - upLeft;
  24348. if (pc < 0) {
  24349. pc = -pc;
  24350. }
  24351. c = rawBytes[i];
  24352. if (pa <= pb && pa <= pc) {
  24353. buffer[j++] = left + c;
  24354. } else if (pb <= pc) {
  24355. buffer[j++] = up + c;
  24356. } else {
  24357. buffer[j++] = upLeft + c;
  24358. }
  24359. }
  24360. break;
  24361. default:
  24362. error('Unsupported predictor: ' + predictor);
  24363. }
  24364. this.bufferLength += rowBytes;
  24365. };
  24366. return PredictorStream;
  24367. }();
  24368. var JpegStream = function JpegStreamClosure() {
  24369. function JpegStream(stream, maybeLength, dict, params) {
  24370. var ch;
  24371. while ((ch = stream.getByte()) !== -1) {
  24372. if (ch === 0xFF) {
  24373. stream.skip(-1);
  24374. break;
  24375. }
  24376. }
  24377. this.stream = stream;
  24378. this.maybeLength = maybeLength;
  24379. this.dict = dict;
  24380. this.params = params;
  24381. DecodeStream.call(this, maybeLength);
  24382. }
  24383. JpegStream.prototype = Object.create(DecodeStream.prototype);
  24384. Object.defineProperty(JpegStream.prototype, 'bytes', {
  24385. get: function JpegStream_bytes() {
  24386. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24387. },
  24388. configurable: true
  24389. });
  24390. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  24391. if (this.bufferLength) {
  24392. return;
  24393. }
  24394. var jpegImage = new JpegImage();
  24395. var decodeArr = this.dict.getArray('Decode', 'D');
  24396. if (this.forceRGB && isArray(decodeArr)) {
  24397. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  24398. var decodeArrLength = decodeArr.length;
  24399. var transform = new Int32Array(decodeArrLength);
  24400. var transformNeeded = false;
  24401. var maxValue = (1 << bitsPerComponent) - 1;
  24402. for (var i = 0; i < decodeArrLength; i += 2) {
  24403. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  24404. transform[i + 1] = decodeArr[i] * maxValue | 0;
  24405. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  24406. transformNeeded = true;
  24407. }
  24408. }
  24409. if (transformNeeded) {
  24410. jpegImage.decodeTransform = transform;
  24411. }
  24412. }
  24413. if (isDict(this.params)) {
  24414. var colorTransform = this.params.get('ColorTransform');
  24415. if (isInt(colorTransform)) {
  24416. jpegImage.colorTransform = colorTransform;
  24417. }
  24418. }
  24419. jpegImage.parse(this.bytes);
  24420. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  24421. this.buffer = data;
  24422. this.bufferLength = data.length;
  24423. this.eof = true;
  24424. };
  24425. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  24426. this.ensureBuffer();
  24427. return this.buffer;
  24428. };
  24429. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  24430. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  24431. };
  24432. return JpegStream;
  24433. }();
  24434. var JpxStream = function JpxStreamClosure() {
  24435. function JpxStream(stream, maybeLength, dict, params) {
  24436. this.stream = stream;
  24437. this.maybeLength = maybeLength;
  24438. this.dict = dict;
  24439. this.params = params;
  24440. DecodeStream.call(this, maybeLength);
  24441. }
  24442. JpxStream.prototype = Object.create(DecodeStream.prototype);
  24443. Object.defineProperty(JpxStream.prototype, 'bytes', {
  24444. get: function JpxStream_bytes() {
  24445. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24446. },
  24447. configurable: true
  24448. });
  24449. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  24450. if (this.bufferLength) {
  24451. return;
  24452. }
  24453. var jpxImage = new JpxImage();
  24454. jpxImage.parse(this.bytes);
  24455. var width = jpxImage.width;
  24456. var height = jpxImage.height;
  24457. var componentsCount = jpxImage.componentsCount;
  24458. var tileCount = jpxImage.tiles.length;
  24459. if (tileCount === 1) {
  24460. this.buffer = jpxImage.tiles[0].items;
  24461. } else {
  24462. var data = new Uint8Array(width * height * componentsCount);
  24463. for (var k = 0; k < tileCount; k++) {
  24464. var tileComponents = jpxImage.tiles[k];
  24465. var tileWidth = tileComponents.width;
  24466. var tileHeight = tileComponents.height;
  24467. var tileLeft = tileComponents.left;
  24468. var tileTop = tileComponents.top;
  24469. var src = tileComponents.items;
  24470. var srcPosition = 0;
  24471. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  24472. var imgRowSize = width * componentsCount;
  24473. var tileRowSize = tileWidth * componentsCount;
  24474. for (var j = 0; j < tileHeight; j++) {
  24475. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  24476. data.set(rowBytes, dataPosition);
  24477. srcPosition += tileRowSize;
  24478. dataPosition += imgRowSize;
  24479. }
  24480. }
  24481. this.buffer = data;
  24482. }
  24483. this.bufferLength = this.buffer.length;
  24484. this.eof = true;
  24485. };
  24486. return JpxStream;
  24487. }();
  24488. var Jbig2Stream = function Jbig2StreamClosure() {
  24489. function Jbig2Stream(stream, maybeLength, dict, params) {
  24490. this.stream = stream;
  24491. this.maybeLength = maybeLength;
  24492. this.dict = dict;
  24493. this.params = params;
  24494. DecodeStream.call(this, maybeLength);
  24495. }
  24496. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  24497. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  24498. get: function Jbig2Stream_bytes() {
  24499. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24500. },
  24501. configurable: true
  24502. });
  24503. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  24504. if (this.bufferLength) {
  24505. return;
  24506. }
  24507. var jbig2Image = new Jbig2Image();
  24508. var chunks = [];
  24509. if (isDict(this.params)) {
  24510. var globalsStream = this.params.get('JBIG2Globals');
  24511. if (isStream(globalsStream)) {
  24512. var globals = globalsStream.getBytes();
  24513. chunks.push({
  24514. data: globals,
  24515. start: 0,
  24516. end: globals.length
  24517. });
  24518. }
  24519. }
  24520. chunks.push({
  24521. data: this.bytes,
  24522. start: 0,
  24523. end: this.bytes.length
  24524. });
  24525. var data = jbig2Image.parseChunks(chunks);
  24526. var dataLength = data.length;
  24527. for (var i = 0; i < dataLength; i++) {
  24528. data[i] ^= 0xFF;
  24529. }
  24530. this.buffer = data;
  24531. this.bufferLength = dataLength;
  24532. this.eof = true;
  24533. };
  24534. return Jbig2Stream;
  24535. }();
  24536. var DecryptStream = function DecryptStreamClosure() {
  24537. function DecryptStream(str, maybeLength, decrypt) {
  24538. this.str = str;
  24539. this.dict = str.dict;
  24540. this.decrypt = decrypt;
  24541. this.nextChunk = null;
  24542. this.initialized = false;
  24543. DecodeStream.call(this, maybeLength);
  24544. }
  24545. var chunkSize = 512;
  24546. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  24547. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  24548. var chunk;
  24549. if (this.initialized) {
  24550. chunk = this.nextChunk;
  24551. } else {
  24552. chunk = this.str.getBytes(chunkSize);
  24553. this.initialized = true;
  24554. }
  24555. if (!chunk || chunk.length === 0) {
  24556. this.eof = true;
  24557. return;
  24558. }
  24559. this.nextChunk = this.str.getBytes(chunkSize);
  24560. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  24561. var decrypt = this.decrypt;
  24562. chunk = decrypt(chunk, !hasMoreData);
  24563. var bufferLength = this.bufferLength;
  24564. var i, n = chunk.length;
  24565. var buffer = this.ensureBuffer(bufferLength + n);
  24566. for (i = 0; i < n; i++) {
  24567. buffer[bufferLength++] = chunk[i];
  24568. }
  24569. this.bufferLength = bufferLength;
  24570. };
  24571. return DecryptStream;
  24572. }();
  24573. var Ascii85Stream = function Ascii85StreamClosure() {
  24574. function Ascii85Stream(str, maybeLength) {
  24575. this.str = str;
  24576. this.dict = str.dict;
  24577. this.input = new Uint8Array(5);
  24578. if (maybeLength) {
  24579. maybeLength = 0.8 * maybeLength;
  24580. }
  24581. DecodeStream.call(this, maybeLength);
  24582. }
  24583. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  24584. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  24585. var TILDA_CHAR = 0x7E;
  24586. var Z_LOWER_CHAR = 0x7A;
  24587. var EOF = -1;
  24588. var str = this.str;
  24589. var c = str.getByte();
  24590. while (isSpace(c)) {
  24591. c = str.getByte();
  24592. }
  24593. if (c === EOF || c === TILDA_CHAR) {
  24594. this.eof = true;
  24595. return;
  24596. }
  24597. var bufferLength = this.bufferLength, buffer;
  24598. var i;
  24599. if (c === Z_LOWER_CHAR) {
  24600. buffer = this.ensureBuffer(bufferLength + 4);
  24601. for (i = 0; i < 4; ++i) {
  24602. buffer[bufferLength + i] = 0;
  24603. }
  24604. this.bufferLength += 4;
  24605. } else {
  24606. var input = this.input;
  24607. input[0] = c;
  24608. for (i = 1; i < 5; ++i) {
  24609. c = str.getByte();
  24610. while (isSpace(c)) {
  24611. c = str.getByte();
  24612. }
  24613. input[i] = c;
  24614. if (c === EOF || c === TILDA_CHAR) {
  24615. break;
  24616. }
  24617. }
  24618. buffer = this.ensureBuffer(bufferLength + i - 1);
  24619. this.bufferLength += i - 1;
  24620. if (i < 5) {
  24621. for (; i < 5; ++i) {
  24622. input[i] = 0x21 + 84;
  24623. }
  24624. this.eof = true;
  24625. }
  24626. var t = 0;
  24627. for (i = 0; i < 5; ++i) {
  24628. t = t * 85 + (input[i] - 0x21);
  24629. }
  24630. for (i = 3; i >= 0; --i) {
  24631. buffer[bufferLength + i] = t & 0xFF;
  24632. t >>= 8;
  24633. }
  24634. }
  24635. };
  24636. return Ascii85Stream;
  24637. }();
  24638. var AsciiHexStream = function AsciiHexStreamClosure() {
  24639. function AsciiHexStream(str, maybeLength) {
  24640. this.str = str;
  24641. this.dict = str.dict;
  24642. this.firstDigit = -1;
  24643. if (maybeLength) {
  24644. maybeLength = 0.5 * maybeLength;
  24645. }
  24646. DecodeStream.call(this, maybeLength);
  24647. }
  24648. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  24649. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  24650. var UPSTREAM_BLOCK_SIZE = 8000;
  24651. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  24652. if (!bytes.length) {
  24653. this.eof = true;
  24654. return;
  24655. }
  24656. var maxDecodeLength = bytes.length + 1 >> 1;
  24657. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  24658. var bufferLength = this.bufferLength;
  24659. var firstDigit = this.firstDigit;
  24660. for (var i = 0, ii = bytes.length; i < ii; i++) {
  24661. var ch = bytes[i], digit;
  24662. if (ch >= 0x30 && ch <= 0x39) {
  24663. digit = ch & 0x0F;
  24664. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  24665. digit = (ch & 0x0F) + 9;
  24666. } else if (ch === 0x3E) {
  24667. this.eof = true;
  24668. break;
  24669. } else {
  24670. continue;
  24671. }
  24672. if (firstDigit < 0) {
  24673. firstDigit = digit;
  24674. } else {
  24675. buffer[bufferLength++] = firstDigit << 4 | digit;
  24676. firstDigit = -1;
  24677. }
  24678. }
  24679. if (firstDigit >= 0 && this.eof) {
  24680. buffer[bufferLength++] = firstDigit << 4;
  24681. firstDigit = -1;
  24682. }
  24683. this.firstDigit = firstDigit;
  24684. this.bufferLength = bufferLength;
  24685. };
  24686. return AsciiHexStream;
  24687. }();
  24688. var RunLengthStream = function RunLengthStreamClosure() {
  24689. function RunLengthStream(str, maybeLength) {
  24690. this.str = str;
  24691. this.dict = str.dict;
  24692. DecodeStream.call(this, maybeLength);
  24693. }
  24694. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  24695. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  24696. var repeatHeader = this.str.getBytes(2);
  24697. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  24698. this.eof = true;
  24699. return;
  24700. }
  24701. var buffer;
  24702. var bufferLength = this.bufferLength;
  24703. var n = repeatHeader[0];
  24704. if (n < 128) {
  24705. buffer = this.ensureBuffer(bufferLength + n + 1);
  24706. buffer[bufferLength++] = repeatHeader[1];
  24707. if (n > 0) {
  24708. var source = this.str.getBytes(n);
  24709. buffer.set(source, bufferLength);
  24710. bufferLength += n;
  24711. }
  24712. } else {
  24713. n = 257 - n;
  24714. var b = repeatHeader[1];
  24715. buffer = this.ensureBuffer(bufferLength + n + 1);
  24716. for (var i = 0; i < n; i++) {
  24717. buffer[bufferLength++] = b;
  24718. }
  24719. }
  24720. this.bufferLength = bufferLength;
  24721. };
  24722. return RunLengthStream;
  24723. }();
  24724. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  24725. var ccittEOL = -2;
  24726. var ccittEOF = -1;
  24727. var twoDimPass = 0;
  24728. var twoDimHoriz = 1;
  24729. var twoDimVert0 = 2;
  24730. var twoDimVertR1 = 3;
  24731. var twoDimVertL1 = 4;
  24732. var twoDimVertR2 = 5;
  24733. var twoDimVertL2 = 6;
  24734. var twoDimVertR3 = 7;
  24735. var twoDimVertL3 = 8;
  24736. var twoDimTable = [
  24737. [
  24738. -1,
  24739. -1
  24740. ],
  24741. [
  24742. -1,
  24743. -1
  24744. ],
  24745. [
  24746. 7,
  24747. twoDimVertL3
  24748. ],
  24749. [
  24750. 7,
  24751. twoDimVertR3
  24752. ],
  24753. [
  24754. 6,
  24755. twoDimVertL2
  24756. ],
  24757. [
  24758. 6,
  24759. twoDimVertL2
  24760. ],
  24761. [
  24762. 6,
  24763. twoDimVertR2
  24764. ],
  24765. [
  24766. 6,
  24767. twoDimVertR2
  24768. ],
  24769. [
  24770. 4,
  24771. twoDimPass
  24772. ],
  24773. [
  24774. 4,
  24775. twoDimPass
  24776. ],
  24777. [
  24778. 4,
  24779. twoDimPass
  24780. ],
  24781. [
  24782. 4,
  24783. twoDimPass
  24784. ],
  24785. [
  24786. 4,
  24787. twoDimPass
  24788. ],
  24789. [
  24790. 4,
  24791. twoDimPass
  24792. ],
  24793. [
  24794. 4,
  24795. twoDimPass
  24796. ],
  24797. [
  24798. 4,
  24799. twoDimPass
  24800. ],
  24801. [
  24802. 3,
  24803. twoDimHoriz
  24804. ],
  24805. [
  24806. 3,
  24807. twoDimHoriz
  24808. ],
  24809. [
  24810. 3,
  24811. twoDimHoriz
  24812. ],
  24813. [
  24814. 3,
  24815. twoDimHoriz
  24816. ],
  24817. [
  24818. 3,
  24819. twoDimHoriz
  24820. ],
  24821. [
  24822. 3,
  24823. twoDimHoriz
  24824. ],
  24825. [
  24826. 3,
  24827. twoDimHoriz
  24828. ],
  24829. [
  24830. 3,
  24831. twoDimHoriz
  24832. ],
  24833. [
  24834. 3,
  24835. twoDimHoriz
  24836. ],
  24837. [
  24838. 3,
  24839. twoDimHoriz
  24840. ],
  24841. [
  24842. 3,
  24843. twoDimHoriz
  24844. ],
  24845. [
  24846. 3,
  24847. twoDimHoriz
  24848. ],
  24849. [
  24850. 3,
  24851. twoDimHoriz
  24852. ],
  24853. [
  24854. 3,
  24855. twoDimHoriz
  24856. ],
  24857. [
  24858. 3,
  24859. twoDimHoriz
  24860. ],
  24861. [
  24862. 3,
  24863. twoDimHoriz
  24864. ],
  24865. [
  24866. 3,
  24867. twoDimVertL1
  24868. ],
  24869. [
  24870. 3,
  24871. twoDimVertL1
  24872. ],
  24873. [
  24874. 3,
  24875. twoDimVertL1
  24876. ],
  24877. [
  24878. 3,
  24879. twoDimVertL1
  24880. ],
  24881. [
  24882. 3,
  24883. twoDimVertL1
  24884. ],
  24885. [
  24886. 3,
  24887. twoDimVertL1
  24888. ],
  24889. [
  24890. 3,
  24891. twoDimVertL1
  24892. ],
  24893. [
  24894. 3,
  24895. twoDimVertL1
  24896. ],
  24897. [
  24898. 3,
  24899. twoDimVertL1
  24900. ],
  24901. [
  24902. 3,
  24903. twoDimVertL1
  24904. ],
  24905. [
  24906. 3,
  24907. twoDimVertL1
  24908. ],
  24909. [
  24910. 3,
  24911. twoDimVertL1
  24912. ],
  24913. [
  24914. 3,
  24915. twoDimVertL1
  24916. ],
  24917. [
  24918. 3,
  24919. twoDimVertL1
  24920. ],
  24921. [
  24922. 3,
  24923. twoDimVertL1
  24924. ],
  24925. [
  24926. 3,
  24927. twoDimVertL1
  24928. ],
  24929. [
  24930. 3,
  24931. twoDimVertR1
  24932. ],
  24933. [
  24934. 3,
  24935. twoDimVertR1
  24936. ],
  24937. [
  24938. 3,
  24939. twoDimVertR1
  24940. ],
  24941. [
  24942. 3,
  24943. twoDimVertR1
  24944. ],
  24945. [
  24946. 3,
  24947. twoDimVertR1
  24948. ],
  24949. [
  24950. 3,
  24951. twoDimVertR1
  24952. ],
  24953. [
  24954. 3,
  24955. twoDimVertR1
  24956. ],
  24957. [
  24958. 3,
  24959. twoDimVertR1
  24960. ],
  24961. [
  24962. 3,
  24963. twoDimVertR1
  24964. ],
  24965. [
  24966. 3,
  24967. twoDimVertR1
  24968. ],
  24969. [
  24970. 3,
  24971. twoDimVertR1
  24972. ],
  24973. [
  24974. 3,
  24975. twoDimVertR1
  24976. ],
  24977. [
  24978. 3,
  24979. twoDimVertR1
  24980. ],
  24981. [
  24982. 3,
  24983. twoDimVertR1
  24984. ],
  24985. [
  24986. 3,
  24987. twoDimVertR1
  24988. ],
  24989. [
  24990. 3,
  24991. twoDimVertR1
  24992. ],
  24993. [
  24994. 1,
  24995. twoDimVert0
  24996. ],
  24997. [
  24998. 1,
  24999. twoDimVert0
  25000. ],
  25001. [
  25002. 1,
  25003. twoDimVert0
  25004. ],
  25005. [
  25006. 1,
  25007. twoDimVert0
  25008. ],
  25009. [
  25010. 1,
  25011. twoDimVert0
  25012. ],
  25013. [
  25014. 1,
  25015. twoDimVert0
  25016. ],
  25017. [
  25018. 1,
  25019. twoDimVert0
  25020. ],
  25021. [
  25022. 1,
  25023. twoDimVert0
  25024. ],
  25025. [
  25026. 1,
  25027. twoDimVert0
  25028. ],
  25029. [
  25030. 1,
  25031. twoDimVert0
  25032. ],
  25033. [
  25034. 1,
  25035. twoDimVert0
  25036. ],
  25037. [
  25038. 1,
  25039. twoDimVert0
  25040. ],
  25041. [
  25042. 1,
  25043. twoDimVert0
  25044. ],
  25045. [
  25046. 1,
  25047. twoDimVert0
  25048. ],
  25049. [
  25050. 1,
  25051. twoDimVert0
  25052. ],
  25053. [
  25054. 1,
  25055. twoDimVert0
  25056. ],
  25057. [
  25058. 1,
  25059. twoDimVert0
  25060. ],
  25061. [
  25062. 1,
  25063. twoDimVert0
  25064. ],
  25065. [
  25066. 1,
  25067. twoDimVert0
  25068. ],
  25069. [
  25070. 1,
  25071. twoDimVert0
  25072. ],
  25073. [
  25074. 1,
  25075. twoDimVert0
  25076. ],
  25077. [
  25078. 1,
  25079. twoDimVert0
  25080. ],
  25081. [
  25082. 1,
  25083. twoDimVert0
  25084. ],
  25085. [
  25086. 1,
  25087. twoDimVert0
  25088. ],
  25089. [
  25090. 1,
  25091. twoDimVert0
  25092. ],
  25093. [
  25094. 1,
  25095. twoDimVert0
  25096. ],
  25097. [
  25098. 1,
  25099. twoDimVert0
  25100. ],
  25101. [
  25102. 1,
  25103. twoDimVert0
  25104. ],
  25105. [
  25106. 1,
  25107. twoDimVert0
  25108. ],
  25109. [
  25110. 1,
  25111. twoDimVert0
  25112. ],
  25113. [
  25114. 1,
  25115. twoDimVert0
  25116. ],
  25117. [
  25118. 1,
  25119. twoDimVert0
  25120. ],
  25121. [
  25122. 1,
  25123. twoDimVert0
  25124. ],
  25125. [
  25126. 1,
  25127. twoDimVert0
  25128. ],
  25129. [
  25130. 1,
  25131. twoDimVert0
  25132. ],
  25133. [
  25134. 1,
  25135. twoDimVert0
  25136. ],
  25137. [
  25138. 1,
  25139. twoDimVert0
  25140. ],
  25141. [
  25142. 1,
  25143. twoDimVert0
  25144. ],
  25145. [
  25146. 1,
  25147. twoDimVert0
  25148. ],
  25149. [
  25150. 1,
  25151. twoDimVert0
  25152. ],
  25153. [
  25154. 1,
  25155. twoDimVert0
  25156. ],
  25157. [
  25158. 1,
  25159. twoDimVert0
  25160. ],
  25161. [
  25162. 1,
  25163. twoDimVert0
  25164. ],
  25165. [
  25166. 1,
  25167. twoDimVert0
  25168. ],
  25169. [
  25170. 1,
  25171. twoDimVert0
  25172. ],
  25173. [
  25174. 1,
  25175. twoDimVert0
  25176. ],
  25177. [
  25178. 1,
  25179. twoDimVert0
  25180. ],
  25181. [
  25182. 1,
  25183. twoDimVert0
  25184. ],
  25185. [
  25186. 1,
  25187. twoDimVert0
  25188. ],
  25189. [
  25190. 1,
  25191. twoDimVert0
  25192. ],
  25193. [
  25194. 1,
  25195. twoDimVert0
  25196. ],
  25197. [
  25198. 1,
  25199. twoDimVert0
  25200. ],
  25201. [
  25202. 1,
  25203. twoDimVert0
  25204. ],
  25205. [
  25206. 1,
  25207. twoDimVert0
  25208. ],
  25209. [
  25210. 1,
  25211. twoDimVert0
  25212. ],
  25213. [
  25214. 1,
  25215. twoDimVert0
  25216. ],
  25217. [
  25218. 1,
  25219. twoDimVert0
  25220. ],
  25221. [
  25222. 1,
  25223. twoDimVert0
  25224. ],
  25225. [
  25226. 1,
  25227. twoDimVert0
  25228. ],
  25229. [
  25230. 1,
  25231. twoDimVert0
  25232. ],
  25233. [
  25234. 1,
  25235. twoDimVert0
  25236. ],
  25237. [
  25238. 1,
  25239. twoDimVert0
  25240. ],
  25241. [
  25242. 1,
  25243. twoDimVert0
  25244. ],
  25245. [
  25246. 1,
  25247. twoDimVert0
  25248. ]
  25249. ];
  25250. var whiteTable1 = [
  25251. [
  25252. -1,
  25253. -1
  25254. ],
  25255. [
  25256. 12,
  25257. ccittEOL
  25258. ],
  25259. [
  25260. -1,
  25261. -1
  25262. ],
  25263. [
  25264. -1,
  25265. -1
  25266. ],
  25267. [
  25268. -1,
  25269. -1
  25270. ],
  25271. [
  25272. -1,
  25273. -1
  25274. ],
  25275. [
  25276. -1,
  25277. -1
  25278. ],
  25279. [
  25280. -1,
  25281. -1
  25282. ],
  25283. [
  25284. -1,
  25285. -1
  25286. ],
  25287. [
  25288. -1,
  25289. -1
  25290. ],
  25291. [
  25292. -1,
  25293. -1
  25294. ],
  25295. [
  25296. -1,
  25297. -1
  25298. ],
  25299. [
  25300. -1,
  25301. -1
  25302. ],
  25303. [
  25304. -1,
  25305. -1
  25306. ],
  25307. [
  25308. -1,
  25309. -1
  25310. ],
  25311. [
  25312. -1,
  25313. -1
  25314. ],
  25315. [
  25316. 11,
  25317. 1792
  25318. ],
  25319. [
  25320. 11,
  25321. 1792
  25322. ],
  25323. [
  25324. 12,
  25325. 1984
  25326. ],
  25327. [
  25328. 12,
  25329. 2048
  25330. ],
  25331. [
  25332. 12,
  25333. 2112
  25334. ],
  25335. [
  25336. 12,
  25337. 2176
  25338. ],
  25339. [
  25340. 12,
  25341. 2240
  25342. ],
  25343. [
  25344. 12,
  25345. 2304
  25346. ],
  25347. [
  25348. 11,
  25349. 1856
  25350. ],
  25351. [
  25352. 11,
  25353. 1856
  25354. ],
  25355. [
  25356. 11,
  25357. 1920
  25358. ],
  25359. [
  25360. 11,
  25361. 1920
  25362. ],
  25363. [
  25364. 12,
  25365. 2368
  25366. ],
  25367. [
  25368. 12,
  25369. 2432
  25370. ],
  25371. [
  25372. 12,
  25373. 2496
  25374. ],
  25375. [
  25376. 12,
  25377. 2560
  25378. ]
  25379. ];
  25380. var whiteTable2 = [
  25381. [
  25382. -1,
  25383. -1
  25384. ],
  25385. [
  25386. -1,
  25387. -1
  25388. ],
  25389. [
  25390. -1,
  25391. -1
  25392. ],
  25393. [
  25394. -1,
  25395. -1
  25396. ],
  25397. [
  25398. 8,
  25399. 29
  25400. ],
  25401. [
  25402. 8,
  25403. 29
  25404. ],
  25405. [
  25406. 8,
  25407. 30
  25408. ],
  25409. [
  25410. 8,
  25411. 30
  25412. ],
  25413. [
  25414. 8,
  25415. 45
  25416. ],
  25417. [
  25418. 8,
  25419. 45
  25420. ],
  25421. [
  25422. 8,
  25423. 46
  25424. ],
  25425. [
  25426. 8,
  25427. 46
  25428. ],
  25429. [
  25430. 7,
  25431. 22
  25432. ],
  25433. [
  25434. 7,
  25435. 22
  25436. ],
  25437. [
  25438. 7,
  25439. 22
  25440. ],
  25441. [
  25442. 7,
  25443. 22
  25444. ],
  25445. [
  25446. 7,
  25447. 23
  25448. ],
  25449. [
  25450. 7,
  25451. 23
  25452. ],
  25453. [
  25454. 7,
  25455. 23
  25456. ],
  25457. [
  25458. 7,
  25459. 23
  25460. ],
  25461. [
  25462. 8,
  25463. 47
  25464. ],
  25465. [
  25466. 8,
  25467. 47
  25468. ],
  25469. [
  25470. 8,
  25471. 48
  25472. ],
  25473. [
  25474. 8,
  25475. 48
  25476. ],
  25477. [
  25478. 6,
  25479. 13
  25480. ],
  25481. [
  25482. 6,
  25483. 13
  25484. ],
  25485. [
  25486. 6,
  25487. 13
  25488. ],
  25489. [
  25490. 6,
  25491. 13
  25492. ],
  25493. [
  25494. 6,
  25495. 13
  25496. ],
  25497. [
  25498. 6,
  25499. 13
  25500. ],
  25501. [
  25502. 6,
  25503. 13
  25504. ],
  25505. [
  25506. 6,
  25507. 13
  25508. ],
  25509. [
  25510. 7,
  25511. 20
  25512. ],
  25513. [
  25514. 7,
  25515. 20
  25516. ],
  25517. [
  25518. 7,
  25519. 20
  25520. ],
  25521. [
  25522. 7,
  25523. 20
  25524. ],
  25525. [
  25526. 8,
  25527. 33
  25528. ],
  25529. [
  25530. 8,
  25531. 33
  25532. ],
  25533. [
  25534. 8,
  25535. 34
  25536. ],
  25537. [
  25538. 8,
  25539. 34
  25540. ],
  25541. [
  25542. 8,
  25543. 35
  25544. ],
  25545. [
  25546. 8,
  25547. 35
  25548. ],
  25549. [
  25550. 8,
  25551. 36
  25552. ],
  25553. [
  25554. 8,
  25555. 36
  25556. ],
  25557. [
  25558. 8,
  25559. 37
  25560. ],
  25561. [
  25562. 8,
  25563. 37
  25564. ],
  25565. [
  25566. 8,
  25567. 38
  25568. ],
  25569. [
  25570. 8,
  25571. 38
  25572. ],
  25573. [
  25574. 7,
  25575. 19
  25576. ],
  25577. [
  25578. 7,
  25579. 19
  25580. ],
  25581. [
  25582. 7,
  25583. 19
  25584. ],
  25585. [
  25586. 7,
  25587. 19
  25588. ],
  25589. [
  25590. 8,
  25591. 31
  25592. ],
  25593. [
  25594. 8,
  25595. 31
  25596. ],
  25597. [
  25598. 8,
  25599. 32
  25600. ],
  25601. [
  25602. 8,
  25603. 32
  25604. ],
  25605. [
  25606. 6,
  25607. 1
  25608. ],
  25609. [
  25610. 6,
  25611. 1
  25612. ],
  25613. [
  25614. 6,
  25615. 1
  25616. ],
  25617. [
  25618. 6,
  25619. 1
  25620. ],
  25621. [
  25622. 6,
  25623. 1
  25624. ],
  25625. [
  25626. 6,
  25627. 1
  25628. ],
  25629. [
  25630. 6,
  25631. 1
  25632. ],
  25633. [
  25634. 6,
  25635. 1
  25636. ],
  25637. [
  25638. 6,
  25639. 12
  25640. ],
  25641. [
  25642. 6,
  25643. 12
  25644. ],
  25645. [
  25646. 6,
  25647. 12
  25648. ],
  25649. [
  25650. 6,
  25651. 12
  25652. ],
  25653. [
  25654. 6,
  25655. 12
  25656. ],
  25657. [
  25658. 6,
  25659. 12
  25660. ],
  25661. [
  25662. 6,
  25663. 12
  25664. ],
  25665. [
  25666. 6,
  25667. 12
  25668. ],
  25669. [
  25670. 8,
  25671. 53
  25672. ],
  25673. [
  25674. 8,
  25675. 53
  25676. ],
  25677. [
  25678. 8,
  25679. 54
  25680. ],
  25681. [
  25682. 8,
  25683. 54
  25684. ],
  25685. [
  25686. 7,
  25687. 26
  25688. ],
  25689. [
  25690. 7,
  25691. 26
  25692. ],
  25693. [
  25694. 7,
  25695. 26
  25696. ],
  25697. [
  25698. 7,
  25699. 26
  25700. ],
  25701. [
  25702. 8,
  25703. 39
  25704. ],
  25705. [
  25706. 8,
  25707. 39
  25708. ],
  25709. [
  25710. 8,
  25711. 40
  25712. ],
  25713. [
  25714. 8,
  25715. 40
  25716. ],
  25717. [
  25718. 8,
  25719. 41
  25720. ],
  25721. [
  25722. 8,
  25723. 41
  25724. ],
  25725. [
  25726. 8,
  25727. 42
  25728. ],
  25729. [
  25730. 8,
  25731. 42
  25732. ],
  25733. [
  25734. 8,
  25735. 43
  25736. ],
  25737. [
  25738. 8,
  25739. 43
  25740. ],
  25741. [
  25742. 8,
  25743. 44
  25744. ],
  25745. [
  25746. 8,
  25747. 44
  25748. ],
  25749. [
  25750. 7,
  25751. 21
  25752. ],
  25753. [
  25754. 7,
  25755. 21
  25756. ],
  25757. [
  25758. 7,
  25759. 21
  25760. ],
  25761. [
  25762. 7,
  25763. 21
  25764. ],
  25765. [
  25766. 7,
  25767. 28
  25768. ],
  25769. [
  25770. 7,
  25771. 28
  25772. ],
  25773. [
  25774. 7,
  25775. 28
  25776. ],
  25777. [
  25778. 7,
  25779. 28
  25780. ],
  25781. [
  25782. 8,
  25783. 61
  25784. ],
  25785. [
  25786. 8,
  25787. 61
  25788. ],
  25789. [
  25790. 8,
  25791. 62
  25792. ],
  25793. [
  25794. 8,
  25795. 62
  25796. ],
  25797. [
  25798. 8,
  25799. 63
  25800. ],
  25801. [
  25802. 8,
  25803. 63
  25804. ],
  25805. [
  25806. 8,
  25807. 0
  25808. ],
  25809. [
  25810. 8,
  25811. 0
  25812. ],
  25813. [
  25814. 8,
  25815. 320
  25816. ],
  25817. [
  25818. 8,
  25819. 320
  25820. ],
  25821. [
  25822. 8,
  25823. 384
  25824. ],
  25825. [
  25826. 8,
  25827. 384
  25828. ],
  25829. [
  25830. 5,
  25831. 10
  25832. ],
  25833. [
  25834. 5,
  25835. 10
  25836. ],
  25837. [
  25838. 5,
  25839. 10
  25840. ],
  25841. [
  25842. 5,
  25843. 10
  25844. ],
  25845. [
  25846. 5,
  25847. 10
  25848. ],
  25849. [
  25850. 5,
  25851. 10
  25852. ],
  25853. [
  25854. 5,
  25855. 10
  25856. ],
  25857. [
  25858. 5,
  25859. 10
  25860. ],
  25861. [
  25862. 5,
  25863. 10
  25864. ],
  25865. [
  25866. 5,
  25867. 10
  25868. ],
  25869. [
  25870. 5,
  25871. 10
  25872. ],
  25873. [
  25874. 5,
  25875. 10
  25876. ],
  25877. [
  25878. 5,
  25879. 10
  25880. ],
  25881. [
  25882. 5,
  25883. 10
  25884. ],
  25885. [
  25886. 5,
  25887. 10
  25888. ],
  25889. [
  25890. 5,
  25891. 10
  25892. ],
  25893. [
  25894. 5,
  25895. 11
  25896. ],
  25897. [
  25898. 5,
  25899. 11
  25900. ],
  25901. [
  25902. 5,
  25903. 11
  25904. ],
  25905. [
  25906. 5,
  25907. 11
  25908. ],
  25909. [
  25910. 5,
  25911. 11
  25912. ],
  25913. [
  25914. 5,
  25915. 11
  25916. ],
  25917. [
  25918. 5,
  25919. 11
  25920. ],
  25921. [
  25922. 5,
  25923. 11
  25924. ],
  25925. [
  25926. 5,
  25927. 11
  25928. ],
  25929. [
  25930. 5,
  25931. 11
  25932. ],
  25933. [
  25934. 5,
  25935. 11
  25936. ],
  25937. [
  25938. 5,
  25939. 11
  25940. ],
  25941. [
  25942. 5,
  25943. 11
  25944. ],
  25945. [
  25946. 5,
  25947. 11
  25948. ],
  25949. [
  25950. 5,
  25951. 11
  25952. ],
  25953. [
  25954. 5,
  25955. 11
  25956. ],
  25957. [
  25958. 7,
  25959. 27
  25960. ],
  25961. [
  25962. 7,
  25963. 27
  25964. ],
  25965. [
  25966. 7,
  25967. 27
  25968. ],
  25969. [
  25970. 7,
  25971. 27
  25972. ],
  25973. [
  25974. 8,
  25975. 59
  25976. ],
  25977. [
  25978. 8,
  25979. 59
  25980. ],
  25981. [
  25982. 8,
  25983. 60
  25984. ],
  25985. [
  25986. 8,
  25987. 60
  25988. ],
  25989. [
  25990. 9,
  25991. 1472
  25992. ],
  25993. [
  25994. 9,
  25995. 1536
  25996. ],
  25997. [
  25998. 9,
  25999. 1600
  26000. ],
  26001. [
  26002. 9,
  26003. 1728
  26004. ],
  26005. [
  26006. 7,
  26007. 18
  26008. ],
  26009. [
  26010. 7,
  26011. 18
  26012. ],
  26013. [
  26014. 7,
  26015. 18
  26016. ],
  26017. [
  26018. 7,
  26019. 18
  26020. ],
  26021. [
  26022. 7,
  26023. 24
  26024. ],
  26025. [
  26026. 7,
  26027. 24
  26028. ],
  26029. [
  26030. 7,
  26031. 24
  26032. ],
  26033. [
  26034. 7,
  26035. 24
  26036. ],
  26037. [
  26038. 8,
  26039. 49
  26040. ],
  26041. [
  26042. 8,
  26043. 49
  26044. ],
  26045. [
  26046. 8,
  26047. 50
  26048. ],
  26049. [
  26050. 8,
  26051. 50
  26052. ],
  26053. [
  26054. 8,
  26055. 51
  26056. ],
  26057. [
  26058. 8,
  26059. 51
  26060. ],
  26061. [
  26062. 8,
  26063. 52
  26064. ],
  26065. [
  26066. 8,
  26067. 52
  26068. ],
  26069. [
  26070. 7,
  26071. 25
  26072. ],
  26073. [
  26074. 7,
  26075. 25
  26076. ],
  26077. [
  26078. 7,
  26079. 25
  26080. ],
  26081. [
  26082. 7,
  26083. 25
  26084. ],
  26085. [
  26086. 8,
  26087. 55
  26088. ],
  26089. [
  26090. 8,
  26091. 55
  26092. ],
  26093. [
  26094. 8,
  26095. 56
  26096. ],
  26097. [
  26098. 8,
  26099. 56
  26100. ],
  26101. [
  26102. 8,
  26103. 57
  26104. ],
  26105. [
  26106. 8,
  26107. 57
  26108. ],
  26109. [
  26110. 8,
  26111. 58
  26112. ],
  26113. [
  26114. 8,
  26115. 58
  26116. ],
  26117. [
  26118. 6,
  26119. 192
  26120. ],
  26121. [
  26122. 6,
  26123. 192
  26124. ],
  26125. [
  26126. 6,
  26127. 192
  26128. ],
  26129. [
  26130. 6,
  26131. 192
  26132. ],
  26133. [
  26134. 6,
  26135. 192
  26136. ],
  26137. [
  26138. 6,
  26139. 192
  26140. ],
  26141. [
  26142. 6,
  26143. 192
  26144. ],
  26145. [
  26146. 6,
  26147. 192
  26148. ],
  26149. [
  26150. 6,
  26151. 1664
  26152. ],
  26153. [
  26154. 6,
  26155. 1664
  26156. ],
  26157. [
  26158. 6,
  26159. 1664
  26160. ],
  26161. [
  26162. 6,
  26163. 1664
  26164. ],
  26165. [
  26166. 6,
  26167. 1664
  26168. ],
  26169. [
  26170. 6,
  26171. 1664
  26172. ],
  26173. [
  26174. 6,
  26175. 1664
  26176. ],
  26177. [
  26178. 6,
  26179. 1664
  26180. ],
  26181. [
  26182. 8,
  26183. 448
  26184. ],
  26185. [
  26186. 8,
  26187. 448
  26188. ],
  26189. [
  26190. 8,
  26191. 512
  26192. ],
  26193. [
  26194. 8,
  26195. 512
  26196. ],
  26197. [
  26198. 9,
  26199. 704
  26200. ],
  26201. [
  26202. 9,
  26203. 768
  26204. ],
  26205. [
  26206. 8,
  26207. 640
  26208. ],
  26209. [
  26210. 8,
  26211. 640
  26212. ],
  26213. [
  26214. 8,
  26215. 576
  26216. ],
  26217. [
  26218. 8,
  26219. 576
  26220. ],
  26221. [
  26222. 9,
  26223. 832
  26224. ],
  26225. [
  26226. 9,
  26227. 896
  26228. ],
  26229. [
  26230. 9,
  26231. 960
  26232. ],
  26233. [
  26234. 9,
  26235. 1024
  26236. ],
  26237. [
  26238. 9,
  26239. 1088
  26240. ],
  26241. [
  26242. 9,
  26243. 1152
  26244. ],
  26245. [
  26246. 9,
  26247. 1216
  26248. ],
  26249. [
  26250. 9,
  26251. 1280
  26252. ],
  26253. [
  26254. 9,
  26255. 1344
  26256. ],
  26257. [
  26258. 9,
  26259. 1408
  26260. ],
  26261. [
  26262. 7,
  26263. 256
  26264. ],
  26265. [
  26266. 7,
  26267. 256
  26268. ],
  26269. [
  26270. 7,
  26271. 256
  26272. ],
  26273. [
  26274. 7,
  26275. 256
  26276. ],
  26277. [
  26278. 4,
  26279. 2
  26280. ],
  26281. [
  26282. 4,
  26283. 2
  26284. ],
  26285. [
  26286. 4,
  26287. 2
  26288. ],
  26289. [
  26290. 4,
  26291. 2
  26292. ],
  26293. [
  26294. 4,
  26295. 2
  26296. ],
  26297. [
  26298. 4,
  26299. 2
  26300. ],
  26301. [
  26302. 4,
  26303. 2
  26304. ],
  26305. [
  26306. 4,
  26307. 2
  26308. ],
  26309. [
  26310. 4,
  26311. 2
  26312. ],
  26313. [
  26314. 4,
  26315. 2
  26316. ],
  26317. [
  26318. 4,
  26319. 2
  26320. ],
  26321. [
  26322. 4,
  26323. 2
  26324. ],
  26325. [
  26326. 4,
  26327. 2
  26328. ],
  26329. [
  26330. 4,
  26331. 2
  26332. ],
  26333. [
  26334. 4,
  26335. 2
  26336. ],
  26337. [
  26338. 4,
  26339. 2
  26340. ],
  26341. [
  26342. 4,
  26343. 2
  26344. ],
  26345. [
  26346. 4,
  26347. 2
  26348. ],
  26349. [
  26350. 4,
  26351. 2
  26352. ],
  26353. [
  26354. 4,
  26355. 2
  26356. ],
  26357. [
  26358. 4,
  26359. 2
  26360. ],
  26361. [
  26362. 4,
  26363. 2
  26364. ],
  26365. [
  26366. 4,
  26367. 2
  26368. ],
  26369. [
  26370. 4,
  26371. 2
  26372. ],
  26373. [
  26374. 4,
  26375. 2
  26376. ],
  26377. [
  26378. 4,
  26379. 2
  26380. ],
  26381. [
  26382. 4,
  26383. 2
  26384. ],
  26385. [
  26386. 4,
  26387. 2
  26388. ],
  26389. [
  26390. 4,
  26391. 2
  26392. ],
  26393. [
  26394. 4,
  26395. 2
  26396. ],
  26397. [
  26398. 4,
  26399. 2
  26400. ],
  26401. [
  26402. 4,
  26403. 2
  26404. ],
  26405. [
  26406. 4,
  26407. 3
  26408. ],
  26409. [
  26410. 4,
  26411. 3
  26412. ],
  26413. [
  26414. 4,
  26415. 3
  26416. ],
  26417. [
  26418. 4,
  26419. 3
  26420. ],
  26421. [
  26422. 4,
  26423. 3
  26424. ],
  26425. [
  26426. 4,
  26427. 3
  26428. ],
  26429. [
  26430. 4,
  26431. 3
  26432. ],
  26433. [
  26434. 4,
  26435. 3
  26436. ],
  26437. [
  26438. 4,
  26439. 3
  26440. ],
  26441. [
  26442. 4,
  26443. 3
  26444. ],
  26445. [
  26446. 4,
  26447. 3
  26448. ],
  26449. [
  26450. 4,
  26451. 3
  26452. ],
  26453. [
  26454. 4,
  26455. 3
  26456. ],
  26457. [
  26458. 4,
  26459. 3
  26460. ],
  26461. [
  26462. 4,
  26463. 3
  26464. ],
  26465. [
  26466. 4,
  26467. 3
  26468. ],
  26469. [
  26470. 4,
  26471. 3
  26472. ],
  26473. [
  26474. 4,
  26475. 3
  26476. ],
  26477. [
  26478. 4,
  26479. 3
  26480. ],
  26481. [
  26482. 4,
  26483. 3
  26484. ],
  26485. [
  26486. 4,
  26487. 3
  26488. ],
  26489. [
  26490. 4,
  26491. 3
  26492. ],
  26493. [
  26494. 4,
  26495. 3
  26496. ],
  26497. [
  26498. 4,
  26499. 3
  26500. ],
  26501. [
  26502. 4,
  26503. 3
  26504. ],
  26505. [
  26506. 4,
  26507. 3
  26508. ],
  26509. [
  26510. 4,
  26511. 3
  26512. ],
  26513. [
  26514. 4,
  26515. 3
  26516. ],
  26517. [
  26518. 4,
  26519. 3
  26520. ],
  26521. [
  26522. 4,
  26523. 3
  26524. ],
  26525. [
  26526. 4,
  26527. 3
  26528. ],
  26529. [
  26530. 4,
  26531. 3
  26532. ],
  26533. [
  26534. 5,
  26535. 128
  26536. ],
  26537. [
  26538. 5,
  26539. 128
  26540. ],
  26541. [
  26542. 5,
  26543. 128
  26544. ],
  26545. [
  26546. 5,
  26547. 128
  26548. ],
  26549. [
  26550. 5,
  26551. 128
  26552. ],
  26553. [
  26554. 5,
  26555. 128
  26556. ],
  26557. [
  26558. 5,
  26559. 128
  26560. ],
  26561. [
  26562. 5,
  26563. 128
  26564. ],
  26565. [
  26566. 5,
  26567. 128
  26568. ],
  26569. [
  26570. 5,
  26571. 128
  26572. ],
  26573. [
  26574. 5,
  26575. 128
  26576. ],
  26577. [
  26578. 5,
  26579. 128
  26580. ],
  26581. [
  26582. 5,
  26583. 128
  26584. ],
  26585. [
  26586. 5,
  26587. 128
  26588. ],
  26589. [
  26590. 5,
  26591. 128
  26592. ],
  26593. [
  26594. 5,
  26595. 128
  26596. ],
  26597. [
  26598. 5,
  26599. 8
  26600. ],
  26601. [
  26602. 5,
  26603. 8
  26604. ],
  26605. [
  26606. 5,
  26607. 8
  26608. ],
  26609. [
  26610. 5,
  26611. 8
  26612. ],
  26613. [
  26614. 5,
  26615. 8
  26616. ],
  26617. [
  26618. 5,
  26619. 8
  26620. ],
  26621. [
  26622. 5,
  26623. 8
  26624. ],
  26625. [
  26626. 5,
  26627. 8
  26628. ],
  26629. [
  26630. 5,
  26631. 8
  26632. ],
  26633. [
  26634. 5,
  26635. 8
  26636. ],
  26637. [
  26638. 5,
  26639. 8
  26640. ],
  26641. [
  26642. 5,
  26643. 8
  26644. ],
  26645. [
  26646. 5,
  26647. 8
  26648. ],
  26649. [
  26650. 5,
  26651. 8
  26652. ],
  26653. [
  26654. 5,
  26655. 8
  26656. ],
  26657. [
  26658. 5,
  26659. 8
  26660. ],
  26661. [
  26662. 5,
  26663. 9
  26664. ],
  26665. [
  26666. 5,
  26667. 9
  26668. ],
  26669. [
  26670. 5,
  26671. 9
  26672. ],
  26673. [
  26674. 5,
  26675. 9
  26676. ],
  26677. [
  26678. 5,
  26679. 9
  26680. ],
  26681. [
  26682. 5,
  26683. 9
  26684. ],
  26685. [
  26686. 5,
  26687. 9
  26688. ],
  26689. [
  26690. 5,
  26691. 9
  26692. ],
  26693. [
  26694. 5,
  26695. 9
  26696. ],
  26697. [
  26698. 5,
  26699. 9
  26700. ],
  26701. [
  26702. 5,
  26703. 9
  26704. ],
  26705. [
  26706. 5,
  26707. 9
  26708. ],
  26709. [
  26710. 5,
  26711. 9
  26712. ],
  26713. [
  26714. 5,
  26715. 9
  26716. ],
  26717. [
  26718. 5,
  26719. 9
  26720. ],
  26721. [
  26722. 5,
  26723. 9
  26724. ],
  26725. [
  26726. 6,
  26727. 16
  26728. ],
  26729. [
  26730. 6,
  26731. 16
  26732. ],
  26733. [
  26734. 6,
  26735. 16
  26736. ],
  26737. [
  26738. 6,
  26739. 16
  26740. ],
  26741. [
  26742. 6,
  26743. 16
  26744. ],
  26745. [
  26746. 6,
  26747. 16
  26748. ],
  26749. [
  26750. 6,
  26751. 16
  26752. ],
  26753. [
  26754. 6,
  26755. 16
  26756. ],
  26757. [
  26758. 6,
  26759. 17
  26760. ],
  26761. [
  26762. 6,
  26763. 17
  26764. ],
  26765. [
  26766. 6,
  26767. 17
  26768. ],
  26769. [
  26770. 6,
  26771. 17
  26772. ],
  26773. [
  26774. 6,
  26775. 17
  26776. ],
  26777. [
  26778. 6,
  26779. 17
  26780. ],
  26781. [
  26782. 6,
  26783. 17
  26784. ],
  26785. [
  26786. 6,
  26787. 17
  26788. ],
  26789. [
  26790. 4,
  26791. 4
  26792. ],
  26793. [
  26794. 4,
  26795. 4
  26796. ],
  26797. [
  26798. 4,
  26799. 4
  26800. ],
  26801. [
  26802. 4,
  26803. 4
  26804. ],
  26805. [
  26806. 4,
  26807. 4
  26808. ],
  26809. [
  26810. 4,
  26811. 4
  26812. ],
  26813. [
  26814. 4,
  26815. 4
  26816. ],
  26817. [
  26818. 4,
  26819. 4
  26820. ],
  26821. [
  26822. 4,
  26823. 4
  26824. ],
  26825. [
  26826. 4,
  26827. 4
  26828. ],
  26829. [
  26830. 4,
  26831. 4
  26832. ],
  26833. [
  26834. 4,
  26835. 4
  26836. ],
  26837. [
  26838. 4,
  26839. 4
  26840. ],
  26841. [
  26842. 4,
  26843. 4
  26844. ],
  26845. [
  26846. 4,
  26847. 4
  26848. ],
  26849. [
  26850. 4,
  26851. 4
  26852. ],
  26853. [
  26854. 4,
  26855. 4
  26856. ],
  26857. [
  26858. 4,
  26859. 4
  26860. ],
  26861. [
  26862. 4,
  26863. 4
  26864. ],
  26865. [
  26866. 4,
  26867. 4
  26868. ],
  26869. [
  26870. 4,
  26871. 4
  26872. ],
  26873. [
  26874. 4,
  26875. 4
  26876. ],
  26877. [
  26878. 4,
  26879. 4
  26880. ],
  26881. [
  26882. 4,
  26883. 4
  26884. ],
  26885. [
  26886. 4,
  26887. 4
  26888. ],
  26889. [
  26890. 4,
  26891. 4
  26892. ],
  26893. [
  26894. 4,
  26895. 4
  26896. ],
  26897. [
  26898. 4,
  26899. 4
  26900. ],
  26901. [
  26902. 4,
  26903. 4
  26904. ],
  26905. [
  26906. 4,
  26907. 4
  26908. ],
  26909. [
  26910. 4,
  26911. 4
  26912. ],
  26913. [
  26914. 4,
  26915. 4
  26916. ],
  26917. [
  26918. 4,
  26919. 5
  26920. ],
  26921. [
  26922. 4,
  26923. 5
  26924. ],
  26925. [
  26926. 4,
  26927. 5
  26928. ],
  26929. [
  26930. 4,
  26931. 5
  26932. ],
  26933. [
  26934. 4,
  26935. 5
  26936. ],
  26937. [
  26938. 4,
  26939. 5
  26940. ],
  26941. [
  26942. 4,
  26943. 5
  26944. ],
  26945. [
  26946. 4,
  26947. 5
  26948. ],
  26949. [
  26950. 4,
  26951. 5
  26952. ],
  26953. [
  26954. 4,
  26955. 5
  26956. ],
  26957. [
  26958. 4,
  26959. 5
  26960. ],
  26961. [
  26962. 4,
  26963. 5
  26964. ],
  26965. [
  26966. 4,
  26967. 5
  26968. ],
  26969. [
  26970. 4,
  26971. 5
  26972. ],
  26973. [
  26974. 4,
  26975. 5
  26976. ],
  26977. [
  26978. 4,
  26979. 5
  26980. ],
  26981. [
  26982. 4,
  26983. 5
  26984. ],
  26985. [
  26986. 4,
  26987. 5
  26988. ],
  26989. [
  26990. 4,
  26991. 5
  26992. ],
  26993. [
  26994. 4,
  26995. 5
  26996. ],
  26997. [
  26998. 4,
  26999. 5
  27000. ],
  27001. [
  27002. 4,
  27003. 5
  27004. ],
  27005. [
  27006. 4,
  27007. 5
  27008. ],
  27009. [
  27010. 4,
  27011. 5
  27012. ],
  27013. [
  27014. 4,
  27015. 5
  27016. ],
  27017. [
  27018. 4,
  27019. 5
  27020. ],
  27021. [
  27022. 4,
  27023. 5
  27024. ],
  27025. [
  27026. 4,
  27027. 5
  27028. ],
  27029. [
  27030. 4,
  27031. 5
  27032. ],
  27033. [
  27034. 4,
  27035. 5
  27036. ],
  27037. [
  27038. 4,
  27039. 5
  27040. ],
  27041. [
  27042. 4,
  27043. 5
  27044. ],
  27045. [
  27046. 6,
  27047. 14
  27048. ],
  27049. [
  27050. 6,
  27051. 14
  27052. ],
  27053. [
  27054. 6,
  27055. 14
  27056. ],
  27057. [
  27058. 6,
  27059. 14
  27060. ],
  27061. [
  27062. 6,
  27063. 14
  27064. ],
  27065. [
  27066. 6,
  27067. 14
  27068. ],
  27069. [
  27070. 6,
  27071. 14
  27072. ],
  27073. [
  27074. 6,
  27075. 14
  27076. ],
  27077. [
  27078. 6,
  27079. 15
  27080. ],
  27081. [
  27082. 6,
  27083. 15
  27084. ],
  27085. [
  27086. 6,
  27087. 15
  27088. ],
  27089. [
  27090. 6,
  27091. 15
  27092. ],
  27093. [
  27094. 6,
  27095. 15
  27096. ],
  27097. [
  27098. 6,
  27099. 15
  27100. ],
  27101. [
  27102. 6,
  27103. 15
  27104. ],
  27105. [
  27106. 6,
  27107. 15
  27108. ],
  27109. [
  27110. 5,
  27111. 64
  27112. ],
  27113. [
  27114. 5,
  27115. 64
  27116. ],
  27117. [
  27118. 5,
  27119. 64
  27120. ],
  27121. [
  27122. 5,
  27123. 64
  27124. ],
  27125. [
  27126. 5,
  27127. 64
  27128. ],
  27129. [
  27130. 5,
  27131. 64
  27132. ],
  27133. [
  27134. 5,
  27135. 64
  27136. ],
  27137. [
  27138. 5,
  27139. 64
  27140. ],
  27141. [
  27142. 5,
  27143. 64
  27144. ],
  27145. [
  27146. 5,
  27147. 64
  27148. ],
  27149. [
  27150. 5,
  27151. 64
  27152. ],
  27153. [
  27154. 5,
  27155. 64
  27156. ],
  27157. [
  27158. 5,
  27159. 64
  27160. ],
  27161. [
  27162. 5,
  27163. 64
  27164. ],
  27165. [
  27166. 5,
  27167. 64
  27168. ],
  27169. [
  27170. 5,
  27171. 64
  27172. ],
  27173. [
  27174. 4,
  27175. 6
  27176. ],
  27177. [
  27178. 4,
  27179. 6
  27180. ],
  27181. [
  27182. 4,
  27183. 6
  27184. ],
  27185. [
  27186. 4,
  27187. 6
  27188. ],
  27189. [
  27190. 4,
  27191. 6
  27192. ],
  27193. [
  27194. 4,
  27195. 6
  27196. ],
  27197. [
  27198. 4,
  27199. 6
  27200. ],
  27201. [
  27202. 4,
  27203. 6
  27204. ],
  27205. [
  27206. 4,
  27207. 6
  27208. ],
  27209. [
  27210. 4,
  27211. 6
  27212. ],
  27213. [
  27214. 4,
  27215. 6
  27216. ],
  27217. [
  27218. 4,
  27219. 6
  27220. ],
  27221. [
  27222. 4,
  27223. 6
  27224. ],
  27225. [
  27226. 4,
  27227. 6
  27228. ],
  27229. [
  27230. 4,
  27231. 6
  27232. ],
  27233. [
  27234. 4,
  27235. 6
  27236. ],
  27237. [
  27238. 4,
  27239. 6
  27240. ],
  27241. [
  27242. 4,
  27243. 6
  27244. ],
  27245. [
  27246. 4,
  27247. 6
  27248. ],
  27249. [
  27250. 4,
  27251. 6
  27252. ],
  27253. [
  27254. 4,
  27255. 6
  27256. ],
  27257. [
  27258. 4,
  27259. 6
  27260. ],
  27261. [
  27262. 4,
  27263. 6
  27264. ],
  27265. [
  27266. 4,
  27267. 6
  27268. ],
  27269. [
  27270. 4,
  27271. 6
  27272. ],
  27273. [
  27274. 4,
  27275. 6
  27276. ],
  27277. [
  27278. 4,
  27279. 6
  27280. ],
  27281. [
  27282. 4,
  27283. 6
  27284. ],
  27285. [
  27286. 4,
  27287. 6
  27288. ],
  27289. [
  27290. 4,
  27291. 6
  27292. ],
  27293. [
  27294. 4,
  27295. 6
  27296. ],
  27297. [
  27298. 4,
  27299. 6
  27300. ],
  27301. [
  27302. 4,
  27303. 7
  27304. ],
  27305. [
  27306. 4,
  27307. 7
  27308. ],
  27309. [
  27310. 4,
  27311. 7
  27312. ],
  27313. [
  27314. 4,
  27315. 7
  27316. ],
  27317. [
  27318. 4,
  27319. 7
  27320. ],
  27321. [
  27322. 4,
  27323. 7
  27324. ],
  27325. [
  27326. 4,
  27327. 7
  27328. ],
  27329. [
  27330. 4,
  27331. 7
  27332. ],
  27333. [
  27334. 4,
  27335. 7
  27336. ],
  27337. [
  27338. 4,
  27339. 7
  27340. ],
  27341. [
  27342. 4,
  27343. 7
  27344. ],
  27345. [
  27346. 4,
  27347. 7
  27348. ],
  27349. [
  27350. 4,
  27351. 7
  27352. ],
  27353. [
  27354. 4,
  27355. 7
  27356. ],
  27357. [
  27358. 4,
  27359. 7
  27360. ],
  27361. [
  27362. 4,
  27363. 7
  27364. ],
  27365. [
  27366. 4,
  27367. 7
  27368. ],
  27369. [
  27370. 4,
  27371. 7
  27372. ],
  27373. [
  27374. 4,
  27375. 7
  27376. ],
  27377. [
  27378. 4,
  27379. 7
  27380. ],
  27381. [
  27382. 4,
  27383. 7
  27384. ],
  27385. [
  27386. 4,
  27387. 7
  27388. ],
  27389. [
  27390. 4,
  27391. 7
  27392. ],
  27393. [
  27394. 4,
  27395. 7
  27396. ],
  27397. [
  27398. 4,
  27399. 7
  27400. ],
  27401. [
  27402. 4,
  27403. 7
  27404. ],
  27405. [
  27406. 4,
  27407. 7
  27408. ],
  27409. [
  27410. 4,
  27411. 7
  27412. ],
  27413. [
  27414. 4,
  27415. 7
  27416. ],
  27417. [
  27418. 4,
  27419. 7
  27420. ],
  27421. [
  27422. 4,
  27423. 7
  27424. ],
  27425. [
  27426. 4,
  27427. 7
  27428. ]
  27429. ];
  27430. var blackTable1 = [
  27431. [
  27432. -1,
  27433. -1
  27434. ],
  27435. [
  27436. -1,
  27437. -1
  27438. ],
  27439. [
  27440. 12,
  27441. ccittEOL
  27442. ],
  27443. [
  27444. 12,
  27445. ccittEOL
  27446. ],
  27447. [
  27448. -1,
  27449. -1
  27450. ],
  27451. [
  27452. -1,
  27453. -1
  27454. ],
  27455. [
  27456. -1,
  27457. -1
  27458. ],
  27459. [
  27460. -1,
  27461. -1
  27462. ],
  27463. [
  27464. -1,
  27465. -1
  27466. ],
  27467. [
  27468. -1,
  27469. -1
  27470. ],
  27471. [
  27472. -1,
  27473. -1
  27474. ],
  27475. [
  27476. -1,
  27477. -1
  27478. ],
  27479. [
  27480. -1,
  27481. -1
  27482. ],
  27483. [
  27484. -1,
  27485. -1
  27486. ],
  27487. [
  27488. -1,
  27489. -1
  27490. ],
  27491. [
  27492. -1,
  27493. -1
  27494. ],
  27495. [
  27496. -1,
  27497. -1
  27498. ],
  27499. [
  27500. -1,
  27501. -1
  27502. ],
  27503. [
  27504. -1,
  27505. -1
  27506. ],
  27507. [
  27508. -1,
  27509. -1
  27510. ],
  27511. [
  27512. -1,
  27513. -1
  27514. ],
  27515. [
  27516. -1,
  27517. -1
  27518. ],
  27519. [
  27520. -1,
  27521. -1
  27522. ],
  27523. [
  27524. -1,
  27525. -1
  27526. ],
  27527. [
  27528. -1,
  27529. -1
  27530. ],
  27531. [
  27532. -1,
  27533. -1
  27534. ],
  27535. [
  27536. -1,
  27537. -1
  27538. ],
  27539. [
  27540. -1,
  27541. -1
  27542. ],
  27543. [
  27544. -1,
  27545. -1
  27546. ],
  27547. [
  27548. -1,
  27549. -1
  27550. ],
  27551. [
  27552. -1,
  27553. -1
  27554. ],
  27555. [
  27556. -1,
  27557. -1
  27558. ],
  27559. [
  27560. 11,
  27561. 1792
  27562. ],
  27563. [
  27564. 11,
  27565. 1792
  27566. ],
  27567. [
  27568. 11,
  27569. 1792
  27570. ],
  27571. [
  27572. 11,
  27573. 1792
  27574. ],
  27575. [
  27576. 12,
  27577. 1984
  27578. ],
  27579. [
  27580. 12,
  27581. 1984
  27582. ],
  27583. [
  27584. 12,
  27585. 2048
  27586. ],
  27587. [
  27588. 12,
  27589. 2048
  27590. ],
  27591. [
  27592. 12,
  27593. 2112
  27594. ],
  27595. [
  27596. 12,
  27597. 2112
  27598. ],
  27599. [
  27600. 12,
  27601. 2176
  27602. ],
  27603. [
  27604. 12,
  27605. 2176
  27606. ],
  27607. [
  27608. 12,
  27609. 2240
  27610. ],
  27611. [
  27612. 12,
  27613. 2240
  27614. ],
  27615. [
  27616. 12,
  27617. 2304
  27618. ],
  27619. [
  27620. 12,
  27621. 2304
  27622. ],
  27623. [
  27624. 11,
  27625. 1856
  27626. ],
  27627. [
  27628. 11,
  27629. 1856
  27630. ],
  27631. [
  27632. 11,
  27633. 1856
  27634. ],
  27635. [
  27636. 11,
  27637. 1856
  27638. ],
  27639. [
  27640. 11,
  27641. 1920
  27642. ],
  27643. [
  27644. 11,
  27645. 1920
  27646. ],
  27647. [
  27648. 11,
  27649. 1920
  27650. ],
  27651. [
  27652. 11,
  27653. 1920
  27654. ],
  27655. [
  27656. 12,
  27657. 2368
  27658. ],
  27659. [
  27660. 12,
  27661. 2368
  27662. ],
  27663. [
  27664. 12,
  27665. 2432
  27666. ],
  27667. [
  27668. 12,
  27669. 2432
  27670. ],
  27671. [
  27672. 12,
  27673. 2496
  27674. ],
  27675. [
  27676. 12,
  27677. 2496
  27678. ],
  27679. [
  27680. 12,
  27681. 2560
  27682. ],
  27683. [
  27684. 12,
  27685. 2560
  27686. ],
  27687. [
  27688. 10,
  27689. 18
  27690. ],
  27691. [
  27692. 10,
  27693. 18
  27694. ],
  27695. [
  27696. 10,
  27697. 18
  27698. ],
  27699. [
  27700. 10,
  27701. 18
  27702. ],
  27703. [
  27704. 10,
  27705. 18
  27706. ],
  27707. [
  27708. 10,
  27709. 18
  27710. ],
  27711. [
  27712. 10,
  27713. 18
  27714. ],
  27715. [
  27716. 10,
  27717. 18
  27718. ],
  27719. [
  27720. 12,
  27721. 52
  27722. ],
  27723. [
  27724. 12,
  27725. 52
  27726. ],
  27727. [
  27728. 13,
  27729. 640
  27730. ],
  27731. [
  27732. 13,
  27733. 704
  27734. ],
  27735. [
  27736. 13,
  27737. 768
  27738. ],
  27739. [
  27740. 13,
  27741. 832
  27742. ],
  27743. [
  27744. 12,
  27745. 55
  27746. ],
  27747. [
  27748. 12,
  27749. 55
  27750. ],
  27751. [
  27752. 12,
  27753. 56
  27754. ],
  27755. [
  27756. 12,
  27757. 56
  27758. ],
  27759. [
  27760. 13,
  27761. 1280
  27762. ],
  27763. [
  27764. 13,
  27765. 1344
  27766. ],
  27767. [
  27768. 13,
  27769. 1408
  27770. ],
  27771. [
  27772. 13,
  27773. 1472
  27774. ],
  27775. [
  27776. 12,
  27777. 59
  27778. ],
  27779. [
  27780. 12,
  27781. 59
  27782. ],
  27783. [
  27784. 12,
  27785. 60
  27786. ],
  27787. [
  27788. 12,
  27789. 60
  27790. ],
  27791. [
  27792. 13,
  27793. 1536
  27794. ],
  27795. [
  27796. 13,
  27797. 1600
  27798. ],
  27799. [
  27800. 11,
  27801. 24
  27802. ],
  27803. [
  27804. 11,
  27805. 24
  27806. ],
  27807. [
  27808. 11,
  27809. 24
  27810. ],
  27811. [
  27812. 11,
  27813. 24
  27814. ],
  27815. [
  27816. 11,
  27817. 25
  27818. ],
  27819. [
  27820. 11,
  27821. 25
  27822. ],
  27823. [
  27824. 11,
  27825. 25
  27826. ],
  27827. [
  27828. 11,
  27829. 25
  27830. ],
  27831. [
  27832. 13,
  27833. 1664
  27834. ],
  27835. [
  27836. 13,
  27837. 1728
  27838. ],
  27839. [
  27840. 12,
  27841. 320
  27842. ],
  27843. [
  27844. 12,
  27845. 320
  27846. ],
  27847. [
  27848. 12,
  27849. 384
  27850. ],
  27851. [
  27852. 12,
  27853. 384
  27854. ],
  27855. [
  27856. 12,
  27857. 448
  27858. ],
  27859. [
  27860. 12,
  27861. 448
  27862. ],
  27863. [
  27864. 13,
  27865. 512
  27866. ],
  27867. [
  27868. 13,
  27869. 576
  27870. ],
  27871. [
  27872. 12,
  27873. 53
  27874. ],
  27875. [
  27876. 12,
  27877. 53
  27878. ],
  27879. [
  27880. 12,
  27881. 54
  27882. ],
  27883. [
  27884. 12,
  27885. 54
  27886. ],
  27887. [
  27888. 13,
  27889. 896
  27890. ],
  27891. [
  27892. 13,
  27893. 960
  27894. ],
  27895. [
  27896. 13,
  27897. 1024
  27898. ],
  27899. [
  27900. 13,
  27901. 1088
  27902. ],
  27903. [
  27904. 13,
  27905. 1152
  27906. ],
  27907. [
  27908. 13,
  27909. 1216
  27910. ],
  27911. [
  27912. 10,
  27913. 64
  27914. ],
  27915. [
  27916. 10,
  27917. 64
  27918. ],
  27919. [
  27920. 10,
  27921. 64
  27922. ],
  27923. [
  27924. 10,
  27925. 64
  27926. ],
  27927. [
  27928. 10,
  27929. 64
  27930. ],
  27931. [
  27932. 10,
  27933. 64
  27934. ],
  27935. [
  27936. 10,
  27937. 64
  27938. ],
  27939. [
  27940. 10,
  27941. 64
  27942. ]
  27943. ];
  27944. var blackTable2 = [
  27945. [
  27946. 8,
  27947. 13
  27948. ],
  27949. [
  27950. 8,
  27951. 13
  27952. ],
  27953. [
  27954. 8,
  27955. 13
  27956. ],
  27957. [
  27958. 8,
  27959. 13
  27960. ],
  27961. [
  27962. 8,
  27963. 13
  27964. ],
  27965. [
  27966. 8,
  27967. 13
  27968. ],
  27969. [
  27970. 8,
  27971. 13
  27972. ],
  27973. [
  27974. 8,
  27975. 13
  27976. ],
  27977. [
  27978. 8,
  27979. 13
  27980. ],
  27981. [
  27982. 8,
  27983. 13
  27984. ],
  27985. [
  27986. 8,
  27987. 13
  27988. ],
  27989. [
  27990. 8,
  27991. 13
  27992. ],
  27993. [
  27994. 8,
  27995. 13
  27996. ],
  27997. [
  27998. 8,
  27999. 13
  28000. ],
  28001. [
  28002. 8,
  28003. 13
  28004. ],
  28005. [
  28006. 8,
  28007. 13
  28008. ],
  28009. [
  28010. 11,
  28011. 23
  28012. ],
  28013. [
  28014. 11,
  28015. 23
  28016. ],
  28017. [
  28018. 12,
  28019. 50
  28020. ],
  28021. [
  28022. 12,
  28023. 51
  28024. ],
  28025. [
  28026. 12,
  28027. 44
  28028. ],
  28029. [
  28030. 12,
  28031. 45
  28032. ],
  28033. [
  28034. 12,
  28035. 46
  28036. ],
  28037. [
  28038. 12,
  28039. 47
  28040. ],
  28041. [
  28042. 12,
  28043. 57
  28044. ],
  28045. [
  28046. 12,
  28047. 58
  28048. ],
  28049. [
  28050. 12,
  28051. 61
  28052. ],
  28053. [
  28054. 12,
  28055. 256
  28056. ],
  28057. [
  28058. 10,
  28059. 16
  28060. ],
  28061. [
  28062. 10,
  28063. 16
  28064. ],
  28065. [
  28066. 10,
  28067. 16
  28068. ],
  28069. [
  28070. 10,
  28071. 16
  28072. ],
  28073. [
  28074. 10,
  28075. 17
  28076. ],
  28077. [
  28078. 10,
  28079. 17
  28080. ],
  28081. [
  28082. 10,
  28083. 17
  28084. ],
  28085. [
  28086. 10,
  28087. 17
  28088. ],
  28089. [
  28090. 12,
  28091. 48
  28092. ],
  28093. [
  28094. 12,
  28095. 49
  28096. ],
  28097. [
  28098. 12,
  28099. 62
  28100. ],
  28101. [
  28102. 12,
  28103. 63
  28104. ],
  28105. [
  28106. 12,
  28107. 30
  28108. ],
  28109. [
  28110. 12,
  28111. 31
  28112. ],
  28113. [
  28114. 12,
  28115. 32
  28116. ],
  28117. [
  28118. 12,
  28119. 33
  28120. ],
  28121. [
  28122. 12,
  28123. 40
  28124. ],
  28125. [
  28126. 12,
  28127. 41
  28128. ],
  28129. [
  28130. 11,
  28131. 22
  28132. ],
  28133. [
  28134. 11,
  28135. 22
  28136. ],
  28137. [
  28138. 8,
  28139. 14
  28140. ],
  28141. [
  28142. 8,
  28143. 14
  28144. ],
  28145. [
  28146. 8,
  28147. 14
  28148. ],
  28149. [
  28150. 8,
  28151. 14
  28152. ],
  28153. [
  28154. 8,
  28155. 14
  28156. ],
  28157. [
  28158. 8,
  28159. 14
  28160. ],
  28161. [
  28162. 8,
  28163. 14
  28164. ],
  28165. [
  28166. 8,
  28167. 14
  28168. ],
  28169. [
  28170. 8,
  28171. 14
  28172. ],
  28173. [
  28174. 8,
  28175. 14
  28176. ],
  28177. [
  28178. 8,
  28179. 14
  28180. ],
  28181. [
  28182. 8,
  28183. 14
  28184. ],
  28185. [
  28186. 8,
  28187. 14
  28188. ],
  28189. [
  28190. 8,
  28191. 14
  28192. ],
  28193. [
  28194. 8,
  28195. 14
  28196. ],
  28197. [
  28198. 8,
  28199. 14
  28200. ],
  28201. [
  28202. 7,
  28203. 10
  28204. ],
  28205. [
  28206. 7,
  28207. 10
  28208. ],
  28209. [
  28210. 7,
  28211. 10
  28212. ],
  28213. [
  28214. 7,
  28215. 10
  28216. ],
  28217. [
  28218. 7,
  28219. 10
  28220. ],
  28221. [
  28222. 7,
  28223. 10
  28224. ],
  28225. [
  28226. 7,
  28227. 10
  28228. ],
  28229. [
  28230. 7,
  28231. 10
  28232. ],
  28233. [
  28234. 7,
  28235. 10
  28236. ],
  28237. [
  28238. 7,
  28239. 10
  28240. ],
  28241. [
  28242. 7,
  28243. 10
  28244. ],
  28245. [
  28246. 7,
  28247. 10
  28248. ],
  28249. [
  28250. 7,
  28251. 10
  28252. ],
  28253. [
  28254. 7,
  28255. 10
  28256. ],
  28257. [
  28258. 7,
  28259. 10
  28260. ],
  28261. [
  28262. 7,
  28263. 10
  28264. ],
  28265. [
  28266. 7,
  28267. 10
  28268. ],
  28269. [
  28270. 7,
  28271. 10
  28272. ],
  28273. [
  28274. 7,
  28275. 10
  28276. ],
  28277. [
  28278. 7,
  28279. 10
  28280. ],
  28281. [
  28282. 7,
  28283. 10
  28284. ],
  28285. [
  28286. 7,
  28287. 10
  28288. ],
  28289. [
  28290. 7,
  28291. 10
  28292. ],
  28293. [
  28294. 7,
  28295. 10
  28296. ],
  28297. [
  28298. 7,
  28299. 10
  28300. ],
  28301. [
  28302. 7,
  28303. 10
  28304. ],
  28305. [
  28306. 7,
  28307. 10
  28308. ],
  28309. [
  28310. 7,
  28311. 10
  28312. ],
  28313. [
  28314. 7,
  28315. 10
  28316. ],
  28317. [
  28318. 7,
  28319. 10
  28320. ],
  28321. [
  28322. 7,
  28323. 10
  28324. ],
  28325. [
  28326. 7,
  28327. 10
  28328. ],
  28329. [
  28330. 7,
  28331. 11
  28332. ],
  28333. [
  28334. 7,
  28335. 11
  28336. ],
  28337. [
  28338. 7,
  28339. 11
  28340. ],
  28341. [
  28342. 7,
  28343. 11
  28344. ],
  28345. [
  28346. 7,
  28347. 11
  28348. ],
  28349. [
  28350. 7,
  28351. 11
  28352. ],
  28353. [
  28354. 7,
  28355. 11
  28356. ],
  28357. [
  28358. 7,
  28359. 11
  28360. ],
  28361. [
  28362. 7,
  28363. 11
  28364. ],
  28365. [
  28366. 7,
  28367. 11
  28368. ],
  28369. [
  28370. 7,
  28371. 11
  28372. ],
  28373. [
  28374. 7,
  28375. 11
  28376. ],
  28377. [
  28378. 7,
  28379. 11
  28380. ],
  28381. [
  28382. 7,
  28383. 11
  28384. ],
  28385. [
  28386. 7,
  28387. 11
  28388. ],
  28389. [
  28390. 7,
  28391. 11
  28392. ],
  28393. [
  28394. 7,
  28395. 11
  28396. ],
  28397. [
  28398. 7,
  28399. 11
  28400. ],
  28401. [
  28402. 7,
  28403. 11
  28404. ],
  28405. [
  28406. 7,
  28407. 11
  28408. ],
  28409. [
  28410. 7,
  28411. 11
  28412. ],
  28413. [
  28414. 7,
  28415. 11
  28416. ],
  28417. [
  28418. 7,
  28419. 11
  28420. ],
  28421. [
  28422. 7,
  28423. 11
  28424. ],
  28425. [
  28426. 7,
  28427. 11
  28428. ],
  28429. [
  28430. 7,
  28431. 11
  28432. ],
  28433. [
  28434. 7,
  28435. 11
  28436. ],
  28437. [
  28438. 7,
  28439. 11
  28440. ],
  28441. [
  28442. 7,
  28443. 11
  28444. ],
  28445. [
  28446. 7,
  28447. 11
  28448. ],
  28449. [
  28450. 7,
  28451. 11
  28452. ],
  28453. [
  28454. 7,
  28455. 11
  28456. ],
  28457. [
  28458. 9,
  28459. 15
  28460. ],
  28461. [
  28462. 9,
  28463. 15
  28464. ],
  28465. [
  28466. 9,
  28467. 15
  28468. ],
  28469. [
  28470. 9,
  28471. 15
  28472. ],
  28473. [
  28474. 9,
  28475. 15
  28476. ],
  28477. [
  28478. 9,
  28479. 15
  28480. ],
  28481. [
  28482. 9,
  28483. 15
  28484. ],
  28485. [
  28486. 9,
  28487. 15
  28488. ],
  28489. [
  28490. 12,
  28491. 128
  28492. ],
  28493. [
  28494. 12,
  28495. 192
  28496. ],
  28497. [
  28498. 12,
  28499. 26
  28500. ],
  28501. [
  28502. 12,
  28503. 27
  28504. ],
  28505. [
  28506. 12,
  28507. 28
  28508. ],
  28509. [
  28510. 12,
  28511. 29
  28512. ],
  28513. [
  28514. 11,
  28515. 19
  28516. ],
  28517. [
  28518. 11,
  28519. 19
  28520. ],
  28521. [
  28522. 11,
  28523. 20
  28524. ],
  28525. [
  28526. 11,
  28527. 20
  28528. ],
  28529. [
  28530. 12,
  28531. 34
  28532. ],
  28533. [
  28534. 12,
  28535. 35
  28536. ],
  28537. [
  28538. 12,
  28539. 36
  28540. ],
  28541. [
  28542. 12,
  28543. 37
  28544. ],
  28545. [
  28546. 12,
  28547. 38
  28548. ],
  28549. [
  28550. 12,
  28551. 39
  28552. ],
  28553. [
  28554. 11,
  28555. 21
  28556. ],
  28557. [
  28558. 11,
  28559. 21
  28560. ],
  28561. [
  28562. 12,
  28563. 42
  28564. ],
  28565. [
  28566. 12,
  28567. 43
  28568. ],
  28569. [
  28570. 10,
  28571. 0
  28572. ],
  28573. [
  28574. 10,
  28575. 0
  28576. ],
  28577. [
  28578. 10,
  28579. 0
  28580. ],
  28581. [
  28582. 10,
  28583. 0
  28584. ],
  28585. [
  28586. 7,
  28587. 12
  28588. ],
  28589. [
  28590. 7,
  28591. 12
  28592. ],
  28593. [
  28594. 7,
  28595. 12
  28596. ],
  28597. [
  28598. 7,
  28599. 12
  28600. ],
  28601. [
  28602. 7,
  28603. 12
  28604. ],
  28605. [
  28606. 7,
  28607. 12
  28608. ],
  28609. [
  28610. 7,
  28611. 12
  28612. ],
  28613. [
  28614. 7,
  28615. 12
  28616. ],
  28617. [
  28618. 7,
  28619. 12
  28620. ],
  28621. [
  28622. 7,
  28623. 12
  28624. ],
  28625. [
  28626. 7,
  28627. 12
  28628. ],
  28629. [
  28630. 7,
  28631. 12
  28632. ],
  28633. [
  28634. 7,
  28635. 12
  28636. ],
  28637. [
  28638. 7,
  28639. 12
  28640. ],
  28641. [
  28642. 7,
  28643. 12
  28644. ],
  28645. [
  28646. 7,
  28647. 12
  28648. ],
  28649. [
  28650. 7,
  28651. 12
  28652. ],
  28653. [
  28654. 7,
  28655. 12
  28656. ],
  28657. [
  28658. 7,
  28659. 12
  28660. ],
  28661. [
  28662. 7,
  28663. 12
  28664. ],
  28665. [
  28666. 7,
  28667. 12
  28668. ],
  28669. [
  28670. 7,
  28671. 12
  28672. ],
  28673. [
  28674. 7,
  28675. 12
  28676. ],
  28677. [
  28678. 7,
  28679. 12
  28680. ],
  28681. [
  28682. 7,
  28683. 12
  28684. ],
  28685. [
  28686. 7,
  28687. 12
  28688. ],
  28689. [
  28690. 7,
  28691. 12
  28692. ],
  28693. [
  28694. 7,
  28695. 12
  28696. ],
  28697. [
  28698. 7,
  28699. 12
  28700. ],
  28701. [
  28702. 7,
  28703. 12
  28704. ],
  28705. [
  28706. 7,
  28707. 12
  28708. ],
  28709. [
  28710. 7,
  28711. 12
  28712. ]
  28713. ];
  28714. var blackTable3 = [
  28715. [
  28716. -1,
  28717. -1
  28718. ],
  28719. [
  28720. -1,
  28721. -1
  28722. ],
  28723. [
  28724. -1,
  28725. -1
  28726. ],
  28727. [
  28728. -1,
  28729. -1
  28730. ],
  28731. [
  28732. 6,
  28733. 9
  28734. ],
  28735. [
  28736. 6,
  28737. 8
  28738. ],
  28739. [
  28740. 5,
  28741. 7
  28742. ],
  28743. [
  28744. 5,
  28745. 7
  28746. ],
  28747. [
  28748. 4,
  28749. 6
  28750. ],
  28751. [
  28752. 4,
  28753. 6
  28754. ],
  28755. [
  28756. 4,
  28757. 6
  28758. ],
  28759. [
  28760. 4,
  28761. 6
  28762. ],
  28763. [
  28764. 4,
  28765. 5
  28766. ],
  28767. [
  28768. 4,
  28769. 5
  28770. ],
  28771. [
  28772. 4,
  28773. 5
  28774. ],
  28775. [
  28776. 4,
  28777. 5
  28778. ],
  28779. [
  28780. 3,
  28781. 1
  28782. ],
  28783. [
  28784. 3,
  28785. 1
  28786. ],
  28787. [
  28788. 3,
  28789. 1
  28790. ],
  28791. [
  28792. 3,
  28793. 1
  28794. ],
  28795. [
  28796. 3,
  28797. 1
  28798. ],
  28799. [
  28800. 3,
  28801. 1
  28802. ],
  28803. [
  28804. 3,
  28805. 1
  28806. ],
  28807. [
  28808. 3,
  28809. 1
  28810. ],
  28811. [
  28812. 3,
  28813. 4
  28814. ],
  28815. [
  28816. 3,
  28817. 4
  28818. ],
  28819. [
  28820. 3,
  28821. 4
  28822. ],
  28823. [
  28824. 3,
  28825. 4
  28826. ],
  28827. [
  28828. 3,
  28829. 4
  28830. ],
  28831. [
  28832. 3,
  28833. 4
  28834. ],
  28835. [
  28836. 3,
  28837. 4
  28838. ],
  28839. [
  28840. 3,
  28841. 4
  28842. ],
  28843. [
  28844. 2,
  28845. 3
  28846. ],
  28847. [
  28848. 2,
  28849. 3
  28850. ],
  28851. [
  28852. 2,
  28853. 3
  28854. ],
  28855. [
  28856. 2,
  28857. 3
  28858. ],
  28859. [
  28860. 2,
  28861. 3
  28862. ],
  28863. [
  28864. 2,
  28865. 3
  28866. ],
  28867. [
  28868. 2,
  28869. 3
  28870. ],
  28871. [
  28872. 2,
  28873. 3
  28874. ],
  28875. [
  28876. 2,
  28877. 3
  28878. ],
  28879. [
  28880. 2,
  28881. 3
  28882. ],
  28883. [
  28884. 2,
  28885. 3
  28886. ],
  28887. [
  28888. 2,
  28889. 3
  28890. ],
  28891. [
  28892. 2,
  28893. 3
  28894. ],
  28895. [
  28896. 2,
  28897. 3
  28898. ],
  28899. [
  28900. 2,
  28901. 3
  28902. ],
  28903. [
  28904. 2,
  28905. 3
  28906. ],
  28907. [
  28908. 2,
  28909. 2
  28910. ],
  28911. [
  28912. 2,
  28913. 2
  28914. ],
  28915. [
  28916. 2,
  28917. 2
  28918. ],
  28919. [
  28920. 2,
  28921. 2
  28922. ],
  28923. [
  28924. 2,
  28925. 2
  28926. ],
  28927. [
  28928. 2,
  28929. 2
  28930. ],
  28931. [
  28932. 2,
  28933. 2
  28934. ],
  28935. [
  28936. 2,
  28937. 2
  28938. ],
  28939. [
  28940. 2,
  28941. 2
  28942. ],
  28943. [
  28944. 2,
  28945. 2
  28946. ],
  28947. [
  28948. 2,
  28949. 2
  28950. ],
  28951. [
  28952. 2,
  28953. 2
  28954. ],
  28955. [
  28956. 2,
  28957. 2
  28958. ],
  28959. [
  28960. 2,
  28961. 2
  28962. ],
  28963. [
  28964. 2,
  28965. 2
  28966. ],
  28967. [
  28968. 2,
  28969. 2
  28970. ]
  28971. ];
  28972. function CCITTFaxStream(str, maybeLength, params) {
  28973. this.str = str;
  28974. this.dict = str.dict;
  28975. params = params || Dict.empty;
  28976. this.encoding = params.get('K') || 0;
  28977. this.eoline = params.get('EndOfLine') || false;
  28978. this.byteAlign = params.get('EncodedByteAlign') || false;
  28979. this.columns = params.get('Columns') || 1728;
  28980. this.rows = params.get('Rows') || 0;
  28981. var eoblock = params.get('EndOfBlock');
  28982. if (eoblock === null || eoblock === undefined) {
  28983. eoblock = true;
  28984. }
  28985. this.eoblock = eoblock;
  28986. this.black = params.get('BlackIs1') || false;
  28987. this.codingLine = new Uint32Array(this.columns + 1);
  28988. this.refLine = new Uint32Array(this.columns + 2);
  28989. this.codingLine[0] = this.columns;
  28990. this.codingPos = 0;
  28991. this.row = 0;
  28992. this.nextLine2D = this.encoding < 0;
  28993. this.inputBits = 0;
  28994. this.inputBuf = 0;
  28995. this.outputBits = 0;
  28996. var code1;
  28997. while ((code1 = this.lookBits(12)) === 0) {
  28998. this.eatBits(1);
  28999. }
  29000. if (code1 === 1) {
  29001. this.eatBits(12);
  29002. }
  29003. if (this.encoding > 0) {
  29004. this.nextLine2D = !this.lookBits(1);
  29005. this.eatBits(1);
  29006. }
  29007. DecodeStream.call(this, maybeLength);
  29008. }
  29009. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  29010. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  29011. while (!this.eof) {
  29012. var c = this.lookChar();
  29013. this.ensureBuffer(this.bufferLength + 1);
  29014. this.buffer[this.bufferLength++] = c;
  29015. }
  29016. };
  29017. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  29018. var codingLine = this.codingLine;
  29019. var codingPos = this.codingPos;
  29020. if (a1 > codingLine[codingPos]) {
  29021. if (a1 > this.columns) {
  29022. info('row is wrong length');
  29023. this.err = true;
  29024. a1 = this.columns;
  29025. }
  29026. if (codingPos & 1 ^ blackPixels) {
  29027. ++codingPos;
  29028. }
  29029. codingLine[codingPos] = a1;
  29030. }
  29031. this.codingPos = codingPos;
  29032. };
  29033. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  29034. var codingLine = this.codingLine;
  29035. var codingPos = this.codingPos;
  29036. if (a1 > codingLine[codingPos]) {
  29037. if (a1 > this.columns) {
  29038. info('row is wrong length');
  29039. this.err = true;
  29040. a1 = this.columns;
  29041. }
  29042. if (codingPos & 1 ^ blackPixels) {
  29043. ++codingPos;
  29044. }
  29045. codingLine[codingPos] = a1;
  29046. } else if (a1 < codingLine[codingPos]) {
  29047. if (a1 < 0) {
  29048. info('invalid code');
  29049. this.err = true;
  29050. a1 = 0;
  29051. }
  29052. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  29053. --codingPos;
  29054. }
  29055. codingLine[codingPos] = a1;
  29056. }
  29057. this.codingPos = codingPos;
  29058. };
  29059. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  29060. var refLine = this.refLine;
  29061. var codingLine = this.codingLine;
  29062. var columns = this.columns;
  29063. var refPos, blackPixels, bits, i;
  29064. if (this.outputBits === 0) {
  29065. if (this.eof) {
  29066. return null;
  29067. }
  29068. this.err = false;
  29069. var code1, code2, code3;
  29070. if (this.nextLine2D) {
  29071. for (i = 0; codingLine[i] < columns; ++i) {
  29072. refLine[i] = codingLine[i];
  29073. }
  29074. refLine[i++] = columns;
  29075. refLine[i] = columns;
  29076. codingLine[0] = 0;
  29077. this.codingPos = 0;
  29078. refPos = 0;
  29079. blackPixels = 0;
  29080. while (codingLine[this.codingPos] < columns) {
  29081. code1 = this.getTwoDimCode();
  29082. switch (code1) {
  29083. case twoDimPass:
  29084. this.addPixels(refLine[refPos + 1], blackPixels);
  29085. if (refLine[refPos + 1] < columns) {
  29086. refPos += 2;
  29087. }
  29088. break;
  29089. case twoDimHoriz:
  29090. code1 = code2 = 0;
  29091. if (blackPixels) {
  29092. do {
  29093. code1 += code3 = this.getBlackCode();
  29094. } while (code3 >= 64);
  29095. do {
  29096. code2 += code3 = this.getWhiteCode();
  29097. } while (code3 >= 64);
  29098. } else {
  29099. do {
  29100. code1 += code3 = this.getWhiteCode();
  29101. } while (code3 >= 64);
  29102. do {
  29103. code2 += code3 = this.getBlackCode();
  29104. } while (code3 >= 64);
  29105. }
  29106. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29107. if (codingLine[this.codingPos] < columns) {
  29108. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  29109. }
  29110. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29111. refPos += 2;
  29112. }
  29113. break;
  29114. case twoDimVertR3:
  29115. this.addPixels(refLine[refPos] + 3, blackPixels);
  29116. blackPixels ^= 1;
  29117. if (codingLine[this.codingPos] < columns) {
  29118. ++refPos;
  29119. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29120. refPos += 2;
  29121. }
  29122. }
  29123. break;
  29124. case twoDimVertR2:
  29125. this.addPixels(refLine[refPos] + 2, blackPixels);
  29126. blackPixels ^= 1;
  29127. if (codingLine[this.codingPos] < columns) {
  29128. ++refPos;
  29129. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29130. refPos += 2;
  29131. }
  29132. }
  29133. break;
  29134. case twoDimVertR1:
  29135. this.addPixels(refLine[refPos] + 1, blackPixels);
  29136. blackPixels ^= 1;
  29137. if (codingLine[this.codingPos] < columns) {
  29138. ++refPos;
  29139. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29140. refPos += 2;
  29141. }
  29142. }
  29143. break;
  29144. case twoDimVert0:
  29145. this.addPixels(refLine[refPos], blackPixels);
  29146. blackPixels ^= 1;
  29147. if (codingLine[this.codingPos] < columns) {
  29148. ++refPos;
  29149. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29150. refPos += 2;
  29151. }
  29152. }
  29153. break;
  29154. case twoDimVertL3:
  29155. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  29156. blackPixels ^= 1;
  29157. if (codingLine[this.codingPos] < columns) {
  29158. if (refPos > 0) {
  29159. --refPos;
  29160. } else {
  29161. ++refPos;
  29162. }
  29163. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29164. refPos += 2;
  29165. }
  29166. }
  29167. break;
  29168. case twoDimVertL2:
  29169. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  29170. blackPixels ^= 1;
  29171. if (codingLine[this.codingPos] < columns) {
  29172. if (refPos > 0) {
  29173. --refPos;
  29174. } else {
  29175. ++refPos;
  29176. }
  29177. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29178. refPos += 2;
  29179. }
  29180. }
  29181. break;
  29182. case twoDimVertL1:
  29183. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  29184. blackPixels ^= 1;
  29185. if (codingLine[this.codingPos] < columns) {
  29186. if (refPos > 0) {
  29187. --refPos;
  29188. } else {
  29189. ++refPos;
  29190. }
  29191. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29192. refPos += 2;
  29193. }
  29194. }
  29195. break;
  29196. case ccittEOF:
  29197. this.addPixels(columns, 0);
  29198. this.eof = true;
  29199. break;
  29200. default:
  29201. info('bad 2d code');
  29202. this.addPixels(columns, 0);
  29203. this.err = true;
  29204. }
  29205. }
  29206. } else {
  29207. codingLine[0] = 0;
  29208. this.codingPos = 0;
  29209. blackPixels = 0;
  29210. while (codingLine[this.codingPos] < columns) {
  29211. code1 = 0;
  29212. if (blackPixels) {
  29213. do {
  29214. code1 += code3 = this.getBlackCode();
  29215. } while (code3 >= 64);
  29216. } else {
  29217. do {
  29218. code1 += code3 = this.getWhiteCode();
  29219. } while (code3 >= 64);
  29220. }
  29221. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29222. blackPixels ^= 1;
  29223. }
  29224. }
  29225. var gotEOL = false;
  29226. if (this.byteAlign) {
  29227. this.inputBits &= ~7;
  29228. }
  29229. if (!this.eoblock && this.row === this.rows - 1) {
  29230. this.eof = true;
  29231. } else {
  29232. code1 = this.lookBits(12);
  29233. if (this.eoline) {
  29234. while (code1 !== ccittEOF && code1 !== 1) {
  29235. this.eatBits(1);
  29236. code1 = this.lookBits(12);
  29237. }
  29238. } else {
  29239. while (code1 === 0) {
  29240. this.eatBits(1);
  29241. code1 = this.lookBits(12);
  29242. }
  29243. }
  29244. if (code1 === 1) {
  29245. this.eatBits(12);
  29246. gotEOL = true;
  29247. } else if (code1 === ccittEOF) {
  29248. this.eof = true;
  29249. }
  29250. }
  29251. if (!this.eof && this.encoding > 0) {
  29252. this.nextLine2D = !this.lookBits(1);
  29253. this.eatBits(1);
  29254. }
  29255. if (this.eoblock && gotEOL && this.byteAlign) {
  29256. code1 = this.lookBits(12);
  29257. if (code1 === 1) {
  29258. this.eatBits(12);
  29259. if (this.encoding > 0) {
  29260. this.lookBits(1);
  29261. this.eatBits(1);
  29262. }
  29263. if (this.encoding >= 0) {
  29264. for (i = 0; i < 4; ++i) {
  29265. code1 = this.lookBits(12);
  29266. if (code1 !== 1) {
  29267. info('bad rtc code: ' + code1);
  29268. }
  29269. this.eatBits(12);
  29270. if (this.encoding > 0) {
  29271. this.lookBits(1);
  29272. this.eatBits(1);
  29273. }
  29274. }
  29275. }
  29276. this.eof = true;
  29277. }
  29278. } else if (this.err && this.eoline) {
  29279. while (true) {
  29280. code1 = this.lookBits(13);
  29281. if (code1 === ccittEOF) {
  29282. this.eof = true;
  29283. return null;
  29284. }
  29285. if (code1 >> 1 === 1) {
  29286. break;
  29287. }
  29288. this.eatBits(1);
  29289. }
  29290. this.eatBits(12);
  29291. if (this.encoding > 0) {
  29292. this.eatBits(1);
  29293. this.nextLine2D = !(code1 & 1);
  29294. }
  29295. }
  29296. if (codingLine[0] > 0) {
  29297. this.outputBits = codingLine[this.codingPos = 0];
  29298. } else {
  29299. this.outputBits = codingLine[this.codingPos = 1];
  29300. }
  29301. this.row++;
  29302. }
  29303. var c;
  29304. if (this.outputBits >= 8) {
  29305. c = this.codingPos & 1 ? 0 : 0xFF;
  29306. this.outputBits -= 8;
  29307. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  29308. this.codingPos++;
  29309. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29310. }
  29311. } else {
  29312. bits = 8;
  29313. c = 0;
  29314. do {
  29315. if (this.outputBits > bits) {
  29316. c <<= bits;
  29317. if (!(this.codingPos & 1)) {
  29318. c |= 0xFF >> 8 - bits;
  29319. }
  29320. this.outputBits -= bits;
  29321. bits = 0;
  29322. } else {
  29323. c <<= this.outputBits;
  29324. if (!(this.codingPos & 1)) {
  29325. c |= 0xFF >> 8 - this.outputBits;
  29326. }
  29327. bits -= this.outputBits;
  29328. this.outputBits = 0;
  29329. if (codingLine[this.codingPos] < columns) {
  29330. this.codingPos++;
  29331. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29332. } else if (bits > 0) {
  29333. c <<= bits;
  29334. bits = 0;
  29335. }
  29336. }
  29337. } while (bits);
  29338. }
  29339. if (this.black) {
  29340. c ^= 0xFF;
  29341. }
  29342. return c;
  29343. };
  29344. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  29345. var limitValue = limit || 0;
  29346. for (var i = start; i <= end; ++i) {
  29347. var code = this.lookBits(i);
  29348. if (code === ccittEOF) {
  29349. return [
  29350. true,
  29351. 1,
  29352. false
  29353. ];
  29354. }
  29355. if (i < end) {
  29356. code <<= end - i;
  29357. }
  29358. if (!limitValue || code >= limitValue) {
  29359. var p = table[code - limitValue];
  29360. if (p[0] === i) {
  29361. this.eatBits(i);
  29362. return [
  29363. true,
  29364. p[1],
  29365. true
  29366. ];
  29367. }
  29368. }
  29369. }
  29370. return [
  29371. false,
  29372. 0,
  29373. false
  29374. ];
  29375. };
  29376. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  29377. var code = 0;
  29378. var p;
  29379. if (this.eoblock) {
  29380. code = this.lookBits(7);
  29381. p = twoDimTable[code];
  29382. if (p && p[0] > 0) {
  29383. this.eatBits(p[0]);
  29384. return p[1];
  29385. }
  29386. } else {
  29387. var result = this.findTableCode(1, 7, twoDimTable);
  29388. if (result[0] && result[2]) {
  29389. return result[1];
  29390. }
  29391. }
  29392. info('Bad two dim code');
  29393. return ccittEOF;
  29394. };
  29395. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  29396. var code = 0;
  29397. var p;
  29398. if (this.eoblock) {
  29399. code = this.lookBits(12);
  29400. if (code === ccittEOF) {
  29401. return 1;
  29402. }
  29403. if (code >> 5 === 0) {
  29404. p = whiteTable1[code];
  29405. } else {
  29406. p = whiteTable2[code >> 3];
  29407. }
  29408. if (p[0] > 0) {
  29409. this.eatBits(p[0]);
  29410. return p[1];
  29411. }
  29412. } else {
  29413. var result = this.findTableCode(1, 9, whiteTable2);
  29414. if (result[0]) {
  29415. return result[1];
  29416. }
  29417. result = this.findTableCode(11, 12, whiteTable1);
  29418. if (result[0]) {
  29419. return result[1];
  29420. }
  29421. }
  29422. info('bad white code');
  29423. this.eatBits(1);
  29424. return 1;
  29425. };
  29426. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  29427. var code, p;
  29428. if (this.eoblock) {
  29429. code = this.lookBits(13);
  29430. if (code === ccittEOF) {
  29431. return 1;
  29432. }
  29433. if (code >> 7 === 0) {
  29434. p = blackTable1[code];
  29435. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  29436. p = blackTable2[(code >> 1) - 64];
  29437. } else {
  29438. p = blackTable3[code >> 7];
  29439. }
  29440. if (p[0] > 0) {
  29441. this.eatBits(p[0]);
  29442. return p[1];
  29443. }
  29444. } else {
  29445. var result = this.findTableCode(2, 6, blackTable3);
  29446. if (result[0]) {
  29447. return result[1];
  29448. }
  29449. result = this.findTableCode(7, 12, blackTable2, 64);
  29450. if (result[0]) {
  29451. return result[1];
  29452. }
  29453. result = this.findTableCode(10, 13, blackTable1);
  29454. if (result[0]) {
  29455. return result[1];
  29456. }
  29457. }
  29458. info('bad black code');
  29459. this.eatBits(1);
  29460. return 1;
  29461. };
  29462. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  29463. var c;
  29464. while (this.inputBits < n) {
  29465. if ((c = this.str.getByte()) === -1) {
  29466. if (this.inputBits === 0) {
  29467. return ccittEOF;
  29468. }
  29469. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  29470. }
  29471. this.inputBuf = this.inputBuf << 8 | c;
  29472. this.inputBits += 8;
  29473. }
  29474. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  29475. };
  29476. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  29477. if ((this.inputBits -= n) < 0) {
  29478. this.inputBits = 0;
  29479. }
  29480. };
  29481. return CCITTFaxStream;
  29482. }();
  29483. var LZWStream = function LZWStreamClosure() {
  29484. function LZWStream(str, maybeLength, earlyChange) {
  29485. this.str = str;
  29486. this.dict = str.dict;
  29487. this.cachedData = 0;
  29488. this.bitsCached = 0;
  29489. var maxLzwDictionarySize = 4096;
  29490. var lzwState = {
  29491. earlyChange: earlyChange,
  29492. codeLength: 9,
  29493. nextCode: 258,
  29494. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  29495. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  29496. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  29497. currentSequence: new Uint8Array(maxLzwDictionarySize),
  29498. currentSequenceLength: 0
  29499. };
  29500. for (var i = 0; i < 256; ++i) {
  29501. lzwState.dictionaryValues[i] = i;
  29502. lzwState.dictionaryLengths[i] = 1;
  29503. }
  29504. this.lzwState = lzwState;
  29505. DecodeStream.call(this, maybeLength);
  29506. }
  29507. LZWStream.prototype = Object.create(DecodeStream.prototype);
  29508. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  29509. var bitsCached = this.bitsCached;
  29510. var cachedData = this.cachedData;
  29511. while (bitsCached < n) {
  29512. var c = this.str.getByte();
  29513. if (c === -1) {
  29514. this.eof = true;
  29515. return null;
  29516. }
  29517. cachedData = cachedData << 8 | c;
  29518. bitsCached += 8;
  29519. }
  29520. this.bitsCached = bitsCached -= n;
  29521. this.cachedData = cachedData;
  29522. this.lastCode = null;
  29523. return cachedData >>> bitsCached & (1 << n) - 1;
  29524. };
  29525. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  29526. var blockSize = 512;
  29527. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  29528. var i, j, q;
  29529. var lzwState = this.lzwState;
  29530. if (!lzwState) {
  29531. return;
  29532. }
  29533. var earlyChange = lzwState.earlyChange;
  29534. var nextCode = lzwState.nextCode;
  29535. var dictionaryValues = lzwState.dictionaryValues;
  29536. var dictionaryLengths = lzwState.dictionaryLengths;
  29537. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  29538. var codeLength = lzwState.codeLength;
  29539. var prevCode = lzwState.prevCode;
  29540. var currentSequence = lzwState.currentSequence;
  29541. var currentSequenceLength = lzwState.currentSequenceLength;
  29542. var decodedLength = 0;
  29543. var currentBufferLength = this.bufferLength;
  29544. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  29545. for (i = 0; i < blockSize; i++) {
  29546. var code = this.readBits(codeLength);
  29547. var hasPrev = currentSequenceLength > 0;
  29548. if (code < 256) {
  29549. currentSequence[0] = code;
  29550. currentSequenceLength = 1;
  29551. } else if (code >= 258) {
  29552. if (code < nextCode) {
  29553. currentSequenceLength = dictionaryLengths[code];
  29554. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  29555. currentSequence[j] = dictionaryValues[q];
  29556. q = dictionaryPrevCodes[q];
  29557. }
  29558. } else {
  29559. currentSequence[currentSequenceLength++] = currentSequence[0];
  29560. }
  29561. } else if (code === 256) {
  29562. codeLength = 9;
  29563. nextCode = 258;
  29564. currentSequenceLength = 0;
  29565. continue;
  29566. } else {
  29567. this.eof = true;
  29568. delete this.lzwState;
  29569. break;
  29570. }
  29571. if (hasPrev) {
  29572. dictionaryPrevCodes[nextCode] = prevCode;
  29573. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  29574. dictionaryValues[nextCode] = currentSequence[0];
  29575. nextCode++;
  29576. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  29577. }
  29578. prevCode = code;
  29579. decodedLength += currentSequenceLength;
  29580. if (estimatedDecodedSize < decodedLength) {
  29581. do {
  29582. estimatedDecodedSize += decodedSizeDelta;
  29583. } while (estimatedDecodedSize < decodedLength);
  29584. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  29585. }
  29586. for (j = 0; j < currentSequenceLength; j++) {
  29587. buffer[currentBufferLength++] = currentSequence[j];
  29588. }
  29589. }
  29590. lzwState.nextCode = nextCode;
  29591. lzwState.codeLength = codeLength;
  29592. lzwState.prevCode = prevCode;
  29593. lzwState.currentSequenceLength = currentSequenceLength;
  29594. this.bufferLength = currentBufferLength;
  29595. };
  29596. return LZWStream;
  29597. }();
  29598. var NullStream = function NullStreamClosure() {
  29599. function NullStream() {
  29600. Stream.call(this, new Uint8Array(0));
  29601. }
  29602. NullStream.prototype = Stream.prototype;
  29603. return NullStream;
  29604. }();
  29605. exports.Ascii85Stream = Ascii85Stream;
  29606. exports.AsciiHexStream = AsciiHexStream;
  29607. exports.CCITTFaxStream = CCITTFaxStream;
  29608. exports.DecryptStream = DecryptStream;
  29609. exports.DecodeStream = DecodeStream;
  29610. exports.FlateStream = FlateStream;
  29611. exports.Jbig2Stream = Jbig2Stream;
  29612. exports.JpegStream = JpegStream;
  29613. exports.JpxStream = JpxStream;
  29614. exports.NullStream = NullStream;
  29615. exports.PredictorStream = PredictorStream;
  29616. exports.RunLengthStream = RunLengthStream;
  29617. exports.Stream = Stream;
  29618. exports.StreamsSequenceStream = StreamsSequenceStream;
  29619. exports.StringStream = StringStream;
  29620. exports.LZWStream = LZWStream;
  29621. }));
  29622. (function (root, factory) {
  29623. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  29624. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  29625. var PasswordException = sharedUtil.PasswordException;
  29626. var PasswordResponses = sharedUtil.PasswordResponses;
  29627. var bytesToString = sharedUtil.bytesToString;
  29628. var warn = sharedUtil.warn;
  29629. var error = sharedUtil.error;
  29630. var assert = sharedUtil.assert;
  29631. var isInt = sharedUtil.isInt;
  29632. var stringToBytes = sharedUtil.stringToBytes;
  29633. var utf8StringToString = sharedUtil.utf8StringToString;
  29634. var Name = corePrimitives.Name;
  29635. var isName = corePrimitives.isName;
  29636. var isDict = corePrimitives.isDict;
  29637. var DecryptStream = coreStream.DecryptStream;
  29638. var ARCFourCipher = function ARCFourCipherClosure() {
  29639. function ARCFourCipher(key) {
  29640. this.a = 0;
  29641. this.b = 0;
  29642. var s = new Uint8Array(256);
  29643. var i, j = 0, tmp, keyLength = key.length;
  29644. for (i = 0; i < 256; ++i) {
  29645. s[i] = i;
  29646. }
  29647. for (i = 0; i < 256; ++i) {
  29648. tmp = s[i];
  29649. j = j + tmp + key[i % keyLength] & 0xFF;
  29650. s[i] = s[j];
  29651. s[j] = tmp;
  29652. }
  29653. this.s = s;
  29654. }
  29655. ARCFourCipher.prototype = {
  29656. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  29657. var i, n = data.length, tmp, tmp2;
  29658. var a = this.a, b = this.b, s = this.s;
  29659. var output = new Uint8Array(n);
  29660. for (i = 0; i < n; ++i) {
  29661. a = a + 1 & 0xFF;
  29662. tmp = s[a];
  29663. b = b + tmp & 0xFF;
  29664. tmp2 = s[b];
  29665. s[a] = tmp2;
  29666. s[b] = tmp;
  29667. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  29668. }
  29669. this.a = a;
  29670. this.b = b;
  29671. return output;
  29672. }
  29673. };
  29674. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  29675. return ARCFourCipher;
  29676. }();
  29677. var calculateMD5 = function calculateMD5Closure() {
  29678. var r = new Uint8Array([
  29679. 7,
  29680. 12,
  29681. 17,
  29682. 22,
  29683. 7,
  29684. 12,
  29685. 17,
  29686. 22,
  29687. 7,
  29688. 12,
  29689. 17,
  29690. 22,
  29691. 7,
  29692. 12,
  29693. 17,
  29694. 22,
  29695. 5,
  29696. 9,
  29697. 14,
  29698. 20,
  29699. 5,
  29700. 9,
  29701. 14,
  29702. 20,
  29703. 5,
  29704. 9,
  29705. 14,
  29706. 20,
  29707. 5,
  29708. 9,
  29709. 14,
  29710. 20,
  29711. 4,
  29712. 11,
  29713. 16,
  29714. 23,
  29715. 4,
  29716. 11,
  29717. 16,
  29718. 23,
  29719. 4,
  29720. 11,
  29721. 16,
  29722. 23,
  29723. 4,
  29724. 11,
  29725. 16,
  29726. 23,
  29727. 6,
  29728. 10,
  29729. 15,
  29730. 21,
  29731. 6,
  29732. 10,
  29733. 15,
  29734. 21,
  29735. 6,
  29736. 10,
  29737. 15,
  29738. 21,
  29739. 6,
  29740. 10,
  29741. 15,
  29742. 21
  29743. ]);
  29744. var k = new Int32Array([
  29745. -680876936,
  29746. -389564586,
  29747. 606105819,
  29748. -1044525330,
  29749. -176418897,
  29750. 1200080426,
  29751. -1473231341,
  29752. -45705983,
  29753. 1770035416,
  29754. -1958414417,
  29755. -42063,
  29756. -1990404162,
  29757. 1804603682,
  29758. -40341101,
  29759. -1502002290,
  29760. 1236535329,
  29761. -165796510,
  29762. -1069501632,
  29763. 643717713,
  29764. -373897302,
  29765. -701558691,
  29766. 38016083,
  29767. -660478335,
  29768. -405537848,
  29769. 568446438,
  29770. -1019803690,
  29771. -187363961,
  29772. 1163531501,
  29773. -1444681467,
  29774. -51403784,
  29775. 1735328473,
  29776. -1926607734,
  29777. -378558,
  29778. -2022574463,
  29779. 1839030562,
  29780. -35309556,
  29781. -1530992060,
  29782. 1272893353,
  29783. -155497632,
  29784. -1094730640,
  29785. 681279174,
  29786. -358537222,
  29787. -722521979,
  29788. 76029189,
  29789. -640364487,
  29790. -421815835,
  29791. 530742520,
  29792. -995338651,
  29793. -198630844,
  29794. 1126891415,
  29795. -1416354905,
  29796. -57434055,
  29797. 1700485571,
  29798. -1894986606,
  29799. -1051523,
  29800. -2054922799,
  29801. 1873313359,
  29802. -30611744,
  29803. -1560198380,
  29804. 1309151649,
  29805. -145523070,
  29806. -1120210379,
  29807. 718787259,
  29808. -343485551
  29809. ]);
  29810. function hash(data, offset, length) {
  29811. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  29812. var paddedLength = length + 72 & ~63;
  29813. var padded = new Uint8Array(paddedLength);
  29814. var i, j, n;
  29815. for (i = 0; i < length; ++i) {
  29816. padded[i] = data[offset++];
  29817. }
  29818. padded[i++] = 0x80;
  29819. n = paddedLength - 8;
  29820. while (i < n) {
  29821. padded[i++] = 0;
  29822. }
  29823. padded[i++] = length << 3 & 0xFF;
  29824. padded[i++] = length >> 5 & 0xFF;
  29825. padded[i++] = length >> 13 & 0xFF;
  29826. padded[i++] = length >> 21 & 0xFF;
  29827. padded[i++] = length >>> 29 & 0xFF;
  29828. padded[i++] = 0;
  29829. padded[i++] = 0;
  29830. padded[i++] = 0;
  29831. var w = new Int32Array(16);
  29832. for (i = 0; i < paddedLength;) {
  29833. for (j = 0; j < 16; ++j, i += 4) {
  29834. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  29835. }
  29836. var a = h0, b = h1, c = h2, d = h3, f, g;
  29837. for (j = 0; j < 64; ++j) {
  29838. if (j < 16) {
  29839. f = b & c | ~b & d;
  29840. g = j;
  29841. } else if (j < 32) {
  29842. f = d & b | ~d & c;
  29843. g = 5 * j + 1 & 15;
  29844. } else if (j < 48) {
  29845. f = b ^ c ^ d;
  29846. g = 3 * j + 5 & 15;
  29847. } else {
  29848. f = c ^ (b | ~d);
  29849. g = 7 * j & 15;
  29850. }
  29851. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  29852. d = c;
  29853. c = b;
  29854. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  29855. a = tmp;
  29856. }
  29857. h0 = h0 + a | 0;
  29858. h1 = h1 + b | 0;
  29859. h2 = h2 + c | 0;
  29860. h3 = h3 + d | 0;
  29861. }
  29862. return new Uint8Array([
  29863. h0 & 0xFF,
  29864. h0 >> 8 & 0xFF,
  29865. h0 >> 16 & 0xFF,
  29866. h0 >>> 24 & 0xFF,
  29867. h1 & 0xFF,
  29868. h1 >> 8 & 0xFF,
  29869. h1 >> 16 & 0xFF,
  29870. h1 >>> 24 & 0xFF,
  29871. h2 & 0xFF,
  29872. h2 >> 8 & 0xFF,
  29873. h2 >> 16 & 0xFF,
  29874. h2 >>> 24 & 0xFF,
  29875. h3 & 0xFF,
  29876. h3 >> 8 & 0xFF,
  29877. h3 >> 16 & 0xFF,
  29878. h3 >>> 24 & 0xFF
  29879. ]);
  29880. }
  29881. return hash;
  29882. }();
  29883. var Word64 = function Word64Closure() {
  29884. function Word64(highInteger, lowInteger) {
  29885. this.high = highInteger | 0;
  29886. this.low = lowInteger | 0;
  29887. }
  29888. Word64.prototype = {
  29889. and: function Word64_and(word) {
  29890. this.high &= word.high;
  29891. this.low &= word.low;
  29892. },
  29893. xor: function Word64_xor(word) {
  29894. this.high ^= word.high;
  29895. this.low ^= word.low;
  29896. },
  29897. or: function Word64_or(word) {
  29898. this.high |= word.high;
  29899. this.low |= word.low;
  29900. },
  29901. shiftRight: function Word64_shiftRight(places) {
  29902. if (places >= 32) {
  29903. this.low = this.high >>> places - 32 | 0;
  29904. this.high = 0;
  29905. } else {
  29906. this.low = this.low >>> places | this.high << 32 - places;
  29907. this.high = this.high >>> places | 0;
  29908. }
  29909. },
  29910. shiftLeft: function Word64_shiftLeft(places) {
  29911. if (places >= 32) {
  29912. this.high = this.low << places - 32;
  29913. this.low = 0;
  29914. } else {
  29915. this.high = this.high << places | this.low >>> 32 - places;
  29916. this.low = this.low << places;
  29917. }
  29918. },
  29919. rotateRight: function Word64_rotateRight(places) {
  29920. var low, high;
  29921. if (places & 32) {
  29922. high = this.low;
  29923. low = this.high;
  29924. } else {
  29925. low = this.low;
  29926. high = this.high;
  29927. }
  29928. places &= 31;
  29929. this.low = low >>> places | high << 32 - places;
  29930. this.high = high >>> places | low << 32 - places;
  29931. },
  29932. not: function Word64_not() {
  29933. this.high = ~this.high;
  29934. this.low = ~this.low;
  29935. },
  29936. add: function Word64_add(word) {
  29937. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  29938. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  29939. if (lowAdd > 0xFFFFFFFF) {
  29940. highAdd += 1;
  29941. }
  29942. this.low = lowAdd | 0;
  29943. this.high = highAdd | 0;
  29944. },
  29945. copyTo: function Word64_copyTo(bytes, offset) {
  29946. bytes[offset] = this.high >>> 24 & 0xFF;
  29947. bytes[offset + 1] = this.high >> 16 & 0xFF;
  29948. bytes[offset + 2] = this.high >> 8 & 0xFF;
  29949. bytes[offset + 3] = this.high & 0xFF;
  29950. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  29951. bytes[offset + 5] = this.low >> 16 & 0xFF;
  29952. bytes[offset + 6] = this.low >> 8 & 0xFF;
  29953. bytes[offset + 7] = this.low & 0xFF;
  29954. },
  29955. assign: function Word64_assign(word) {
  29956. this.high = word.high;
  29957. this.low = word.low;
  29958. }
  29959. };
  29960. return Word64;
  29961. }();
  29962. var calculateSHA256 = function calculateSHA256Closure() {
  29963. function rotr(x, n) {
  29964. return x >>> n | x << 32 - n;
  29965. }
  29966. function ch(x, y, z) {
  29967. return x & y ^ ~x & z;
  29968. }
  29969. function maj(x, y, z) {
  29970. return x & y ^ x & z ^ y & z;
  29971. }
  29972. function sigma(x) {
  29973. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  29974. }
  29975. function sigmaPrime(x) {
  29976. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  29977. }
  29978. function littleSigma(x) {
  29979. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  29980. }
  29981. function littleSigmaPrime(x) {
  29982. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  29983. }
  29984. var k = [
  29985. 0x428a2f98,
  29986. 0x71374491,
  29987. 0xb5c0fbcf,
  29988. 0xe9b5dba5,
  29989. 0x3956c25b,
  29990. 0x59f111f1,
  29991. 0x923f82a4,
  29992. 0xab1c5ed5,
  29993. 0xd807aa98,
  29994. 0x12835b01,
  29995. 0x243185be,
  29996. 0x550c7dc3,
  29997. 0x72be5d74,
  29998. 0x80deb1fe,
  29999. 0x9bdc06a7,
  30000. 0xc19bf174,
  30001. 0xe49b69c1,
  30002. 0xefbe4786,
  30003. 0x0fc19dc6,
  30004. 0x240ca1cc,
  30005. 0x2de92c6f,
  30006. 0x4a7484aa,
  30007. 0x5cb0a9dc,
  30008. 0x76f988da,
  30009. 0x983e5152,
  30010. 0xa831c66d,
  30011. 0xb00327c8,
  30012. 0xbf597fc7,
  30013. 0xc6e00bf3,
  30014. 0xd5a79147,
  30015. 0x06ca6351,
  30016. 0x14292967,
  30017. 0x27b70a85,
  30018. 0x2e1b2138,
  30019. 0x4d2c6dfc,
  30020. 0x53380d13,
  30021. 0x650a7354,
  30022. 0x766a0abb,
  30023. 0x81c2c92e,
  30024. 0x92722c85,
  30025. 0xa2bfe8a1,
  30026. 0xa81a664b,
  30027. 0xc24b8b70,
  30028. 0xc76c51a3,
  30029. 0xd192e819,
  30030. 0xd6990624,
  30031. 0xf40e3585,
  30032. 0x106aa070,
  30033. 0x19a4c116,
  30034. 0x1e376c08,
  30035. 0x2748774c,
  30036. 0x34b0bcb5,
  30037. 0x391c0cb3,
  30038. 0x4ed8aa4a,
  30039. 0x5b9cca4f,
  30040. 0x682e6ff3,
  30041. 0x748f82ee,
  30042. 0x78a5636f,
  30043. 0x84c87814,
  30044. 0x8cc70208,
  30045. 0x90befffa,
  30046. 0xa4506ceb,
  30047. 0xbef9a3f7,
  30048. 0xc67178f2
  30049. ];
  30050. function hash(data, offset, length) {
  30051. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  30052. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  30053. var padded = new Uint8Array(paddedLength);
  30054. var i, j, n;
  30055. for (i = 0; i < length; ++i) {
  30056. padded[i] = data[offset++];
  30057. }
  30058. padded[i++] = 0x80;
  30059. n = paddedLength - 8;
  30060. while (i < n) {
  30061. padded[i++] = 0;
  30062. }
  30063. padded[i++] = 0;
  30064. padded[i++] = 0;
  30065. padded[i++] = 0;
  30066. padded[i++] = length >>> 29 & 0xFF;
  30067. padded[i++] = length >> 21 & 0xFF;
  30068. padded[i++] = length >> 13 & 0xFF;
  30069. padded[i++] = length >> 5 & 0xFF;
  30070. padded[i++] = length << 3 & 0xFF;
  30071. var w = new Uint32Array(64);
  30072. for (i = 0; i < paddedLength;) {
  30073. for (j = 0; j < 16; ++j) {
  30074. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  30075. i += 4;
  30076. }
  30077. for (j = 16; j < 64; ++j) {
  30078. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  30079. }
  30080. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  30081. for (j = 0; j < 64; ++j) {
  30082. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  30083. t2 = sigma(a) + maj(a, b, c);
  30084. h = g;
  30085. g = f;
  30086. f = e;
  30087. e = d + t1 | 0;
  30088. d = c;
  30089. c = b;
  30090. b = a;
  30091. a = t1 + t2 | 0;
  30092. }
  30093. h0 = h0 + a | 0;
  30094. h1 = h1 + b | 0;
  30095. h2 = h2 + c | 0;
  30096. h3 = h3 + d | 0;
  30097. h4 = h4 + e | 0;
  30098. h5 = h5 + f | 0;
  30099. h6 = h6 + g | 0;
  30100. h7 = h7 + h | 0;
  30101. }
  30102. return new Uint8Array([
  30103. h0 >> 24 & 0xFF,
  30104. h0 >> 16 & 0xFF,
  30105. h0 >> 8 & 0xFF,
  30106. h0 & 0xFF,
  30107. h1 >> 24 & 0xFF,
  30108. h1 >> 16 & 0xFF,
  30109. h1 >> 8 & 0xFF,
  30110. h1 & 0xFF,
  30111. h2 >> 24 & 0xFF,
  30112. h2 >> 16 & 0xFF,
  30113. h2 >> 8 & 0xFF,
  30114. h2 & 0xFF,
  30115. h3 >> 24 & 0xFF,
  30116. h3 >> 16 & 0xFF,
  30117. h3 >> 8 & 0xFF,
  30118. h3 & 0xFF,
  30119. h4 >> 24 & 0xFF,
  30120. h4 >> 16 & 0xFF,
  30121. h4 >> 8 & 0xFF,
  30122. h4 & 0xFF,
  30123. h5 >> 24 & 0xFF,
  30124. h5 >> 16 & 0xFF,
  30125. h5 >> 8 & 0xFF,
  30126. h5 & 0xFF,
  30127. h6 >> 24 & 0xFF,
  30128. h6 >> 16 & 0xFF,
  30129. h6 >> 8 & 0xFF,
  30130. h6 & 0xFF,
  30131. h7 >> 24 & 0xFF,
  30132. h7 >> 16 & 0xFF,
  30133. h7 >> 8 & 0xFF,
  30134. h7 & 0xFF
  30135. ]);
  30136. }
  30137. return hash;
  30138. }();
  30139. var calculateSHA512 = function calculateSHA512Closure() {
  30140. function ch(result, x, y, z, tmp) {
  30141. result.assign(x);
  30142. result.and(y);
  30143. tmp.assign(x);
  30144. tmp.not();
  30145. tmp.and(z);
  30146. result.xor(tmp);
  30147. }
  30148. function maj(result, x, y, z, tmp) {
  30149. result.assign(x);
  30150. result.and(y);
  30151. tmp.assign(x);
  30152. tmp.and(z);
  30153. result.xor(tmp);
  30154. tmp.assign(y);
  30155. tmp.and(z);
  30156. result.xor(tmp);
  30157. }
  30158. function sigma(result, x, tmp) {
  30159. result.assign(x);
  30160. result.rotateRight(28);
  30161. tmp.assign(x);
  30162. tmp.rotateRight(34);
  30163. result.xor(tmp);
  30164. tmp.assign(x);
  30165. tmp.rotateRight(39);
  30166. result.xor(tmp);
  30167. }
  30168. function sigmaPrime(result, x, tmp) {
  30169. result.assign(x);
  30170. result.rotateRight(14);
  30171. tmp.assign(x);
  30172. tmp.rotateRight(18);
  30173. result.xor(tmp);
  30174. tmp.assign(x);
  30175. tmp.rotateRight(41);
  30176. result.xor(tmp);
  30177. }
  30178. function littleSigma(result, x, tmp) {
  30179. result.assign(x);
  30180. result.rotateRight(1);
  30181. tmp.assign(x);
  30182. tmp.rotateRight(8);
  30183. result.xor(tmp);
  30184. tmp.assign(x);
  30185. tmp.shiftRight(7);
  30186. result.xor(tmp);
  30187. }
  30188. function littleSigmaPrime(result, x, tmp) {
  30189. result.assign(x);
  30190. result.rotateRight(19);
  30191. tmp.assign(x);
  30192. tmp.rotateRight(61);
  30193. result.xor(tmp);
  30194. tmp.assign(x);
  30195. tmp.shiftRight(6);
  30196. result.xor(tmp);
  30197. }
  30198. var k = [
  30199. new Word64(0x428a2f98, 0xd728ae22),
  30200. new Word64(0x71374491, 0x23ef65cd),
  30201. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  30202. new Word64(0xe9b5dba5, 0x8189dbbc),
  30203. new Word64(0x3956c25b, 0xf348b538),
  30204. new Word64(0x59f111f1, 0xb605d019),
  30205. new Word64(0x923f82a4, 0xaf194f9b),
  30206. new Word64(0xab1c5ed5, 0xda6d8118),
  30207. new Word64(0xd807aa98, 0xa3030242),
  30208. new Word64(0x12835b01, 0x45706fbe),
  30209. new Word64(0x243185be, 0x4ee4b28c),
  30210. new Word64(0x550c7dc3, 0xd5ffb4e2),
  30211. new Word64(0x72be5d74, 0xf27b896f),
  30212. new Word64(0x80deb1fe, 0x3b1696b1),
  30213. new Word64(0x9bdc06a7, 0x25c71235),
  30214. new Word64(0xc19bf174, 0xcf692694),
  30215. new Word64(0xe49b69c1, 0x9ef14ad2),
  30216. new Word64(0xefbe4786, 0x384f25e3),
  30217. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  30218. new Word64(0x240ca1cc, 0x77ac9c65),
  30219. new Word64(0x2de92c6f, 0x592b0275),
  30220. new Word64(0x4a7484aa, 0x6ea6e483),
  30221. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  30222. new Word64(0x76f988da, 0x831153b5),
  30223. new Word64(0x983e5152, 0xee66dfab),
  30224. new Word64(0xa831c66d, 0x2db43210),
  30225. new Word64(0xb00327c8, 0x98fb213f),
  30226. new Word64(0xbf597fc7, 0xbeef0ee4),
  30227. new Word64(0xc6e00bf3, 0x3da88fc2),
  30228. new Word64(0xd5a79147, 0x930aa725),
  30229. new Word64(0x06ca6351, 0xe003826f),
  30230. new Word64(0x14292967, 0x0a0e6e70),
  30231. new Word64(0x27b70a85, 0x46d22ffc),
  30232. new Word64(0x2e1b2138, 0x5c26c926),
  30233. new Word64(0x4d2c6dfc, 0x5ac42aed),
  30234. new Word64(0x53380d13, 0x9d95b3df),
  30235. new Word64(0x650a7354, 0x8baf63de),
  30236. new Word64(0x766a0abb, 0x3c77b2a8),
  30237. new Word64(0x81c2c92e, 0x47edaee6),
  30238. new Word64(0x92722c85, 0x1482353b),
  30239. new Word64(0xa2bfe8a1, 0x4cf10364),
  30240. new Word64(0xa81a664b, 0xbc423001),
  30241. new Word64(0xc24b8b70, 0xd0f89791),
  30242. new Word64(0xc76c51a3, 0x0654be30),
  30243. new Word64(0xd192e819, 0xd6ef5218),
  30244. new Word64(0xd6990624, 0x5565a910),
  30245. new Word64(0xf40e3585, 0x5771202a),
  30246. new Word64(0x106aa070, 0x32bbd1b8),
  30247. new Word64(0x19a4c116, 0xb8d2d0c8),
  30248. new Word64(0x1e376c08, 0x5141ab53),
  30249. new Word64(0x2748774c, 0xdf8eeb99),
  30250. new Word64(0x34b0bcb5, 0xe19b48a8),
  30251. new Word64(0x391c0cb3, 0xc5c95a63),
  30252. new Word64(0x4ed8aa4a, 0xe3418acb),
  30253. new Word64(0x5b9cca4f, 0x7763e373),
  30254. new Word64(0x682e6ff3, 0xd6b2b8a3),
  30255. new Word64(0x748f82ee, 0x5defb2fc),
  30256. new Word64(0x78a5636f, 0x43172f60),
  30257. new Word64(0x84c87814, 0xa1f0ab72),
  30258. new Word64(0x8cc70208, 0x1a6439ec),
  30259. new Word64(0x90befffa, 0x23631e28),
  30260. new Word64(0xa4506ceb, 0xde82bde9),
  30261. new Word64(0xbef9a3f7, 0xb2c67915),
  30262. new Word64(0xc67178f2, 0xe372532b),
  30263. new Word64(0xca273ece, 0xea26619c),
  30264. new Word64(0xd186b8c7, 0x21c0c207),
  30265. new Word64(0xeada7dd6, 0xcde0eb1e),
  30266. new Word64(0xf57d4f7f, 0xee6ed178),
  30267. new Word64(0x06f067aa, 0x72176fba),
  30268. new Word64(0x0a637dc5, 0xa2c898a6),
  30269. new Word64(0x113f9804, 0xbef90dae),
  30270. new Word64(0x1b710b35, 0x131c471b),
  30271. new Word64(0x28db77f5, 0x23047d84),
  30272. new Word64(0x32caab7b, 0x40c72493),
  30273. new Word64(0x3c9ebe0a, 0x15c9bebc),
  30274. new Word64(0x431d67c4, 0x9c100d4c),
  30275. new Word64(0x4cc5d4be, 0xcb3e42b6),
  30276. new Word64(0x597f299c, 0xfc657e2a),
  30277. new Word64(0x5fcb6fab, 0x3ad6faec),
  30278. new Word64(0x6c44198c, 0x4a475817)
  30279. ];
  30280. function hash(data, offset, length, mode384) {
  30281. mode384 = !!mode384;
  30282. var h0, h1, h2, h3, h4, h5, h6, h7;
  30283. if (!mode384) {
  30284. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  30285. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  30286. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  30287. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  30288. h4 = new Word64(0x510e527f, 0xade682d1);
  30289. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  30290. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  30291. h7 = new Word64(0x5be0cd19, 0x137e2179);
  30292. } else {
  30293. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  30294. h1 = new Word64(0x629a292a, 0x367cd507);
  30295. h2 = new Word64(0x9159015a, 0x3070dd17);
  30296. h3 = new Word64(0x152fecd8, 0xf70e5939);
  30297. h4 = new Word64(0x67332667, 0xffc00b31);
  30298. h5 = new Word64(0x8eb44a87, 0x68581511);
  30299. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  30300. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  30301. }
  30302. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  30303. var padded = new Uint8Array(paddedLength);
  30304. var i, j, n;
  30305. for (i = 0; i < length; ++i) {
  30306. padded[i] = data[offset++];
  30307. }
  30308. padded[i++] = 0x80;
  30309. n = paddedLength - 16;
  30310. while (i < n) {
  30311. padded[i++] = 0;
  30312. }
  30313. padded[i++] = 0;
  30314. padded[i++] = 0;
  30315. padded[i++] = 0;
  30316. padded[i++] = 0;
  30317. padded[i++] = 0;
  30318. padded[i++] = 0;
  30319. padded[i++] = 0;
  30320. padded[i++] = 0;
  30321. padded[i++] = 0;
  30322. padded[i++] = 0;
  30323. padded[i++] = 0;
  30324. padded[i++] = length >>> 29 & 0xFF;
  30325. padded[i++] = length >> 21 & 0xFF;
  30326. padded[i++] = length >> 13 & 0xFF;
  30327. padded[i++] = length >> 5 & 0xFF;
  30328. padded[i++] = length << 3 & 0xFF;
  30329. var w = new Array(80);
  30330. for (i = 0; i < 80; i++) {
  30331. w[i] = new Word64(0, 0);
  30332. }
  30333. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  30334. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  30335. var g = new Word64(0, 0), h = new Word64(0, 0);
  30336. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  30337. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  30338. for (i = 0; i < paddedLength;) {
  30339. for (j = 0; j < 16; ++j) {
  30340. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  30341. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  30342. i += 8;
  30343. }
  30344. for (j = 16; j < 80; ++j) {
  30345. tmp3 = w[j];
  30346. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  30347. tmp3.add(w[j - 7]);
  30348. littleSigma(tmp1, w[j - 15], tmp2);
  30349. tmp3.add(tmp1);
  30350. tmp3.add(w[j - 16]);
  30351. }
  30352. a.assign(h0);
  30353. b.assign(h1);
  30354. c.assign(h2);
  30355. d.assign(h3);
  30356. e.assign(h4);
  30357. f.assign(h5);
  30358. g.assign(h6);
  30359. h.assign(h7);
  30360. for (j = 0; j < 80; ++j) {
  30361. t1.assign(h);
  30362. sigmaPrime(tmp1, e, tmp2);
  30363. t1.add(tmp1);
  30364. ch(tmp1, e, f, g, tmp2);
  30365. t1.add(tmp1);
  30366. t1.add(k[j]);
  30367. t1.add(w[j]);
  30368. sigma(t2, a, tmp2);
  30369. maj(tmp1, a, b, c, tmp2);
  30370. t2.add(tmp1);
  30371. tmp3 = h;
  30372. h = g;
  30373. g = f;
  30374. f = e;
  30375. d.add(t1);
  30376. e = d;
  30377. d = c;
  30378. c = b;
  30379. b = a;
  30380. tmp3.assign(t1);
  30381. tmp3.add(t2);
  30382. a = tmp3;
  30383. }
  30384. h0.add(a);
  30385. h1.add(b);
  30386. h2.add(c);
  30387. h3.add(d);
  30388. h4.add(e);
  30389. h5.add(f);
  30390. h6.add(g);
  30391. h7.add(h);
  30392. }
  30393. var result;
  30394. if (!mode384) {
  30395. result = new Uint8Array(64);
  30396. h0.copyTo(result, 0);
  30397. h1.copyTo(result, 8);
  30398. h2.copyTo(result, 16);
  30399. h3.copyTo(result, 24);
  30400. h4.copyTo(result, 32);
  30401. h5.copyTo(result, 40);
  30402. h6.copyTo(result, 48);
  30403. h7.copyTo(result, 56);
  30404. } else {
  30405. result = new Uint8Array(48);
  30406. h0.copyTo(result, 0);
  30407. h1.copyTo(result, 8);
  30408. h2.copyTo(result, 16);
  30409. h3.copyTo(result, 24);
  30410. h4.copyTo(result, 32);
  30411. h5.copyTo(result, 40);
  30412. }
  30413. return result;
  30414. }
  30415. return hash;
  30416. }();
  30417. var calculateSHA384 = function calculateSHA384Closure() {
  30418. function hash(data, offset, length) {
  30419. return calculateSHA512(data, offset, length, true);
  30420. }
  30421. return hash;
  30422. }();
  30423. var NullCipher = function NullCipherClosure() {
  30424. function NullCipher() {
  30425. }
  30426. NullCipher.prototype = {
  30427. decryptBlock: function NullCipher_decryptBlock(data) {
  30428. return data;
  30429. }
  30430. };
  30431. return NullCipher;
  30432. }();
  30433. var AES128Cipher = function AES128CipherClosure() {
  30434. var rcon = new Uint8Array([
  30435. 0x8d,
  30436. 0x01,
  30437. 0x02,
  30438. 0x04,
  30439. 0x08,
  30440. 0x10,
  30441. 0x20,
  30442. 0x40,
  30443. 0x80,
  30444. 0x1b,
  30445. 0x36,
  30446. 0x6c,
  30447. 0xd8,
  30448. 0xab,
  30449. 0x4d,
  30450. 0x9a,
  30451. 0x2f,
  30452. 0x5e,
  30453. 0xbc,
  30454. 0x63,
  30455. 0xc6,
  30456. 0x97,
  30457. 0x35,
  30458. 0x6a,
  30459. 0xd4,
  30460. 0xb3,
  30461. 0x7d,
  30462. 0xfa,
  30463. 0xef,
  30464. 0xc5,
  30465. 0x91,
  30466. 0x39,
  30467. 0x72,
  30468. 0xe4,
  30469. 0xd3,
  30470. 0xbd,
  30471. 0x61,
  30472. 0xc2,
  30473. 0x9f,
  30474. 0x25,
  30475. 0x4a,
  30476. 0x94,
  30477. 0x33,
  30478. 0x66,
  30479. 0xcc,
  30480. 0x83,
  30481. 0x1d,
  30482. 0x3a,
  30483. 0x74,
  30484. 0xe8,
  30485. 0xcb,
  30486. 0x8d,
  30487. 0x01,
  30488. 0x02,
  30489. 0x04,
  30490. 0x08,
  30491. 0x10,
  30492. 0x20,
  30493. 0x40,
  30494. 0x80,
  30495. 0x1b,
  30496. 0x36,
  30497. 0x6c,
  30498. 0xd8,
  30499. 0xab,
  30500. 0x4d,
  30501. 0x9a,
  30502. 0x2f,
  30503. 0x5e,
  30504. 0xbc,
  30505. 0x63,
  30506. 0xc6,
  30507. 0x97,
  30508. 0x35,
  30509. 0x6a,
  30510. 0xd4,
  30511. 0xb3,
  30512. 0x7d,
  30513. 0xfa,
  30514. 0xef,
  30515. 0xc5,
  30516. 0x91,
  30517. 0x39,
  30518. 0x72,
  30519. 0xe4,
  30520. 0xd3,
  30521. 0xbd,
  30522. 0x61,
  30523. 0xc2,
  30524. 0x9f,
  30525. 0x25,
  30526. 0x4a,
  30527. 0x94,
  30528. 0x33,
  30529. 0x66,
  30530. 0xcc,
  30531. 0x83,
  30532. 0x1d,
  30533. 0x3a,
  30534. 0x74,
  30535. 0xe8,
  30536. 0xcb,
  30537. 0x8d,
  30538. 0x01,
  30539. 0x02,
  30540. 0x04,
  30541. 0x08,
  30542. 0x10,
  30543. 0x20,
  30544. 0x40,
  30545. 0x80,
  30546. 0x1b,
  30547. 0x36,
  30548. 0x6c,
  30549. 0xd8,
  30550. 0xab,
  30551. 0x4d,
  30552. 0x9a,
  30553. 0x2f,
  30554. 0x5e,
  30555. 0xbc,
  30556. 0x63,
  30557. 0xc6,
  30558. 0x97,
  30559. 0x35,
  30560. 0x6a,
  30561. 0xd4,
  30562. 0xb3,
  30563. 0x7d,
  30564. 0xfa,
  30565. 0xef,
  30566. 0xc5,
  30567. 0x91,
  30568. 0x39,
  30569. 0x72,
  30570. 0xe4,
  30571. 0xd3,
  30572. 0xbd,
  30573. 0x61,
  30574. 0xc2,
  30575. 0x9f,
  30576. 0x25,
  30577. 0x4a,
  30578. 0x94,
  30579. 0x33,
  30580. 0x66,
  30581. 0xcc,
  30582. 0x83,
  30583. 0x1d,
  30584. 0x3a,
  30585. 0x74,
  30586. 0xe8,
  30587. 0xcb,
  30588. 0x8d,
  30589. 0x01,
  30590. 0x02,
  30591. 0x04,
  30592. 0x08,
  30593. 0x10,
  30594. 0x20,
  30595. 0x40,
  30596. 0x80,
  30597. 0x1b,
  30598. 0x36,
  30599. 0x6c,
  30600. 0xd8,
  30601. 0xab,
  30602. 0x4d,
  30603. 0x9a,
  30604. 0x2f,
  30605. 0x5e,
  30606. 0xbc,
  30607. 0x63,
  30608. 0xc6,
  30609. 0x97,
  30610. 0x35,
  30611. 0x6a,
  30612. 0xd4,
  30613. 0xb3,
  30614. 0x7d,
  30615. 0xfa,
  30616. 0xef,
  30617. 0xc5,
  30618. 0x91,
  30619. 0x39,
  30620. 0x72,
  30621. 0xe4,
  30622. 0xd3,
  30623. 0xbd,
  30624. 0x61,
  30625. 0xc2,
  30626. 0x9f,
  30627. 0x25,
  30628. 0x4a,
  30629. 0x94,
  30630. 0x33,
  30631. 0x66,
  30632. 0xcc,
  30633. 0x83,
  30634. 0x1d,
  30635. 0x3a,
  30636. 0x74,
  30637. 0xe8,
  30638. 0xcb,
  30639. 0x8d,
  30640. 0x01,
  30641. 0x02,
  30642. 0x04,
  30643. 0x08,
  30644. 0x10,
  30645. 0x20,
  30646. 0x40,
  30647. 0x80,
  30648. 0x1b,
  30649. 0x36,
  30650. 0x6c,
  30651. 0xd8,
  30652. 0xab,
  30653. 0x4d,
  30654. 0x9a,
  30655. 0x2f,
  30656. 0x5e,
  30657. 0xbc,
  30658. 0x63,
  30659. 0xc6,
  30660. 0x97,
  30661. 0x35,
  30662. 0x6a,
  30663. 0xd4,
  30664. 0xb3,
  30665. 0x7d,
  30666. 0xfa,
  30667. 0xef,
  30668. 0xc5,
  30669. 0x91,
  30670. 0x39,
  30671. 0x72,
  30672. 0xe4,
  30673. 0xd3,
  30674. 0xbd,
  30675. 0x61,
  30676. 0xc2,
  30677. 0x9f,
  30678. 0x25,
  30679. 0x4a,
  30680. 0x94,
  30681. 0x33,
  30682. 0x66,
  30683. 0xcc,
  30684. 0x83,
  30685. 0x1d,
  30686. 0x3a,
  30687. 0x74,
  30688. 0xe8,
  30689. 0xcb,
  30690. 0x8d
  30691. ]);
  30692. var s = new Uint8Array([
  30693. 0x63,
  30694. 0x7c,
  30695. 0x77,
  30696. 0x7b,
  30697. 0xf2,
  30698. 0x6b,
  30699. 0x6f,
  30700. 0xc5,
  30701. 0x30,
  30702. 0x01,
  30703. 0x67,
  30704. 0x2b,
  30705. 0xfe,
  30706. 0xd7,
  30707. 0xab,
  30708. 0x76,
  30709. 0xca,
  30710. 0x82,
  30711. 0xc9,
  30712. 0x7d,
  30713. 0xfa,
  30714. 0x59,
  30715. 0x47,
  30716. 0xf0,
  30717. 0xad,
  30718. 0xd4,
  30719. 0xa2,
  30720. 0xaf,
  30721. 0x9c,
  30722. 0xa4,
  30723. 0x72,
  30724. 0xc0,
  30725. 0xb7,
  30726. 0xfd,
  30727. 0x93,
  30728. 0x26,
  30729. 0x36,
  30730. 0x3f,
  30731. 0xf7,
  30732. 0xcc,
  30733. 0x34,
  30734. 0xa5,
  30735. 0xe5,
  30736. 0xf1,
  30737. 0x71,
  30738. 0xd8,
  30739. 0x31,
  30740. 0x15,
  30741. 0x04,
  30742. 0xc7,
  30743. 0x23,
  30744. 0xc3,
  30745. 0x18,
  30746. 0x96,
  30747. 0x05,
  30748. 0x9a,
  30749. 0x07,
  30750. 0x12,
  30751. 0x80,
  30752. 0xe2,
  30753. 0xeb,
  30754. 0x27,
  30755. 0xb2,
  30756. 0x75,
  30757. 0x09,
  30758. 0x83,
  30759. 0x2c,
  30760. 0x1a,
  30761. 0x1b,
  30762. 0x6e,
  30763. 0x5a,
  30764. 0xa0,
  30765. 0x52,
  30766. 0x3b,
  30767. 0xd6,
  30768. 0xb3,
  30769. 0x29,
  30770. 0xe3,
  30771. 0x2f,
  30772. 0x84,
  30773. 0x53,
  30774. 0xd1,
  30775. 0x00,
  30776. 0xed,
  30777. 0x20,
  30778. 0xfc,
  30779. 0xb1,
  30780. 0x5b,
  30781. 0x6a,
  30782. 0xcb,
  30783. 0xbe,
  30784. 0x39,
  30785. 0x4a,
  30786. 0x4c,
  30787. 0x58,
  30788. 0xcf,
  30789. 0xd0,
  30790. 0xef,
  30791. 0xaa,
  30792. 0xfb,
  30793. 0x43,
  30794. 0x4d,
  30795. 0x33,
  30796. 0x85,
  30797. 0x45,
  30798. 0xf9,
  30799. 0x02,
  30800. 0x7f,
  30801. 0x50,
  30802. 0x3c,
  30803. 0x9f,
  30804. 0xa8,
  30805. 0x51,
  30806. 0xa3,
  30807. 0x40,
  30808. 0x8f,
  30809. 0x92,
  30810. 0x9d,
  30811. 0x38,
  30812. 0xf5,
  30813. 0xbc,
  30814. 0xb6,
  30815. 0xda,
  30816. 0x21,
  30817. 0x10,
  30818. 0xff,
  30819. 0xf3,
  30820. 0xd2,
  30821. 0xcd,
  30822. 0x0c,
  30823. 0x13,
  30824. 0xec,
  30825. 0x5f,
  30826. 0x97,
  30827. 0x44,
  30828. 0x17,
  30829. 0xc4,
  30830. 0xa7,
  30831. 0x7e,
  30832. 0x3d,
  30833. 0x64,
  30834. 0x5d,
  30835. 0x19,
  30836. 0x73,
  30837. 0x60,
  30838. 0x81,
  30839. 0x4f,
  30840. 0xdc,
  30841. 0x22,
  30842. 0x2a,
  30843. 0x90,
  30844. 0x88,
  30845. 0x46,
  30846. 0xee,
  30847. 0xb8,
  30848. 0x14,
  30849. 0xde,
  30850. 0x5e,
  30851. 0x0b,
  30852. 0xdb,
  30853. 0xe0,
  30854. 0x32,
  30855. 0x3a,
  30856. 0x0a,
  30857. 0x49,
  30858. 0x06,
  30859. 0x24,
  30860. 0x5c,
  30861. 0xc2,
  30862. 0xd3,
  30863. 0xac,
  30864. 0x62,
  30865. 0x91,
  30866. 0x95,
  30867. 0xe4,
  30868. 0x79,
  30869. 0xe7,
  30870. 0xc8,
  30871. 0x37,
  30872. 0x6d,
  30873. 0x8d,
  30874. 0xd5,
  30875. 0x4e,
  30876. 0xa9,
  30877. 0x6c,
  30878. 0x56,
  30879. 0xf4,
  30880. 0xea,
  30881. 0x65,
  30882. 0x7a,
  30883. 0xae,
  30884. 0x08,
  30885. 0xba,
  30886. 0x78,
  30887. 0x25,
  30888. 0x2e,
  30889. 0x1c,
  30890. 0xa6,
  30891. 0xb4,
  30892. 0xc6,
  30893. 0xe8,
  30894. 0xdd,
  30895. 0x74,
  30896. 0x1f,
  30897. 0x4b,
  30898. 0xbd,
  30899. 0x8b,
  30900. 0x8a,
  30901. 0x70,
  30902. 0x3e,
  30903. 0xb5,
  30904. 0x66,
  30905. 0x48,
  30906. 0x03,
  30907. 0xf6,
  30908. 0x0e,
  30909. 0x61,
  30910. 0x35,
  30911. 0x57,
  30912. 0xb9,
  30913. 0x86,
  30914. 0xc1,
  30915. 0x1d,
  30916. 0x9e,
  30917. 0xe1,
  30918. 0xf8,
  30919. 0x98,
  30920. 0x11,
  30921. 0x69,
  30922. 0xd9,
  30923. 0x8e,
  30924. 0x94,
  30925. 0x9b,
  30926. 0x1e,
  30927. 0x87,
  30928. 0xe9,
  30929. 0xce,
  30930. 0x55,
  30931. 0x28,
  30932. 0xdf,
  30933. 0x8c,
  30934. 0xa1,
  30935. 0x89,
  30936. 0x0d,
  30937. 0xbf,
  30938. 0xe6,
  30939. 0x42,
  30940. 0x68,
  30941. 0x41,
  30942. 0x99,
  30943. 0x2d,
  30944. 0x0f,
  30945. 0xb0,
  30946. 0x54,
  30947. 0xbb,
  30948. 0x16
  30949. ]);
  30950. var inv_s = new Uint8Array([
  30951. 0x52,
  30952. 0x09,
  30953. 0x6a,
  30954. 0xd5,
  30955. 0x30,
  30956. 0x36,
  30957. 0xa5,
  30958. 0x38,
  30959. 0xbf,
  30960. 0x40,
  30961. 0xa3,
  30962. 0x9e,
  30963. 0x81,
  30964. 0xf3,
  30965. 0xd7,
  30966. 0xfb,
  30967. 0x7c,
  30968. 0xe3,
  30969. 0x39,
  30970. 0x82,
  30971. 0x9b,
  30972. 0x2f,
  30973. 0xff,
  30974. 0x87,
  30975. 0x34,
  30976. 0x8e,
  30977. 0x43,
  30978. 0x44,
  30979. 0xc4,
  30980. 0xde,
  30981. 0xe9,
  30982. 0xcb,
  30983. 0x54,
  30984. 0x7b,
  30985. 0x94,
  30986. 0x32,
  30987. 0xa6,
  30988. 0xc2,
  30989. 0x23,
  30990. 0x3d,
  30991. 0xee,
  30992. 0x4c,
  30993. 0x95,
  30994. 0x0b,
  30995. 0x42,
  30996. 0xfa,
  30997. 0xc3,
  30998. 0x4e,
  30999. 0x08,
  31000. 0x2e,
  31001. 0xa1,
  31002. 0x66,
  31003. 0x28,
  31004. 0xd9,
  31005. 0x24,
  31006. 0xb2,
  31007. 0x76,
  31008. 0x5b,
  31009. 0xa2,
  31010. 0x49,
  31011. 0x6d,
  31012. 0x8b,
  31013. 0xd1,
  31014. 0x25,
  31015. 0x72,
  31016. 0xf8,
  31017. 0xf6,
  31018. 0x64,
  31019. 0x86,
  31020. 0x68,
  31021. 0x98,
  31022. 0x16,
  31023. 0xd4,
  31024. 0xa4,
  31025. 0x5c,
  31026. 0xcc,
  31027. 0x5d,
  31028. 0x65,
  31029. 0xb6,
  31030. 0x92,
  31031. 0x6c,
  31032. 0x70,
  31033. 0x48,
  31034. 0x50,
  31035. 0xfd,
  31036. 0xed,
  31037. 0xb9,
  31038. 0xda,
  31039. 0x5e,
  31040. 0x15,
  31041. 0x46,
  31042. 0x57,
  31043. 0xa7,
  31044. 0x8d,
  31045. 0x9d,
  31046. 0x84,
  31047. 0x90,
  31048. 0xd8,
  31049. 0xab,
  31050. 0x00,
  31051. 0x8c,
  31052. 0xbc,
  31053. 0xd3,
  31054. 0x0a,
  31055. 0xf7,
  31056. 0xe4,
  31057. 0x58,
  31058. 0x05,
  31059. 0xb8,
  31060. 0xb3,
  31061. 0x45,
  31062. 0x06,
  31063. 0xd0,
  31064. 0x2c,
  31065. 0x1e,
  31066. 0x8f,
  31067. 0xca,
  31068. 0x3f,
  31069. 0x0f,
  31070. 0x02,
  31071. 0xc1,
  31072. 0xaf,
  31073. 0xbd,
  31074. 0x03,
  31075. 0x01,
  31076. 0x13,
  31077. 0x8a,
  31078. 0x6b,
  31079. 0x3a,
  31080. 0x91,
  31081. 0x11,
  31082. 0x41,
  31083. 0x4f,
  31084. 0x67,
  31085. 0xdc,
  31086. 0xea,
  31087. 0x97,
  31088. 0xf2,
  31089. 0xcf,
  31090. 0xce,
  31091. 0xf0,
  31092. 0xb4,
  31093. 0xe6,
  31094. 0x73,
  31095. 0x96,
  31096. 0xac,
  31097. 0x74,
  31098. 0x22,
  31099. 0xe7,
  31100. 0xad,
  31101. 0x35,
  31102. 0x85,
  31103. 0xe2,
  31104. 0xf9,
  31105. 0x37,
  31106. 0xe8,
  31107. 0x1c,
  31108. 0x75,
  31109. 0xdf,
  31110. 0x6e,
  31111. 0x47,
  31112. 0xf1,
  31113. 0x1a,
  31114. 0x71,
  31115. 0x1d,
  31116. 0x29,
  31117. 0xc5,
  31118. 0x89,
  31119. 0x6f,
  31120. 0xb7,
  31121. 0x62,
  31122. 0x0e,
  31123. 0xaa,
  31124. 0x18,
  31125. 0xbe,
  31126. 0x1b,
  31127. 0xfc,
  31128. 0x56,
  31129. 0x3e,
  31130. 0x4b,
  31131. 0xc6,
  31132. 0xd2,
  31133. 0x79,
  31134. 0x20,
  31135. 0x9a,
  31136. 0xdb,
  31137. 0xc0,
  31138. 0xfe,
  31139. 0x78,
  31140. 0xcd,
  31141. 0x5a,
  31142. 0xf4,
  31143. 0x1f,
  31144. 0xdd,
  31145. 0xa8,
  31146. 0x33,
  31147. 0x88,
  31148. 0x07,
  31149. 0xc7,
  31150. 0x31,
  31151. 0xb1,
  31152. 0x12,
  31153. 0x10,
  31154. 0x59,
  31155. 0x27,
  31156. 0x80,
  31157. 0xec,
  31158. 0x5f,
  31159. 0x60,
  31160. 0x51,
  31161. 0x7f,
  31162. 0xa9,
  31163. 0x19,
  31164. 0xb5,
  31165. 0x4a,
  31166. 0x0d,
  31167. 0x2d,
  31168. 0xe5,
  31169. 0x7a,
  31170. 0x9f,
  31171. 0x93,
  31172. 0xc9,
  31173. 0x9c,
  31174. 0xef,
  31175. 0xa0,
  31176. 0xe0,
  31177. 0x3b,
  31178. 0x4d,
  31179. 0xae,
  31180. 0x2a,
  31181. 0xf5,
  31182. 0xb0,
  31183. 0xc8,
  31184. 0xeb,
  31185. 0xbb,
  31186. 0x3c,
  31187. 0x83,
  31188. 0x53,
  31189. 0x99,
  31190. 0x61,
  31191. 0x17,
  31192. 0x2b,
  31193. 0x04,
  31194. 0x7e,
  31195. 0xba,
  31196. 0x77,
  31197. 0xd6,
  31198. 0x26,
  31199. 0xe1,
  31200. 0x69,
  31201. 0x14,
  31202. 0x63,
  31203. 0x55,
  31204. 0x21,
  31205. 0x0c,
  31206. 0x7d
  31207. ]);
  31208. var mixCol = new Uint8Array(256);
  31209. for (var i = 0; i < 256; i++) {
  31210. if (i < 128) {
  31211. mixCol[i] = i << 1;
  31212. } else {
  31213. mixCol[i] = i << 1 ^ 0x1b;
  31214. }
  31215. }
  31216. var mix = new Uint32Array([
  31217. 0x00000000,
  31218. 0x0e090d0b,
  31219. 0x1c121a16,
  31220. 0x121b171d,
  31221. 0x3824342c,
  31222. 0x362d3927,
  31223. 0x24362e3a,
  31224. 0x2a3f2331,
  31225. 0x70486858,
  31226. 0x7e416553,
  31227. 0x6c5a724e,
  31228. 0x62537f45,
  31229. 0x486c5c74,
  31230. 0x4665517f,
  31231. 0x547e4662,
  31232. 0x5a774b69,
  31233. 0xe090d0b0,
  31234. 0xee99ddbb,
  31235. 0xfc82caa6,
  31236. 0xf28bc7ad,
  31237. 0xd8b4e49c,
  31238. 0xd6bde997,
  31239. 0xc4a6fe8a,
  31240. 0xcaaff381,
  31241. 0x90d8b8e8,
  31242. 0x9ed1b5e3,
  31243. 0x8ccaa2fe,
  31244. 0x82c3aff5,
  31245. 0xa8fc8cc4,
  31246. 0xa6f581cf,
  31247. 0xb4ee96d2,
  31248. 0xbae79bd9,
  31249. 0xdb3bbb7b,
  31250. 0xd532b670,
  31251. 0xc729a16d,
  31252. 0xc920ac66,
  31253. 0xe31f8f57,
  31254. 0xed16825c,
  31255. 0xff0d9541,
  31256. 0xf104984a,
  31257. 0xab73d323,
  31258. 0xa57ade28,
  31259. 0xb761c935,
  31260. 0xb968c43e,
  31261. 0x9357e70f,
  31262. 0x9d5eea04,
  31263. 0x8f45fd19,
  31264. 0x814cf012,
  31265. 0x3bab6bcb,
  31266. 0x35a266c0,
  31267. 0x27b971dd,
  31268. 0x29b07cd6,
  31269. 0x038f5fe7,
  31270. 0x0d8652ec,
  31271. 0x1f9d45f1,
  31272. 0x119448fa,
  31273. 0x4be30393,
  31274. 0x45ea0e98,
  31275. 0x57f11985,
  31276. 0x59f8148e,
  31277. 0x73c737bf,
  31278. 0x7dce3ab4,
  31279. 0x6fd52da9,
  31280. 0x61dc20a2,
  31281. 0xad766df6,
  31282. 0xa37f60fd,
  31283. 0xb16477e0,
  31284. 0xbf6d7aeb,
  31285. 0x955259da,
  31286. 0x9b5b54d1,
  31287. 0x894043cc,
  31288. 0x87494ec7,
  31289. 0xdd3e05ae,
  31290. 0xd33708a5,
  31291. 0xc12c1fb8,
  31292. 0xcf2512b3,
  31293. 0xe51a3182,
  31294. 0xeb133c89,
  31295. 0xf9082b94,
  31296. 0xf701269f,
  31297. 0x4de6bd46,
  31298. 0x43efb04d,
  31299. 0x51f4a750,
  31300. 0x5ffdaa5b,
  31301. 0x75c2896a,
  31302. 0x7bcb8461,
  31303. 0x69d0937c,
  31304. 0x67d99e77,
  31305. 0x3daed51e,
  31306. 0x33a7d815,
  31307. 0x21bccf08,
  31308. 0x2fb5c203,
  31309. 0x058ae132,
  31310. 0x0b83ec39,
  31311. 0x1998fb24,
  31312. 0x1791f62f,
  31313. 0x764dd68d,
  31314. 0x7844db86,
  31315. 0x6a5fcc9b,
  31316. 0x6456c190,
  31317. 0x4e69e2a1,
  31318. 0x4060efaa,
  31319. 0x527bf8b7,
  31320. 0x5c72f5bc,
  31321. 0x0605bed5,
  31322. 0x080cb3de,
  31323. 0x1a17a4c3,
  31324. 0x141ea9c8,
  31325. 0x3e218af9,
  31326. 0x302887f2,
  31327. 0x223390ef,
  31328. 0x2c3a9de4,
  31329. 0x96dd063d,
  31330. 0x98d40b36,
  31331. 0x8acf1c2b,
  31332. 0x84c61120,
  31333. 0xaef93211,
  31334. 0xa0f03f1a,
  31335. 0xb2eb2807,
  31336. 0xbce2250c,
  31337. 0xe6956e65,
  31338. 0xe89c636e,
  31339. 0xfa877473,
  31340. 0xf48e7978,
  31341. 0xdeb15a49,
  31342. 0xd0b85742,
  31343. 0xc2a3405f,
  31344. 0xccaa4d54,
  31345. 0x41ecdaf7,
  31346. 0x4fe5d7fc,
  31347. 0x5dfec0e1,
  31348. 0x53f7cdea,
  31349. 0x79c8eedb,
  31350. 0x77c1e3d0,
  31351. 0x65daf4cd,
  31352. 0x6bd3f9c6,
  31353. 0x31a4b2af,
  31354. 0x3fadbfa4,
  31355. 0x2db6a8b9,
  31356. 0x23bfa5b2,
  31357. 0x09808683,
  31358. 0x07898b88,
  31359. 0x15929c95,
  31360. 0x1b9b919e,
  31361. 0xa17c0a47,
  31362. 0xaf75074c,
  31363. 0xbd6e1051,
  31364. 0xb3671d5a,
  31365. 0x99583e6b,
  31366. 0x97513360,
  31367. 0x854a247d,
  31368. 0x8b432976,
  31369. 0xd134621f,
  31370. 0xdf3d6f14,
  31371. 0xcd267809,
  31372. 0xc32f7502,
  31373. 0xe9105633,
  31374. 0xe7195b38,
  31375. 0xf5024c25,
  31376. 0xfb0b412e,
  31377. 0x9ad7618c,
  31378. 0x94de6c87,
  31379. 0x86c57b9a,
  31380. 0x88cc7691,
  31381. 0xa2f355a0,
  31382. 0xacfa58ab,
  31383. 0xbee14fb6,
  31384. 0xb0e842bd,
  31385. 0xea9f09d4,
  31386. 0xe49604df,
  31387. 0xf68d13c2,
  31388. 0xf8841ec9,
  31389. 0xd2bb3df8,
  31390. 0xdcb230f3,
  31391. 0xcea927ee,
  31392. 0xc0a02ae5,
  31393. 0x7a47b13c,
  31394. 0x744ebc37,
  31395. 0x6655ab2a,
  31396. 0x685ca621,
  31397. 0x42638510,
  31398. 0x4c6a881b,
  31399. 0x5e719f06,
  31400. 0x5078920d,
  31401. 0x0a0fd964,
  31402. 0x0406d46f,
  31403. 0x161dc372,
  31404. 0x1814ce79,
  31405. 0x322bed48,
  31406. 0x3c22e043,
  31407. 0x2e39f75e,
  31408. 0x2030fa55,
  31409. 0xec9ab701,
  31410. 0xe293ba0a,
  31411. 0xf088ad17,
  31412. 0xfe81a01c,
  31413. 0xd4be832d,
  31414. 0xdab78e26,
  31415. 0xc8ac993b,
  31416. 0xc6a59430,
  31417. 0x9cd2df59,
  31418. 0x92dbd252,
  31419. 0x80c0c54f,
  31420. 0x8ec9c844,
  31421. 0xa4f6eb75,
  31422. 0xaaffe67e,
  31423. 0xb8e4f163,
  31424. 0xb6edfc68,
  31425. 0x0c0a67b1,
  31426. 0x02036aba,
  31427. 0x10187da7,
  31428. 0x1e1170ac,
  31429. 0x342e539d,
  31430. 0x3a275e96,
  31431. 0x283c498b,
  31432. 0x26354480,
  31433. 0x7c420fe9,
  31434. 0x724b02e2,
  31435. 0x605015ff,
  31436. 0x6e5918f4,
  31437. 0x44663bc5,
  31438. 0x4a6f36ce,
  31439. 0x587421d3,
  31440. 0x567d2cd8,
  31441. 0x37a10c7a,
  31442. 0x39a80171,
  31443. 0x2bb3166c,
  31444. 0x25ba1b67,
  31445. 0x0f853856,
  31446. 0x018c355d,
  31447. 0x13972240,
  31448. 0x1d9e2f4b,
  31449. 0x47e96422,
  31450. 0x49e06929,
  31451. 0x5bfb7e34,
  31452. 0x55f2733f,
  31453. 0x7fcd500e,
  31454. 0x71c45d05,
  31455. 0x63df4a18,
  31456. 0x6dd64713,
  31457. 0xd731dcca,
  31458. 0xd938d1c1,
  31459. 0xcb23c6dc,
  31460. 0xc52acbd7,
  31461. 0xef15e8e6,
  31462. 0xe11ce5ed,
  31463. 0xf307f2f0,
  31464. 0xfd0efffb,
  31465. 0xa779b492,
  31466. 0xa970b999,
  31467. 0xbb6bae84,
  31468. 0xb562a38f,
  31469. 0x9f5d80be,
  31470. 0x91548db5,
  31471. 0x834f9aa8,
  31472. 0x8d4697a3
  31473. ]);
  31474. function expandKey128(cipherKey) {
  31475. var b = 176, result = new Uint8Array(b);
  31476. result.set(cipherKey);
  31477. for (var j = 16, i = 1; j < b; ++i) {
  31478. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  31479. t1 = s[t1];
  31480. t2 = s[t2];
  31481. t3 = s[t3];
  31482. t4 = s[t4];
  31483. t1 = t1 ^ rcon[i];
  31484. for (var n = 0; n < 4; ++n) {
  31485. result[j] = t1 ^= result[j - 16];
  31486. j++;
  31487. result[j] = t2 ^= result[j - 16];
  31488. j++;
  31489. result[j] = t3 ^= result[j - 16];
  31490. j++;
  31491. result[j] = t4 ^= result[j - 16];
  31492. j++;
  31493. }
  31494. }
  31495. return result;
  31496. }
  31497. function decrypt128(input, key) {
  31498. var state = new Uint8Array(16);
  31499. state.set(input);
  31500. var i, j, k;
  31501. var t, u, v;
  31502. for (j = 0, k = 160; j < 16; ++j, ++k) {
  31503. state[j] ^= key[k];
  31504. }
  31505. for (i = 9; i >= 1; --i) {
  31506. t = state[13];
  31507. state[13] = state[9];
  31508. state[9] = state[5];
  31509. state[5] = state[1];
  31510. state[1] = t;
  31511. t = state[14];
  31512. u = state[10];
  31513. state[14] = state[6];
  31514. state[10] = state[2];
  31515. state[6] = t;
  31516. state[2] = u;
  31517. t = state[15];
  31518. u = state[11];
  31519. v = state[7];
  31520. state[15] = state[3];
  31521. state[11] = t;
  31522. state[7] = u;
  31523. state[3] = v;
  31524. for (j = 0; j < 16; ++j) {
  31525. state[j] = inv_s[state[j]];
  31526. }
  31527. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  31528. state[j] ^= key[k];
  31529. }
  31530. for (j = 0; j < 16; j += 4) {
  31531. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  31532. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  31533. state[j] = t >>> 24 & 0xFF;
  31534. state[j + 1] = t >> 16 & 0xFF;
  31535. state[j + 2] = t >> 8 & 0xFF;
  31536. state[j + 3] = t & 0xFF;
  31537. }
  31538. }
  31539. t = state[13];
  31540. state[13] = state[9];
  31541. state[9] = state[5];
  31542. state[5] = state[1];
  31543. state[1] = t;
  31544. t = state[14];
  31545. u = state[10];
  31546. state[14] = state[6];
  31547. state[10] = state[2];
  31548. state[6] = t;
  31549. state[2] = u;
  31550. t = state[15];
  31551. u = state[11];
  31552. v = state[7];
  31553. state[15] = state[3];
  31554. state[11] = t;
  31555. state[7] = u;
  31556. state[3] = v;
  31557. for (j = 0; j < 16; ++j) {
  31558. state[j] = inv_s[state[j]];
  31559. state[j] ^= key[j];
  31560. }
  31561. return state;
  31562. }
  31563. function encrypt128(input, key) {
  31564. var t, u, v, k;
  31565. var state = new Uint8Array(16);
  31566. state.set(input);
  31567. for (j = 0; j < 16; ++j) {
  31568. state[j] ^= key[j];
  31569. }
  31570. for (i = 1; i < 10; i++) {
  31571. for (j = 0; j < 16; ++j) {
  31572. state[j] = s[state[j]];
  31573. }
  31574. v = state[1];
  31575. state[1] = state[5];
  31576. state[5] = state[9];
  31577. state[9] = state[13];
  31578. state[13] = v;
  31579. v = state[2];
  31580. u = state[6];
  31581. state[2] = state[10];
  31582. state[6] = state[14];
  31583. state[10] = v;
  31584. state[14] = u;
  31585. v = state[3];
  31586. u = state[7];
  31587. t = state[11];
  31588. state[3] = state[15];
  31589. state[7] = v;
  31590. state[11] = u;
  31591. state[15] = t;
  31592. for (var j = 0; j < 16; j += 4) {
  31593. var s0 = state[j + 0], s1 = state[j + 1];
  31594. var s2 = state[j + 2], s3 = state[j + 3];
  31595. t = s0 ^ s1 ^ s2 ^ s3;
  31596. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  31597. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  31598. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  31599. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  31600. }
  31601. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  31602. state[j] ^= key[k];
  31603. }
  31604. }
  31605. for (j = 0; j < 16; ++j) {
  31606. state[j] = s[state[j]];
  31607. }
  31608. v = state[1];
  31609. state[1] = state[5];
  31610. state[5] = state[9];
  31611. state[9] = state[13];
  31612. state[13] = v;
  31613. v = state[2];
  31614. u = state[6];
  31615. state[2] = state[10];
  31616. state[6] = state[14];
  31617. state[10] = v;
  31618. state[14] = u;
  31619. v = state[3];
  31620. u = state[7];
  31621. t = state[11];
  31622. state[3] = state[15];
  31623. state[7] = v;
  31624. state[11] = u;
  31625. state[15] = t;
  31626. for (j = 0, k = 160; j < 16; ++j, ++k) {
  31627. state[j] ^= key[k];
  31628. }
  31629. return state;
  31630. }
  31631. function AES128Cipher(key) {
  31632. this.key = expandKey128(key);
  31633. this.buffer = new Uint8Array(16);
  31634. this.bufferPosition = 0;
  31635. }
  31636. function decryptBlock2(data, finalize) {
  31637. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  31638. for (i = 0; i < sourceLength; ++i) {
  31639. buffer[bufferLength] = data[i];
  31640. ++bufferLength;
  31641. if (bufferLength < 16) {
  31642. continue;
  31643. }
  31644. var plain = decrypt128(buffer, this.key);
  31645. for (j = 0; j < 16; ++j) {
  31646. plain[j] ^= iv[j];
  31647. }
  31648. iv = buffer;
  31649. result.push(plain);
  31650. buffer = new Uint8Array(16);
  31651. bufferLength = 0;
  31652. }
  31653. this.buffer = buffer;
  31654. this.bufferLength = bufferLength;
  31655. this.iv = iv;
  31656. if (result.length === 0) {
  31657. return new Uint8Array([]);
  31658. }
  31659. var outputLength = 16 * result.length;
  31660. if (finalize) {
  31661. var lastBlock = result[result.length - 1];
  31662. var psLen = lastBlock[15];
  31663. if (psLen <= 16) {
  31664. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  31665. if (lastBlock[i] !== psLen) {
  31666. psLen = 0;
  31667. break;
  31668. }
  31669. }
  31670. outputLength -= psLen;
  31671. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  31672. }
  31673. }
  31674. var output = new Uint8Array(outputLength);
  31675. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  31676. output.set(result[i], j);
  31677. }
  31678. return output;
  31679. }
  31680. AES128Cipher.prototype = {
  31681. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  31682. var i, sourceLength = data.length;
  31683. var buffer = this.buffer, bufferLength = this.bufferPosition;
  31684. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  31685. buffer[bufferLength] = data[i];
  31686. }
  31687. if (bufferLength < 16) {
  31688. this.bufferLength = bufferLength;
  31689. return new Uint8Array([]);
  31690. }
  31691. this.iv = buffer;
  31692. this.buffer = new Uint8Array(16);
  31693. this.bufferLength = 0;
  31694. this.decryptBlock = decryptBlock2;
  31695. return this.decryptBlock(data.subarray(16), finalize);
  31696. },
  31697. encrypt: function AES128Cipher_encrypt(data, iv) {
  31698. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  31699. if (!iv) {
  31700. iv = new Uint8Array(16);
  31701. }
  31702. for (i = 0; i < sourceLength; ++i) {
  31703. buffer[bufferLength] = data[i];
  31704. ++bufferLength;
  31705. if (bufferLength < 16) {
  31706. continue;
  31707. }
  31708. for (j = 0; j < 16; ++j) {
  31709. buffer[j] ^= iv[j];
  31710. }
  31711. var cipher = encrypt128(buffer, this.key);
  31712. iv = cipher;
  31713. result.push(cipher);
  31714. buffer = new Uint8Array(16);
  31715. bufferLength = 0;
  31716. }
  31717. this.buffer = buffer;
  31718. this.bufferLength = bufferLength;
  31719. this.iv = iv;
  31720. if (result.length === 0) {
  31721. return new Uint8Array([]);
  31722. }
  31723. var outputLength = 16 * result.length;
  31724. var output = new Uint8Array(outputLength);
  31725. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  31726. output.set(result[i], j);
  31727. }
  31728. return output;
  31729. }
  31730. };
  31731. return AES128Cipher;
  31732. }();
  31733. var AES256Cipher = function AES256CipherClosure() {
  31734. var rcon = new Uint8Array([
  31735. 0x8d,
  31736. 0x01,
  31737. 0x02,
  31738. 0x04,
  31739. 0x08,
  31740. 0x10,
  31741. 0x20,
  31742. 0x40,
  31743. 0x80,
  31744. 0x1b,
  31745. 0x36,
  31746. 0x6c,
  31747. 0xd8,
  31748. 0xab,
  31749. 0x4d,
  31750. 0x9a,
  31751. 0x2f,
  31752. 0x5e,
  31753. 0xbc,
  31754. 0x63,
  31755. 0xc6,
  31756. 0x97,
  31757. 0x35,
  31758. 0x6a,
  31759. 0xd4,
  31760. 0xb3,
  31761. 0x7d,
  31762. 0xfa,
  31763. 0xef,
  31764. 0xc5,
  31765. 0x91,
  31766. 0x39,
  31767. 0x72,
  31768. 0xe4,
  31769. 0xd3,
  31770. 0xbd,
  31771. 0x61,
  31772. 0xc2,
  31773. 0x9f,
  31774. 0x25,
  31775. 0x4a,
  31776. 0x94,
  31777. 0x33,
  31778. 0x66,
  31779. 0xcc,
  31780. 0x83,
  31781. 0x1d,
  31782. 0x3a,
  31783. 0x74,
  31784. 0xe8,
  31785. 0xcb,
  31786. 0x8d,
  31787. 0x01,
  31788. 0x02,
  31789. 0x04,
  31790. 0x08,
  31791. 0x10,
  31792. 0x20,
  31793. 0x40,
  31794. 0x80,
  31795. 0x1b,
  31796. 0x36,
  31797. 0x6c,
  31798. 0xd8,
  31799. 0xab,
  31800. 0x4d,
  31801. 0x9a,
  31802. 0x2f,
  31803. 0x5e,
  31804. 0xbc,
  31805. 0x63,
  31806. 0xc6,
  31807. 0x97,
  31808. 0x35,
  31809. 0x6a,
  31810. 0xd4,
  31811. 0xb3,
  31812. 0x7d,
  31813. 0xfa,
  31814. 0xef,
  31815. 0xc5,
  31816. 0x91,
  31817. 0x39,
  31818. 0x72,
  31819. 0xe4,
  31820. 0xd3,
  31821. 0xbd,
  31822. 0x61,
  31823. 0xc2,
  31824. 0x9f,
  31825. 0x25,
  31826. 0x4a,
  31827. 0x94,
  31828. 0x33,
  31829. 0x66,
  31830. 0xcc,
  31831. 0x83,
  31832. 0x1d,
  31833. 0x3a,
  31834. 0x74,
  31835. 0xe8,
  31836. 0xcb,
  31837. 0x8d,
  31838. 0x01,
  31839. 0x02,
  31840. 0x04,
  31841. 0x08,
  31842. 0x10,
  31843. 0x20,
  31844. 0x40,
  31845. 0x80,
  31846. 0x1b,
  31847. 0x36,
  31848. 0x6c,
  31849. 0xd8,
  31850. 0xab,
  31851. 0x4d,
  31852. 0x9a,
  31853. 0x2f,
  31854. 0x5e,
  31855. 0xbc,
  31856. 0x63,
  31857. 0xc6,
  31858. 0x97,
  31859. 0x35,
  31860. 0x6a,
  31861. 0xd4,
  31862. 0xb3,
  31863. 0x7d,
  31864. 0xfa,
  31865. 0xef,
  31866. 0xc5,
  31867. 0x91,
  31868. 0x39,
  31869. 0x72,
  31870. 0xe4,
  31871. 0xd3,
  31872. 0xbd,
  31873. 0x61,
  31874. 0xc2,
  31875. 0x9f,
  31876. 0x25,
  31877. 0x4a,
  31878. 0x94,
  31879. 0x33,
  31880. 0x66,
  31881. 0xcc,
  31882. 0x83,
  31883. 0x1d,
  31884. 0x3a,
  31885. 0x74,
  31886. 0xe8,
  31887. 0xcb,
  31888. 0x8d,
  31889. 0x01,
  31890. 0x02,
  31891. 0x04,
  31892. 0x08,
  31893. 0x10,
  31894. 0x20,
  31895. 0x40,
  31896. 0x80,
  31897. 0x1b,
  31898. 0x36,
  31899. 0x6c,
  31900. 0xd8,
  31901. 0xab,
  31902. 0x4d,
  31903. 0x9a,
  31904. 0x2f,
  31905. 0x5e,
  31906. 0xbc,
  31907. 0x63,
  31908. 0xc6,
  31909. 0x97,
  31910. 0x35,
  31911. 0x6a,
  31912. 0xd4,
  31913. 0xb3,
  31914. 0x7d,
  31915. 0xfa,
  31916. 0xef,
  31917. 0xc5,
  31918. 0x91,
  31919. 0x39,
  31920. 0x72,
  31921. 0xe4,
  31922. 0xd3,
  31923. 0xbd,
  31924. 0x61,
  31925. 0xc2,
  31926. 0x9f,
  31927. 0x25,
  31928. 0x4a,
  31929. 0x94,
  31930. 0x33,
  31931. 0x66,
  31932. 0xcc,
  31933. 0x83,
  31934. 0x1d,
  31935. 0x3a,
  31936. 0x74,
  31937. 0xe8,
  31938. 0xcb,
  31939. 0x8d,
  31940. 0x01,
  31941. 0x02,
  31942. 0x04,
  31943. 0x08,
  31944. 0x10,
  31945. 0x20,
  31946. 0x40,
  31947. 0x80,
  31948. 0x1b,
  31949. 0x36,
  31950. 0x6c,
  31951. 0xd8,
  31952. 0xab,
  31953. 0x4d,
  31954. 0x9a,
  31955. 0x2f,
  31956. 0x5e,
  31957. 0xbc,
  31958. 0x63,
  31959. 0xc6,
  31960. 0x97,
  31961. 0x35,
  31962. 0x6a,
  31963. 0xd4,
  31964. 0xb3,
  31965. 0x7d,
  31966. 0xfa,
  31967. 0xef,
  31968. 0xc5,
  31969. 0x91,
  31970. 0x39,
  31971. 0x72,
  31972. 0xe4,
  31973. 0xd3,
  31974. 0xbd,
  31975. 0x61,
  31976. 0xc2,
  31977. 0x9f,
  31978. 0x25,
  31979. 0x4a,
  31980. 0x94,
  31981. 0x33,
  31982. 0x66,
  31983. 0xcc,
  31984. 0x83,
  31985. 0x1d,
  31986. 0x3a,
  31987. 0x74,
  31988. 0xe8,
  31989. 0xcb,
  31990. 0x8d
  31991. ]);
  31992. var s = new Uint8Array([
  31993. 0x63,
  31994. 0x7c,
  31995. 0x77,
  31996. 0x7b,
  31997. 0xf2,
  31998. 0x6b,
  31999. 0x6f,
  32000. 0xc5,
  32001. 0x30,
  32002. 0x01,
  32003. 0x67,
  32004. 0x2b,
  32005. 0xfe,
  32006. 0xd7,
  32007. 0xab,
  32008. 0x76,
  32009. 0xca,
  32010. 0x82,
  32011. 0xc9,
  32012. 0x7d,
  32013. 0xfa,
  32014. 0x59,
  32015. 0x47,
  32016. 0xf0,
  32017. 0xad,
  32018. 0xd4,
  32019. 0xa2,
  32020. 0xaf,
  32021. 0x9c,
  32022. 0xa4,
  32023. 0x72,
  32024. 0xc0,
  32025. 0xb7,
  32026. 0xfd,
  32027. 0x93,
  32028. 0x26,
  32029. 0x36,
  32030. 0x3f,
  32031. 0xf7,
  32032. 0xcc,
  32033. 0x34,
  32034. 0xa5,
  32035. 0xe5,
  32036. 0xf1,
  32037. 0x71,
  32038. 0xd8,
  32039. 0x31,
  32040. 0x15,
  32041. 0x04,
  32042. 0xc7,
  32043. 0x23,
  32044. 0xc3,
  32045. 0x18,
  32046. 0x96,
  32047. 0x05,
  32048. 0x9a,
  32049. 0x07,
  32050. 0x12,
  32051. 0x80,
  32052. 0xe2,
  32053. 0xeb,
  32054. 0x27,
  32055. 0xb2,
  32056. 0x75,
  32057. 0x09,
  32058. 0x83,
  32059. 0x2c,
  32060. 0x1a,
  32061. 0x1b,
  32062. 0x6e,
  32063. 0x5a,
  32064. 0xa0,
  32065. 0x52,
  32066. 0x3b,
  32067. 0xd6,
  32068. 0xb3,
  32069. 0x29,
  32070. 0xe3,
  32071. 0x2f,
  32072. 0x84,
  32073. 0x53,
  32074. 0xd1,
  32075. 0x00,
  32076. 0xed,
  32077. 0x20,
  32078. 0xfc,
  32079. 0xb1,
  32080. 0x5b,
  32081. 0x6a,
  32082. 0xcb,
  32083. 0xbe,
  32084. 0x39,
  32085. 0x4a,
  32086. 0x4c,
  32087. 0x58,
  32088. 0xcf,
  32089. 0xd0,
  32090. 0xef,
  32091. 0xaa,
  32092. 0xfb,
  32093. 0x43,
  32094. 0x4d,
  32095. 0x33,
  32096. 0x85,
  32097. 0x45,
  32098. 0xf9,
  32099. 0x02,
  32100. 0x7f,
  32101. 0x50,
  32102. 0x3c,
  32103. 0x9f,
  32104. 0xa8,
  32105. 0x51,
  32106. 0xa3,
  32107. 0x40,
  32108. 0x8f,
  32109. 0x92,
  32110. 0x9d,
  32111. 0x38,
  32112. 0xf5,
  32113. 0xbc,
  32114. 0xb6,
  32115. 0xda,
  32116. 0x21,
  32117. 0x10,
  32118. 0xff,
  32119. 0xf3,
  32120. 0xd2,
  32121. 0xcd,
  32122. 0x0c,
  32123. 0x13,
  32124. 0xec,
  32125. 0x5f,
  32126. 0x97,
  32127. 0x44,
  32128. 0x17,
  32129. 0xc4,
  32130. 0xa7,
  32131. 0x7e,
  32132. 0x3d,
  32133. 0x64,
  32134. 0x5d,
  32135. 0x19,
  32136. 0x73,
  32137. 0x60,
  32138. 0x81,
  32139. 0x4f,
  32140. 0xdc,
  32141. 0x22,
  32142. 0x2a,
  32143. 0x90,
  32144. 0x88,
  32145. 0x46,
  32146. 0xee,
  32147. 0xb8,
  32148. 0x14,
  32149. 0xde,
  32150. 0x5e,
  32151. 0x0b,
  32152. 0xdb,
  32153. 0xe0,
  32154. 0x32,
  32155. 0x3a,
  32156. 0x0a,
  32157. 0x49,
  32158. 0x06,
  32159. 0x24,
  32160. 0x5c,
  32161. 0xc2,
  32162. 0xd3,
  32163. 0xac,
  32164. 0x62,
  32165. 0x91,
  32166. 0x95,
  32167. 0xe4,
  32168. 0x79,
  32169. 0xe7,
  32170. 0xc8,
  32171. 0x37,
  32172. 0x6d,
  32173. 0x8d,
  32174. 0xd5,
  32175. 0x4e,
  32176. 0xa9,
  32177. 0x6c,
  32178. 0x56,
  32179. 0xf4,
  32180. 0xea,
  32181. 0x65,
  32182. 0x7a,
  32183. 0xae,
  32184. 0x08,
  32185. 0xba,
  32186. 0x78,
  32187. 0x25,
  32188. 0x2e,
  32189. 0x1c,
  32190. 0xa6,
  32191. 0xb4,
  32192. 0xc6,
  32193. 0xe8,
  32194. 0xdd,
  32195. 0x74,
  32196. 0x1f,
  32197. 0x4b,
  32198. 0xbd,
  32199. 0x8b,
  32200. 0x8a,
  32201. 0x70,
  32202. 0x3e,
  32203. 0xb5,
  32204. 0x66,
  32205. 0x48,
  32206. 0x03,
  32207. 0xf6,
  32208. 0x0e,
  32209. 0x61,
  32210. 0x35,
  32211. 0x57,
  32212. 0xb9,
  32213. 0x86,
  32214. 0xc1,
  32215. 0x1d,
  32216. 0x9e,
  32217. 0xe1,
  32218. 0xf8,
  32219. 0x98,
  32220. 0x11,
  32221. 0x69,
  32222. 0xd9,
  32223. 0x8e,
  32224. 0x94,
  32225. 0x9b,
  32226. 0x1e,
  32227. 0x87,
  32228. 0xe9,
  32229. 0xce,
  32230. 0x55,
  32231. 0x28,
  32232. 0xdf,
  32233. 0x8c,
  32234. 0xa1,
  32235. 0x89,
  32236. 0x0d,
  32237. 0xbf,
  32238. 0xe6,
  32239. 0x42,
  32240. 0x68,
  32241. 0x41,
  32242. 0x99,
  32243. 0x2d,
  32244. 0x0f,
  32245. 0xb0,
  32246. 0x54,
  32247. 0xbb,
  32248. 0x16
  32249. ]);
  32250. var inv_s = new Uint8Array([
  32251. 0x52,
  32252. 0x09,
  32253. 0x6a,
  32254. 0xd5,
  32255. 0x30,
  32256. 0x36,
  32257. 0xa5,
  32258. 0x38,
  32259. 0xbf,
  32260. 0x40,
  32261. 0xa3,
  32262. 0x9e,
  32263. 0x81,
  32264. 0xf3,
  32265. 0xd7,
  32266. 0xfb,
  32267. 0x7c,
  32268. 0xe3,
  32269. 0x39,
  32270. 0x82,
  32271. 0x9b,
  32272. 0x2f,
  32273. 0xff,
  32274. 0x87,
  32275. 0x34,
  32276. 0x8e,
  32277. 0x43,
  32278. 0x44,
  32279. 0xc4,
  32280. 0xde,
  32281. 0xe9,
  32282. 0xcb,
  32283. 0x54,
  32284. 0x7b,
  32285. 0x94,
  32286. 0x32,
  32287. 0xa6,
  32288. 0xc2,
  32289. 0x23,
  32290. 0x3d,
  32291. 0xee,
  32292. 0x4c,
  32293. 0x95,
  32294. 0x0b,
  32295. 0x42,
  32296. 0xfa,
  32297. 0xc3,
  32298. 0x4e,
  32299. 0x08,
  32300. 0x2e,
  32301. 0xa1,
  32302. 0x66,
  32303. 0x28,
  32304. 0xd9,
  32305. 0x24,
  32306. 0xb2,
  32307. 0x76,
  32308. 0x5b,
  32309. 0xa2,
  32310. 0x49,
  32311. 0x6d,
  32312. 0x8b,
  32313. 0xd1,
  32314. 0x25,
  32315. 0x72,
  32316. 0xf8,
  32317. 0xf6,
  32318. 0x64,
  32319. 0x86,
  32320. 0x68,
  32321. 0x98,
  32322. 0x16,
  32323. 0xd4,
  32324. 0xa4,
  32325. 0x5c,
  32326. 0xcc,
  32327. 0x5d,
  32328. 0x65,
  32329. 0xb6,
  32330. 0x92,
  32331. 0x6c,
  32332. 0x70,
  32333. 0x48,
  32334. 0x50,
  32335. 0xfd,
  32336. 0xed,
  32337. 0xb9,
  32338. 0xda,
  32339. 0x5e,
  32340. 0x15,
  32341. 0x46,
  32342. 0x57,
  32343. 0xa7,
  32344. 0x8d,
  32345. 0x9d,
  32346. 0x84,
  32347. 0x90,
  32348. 0xd8,
  32349. 0xab,
  32350. 0x00,
  32351. 0x8c,
  32352. 0xbc,
  32353. 0xd3,
  32354. 0x0a,
  32355. 0xf7,
  32356. 0xe4,
  32357. 0x58,
  32358. 0x05,
  32359. 0xb8,
  32360. 0xb3,
  32361. 0x45,
  32362. 0x06,
  32363. 0xd0,
  32364. 0x2c,
  32365. 0x1e,
  32366. 0x8f,
  32367. 0xca,
  32368. 0x3f,
  32369. 0x0f,
  32370. 0x02,
  32371. 0xc1,
  32372. 0xaf,
  32373. 0xbd,
  32374. 0x03,
  32375. 0x01,
  32376. 0x13,
  32377. 0x8a,
  32378. 0x6b,
  32379. 0x3a,
  32380. 0x91,
  32381. 0x11,
  32382. 0x41,
  32383. 0x4f,
  32384. 0x67,
  32385. 0xdc,
  32386. 0xea,
  32387. 0x97,
  32388. 0xf2,
  32389. 0xcf,
  32390. 0xce,
  32391. 0xf0,
  32392. 0xb4,
  32393. 0xe6,
  32394. 0x73,
  32395. 0x96,
  32396. 0xac,
  32397. 0x74,
  32398. 0x22,
  32399. 0xe7,
  32400. 0xad,
  32401. 0x35,
  32402. 0x85,
  32403. 0xe2,
  32404. 0xf9,
  32405. 0x37,
  32406. 0xe8,
  32407. 0x1c,
  32408. 0x75,
  32409. 0xdf,
  32410. 0x6e,
  32411. 0x47,
  32412. 0xf1,
  32413. 0x1a,
  32414. 0x71,
  32415. 0x1d,
  32416. 0x29,
  32417. 0xc5,
  32418. 0x89,
  32419. 0x6f,
  32420. 0xb7,
  32421. 0x62,
  32422. 0x0e,
  32423. 0xaa,
  32424. 0x18,
  32425. 0xbe,
  32426. 0x1b,
  32427. 0xfc,
  32428. 0x56,
  32429. 0x3e,
  32430. 0x4b,
  32431. 0xc6,
  32432. 0xd2,
  32433. 0x79,
  32434. 0x20,
  32435. 0x9a,
  32436. 0xdb,
  32437. 0xc0,
  32438. 0xfe,
  32439. 0x78,
  32440. 0xcd,
  32441. 0x5a,
  32442. 0xf4,
  32443. 0x1f,
  32444. 0xdd,
  32445. 0xa8,
  32446. 0x33,
  32447. 0x88,
  32448. 0x07,
  32449. 0xc7,
  32450. 0x31,
  32451. 0xb1,
  32452. 0x12,
  32453. 0x10,
  32454. 0x59,
  32455. 0x27,
  32456. 0x80,
  32457. 0xec,
  32458. 0x5f,
  32459. 0x60,
  32460. 0x51,
  32461. 0x7f,
  32462. 0xa9,
  32463. 0x19,
  32464. 0xb5,
  32465. 0x4a,
  32466. 0x0d,
  32467. 0x2d,
  32468. 0xe5,
  32469. 0x7a,
  32470. 0x9f,
  32471. 0x93,
  32472. 0xc9,
  32473. 0x9c,
  32474. 0xef,
  32475. 0xa0,
  32476. 0xe0,
  32477. 0x3b,
  32478. 0x4d,
  32479. 0xae,
  32480. 0x2a,
  32481. 0xf5,
  32482. 0xb0,
  32483. 0xc8,
  32484. 0xeb,
  32485. 0xbb,
  32486. 0x3c,
  32487. 0x83,
  32488. 0x53,
  32489. 0x99,
  32490. 0x61,
  32491. 0x17,
  32492. 0x2b,
  32493. 0x04,
  32494. 0x7e,
  32495. 0xba,
  32496. 0x77,
  32497. 0xd6,
  32498. 0x26,
  32499. 0xe1,
  32500. 0x69,
  32501. 0x14,
  32502. 0x63,
  32503. 0x55,
  32504. 0x21,
  32505. 0x0c,
  32506. 0x7d
  32507. ]);
  32508. var mixCol = new Uint8Array(256);
  32509. for (var i = 0; i < 256; i++) {
  32510. if (i < 128) {
  32511. mixCol[i] = i << 1;
  32512. } else {
  32513. mixCol[i] = i << 1 ^ 0x1b;
  32514. }
  32515. }
  32516. var mix = new Uint32Array([
  32517. 0x00000000,
  32518. 0x0e090d0b,
  32519. 0x1c121a16,
  32520. 0x121b171d,
  32521. 0x3824342c,
  32522. 0x362d3927,
  32523. 0x24362e3a,
  32524. 0x2a3f2331,
  32525. 0x70486858,
  32526. 0x7e416553,
  32527. 0x6c5a724e,
  32528. 0x62537f45,
  32529. 0x486c5c74,
  32530. 0x4665517f,
  32531. 0x547e4662,
  32532. 0x5a774b69,
  32533. 0xe090d0b0,
  32534. 0xee99ddbb,
  32535. 0xfc82caa6,
  32536. 0xf28bc7ad,
  32537. 0xd8b4e49c,
  32538. 0xd6bde997,
  32539. 0xc4a6fe8a,
  32540. 0xcaaff381,
  32541. 0x90d8b8e8,
  32542. 0x9ed1b5e3,
  32543. 0x8ccaa2fe,
  32544. 0x82c3aff5,
  32545. 0xa8fc8cc4,
  32546. 0xa6f581cf,
  32547. 0xb4ee96d2,
  32548. 0xbae79bd9,
  32549. 0xdb3bbb7b,
  32550. 0xd532b670,
  32551. 0xc729a16d,
  32552. 0xc920ac66,
  32553. 0xe31f8f57,
  32554. 0xed16825c,
  32555. 0xff0d9541,
  32556. 0xf104984a,
  32557. 0xab73d323,
  32558. 0xa57ade28,
  32559. 0xb761c935,
  32560. 0xb968c43e,
  32561. 0x9357e70f,
  32562. 0x9d5eea04,
  32563. 0x8f45fd19,
  32564. 0x814cf012,
  32565. 0x3bab6bcb,
  32566. 0x35a266c0,
  32567. 0x27b971dd,
  32568. 0x29b07cd6,
  32569. 0x038f5fe7,
  32570. 0x0d8652ec,
  32571. 0x1f9d45f1,
  32572. 0x119448fa,
  32573. 0x4be30393,
  32574. 0x45ea0e98,
  32575. 0x57f11985,
  32576. 0x59f8148e,
  32577. 0x73c737bf,
  32578. 0x7dce3ab4,
  32579. 0x6fd52da9,
  32580. 0x61dc20a2,
  32581. 0xad766df6,
  32582. 0xa37f60fd,
  32583. 0xb16477e0,
  32584. 0xbf6d7aeb,
  32585. 0x955259da,
  32586. 0x9b5b54d1,
  32587. 0x894043cc,
  32588. 0x87494ec7,
  32589. 0xdd3e05ae,
  32590. 0xd33708a5,
  32591. 0xc12c1fb8,
  32592. 0xcf2512b3,
  32593. 0xe51a3182,
  32594. 0xeb133c89,
  32595. 0xf9082b94,
  32596. 0xf701269f,
  32597. 0x4de6bd46,
  32598. 0x43efb04d,
  32599. 0x51f4a750,
  32600. 0x5ffdaa5b,
  32601. 0x75c2896a,
  32602. 0x7bcb8461,
  32603. 0x69d0937c,
  32604. 0x67d99e77,
  32605. 0x3daed51e,
  32606. 0x33a7d815,
  32607. 0x21bccf08,
  32608. 0x2fb5c203,
  32609. 0x058ae132,
  32610. 0x0b83ec39,
  32611. 0x1998fb24,
  32612. 0x1791f62f,
  32613. 0x764dd68d,
  32614. 0x7844db86,
  32615. 0x6a5fcc9b,
  32616. 0x6456c190,
  32617. 0x4e69e2a1,
  32618. 0x4060efaa,
  32619. 0x527bf8b7,
  32620. 0x5c72f5bc,
  32621. 0x0605bed5,
  32622. 0x080cb3de,
  32623. 0x1a17a4c3,
  32624. 0x141ea9c8,
  32625. 0x3e218af9,
  32626. 0x302887f2,
  32627. 0x223390ef,
  32628. 0x2c3a9de4,
  32629. 0x96dd063d,
  32630. 0x98d40b36,
  32631. 0x8acf1c2b,
  32632. 0x84c61120,
  32633. 0xaef93211,
  32634. 0xa0f03f1a,
  32635. 0xb2eb2807,
  32636. 0xbce2250c,
  32637. 0xe6956e65,
  32638. 0xe89c636e,
  32639. 0xfa877473,
  32640. 0xf48e7978,
  32641. 0xdeb15a49,
  32642. 0xd0b85742,
  32643. 0xc2a3405f,
  32644. 0xccaa4d54,
  32645. 0x41ecdaf7,
  32646. 0x4fe5d7fc,
  32647. 0x5dfec0e1,
  32648. 0x53f7cdea,
  32649. 0x79c8eedb,
  32650. 0x77c1e3d0,
  32651. 0x65daf4cd,
  32652. 0x6bd3f9c6,
  32653. 0x31a4b2af,
  32654. 0x3fadbfa4,
  32655. 0x2db6a8b9,
  32656. 0x23bfa5b2,
  32657. 0x09808683,
  32658. 0x07898b88,
  32659. 0x15929c95,
  32660. 0x1b9b919e,
  32661. 0xa17c0a47,
  32662. 0xaf75074c,
  32663. 0xbd6e1051,
  32664. 0xb3671d5a,
  32665. 0x99583e6b,
  32666. 0x97513360,
  32667. 0x854a247d,
  32668. 0x8b432976,
  32669. 0xd134621f,
  32670. 0xdf3d6f14,
  32671. 0xcd267809,
  32672. 0xc32f7502,
  32673. 0xe9105633,
  32674. 0xe7195b38,
  32675. 0xf5024c25,
  32676. 0xfb0b412e,
  32677. 0x9ad7618c,
  32678. 0x94de6c87,
  32679. 0x86c57b9a,
  32680. 0x88cc7691,
  32681. 0xa2f355a0,
  32682. 0xacfa58ab,
  32683. 0xbee14fb6,
  32684. 0xb0e842bd,
  32685. 0xea9f09d4,
  32686. 0xe49604df,
  32687. 0xf68d13c2,
  32688. 0xf8841ec9,
  32689. 0xd2bb3df8,
  32690. 0xdcb230f3,
  32691. 0xcea927ee,
  32692. 0xc0a02ae5,
  32693. 0x7a47b13c,
  32694. 0x744ebc37,
  32695. 0x6655ab2a,
  32696. 0x685ca621,
  32697. 0x42638510,
  32698. 0x4c6a881b,
  32699. 0x5e719f06,
  32700. 0x5078920d,
  32701. 0x0a0fd964,
  32702. 0x0406d46f,
  32703. 0x161dc372,
  32704. 0x1814ce79,
  32705. 0x322bed48,
  32706. 0x3c22e043,
  32707. 0x2e39f75e,
  32708. 0x2030fa55,
  32709. 0xec9ab701,
  32710. 0xe293ba0a,
  32711. 0xf088ad17,
  32712. 0xfe81a01c,
  32713. 0xd4be832d,
  32714. 0xdab78e26,
  32715. 0xc8ac993b,
  32716. 0xc6a59430,
  32717. 0x9cd2df59,
  32718. 0x92dbd252,
  32719. 0x80c0c54f,
  32720. 0x8ec9c844,
  32721. 0xa4f6eb75,
  32722. 0xaaffe67e,
  32723. 0xb8e4f163,
  32724. 0xb6edfc68,
  32725. 0x0c0a67b1,
  32726. 0x02036aba,
  32727. 0x10187da7,
  32728. 0x1e1170ac,
  32729. 0x342e539d,
  32730. 0x3a275e96,
  32731. 0x283c498b,
  32732. 0x26354480,
  32733. 0x7c420fe9,
  32734. 0x724b02e2,
  32735. 0x605015ff,
  32736. 0x6e5918f4,
  32737. 0x44663bc5,
  32738. 0x4a6f36ce,
  32739. 0x587421d3,
  32740. 0x567d2cd8,
  32741. 0x37a10c7a,
  32742. 0x39a80171,
  32743. 0x2bb3166c,
  32744. 0x25ba1b67,
  32745. 0x0f853856,
  32746. 0x018c355d,
  32747. 0x13972240,
  32748. 0x1d9e2f4b,
  32749. 0x47e96422,
  32750. 0x49e06929,
  32751. 0x5bfb7e34,
  32752. 0x55f2733f,
  32753. 0x7fcd500e,
  32754. 0x71c45d05,
  32755. 0x63df4a18,
  32756. 0x6dd64713,
  32757. 0xd731dcca,
  32758. 0xd938d1c1,
  32759. 0xcb23c6dc,
  32760. 0xc52acbd7,
  32761. 0xef15e8e6,
  32762. 0xe11ce5ed,
  32763. 0xf307f2f0,
  32764. 0xfd0efffb,
  32765. 0xa779b492,
  32766. 0xa970b999,
  32767. 0xbb6bae84,
  32768. 0xb562a38f,
  32769. 0x9f5d80be,
  32770. 0x91548db5,
  32771. 0x834f9aa8,
  32772. 0x8d4697a3
  32773. ]);
  32774. function expandKey256(cipherKey) {
  32775. var b = 240, result = new Uint8Array(b);
  32776. var r = 1;
  32777. result.set(cipherKey);
  32778. for (var j = 32, i = 1; j < b; ++i) {
  32779. if (j % 32 === 16) {
  32780. t1 = s[t1];
  32781. t2 = s[t2];
  32782. t3 = s[t3];
  32783. t4 = s[t4];
  32784. } else if (j % 32 === 0) {
  32785. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  32786. t1 = s[t1];
  32787. t2 = s[t2];
  32788. t3 = s[t3];
  32789. t4 = s[t4];
  32790. t1 = t1 ^ r;
  32791. if ((r <<= 1) >= 256) {
  32792. r = (r ^ 0x1b) & 0xFF;
  32793. }
  32794. }
  32795. for (var n = 0; n < 4; ++n) {
  32796. result[j] = t1 ^= result[j - 32];
  32797. j++;
  32798. result[j] = t2 ^= result[j - 32];
  32799. j++;
  32800. result[j] = t3 ^= result[j - 32];
  32801. j++;
  32802. result[j] = t4 ^= result[j - 32];
  32803. j++;
  32804. }
  32805. }
  32806. return result;
  32807. }
  32808. function decrypt256(input, key) {
  32809. var state = new Uint8Array(16);
  32810. state.set(input);
  32811. var i, j, k;
  32812. var t, u, v;
  32813. for (j = 0, k = 224; j < 16; ++j, ++k) {
  32814. state[j] ^= key[k];
  32815. }
  32816. for (i = 13; i >= 1; --i) {
  32817. t = state[13];
  32818. state[13] = state[9];
  32819. state[9] = state[5];
  32820. state[5] = state[1];
  32821. state[1] = t;
  32822. t = state[14];
  32823. u = state[10];
  32824. state[14] = state[6];
  32825. state[10] = state[2];
  32826. state[6] = t;
  32827. state[2] = u;
  32828. t = state[15];
  32829. u = state[11];
  32830. v = state[7];
  32831. state[15] = state[3];
  32832. state[11] = t;
  32833. state[7] = u;
  32834. state[3] = v;
  32835. for (j = 0; j < 16; ++j) {
  32836. state[j] = inv_s[state[j]];
  32837. }
  32838. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  32839. state[j] ^= key[k];
  32840. }
  32841. for (j = 0; j < 16; j += 4) {
  32842. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  32843. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  32844. state[j] = t >>> 24 & 0xFF;
  32845. state[j + 1] = t >> 16 & 0xFF;
  32846. state[j + 2] = t >> 8 & 0xFF;
  32847. state[j + 3] = t & 0xFF;
  32848. }
  32849. }
  32850. t = state[13];
  32851. state[13] = state[9];
  32852. state[9] = state[5];
  32853. state[5] = state[1];
  32854. state[1] = t;
  32855. t = state[14];
  32856. u = state[10];
  32857. state[14] = state[6];
  32858. state[10] = state[2];
  32859. state[6] = t;
  32860. state[2] = u;
  32861. t = state[15];
  32862. u = state[11];
  32863. v = state[7];
  32864. state[15] = state[3];
  32865. state[11] = t;
  32866. state[7] = u;
  32867. state[3] = v;
  32868. for (j = 0; j < 16; ++j) {
  32869. state[j] = inv_s[state[j]];
  32870. state[j] ^= key[j];
  32871. }
  32872. return state;
  32873. }
  32874. function encrypt256(input, key) {
  32875. var t, u, v, k;
  32876. var state = new Uint8Array(16);
  32877. state.set(input);
  32878. for (j = 0; j < 16; ++j) {
  32879. state[j] ^= key[j];
  32880. }
  32881. for (i = 1; i < 14; i++) {
  32882. for (j = 0; j < 16; ++j) {
  32883. state[j] = s[state[j]];
  32884. }
  32885. v = state[1];
  32886. state[1] = state[5];
  32887. state[5] = state[9];
  32888. state[9] = state[13];
  32889. state[13] = v;
  32890. v = state[2];
  32891. u = state[6];
  32892. state[2] = state[10];
  32893. state[6] = state[14];
  32894. state[10] = v;
  32895. state[14] = u;
  32896. v = state[3];
  32897. u = state[7];
  32898. t = state[11];
  32899. state[3] = state[15];
  32900. state[7] = v;
  32901. state[11] = u;
  32902. state[15] = t;
  32903. for (var j = 0; j < 16; j += 4) {
  32904. var s0 = state[j + 0], s1 = state[j + 1];
  32905. var s2 = state[j + 2], s3 = state[j + 3];
  32906. t = s0 ^ s1 ^ s2 ^ s3;
  32907. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  32908. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  32909. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  32910. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  32911. }
  32912. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  32913. state[j] ^= key[k];
  32914. }
  32915. }
  32916. for (j = 0; j < 16; ++j) {
  32917. state[j] = s[state[j]];
  32918. }
  32919. v = state[1];
  32920. state[1] = state[5];
  32921. state[5] = state[9];
  32922. state[9] = state[13];
  32923. state[13] = v;
  32924. v = state[2];
  32925. u = state[6];
  32926. state[2] = state[10];
  32927. state[6] = state[14];
  32928. state[10] = v;
  32929. state[14] = u;
  32930. v = state[3];
  32931. u = state[7];
  32932. t = state[11];
  32933. state[3] = state[15];
  32934. state[7] = v;
  32935. state[11] = u;
  32936. state[15] = t;
  32937. for (j = 0, k = 224; j < 16; ++j, ++k) {
  32938. state[j] ^= key[k];
  32939. }
  32940. return state;
  32941. }
  32942. function AES256Cipher(key) {
  32943. this.key = expandKey256(key);
  32944. this.buffer = new Uint8Array(16);
  32945. this.bufferPosition = 0;
  32946. }
  32947. function decryptBlock2(data, finalize) {
  32948. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  32949. for (i = 0; i < sourceLength; ++i) {
  32950. buffer[bufferLength] = data[i];
  32951. ++bufferLength;
  32952. if (bufferLength < 16) {
  32953. continue;
  32954. }
  32955. var plain = decrypt256(buffer, this.key);
  32956. for (j = 0; j < 16; ++j) {
  32957. plain[j] ^= iv[j];
  32958. }
  32959. iv = buffer;
  32960. result.push(plain);
  32961. buffer = new Uint8Array(16);
  32962. bufferLength = 0;
  32963. }
  32964. this.buffer = buffer;
  32965. this.bufferLength = bufferLength;
  32966. this.iv = iv;
  32967. if (result.length === 0) {
  32968. return new Uint8Array([]);
  32969. }
  32970. var outputLength = 16 * result.length;
  32971. if (finalize) {
  32972. var lastBlock = result[result.length - 1];
  32973. var psLen = lastBlock[15];
  32974. if (psLen <= 16) {
  32975. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  32976. if (lastBlock[i] !== psLen) {
  32977. psLen = 0;
  32978. break;
  32979. }
  32980. }
  32981. outputLength -= psLen;
  32982. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  32983. }
  32984. }
  32985. var output = new Uint8Array(outputLength);
  32986. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  32987. output.set(result[i], j);
  32988. }
  32989. return output;
  32990. }
  32991. AES256Cipher.prototype = {
  32992. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  32993. var i, sourceLength = data.length;
  32994. var buffer = this.buffer, bufferLength = this.bufferPosition;
  32995. if (iv) {
  32996. this.iv = iv;
  32997. } else {
  32998. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  32999. buffer[bufferLength] = data[i];
  33000. }
  33001. if (bufferLength < 16) {
  33002. this.bufferLength = bufferLength;
  33003. return new Uint8Array([]);
  33004. }
  33005. this.iv = buffer;
  33006. data = data.subarray(16);
  33007. }
  33008. this.buffer = new Uint8Array(16);
  33009. this.bufferLength = 0;
  33010. this.decryptBlock = decryptBlock2;
  33011. return this.decryptBlock(data, finalize);
  33012. },
  33013. encrypt: function AES256Cipher_encrypt(data, iv) {
  33014. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  33015. if (!iv) {
  33016. iv = new Uint8Array(16);
  33017. }
  33018. for (i = 0; i < sourceLength; ++i) {
  33019. buffer[bufferLength] = data[i];
  33020. ++bufferLength;
  33021. if (bufferLength < 16) {
  33022. continue;
  33023. }
  33024. for (j = 0; j < 16; ++j) {
  33025. buffer[j] ^= iv[j];
  33026. }
  33027. var cipher = encrypt256(buffer, this.key);
  33028. this.iv = cipher;
  33029. result.push(cipher);
  33030. buffer = new Uint8Array(16);
  33031. bufferLength = 0;
  33032. }
  33033. this.buffer = buffer;
  33034. this.bufferLength = bufferLength;
  33035. this.iv = iv;
  33036. if (result.length === 0) {
  33037. return new Uint8Array([]);
  33038. }
  33039. var outputLength = 16 * result.length;
  33040. var output = new Uint8Array(outputLength);
  33041. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  33042. output.set(result[i], j);
  33043. }
  33044. return output;
  33045. }
  33046. };
  33047. return AES256Cipher;
  33048. }();
  33049. var PDF17 = function PDF17Closure() {
  33050. function compareByteArrays(array1, array2) {
  33051. if (array1.length !== array2.length) {
  33052. return false;
  33053. }
  33054. for (var i = 0; i < array1.length; i++) {
  33055. if (array1[i] !== array2[i]) {
  33056. return false;
  33057. }
  33058. }
  33059. return true;
  33060. }
  33061. function PDF17() {
  33062. }
  33063. PDF17.prototype = {
  33064. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  33065. var hashData = new Uint8Array(password.length + 56);
  33066. hashData.set(password, 0);
  33067. hashData.set(ownerValidationSalt, password.length);
  33068. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  33069. var result = calculateSHA256(hashData, 0, hashData.length);
  33070. return compareByteArrays(result, ownerPassword);
  33071. },
  33072. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  33073. var hashData = new Uint8Array(password.length + 8);
  33074. hashData.set(password, 0);
  33075. hashData.set(userValidationSalt, password.length);
  33076. var result = calculateSHA256(hashData, 0, hashData.length);
  33077. return compareByteArrays(result, userPassword);
  33078. },
  33079. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  33080. var hashData = new Uint8Array(password.length + 56);
  33081. hashData.set(password, 0);
  33082. hashData.set(ownerKeySalt, password.length);
  33083. hashData.set(userBytes, password.length + ownerKeySalt.length);
  33084. var key = calculateSHA256(hashData, 0, hashData.length);
  33085. var cipher = new AES256Cipher(key);
  33086. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  33087. },
  33088. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  33089. var hashData = new Uint8Array(password.length + 8);
  33090. hashData.set(password, 0);
  33091. hashData.set(userKeySalt, password.length);
  33092. var key = calculateSHA256(hashData, 0, hashData.length);
  33093. var cipher = new AES256Cipher(key);
  33094. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  33095. }
  33096. };
  33097. return PDF17;
  33098. }();
  33099. var PDF20 = function PDF20Closure() {
  33100. function concatArrays(array1, array2) {
  33101. var t = new Uint8Array(array1.length + array2.length);
  33102. t.set(array1, 0);
  33103. t.set(array2, array1.length);
  33104. return t;
  33105. }
  33106. function calculatePDF20Hash(password, input, userBytes) {
  33107. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  33108. var e = [0];
  33109. var i = 0;
  33110. while (i < 64 || e[e.length - 1] > i - 32) {
  33111. var arrayLength = password.length + k.length + userBytes.length;
  33112. var k1 = new Uint8Array(arrayLength * 64);
  33113. var array = concatArrays(password, k);
  33114. array = concatArrays(array, userBytes);
  33115. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  33116. k1.set(array, pos);
  33117. }
  33118. var cipher = new AES128Cipher(k.subarray(0, 16));
  33119. e = cipher.encrypt(k1, k.subarray(16, 32));
  33120. var remainder = 0;
  33121. for (var z = 0; z < 16; z++) {
  33122. remainder *= 256 % 3;
  33123. remainder %= 3;
  33124. remainder += (e[z] >>> 0) % 3;
  33125. remainder %= 3;
  33126. }
  33127. if (remainder === 0) {
  33128. k = calculateSHA256(e, 0, e.length);
  33129. } else if (remainder === 1) {
  33130. k = calculateSHA384(e, 0, e.length);
  33131. } else if (remainder === 2) {
  33132. k = calculateSHA512(e, 0, e.length);
  33133. }
  33134. i++;
  33135. }
  33136. return k.subarray(0, 32);
  33137. }
  33138. function PDF20() {
  33139. }
  33140. function compareByteArrays(array1, array2) {
  33141. if (array1.length !== array2.length) {
  33142. return false;
  33143. }
  33144. for (var i = 0; i < array1.length; i++) {
  33145. if (array1[i] !== array2[i]) {
  33146. return false;
  33147. }
  33148. }
  33149. return true;
  33150. }
  33151. PDF20.prototype = {
  33152. hash: function PDF20_hash(password, concatBytes, userBytes) {
  33153. return calculatePDF20Hash(password, concatBytes, userBytes);
  33154. },
  33155. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  33156. var hashData = new Uint8Array(password.length + 56);
  33157. hashData.set(password, 0);
  33158. hashData.set(ownerValidationSalt, password.length);
  33159. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  33160. var result = calculatePDF20Hash(password, hashData, userBytes);
  33161. return compareByteArrays(result, ownerPassword);
  33162. },
  33163. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  33164. var hashData = new Uint8Array(password.length + 8);
  33165. hashData.set(password, 0);
  33166. hashData.set(userValidationSalt, password.length);
  33167. var result = calculatePDF20Hash(password, hashData, []);
  33168. return compareByteArrays(result, userPassword);
  33169. },
  33170. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  33171. var hashData = new Uint8Array(password.length + 56);
  33172. hashData.set(password, 0);
  33173. hashData.set(ownerKeySalt, password.length);
  33174. hashData.set(userBytes, password.length + ownerKeySalt.length);
  33175. var key = calculatePDF20Hash(password, hashData, userBytes);
  33176. var cipher = new AES256Cipher(key);
  33177. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  33178. },
  33179. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  33180. var hashData = new Uint8Array(password.length + 8);
  33181. hashData.set(password, 0);
  33182. hashData.set(userKeySalt, password.length);
  33183. var key = calculatePDF20Hash(password, hashData, []);
  33184. var cipher = new AES256Cipher(key);
  33185. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  33186. }
  33187. };
  33188. return PDF20;
  33189. }();
  33190. var CipherTransform = function CipherTransformClosure() {
  33191. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  33192. this.stringCipherConstructor = stringCipherConstructor;
  33193. this.streamCipherConstructor = streamCipherConstructor;
  33194. }
  33195. CipherTransform.prototype = {
  33196. createStream: function CipherTransform_createStream(stream, length) {
  33197. var cipher = new this.streamCipherConstructor();
  33198. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  33199. return cipher.decryptBlock(data, finalize);
  33200. });
  33201. },
  33202. decryptString: function CipherTransform_decryptString(s) {
  33203. var cipher = new this.stringCipherConstructor();
  33204. var data = stringToBytes(s);
  33205. data = cipher.decryptBlock(data, true);
  33206. return bytesToString(data);
  33207. }
  33208. };
  33209. return CipherTransform;
  33210. }();
  33211. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  33212. var defaultPasswordBytes = new Uint8Array([
  33213. 0x28,
  33214. 0xBF,
  33215. 0x4E,
  33216. 0x5E,
  33217. 0x4E,
  33218. 0x75,
  33219. 0x8A,
  33220. 0x41,
  33221. 0x64,
  33222. 0x00,
  33223. 0x4E,
  33224. 0x56,
  33225. 0xFF,
  33226. 0xFA,
  33227. 0x01,
  33228. 0x08,
  33229. 0x2E,
  33230. 0x2E,
  33231. 0x00,
  33232. 0xB6,
  33233. 0xD0,
  33234. 0x68,
  33235. 0x3E,
  33236. 0x80,
  33237. 0x2F,
  33238. 0x0C,
  33239. 0xA9,
  33240. 0xFE,
  33241. 0x64,
  33242. 0x53,
  33243. 0x69,
  33244. 0x7A
  33245. ]);
  33246. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  33247. if (password) {
  33248. var passwordLength = Math.min(127, password.length);
  33249. password = password.subarray(0, passwordLength);
  33250. } else {
  33251. password = [];
  33252. }
  33253. var pdfAlgorithm;
  33254. if (revision === 6) {
  33255. pdfAlgorithm = new PDF20();
  33256. } else {
  33257. pdfAlgorithm = new PDF17();
  33258. }
  33259. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  33260. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  33261. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  33262. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  33263. }
  33264. return null;
  33265. }
  33266. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  33267. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  33268. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  33269. if (password) {
  33270. n = Math.min(32, password.length);
  33271. for (; i < n; ++i) {
  33272. hashData[i] = password[i];
  33273. }
  33274. }
  33275. j = 0;
  33276. while (i < 32) {
  33277. hashData[i++] = defaultPasswordBytes[j++];
  33278. }
  33279. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  33280. hashData[i++] = ownerPassword[j];
  33281. }
  33282. hashData[i++] = flags & 0xFF;
  33283. hashData[i++] = flags >> 8 & 0xFF;
  33284. hashData[i++] = flags >> 16 & 0xFF;
  33285. hashData[i++] = flags >>> 24 & 0xFF;
  33286. for (j = 0, n = fileId.length; j < n; ++j) {
  33287. hashData[i++] = fileId[j];
  33288. }
  33289. if (revision >= 4 && !encryptMetadata) {
  33290. hashData[i++] = 0xFF;
  33291. hashData[i++] = 0xFF;
  33292. hashData[i++] = 0xFF;
  33293. hashData[i++] = 0xFF;
  33294. }
  33295. var hash = calculateMD5(hashData, 0, i);
  33296. var keyLengthInBytes = keyLength >> 3;
  33297. if (revision >= 3) {
  33298. for (j = 0; j < 50; ++j) {
  33299. hash = calculateMD5(hash, 0, keyLengthInBytes);
  33300. }
  33301. }
  33302. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  33303. var cipher, checkData;
  33304. if (revision >= 3) {
  33305. for (i = 0; i < 32; ++i) {
  33306. hashData[i] = defaultPasswordBytes[i];
  33307. }
  33308. for (j = 0, n = fileId.length; j < n; ++j) {
  33309. hashData[i++] = fileId[j];
  33310. }
  33311. cipher = new ARCFourCipher(encryptionKey);
  33312. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  33313. n = encryptionKey.length;
  33314. var derivedKey = new Uint8Array(n), k;
  33315. for (j = 1; j <= 19; ++j) {
  33316. for (k = 0; k < n; ++k) {
  33317. derivedKey[k] = encryptionKey[k] ^ j;
  33318. }
  33319. cipher = new ARCFourCipher(derivedKey);
  33320. checkData = cipher.encryptBlock(checkData);
  33321. }
  33322. for (j = 0, n = checkData.length; j < n; ++j) {
  33323. if (userPassword[j] !== checkData[j]) {
  33324. return null;
  33325. }
  33326. }
  33327. } else {
  33328. cipher = new ARCFourCipher(encryptionKey);
  33329. checkData = cipher.encryptBlock(defaultPasswordBytes);
  33330. for (j = 0, n = checkData.length; j < n; ++j) {
  33331. if (userPassword[j] !== checkData[j]) {
  33332. return null;
  33333. }
  33334. }
  33335. }
  33336. return encryptionKey;
  33337. }
  33338. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  33339. var hashData = new Uint8Array(32), i = 0, j, n;
  33340. n = Math.min(32, password.length);
  33341. for (; i < n; ++i) {
  33342. hashData[i] = password[i];
  33343. }
  33344. j = 0;
  33345. while (i < 32) {
  33346. hashData[i++] = defaultPasswordBytes[j++];
  33347. }
  33348. var hash = calculateMD5(hashData, 0, i);
  33349. var keyLengthInBytes = keyLength >> 3;
  33350. if (revision >= 3) {
  33351. for (j = 0; j < 50; ++j) {
  33352. hash = calculateMD5(hash, 0, hash.length);
  33353. }
  33354. }
  33355. var cipher, userPassword;
  33356. if (revision >= 3) {
  33357. userPassword = ownerPassword;
  33358. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  33359. for (j = 19; j >= 0; j--) {
  33360. for (k = 0; k < keyLengthInBytes; ++k) {
  33361. derivedKey[k] = hash[k] ^ j;
  33362. }
  33363. cipher = new ARCFourCipher(derivedKey);
  33364. userPassword = cipher.encryptBlock(userPassword);
  33365. }
  33366. } else {
  33367. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  33368. userPassword = cipher.encryptBlock(ownerPassword);
  33369. }
  33370. return userPassword;
  33371. }
  33372. var identityName = Name.get('Identity');
  33373. function CipherTransformFactory(dict, fileId, password) {
  33374. var filter = dict.get('Filter');
  33375. if (!isName(filter, 'Standard')) {
  33376. error('unknown encryption method');
  33377. }
  33378. this.dict = dict;
  33379. var algorithm = dict.get('V');
  33380. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  33381. error('unsupported encryption algorithm');
  33382. }
  33383. this.algorithm = algorithm;
  33384. var keyLength = dict.get('Length');
  33385. if (!keyLength) {
  33386. if (algorithm <= 3) {
  33387. keyLength = 40;
  33388. } else {
  33389. var cfDict = dict.get('CF');
  33390. var streamCryptoName = dict.get('StmF');
  33391. if (isDict(cfDict) && isName(streamCryptoName)) {
  33392. cfDict.suppressEncryption = true;
  33393. var handlerDict = cfDict.get(streamCryptoName.name);
  33394. keyLength = handlerDict && handlerDict.get('Length') || 128;
  33395. if (keyLength < 40) {
  33396. keyLength <<= 3;
  33397. }
  33398. }
  33399. }
  33400. }
  33401. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  33402. error('invalid key length');
  33403. }
  33404. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  33405. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  33406. var flags = dict.get('P');
  33407. var revision = dict.get('R');
  33408. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  33409. this.encryptMetadata = encryptMetadata;
  33410. var fileIdBytes = stringToBytes(fileId);
  33411. var passwordBytes;
  33412. if (password) {
  33413. if (revision === 6) {
  33414. try {
  33415. password = utf8StringToString(password);
  33416. } catch (ex) {
  33417. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  33418. }
  33419. }
  33420. passwordBytes = stringToBytes(password);
  33421. }
  33422. var encryptionKey;
  33423. if (algorithm !== 5) {
  33424. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  33425. } else {
  33426. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  33427. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  33428. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  33429. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  33430. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  33431. var ownerEncryption = stringToBytes(dict.get('OE'));
  33432. var userEncryption = stringToBytes(dict.get('UE'));
  33433. var perms = stringToBytes(dict.get('Perms'));
  33434. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  33435. }
  33436. if (!encryptionKey && !password) {
  33437. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  33438. } else if (!encryptionKey && password) {
  33439. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  33440. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  33441. }
  33442. if (!encryptionKey) {
  33443. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  33444. }
  33445. this.encryptionKey = encryptionKey;
  33446. if (algorithm >= 4) {
  33447. var cf = dict.get('CF');
  33448. if (isDict(cf)) {
  33449. cf.suppressEncryption = true;
  33450. }
  33451. this.cf = cf;
  33452. this.stmf = dict.get('StmF') || identityName;
  33453. this.strf = dict.get('StrF') || identityName;
  33454. this.eff = dict.get('EFF') || this.stmf;
  33455. }
  33456. }
  33457. function buildObjectKey(num, gen, encryptionKey, isAes) {
  33458. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  33459. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  33460. key[i] = encryptionKey[i];
  33461. }
  33462. key[i++] = num & 0xFF;
  33463. key[i++] = num >> 8 & 0xFF;
  33464. key[i++] = num >> 16 & 0xFF;
  33465. key[i++] = gen & 0xFF;
  33466. key[i++] = gen >> 8 & 0xFF;
  33467. if (isAes) {
  33468. key[i++] = 0x73;
  33469. key[i++] = 0x41;
  33470. key[i++] = 0x6C;
  33471. key[i++] = 0x54;
  33472. }
  33473. var hash = calculateMD5(key, 0, i);
  33474. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  33475. }
  33476. function buildCipherConstructor(cf, name, num, gen, key) {
  33477. assert(isName(name), 'Invalid crypt filter name.');
  33478. var cryptFilter = cf.get(name.name);
  33479. var cfm;
  33480. if (cryptFilter !== null && cryptFilter !== undefined) {
  33481. cfm = cryptFilter.get('CFM');
  33482. }
  33483. if (!cfm || cfm.name === 'None') {
  33484. return function cipherTransformFactoryBuildCipherConstructorNone() {
  33485. return new NullCipher();
  33486. };
  33487. }
  33488. if ('V2' === cfm.name) {
  33489. return function cipherTransformFactoryBuildCipherConstructorV2() {
  33490. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  33491. };
  33492. }
  33493. if ('AESV2' === cfm.name) {
  33494. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  33495. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  33496. };
  33497. }
  33498. if ('AESV3' === cfm.name) {
  33499. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  33500. return new AES256Cipher(key);
  33501. };
  33502. }
  33503. error('Unknown crypto method');
  33504. }
  33505. CipherTransformFactory.prototype = {
  33506. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  33507. if (this.algorithm === 4 || this.algorithm === 5) {
  33508. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  33509. }
  33510. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  33511. var cipherConstructor = function buildCipherCipherConstructor() {
  33512. return new ARCFourCipher(key);
  33513. };
  33514. return new CipherTransform(cipherConstructor, cipherConstructor);
  33515. }
  33516. };
  33517. return CipherTransformFactory;
  33518. }();
  33519. exports.AES128Cipher = AES128Cipher;
  33520. exports.AES256Cipher = AES256Cipher;
  33521. exports.ARCFourCipher = ARCFourCipher;
  33522. exports.CipherTransformFactory = CipherTransformFactory;
  33523. exports.PDF17 = PDF17;
  33524. exports.PDF20 = PDF20;
  33525. exports.calculateMD5 = calculateMD5;
  33526. exports.calculateSHA256 = calculateSHA256;
  33527. exports.calculateSHA384 = calculateSHA384;
  33528. exports.calculateSHA512 = calculateSHA512;
  33529. }));
  33530. (function (root, factory) {
  33531. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  33532. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  33533. var Util = sharedUtil.Util;
  33534. var bytesToString = sharedUtil.bytesToString;
  33535. var error = sharedUtil.error;
  33536. var Stream = coreStream.Stream;
  33537. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  33538. var StandardEncoding = coreEncodings.StandardEncoding;
  33539. var CFFParser = coreCFFParser.CFFParser;
  33540. var FontRendererFactory = function FontRendererFactoryClosure() {
  33541. function getLong(data, offset) {
  33542. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  33543. }
  33544. function getUshort(data, offset) {
  33545. return data[offset] << 8 | data[offset + 1];
  33546. }
  33547. function parseCmap(data, start, end) {
  33548. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  33549. var format = getUshort(data, start + offset);
  33550. var length, ranges, p, i;
  33551. if (format === 4) {
  33552. length = getUshort(data, start + offset + 2);
  33553. var segCount = getUshort(data, start + offset + 6) >> 1;
  33554. p = start + offset + 14;
  33555. ranges = [];
  33556. for (i = 0; i < segCount; i++, p += 2) {
  33557. ranges[i] = { end: getUshort(data, p) };
  33558. }
  33559. p += 2;
  33560. for (i = 0; i < segCount; i++, p += 2) {
  33561. ranges[i].start = getUshort(data, p);
  33562. }
  33563. for (i = 0; i < segCount; i++, p += 2) {
  33564. ranges[i].idDelta = getUshort(data, p);
  33565. }
  33566. for (i = 0; i < segCount; i++, p += 2) {
  33567. var idOffset = getUshort(data, p);
  33568. if (idOffset === 0) {
  33569. continue;
  33570. }
  33571. ranges[i].ids = [];
  33572. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  33573. ranges[i].ids[j] = getUshort(data, p + idOffset);
  33574. idOffset += 2;
  33575. }
  33576. }
  33577. return ranges;
  33578. } else if (format === 12) {
  33579. length = getLong(data, start + offset + 4);
  33580. var groups = getLong(data, start + offset + 12);
  33581. p = start + offset + 16;
  33582. ranges = [];
  33583. for (i = 0; i < groups; i++) {
  33584. ranges.push({
  33585. start: getLong(data, p),
  33586. end: getLong(data, p + 4),
  33587. idDelta: getLong(data, p + 8) - getLong(data, p)
  33588. });
  33589. p += 12;
  33590. }
  33591. return ranges;
  33592. }
  33593. error('not supported cmap: ' + format);
  33594. }
  33595. function parseCff(data, start, end, seacAnalysisEnabled) {
  33596. var properties = {};
  33597. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  33598. var cff = parser.parse();
  33599. return {
  33600. glyphs: cff.charStrings.objects,
  33601. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  33602. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  33603. };
  33604. }
  33605. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  33606. var itemSize, itemDecode;
  33607. if (isGlyphLocationsLong) {
  33608. itemSize = 4;
  33609. itemDecode = function fontItemDecodeLong(data, offset) {
  33610. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  33611. };
  33612. } else {
  33613. itemSize = 2;
  33614. itemDecode = function fontItemDecode(data, offset) {
  33615. return data[offset] << 9 | data[offset + 1] << 1;
  33616. };
  33617. }
  33618. var glyphs = [];
  33619. var startOffset = itemDecode(loca, 0);
  33620. for (var j = itemSize; j < loca.length; j += itemSize) {
  33621. var endOffset = itemDecode(loca, j);
  33622. glyphs.push(glyf.subarray(startOffset, endOffset));
  33623. startOffset = endOffset;
  33624. }
  33625. return glyphs;
  33626. }
  33627. function lookupCmap(ranges, unicode) {
  33628. var code = unicode.charCodeAt(0), gid = 0;
  33629. var l = 0, r = ranges.length - 1;
  33630. while (l < r) {
  33631. var c = l + r + 1 >> 1;
  33632. if (code < ranges[c].start) {
  33633. r = c - 1;
  33634. } else {
  33635. l = c;
  33636. }
  33637. }
  33638. if (ranges[l].start <= code && code <= ranges[l].end) {
  33639. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  33640. }
  33641. return {
  33642. charCode: code,
  33643. glyphId: gid
  33644. };
  33645. }
  33646. function compileGlyf(code, cmds, font) {
  33647. function moveTo(x, y) {
  33648. cmds.push({
  33649. cmd: 'moveTo',
  33650. args: [
  33651. x,
  33652. y
  33653. ]
  33654. });
  33655. }
  33656. function lineTo(x, y) {
  33657. cmds.push({
  33658. cmd: 'lineTo',
  33659. args: [
  33660. x,
  33661. y
  33662. ]
  33663. });
  33664. }
  33665. function quadraticCurveTo(xa, ya, x, y) {
  33666. cmds.push({
  33667. cmd: 'quadraticCurveTo',
  33668. args: [
  33669. xa,
  33670. ya,
  33671. x,
  33672. y
  33673. ]
  33674. });
  33675. }
  33676. var i = 0;
  33677. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  33678. var flags;
  33679. var x = 0, y = 0;
  33680. i += 10;
  33681. if (numberOfContours < 0) {
  33682. do {
  33683. flags = code[i] << 8 | code[i + 1];
  33684. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  33685. i += 4;
  33686. var arg1, arg2;
  33687. if (flags & 0x01) {
  33688. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  33689. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  33690. i += 4;
  33691. } else {
  33692. arg1 = code[i++];
  33693. arg2 = code[i++];
  33694. }
  33695. if (flags & 0x02) {
  33696. x = arg1;
  33697. y = arg2;
  33698. } else {
  33699. x = 0;
  33700. y = 0;
  33701. }
  33702. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  33703. if (flags & 0x08) {
  33704. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33705. i += 2;
  33706. } else if (flags & 0x40) {
  33707. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33708. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  33709. i += 4;
  33710. } else if (flags & 0x80) {
  33711. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33712. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  33713. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  33714. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  33715. i += 8;
  33716. }
  33717. var subglyph = font.glyphs[glyphIndex];
  33718. if (subglyph) {
  33719. cmds.push({ cmd: 'save' });
  33720. cmds.push({
  33721. cmd: 'transform',
  33722. args: [
  33723. scaleX,
  33724. scale01,
  33725. scale10,
  33726. scaleY,
  33727. x,
  33728. y
  33729. ]
  33730. });
  33731. compileGlyf(subglyph, cmds, font);
  33732. cmds.push({ cmd: 'restore' });
  33733. }
  33734. } while (flags & 0x20);
  33735. } else {
  33736. var endPtsOfContours = [];
  33737. var j, jj;
  33738. for (j = 0; j < numberOfContours; j++) {
  33739. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  33740. i += 2;
  33741. }
  33742. var instructionLength = code[i] << 8 | code[i + 1];
  33743. i += 2 + instructionLength;
  33744. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  33745. var points = [];
  33746. while (points.length < numberOfPoints) {
  33747. flags = code[i++];
  33748. var repeat = 1;
  33749. if (flags & 0x08) {
  33750. repeat += code[i++];
  33751. }
  33752. while (repeat-- > 0) {
  33753. points.push({ flags: flags });
  33754. }
  33755. }
  33756. for (j = 0; j < numberOfPoints; j++) {
  33757. switch (points[j].flags & 0x12) {
  33758. case 0x00:
  33759. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  33760. i += 2;
  33761. break;
  33762. case 0x02:
  33763. x -= code[i++];
  33764. break;
  33765. case 0x12:
  33766. x += code[i++];
  33767. break;
  33768. }
  33769. points[j].x = x;
  33770. }
  33771. for (j = 0; j < numberOfPoints; j++) {
  33772. switch (points[j].flags & 0x24) {
  33773. case 0x00:
  33774. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  33775. i += 2;
  33776. break;
  33777. case 0x04:
  33778. y -= code[i++];
  33779. break;
  33780. case 0x24:
  33781. y += code[i++];
  33782. break;
  33783. }
  33784. points[j].y = y;
  33785. }
  33786. var startPoint = 0;
  33787. for (i = 0; i < numberOfContours; i++) {
  33788. var endPoint = endPtsOfContours[i];
  33789. var contour = points.slice(startPoint, endPoint + 1);
  33790. if (contour[0].flags & 1) {
  33791. contour.push(contour[0]);
  33792. } else if (contour[contour.length - 1].flags & 1) {
  33793. contour.unshift(contour[contour.length - 1]);
  33794. } else {
  33795. var p = {
  33796. flags: 1,
  33797. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  33798. y: (contour[0].y + contour[contour.length - 1].y) / 2
  33799. };
  33800. contour.unshift(p);
  33801. contour.push(p);
  33802. }
  33803. moveTo(contour[0].x, contour[0].y);
  33804. for (j = 1, jj = contour.length; j < jj; j++) {
  33805. if (contour[j].flags & 1) {
  33806. lineTo(contour[j].x, contour[j].y);
  33807. } else if (contour[j + 1].flags & 1) {
  33808. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  33809. j++;
  33810. } else {
  33811. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  33812. }
  33813. }
  33814. startPoint = endPoint + 1;
  33815. }
  33816. }
  33817. }
  33818. function compileCharString(code, cmds, font) {
  33819. var stack = [];
  33820. var x = 0, y = 0;
  33821. var stems = 0;
  33822. function moveTo(x, y) {
  33823. cmds.push({
  33824. cmd: 'moveTo',
  33825. args: [
  33826. x,
  33827. y
  33828. ]
  33829. });
  33830. }
  33831. function lineTo(x, y) {
  33832. cmds.push({
  33833. cmd: 'lineTo',
  33834. args: [
  33835. x,
  33836. y
  33837. ]
  33838. });
  33839. }
  33840. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  33841. cmds.push({
  33842. cmd: 'bezierCurveTo',
  33843. args: [
  33844. x1,
  33845. y1,
  33846. x2,
  33847. y2,
  33848. x,
  33849. y
  33850. ]
  33851. });
  33852. }
  33853. function parse(code) {
  33854. var i = 0;
  33855. while (i < code.length) {
  33856. var stackClean = false;
  33857. var v = code[i++];
  33858. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  33859. switch (v) {
  33860. case 1:
  33861. stems += stack.length >> 1;
  33862. stackClean = true;
  33863. break;
  33864. case 3:
  33865. stems += stack.length >> 1;
  33866. stackClean = true;
  33867. break;
  33868. case 4:
  33869. y += stack.pop();
  33870. moveTo(x, y);
  33871. stackClean = true;
  33872. break;
  33873. case 5:
  33874. while (stack.length > 0) {
  33875. x += stack.shift();
  33876. y += stack.shift();
  33877. lineTo(x, y);
  33878. }
  33879. break;
  33880. case 6:
  33881. while (stack.length > 0) {
  33882. x += stack.shift();
  33883. lineTo(x, y);
  33884. if (stack.length === 0) {
  33885. break;
  33886. }
  33887. y += stack.shift();
  33888. lineTo(x, y);
  33889. }
  33890. break;
  33891. case 7:
  33892. while (stack.length > 0) {
  33893. y += stack.shift();
  33894. lineTo(x, y);
  33895. if (stack.length === 0) {
  33896. break;
  33897. }
  33898. x += stack.shift();
  33899. lineTo(x, y);
  33900. }
  33901. break;
  33902. case 8:
  33903. while (stack.length > 0) {
  33904. xa = x + stack.shift();
  33905. ya = y + stack.shift();
  33906. xb = xa + stack.shift();
  33907. yb = ya + stack.shift();
  33908. x = xb + stack.shift();
  33909. y = yb + stack.shift();
  33910. bezierCurveTo(xa, ya, xb, yb, x, y);
  33911. }
  33912. break;
  33913. case 10:
  33914. n = stack.pop() + font.subrsBias;
  33915. subrCode = font.subrs[n];
  33916. if (subrCode) {
  33917. parse(subrCode);
  33918. }
  33919. break;
  33920. case 11:
  33921. return;
  33922. case 12:
  33923. v = code[i++];
  33924. switch (v) {
  33925. case 34:
  33926. xa = x + stack.shift();
  33927. xb = xa + stack.shift();
  33928. y1 = y + stack.shift();
  33929. x = xb + stack.shift();
  33930. bezierCurveTo(xa, y, xb, y1, x, y1);
  33931. xa = x + stack.shift();
  33932. xb = xa + stack.shift();
  33933. x = xb + stack.shift();
  33934. bezierCurveTo(xa, y1, xb, y, x, y);
  33935. break;
  33936. case 35:
  33937. xa = x + stack.shift();
  33938. ya = y + stack.shift();
  33939. xb = xa + stack.shift();
  33940. yb = ya + stack.shift();
  33941. x = xb + stack.shift();
  33942. y = yb + stack.shift();
  33943. bezierCurveTo(xa, ya, xb, yb, x, y);
  33944. xa = x + stack.shift();
  33945. ya = y + stack.shift();
  33946. xb = xa + stack.shift();
  33947. yb = ya + stack.shift();
  33948. x = xb + stack.shift();
  33949. y = yb + stack.shift();
  33950. bezierCurveTo(xa, ya, xb, yb, x, y);
  33951. stack.pop();
  33952. break;
  33953. case 36:
  33954. xa = x + stack.shift();
  33955. y1 = y + stack.shift();
  33956. xb = xa + stack.shift();
  33957. y2 = y1 + stack.shift();
  33958. x = xb + stack.shift();
  33959. bezierCurveTo(xa, y1, xb, y2, x, y2);
  33960. xa = x + stack.shift();
  33961. xb = xa + stack.shift();
  33962. y3 = y2 + stack.shift();
  33963. x = xb + stack.shift();
  33964. bezierCurveTo(xa, y2, xb, y3, x, y);
  33965. break;
  33966. case 37:
  33967. var x0 = x, y0 = y;
  33968. xa = x + stack.shift();
  33969. ya = y + stack.shift();
  33970. xb = xa + stack.shift();
  33971. yb = ya + stack.shift();
  33972. x = xb + stack.shift();
  33973. y = yb + stack.shift();
  33974. bezierCurveTo(xa, ya, xb, yb, x, y);
  33975. xa = x + stack.shift();
  33976. ya = y + stack.shift();
  33977. xb = xa + stack.shift();
  33978. yb = ya + stack.shift();
  33979. x = xb;
  33980. y = yb;
  33981. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  33982. x += stack.shift();
  33983. } else {
  33984. y += stack.shift();
  33985. }
  33986. bezierCurveTo(xa, ya, xb, yb, x, y);
  33987. break;
  33988. default:
  33989. error('unknown operator: 12 ' + v);
  33990. }
  33991. break;
  33992. case 14:
  33993. if (stack.length >= 4) {
  33994. var achar = stack.pop();
  33995. var bchar = stack.pop();
  33996. y = stack.pop();
  33997. x = stack.pop();
  33998. cmds.push({ cmd: 'save' });
  33999. cmds.push({
  34000. cmd: 'translate',
  34001. args: [
  34002. x,
  34003. y
  34004. ]
  34005. });
  34006. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  34007. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  34008. cmds.push({ cmd: 'restore' });
  34009. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  34010. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  34011. }
  34012. return;
  34013. case 18:
  34014. stems += stack.length >> 1;
  34015. stackClean = true;
  34016. break;
  34017. case 19:
  34018. stems += stack.length >> 1;
  34019. i += stems + 7 >> 3;
  34020. stackClean = true;
  34021. break;
  34022. case 20:
  34023. stems += stack.length >> 1;
  34024. i += stems + 7 >> 3;
  34025. stackClean = true;
  34026. break;
  34027. case 21:
  34028. y += stack.pop();
  34029. x += stack.pop();
  34030. moveTo(x, y);
  34031. stackClean = true;
  34032. break;
  34033. case 22:
  34034. x += stack.pop();
  34035. moveTo(x, y);
  34036. stackClean = true;
  34037. break;
  34038. case 23:
  34039. stems += stack.length >> 1;
  34040. stackClean = true;
  34041. break;
  34042. case 24:
  34043. while (stack.length > 2) {
  34044. xa = x + stack.shift();
  34045. ya = y + stack.shift();
  34046. xb = xa + stack.shift();
  34047. yb = ya + stack.shift();
  34048. x = xb + stack.shift();
  34049. y = yb + stack.shift();
  34050. bezierCurveTo(xa, ya, xb, yb, x, y);
  34051. }
  34052. x += stack.shift();
  34053. y += stack.shift();
  34054. lineTo(x, y);
  34055. break;
  34056. case 25:
  34057. while (stack.length > 6) {
  34058. x += stack.shift();
  34059. y += stack.shift();
  34060. lineTo(x, y);
  34061. }
  34062. xa = x + stack.shift();
  34063. ya = y + stack.shift();
  34064. xb = xa + stack.shift();
  34065. yb = ya + stack.shift();
  34066. x = xb + stack.shift();
  34067. y = yb + stack.shift();
  34068. bezierCurveTo(xa, ya, xb, yb, x, y);
  34069. break;
  34070. case 26:
  34071. if (stack.length % 2) {
  34072. x += stack.shift();
  34073. }
  34074. while (stack.length > 0) {
  34075. xa = x;
  34076. ya = y + stack.shift();
  34077. xb = xa + stack.shift();
  34078. yb = ya + stack.shift();
  34079. x = xb;
  34080. y = yb + stack.shift();
  34081. bezierCurveTo(xa, ya, xb, yb, x, y);
  34082. }
  34083. break;
  34084. case 27:
  34085. if (stack.length % 2) {
  34086. y += stack.shift();
  34087. }
  34088. while (stack.length > 0) {
  34089. xa = x + stack.shift();
  34090. ya = y;
  34091. xb = xa + stack.shift();
  34092. yb = ya + stack.shift();
  34093. x = xb + stack.shift();
  34094. y = yb;
  34095. bezierCurveTo(xa, ya, xb, yb, x, y);
  34096. }
  34097. break;
  34098. case 28:
  34099. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  34100. i += 2;
  34101. break;
  34102. case 29:
  34103. n = stack.pop() + font.gsubrsBias;
  34104. subrCode = font.gsubrs[n];
  34105. if (subrCode) {
  34106. parse(subrCode);
  34107. }
  34108. break;
  34109. case 30:
  34110. while (stack.length > 0) {
  34111. xa = x;
  34112. ya = y + stack.shift();
  34113. xb = xa + stack.shift();
  34114. yb = ya + stack.shift();
  34115. x = xb + stack.shift();
  34116. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34117. bezierCurveTo(xa, ya, xb, yb, x, y);
  34118. if (stack.length === 0) {
  34119. break;
  34120. }
  34121. xa = x + stack.shift();
  34122. ya = y;
  34123. xb = xa + stack.shift();
  34124. yb = ya + stack.shift();
  34125. y = yb + stack.shift();
  34126. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34127. bezierCurveTo(xa, ya, xb, yb, x, y);
  34128. }
  34129. break;
  34130. case 31:
  34131. while (stack.length > 0) {
  34132. xa = x + stack.shift();
  34133. ya = y;
  34134. xb = xa + stack.shift();
  34135. yb = ya + stack.shift();
  34136. y = yb + stack.shift();
  34137. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34138. bezierCurveTo(xa, ya, xb, yb, x, y);
  34139. if (stack.length === 0) {
  34140. break;
  34141. }
  34142. xa = x;
  34143. ya = y + stack.shift();
  34144. xb = xa + stack.shift();
  34145. yb = ya + stack.shift();
  34146. x = xb + stack.shift();
  34147. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34148. bezierCurveTo(xa, ya, xb, yb, x, y);
  34149. }
  34150. break;
  34151. default:
  34152. if (v < 32) {
  34153. error('unknown operator: ' + v);
  34154. }
  34155. if (v < 247) {
  34156. stack.push(v - 139);
  34157. } else if (v < 251) {
  34158. stack.push((v - 247) * 256 + code[i++] + 108);
  34159. } else if (v < 255) {
  34160. stack.push(-(v - 251) * 256 - code[i++] - 108);
  34161. } else {
  34162. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  34163. i += 4;
  34164. }
  34165. break;
  34166. }
  34167. if (stackClean) {
  34168. stack.length = 0;
  34169. }
  34170. }
  34171. }
  34172. parse(code);
  34173. }
  34174. var noop = '';
  34175. function CompiledFont(fontMatrix) {
  34176. this.compiledGlyphs = Object.create(null);
  34177. this.compiledCharCodeToGlyphId = Object.create(null);
  34178. this.fontMatrix = fontMatrix;
  34179. }
  34180. CompiledFont.prototype = {
  34181. getPathJs: function (unicode) {
  34182. var cmap = lookupCmap(this.cmap, unicode);
  34183. var fn = this.compiledGlyphs[cmap.glyphId];
  34184. if (!fn) {
  34185. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  34186. this.compiledGlyphs[cmap.glyphId] = fn;
  34187. }
  34188. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  34189. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  34190. }
  34191. return fn;
  34192. },
  34193. compileGlyph: function (code) {
  34194. if (!code || code.length === 0 || code[0] === 14) {
  34195. return noop;
  34196. }
  34197. var cmds = [];
  34198. cmds.push({ cmd: 'save' });
  34199. cmds.push({
  34200. cmd: 'transform',
  34201. args: this.fontMatrix.slice()
  34202. });
  34203. cmds.push({
  34204. cmd: 'scale',
  34205. args: [
  34206. 'size',
  34207. '-size'
  34208. ]
  34209. });
  34210. this.compileGlyphImpl(code, cmds);
  34211. cmds.push({ cmd: 'restore' });
  34212. return cmds;
  34213. },
  34214. compileGlyphImpl: function () {
  34215. error('Children classes should implement this.');
  34216. },
  34217. hasBuiltPath: function (unicode) {
  34218. var cmap = lookupCmap(this.cmap, unicode);
  34219. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  34220. }
  34221. };
  34222. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  34223. fontMatrix = fontMatrix || [
  34224. 0.000488,
  34225. 0,
  34226. 0,
  34227. 0.000488,
  34228. 0,
  34229. 0
  34230. ];
  34231. CompiledFont.call(this, fontMatrix);
  34232. this.glyphs = glyphs;
  34233. this.cmap = cmap;
  34234. }
  34235. Util.inherit(TrueTypeCompiled, CompiledFont, {
  34236. compileGlyphImpl: function (code, cmds) {
  34237. compileGlyf(code, cmds, this);
  34238. }
  34239. });
  34240. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  34241. fontMatrix = fontMatrix || [
  34242. 0.001,
  34243. 0,
  34244. 0,
  34245. 0.001,
  34246. 0,
  34247. 0
  34248. ];
  34249. CompiledFont.call(this, fontMatrix);
  34250. this.glyphs = cffInfo.glyphs;
  34251. this.gsubrs = cffInfo.gsubrs || [];
  34252. this.subrs = cffInfo.subrs || [];
  34253. this.cmap = cmap;
  34254. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  34255. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  34256. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  34257. }
  34258. Util.inherit(Type2Compiled, CompiledFont, {
  34259. compileGlyphImpl: function (code, cmds) {
  34260. compileCharString(code, cmds, this);
  34261. }
  34262. });
  34263. return {
  34264. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  34265. var data = new Uint8Array(font.data);
  34266. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  34267. var numTables = getUshort(data, 4);
  34268. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  34269. var tag = bytesToString(data.subarray(p, p + 4));
  34270. var offset = getLong(data, p + 8);
  34271. var length = getLong(data, p + 12);
  34272. switch (tag) {
  34273. case 'cmap':
  34274. cmap = parseCmap(data, offset, offset + length);
  34275. break;
  34276. case 'glyf':
  34277. glyf = data.subarray(offset, offset + length);
  34278. break;
  34279. case 'loca':
  34280. loca = data.subarray(offset, offset + length);
  34281. break;
  34282. case 'head':
  34283. unitsPerEm = getUshort(data, offset + 18);
  34284. indexToLocFormat = getUshort(data, offset + 50);
  34285. break;
  34286. case 'CFF ':
  34287. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  34288. break;
  34289. }
  34290. }
  34291. if (glyf) {
  34292. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  34293. 1 / unitsPerEm,
  34294. 0,
  34295. 0,
  34296. 1 / unitsPerEm,
  34297. 0,
  34298. 0
  34299. ];
  34300. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  34301. } else {
  34302. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  34303. }
  34304. }
  34305. };
  34306. }();
  34307. exports.FontRendererFactory = FontRendererFactory;
  34308. }));
  34309. (function (root, factory) {
  34310. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  34311. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  34312. var MissingDataException = sharedUtil.MissingDataException;
  34313. var StreamType = sharedUtil.StreamType;
  34314. var assert = sharedUtil.assert;
  34315. var error = sharedUtil.error;
  34316. var info = sharedUtil.info;
  34317. var isArray = sharedUtil.isArray;
  34318. var isInt = sharedUtil.isInt;
  34319. var isNum = sharedUtil.isNum;
  34320. var isString = sharedUtil.isString;
  34321. var warn = sharedUtil.warn;
  34322. var Cmd = corePrimitives.Cmd;
  34323. var Dict = corePrimitives.Dict;
  34324. var Name = corePrimitives.Name;
  34325. var Ref = corePrimitives.Ref;
  34326. var isCmd = corePrimitives.isCmd;
  34327. var isDict = corePrimitives.isDict;
  34328. var isName = corePrimitives.isName;
  34329. var Ascii85Stream = coreStream.Ascii85Stream;
  34330. var AsciiHexStream = coreStream.AsciiHexStream;
  34331. var CCITTFaxStream = coreStream.CCITTFaxStream;
  34332. var FlateStream = coreStream.FlateStream;
  34333. var Jbig2Stream = coreStream.Jbig2Stream;
  34334. var JpegStream = coreStream.JpegStream;
  34335. var JpxStream = coreStream.JpxStream;
  34336. var LZWStream = coreStream.LZWStream;
  34337. var NullStream = coreStream.NullStream;
  34338. var PredictorStream = coreStream.PredictorStream;
  34339. var RunLengthStream = coreStream.RunLengthStream;
  34340. var EOF = {};
  34341. function isEOF(v) {
  34342. return v === EOF;
  34343. }
  34344. var MAX_LENGTH_TO_CACHE = 1000;
  34345. var Parser = function ParserClosure() {
  34346. function Parser(lexer, allowStreams, xref, recoveryMode) {
  34347. this.lexer = lexer;
  34348. this.allowStreams = allowStreams;
  34349. this.xref = xref;
  34350. this.recoveryMode = recoveryMode || false;
  34351. this.imageCache = Object.create(null);
  34352. this.refill();
  34353. }
  34354. Parser.prototype = {
  34355. refill: function Parser_refill() {
  34356. this.buf1 = this.lexer.getObj();
  34357. this.buf2 = this.lexer.getObj();
  34358. },
  34359. shift: function Parser_shift() {
  34360. if (isCmd(this.buf2, 'ID')) {
  34361. this.buf1 = this.buf2;
  34362. this.buf2 = null;
  34363. } else {
  34364. this.buf1 = this.buf2;
  34365. this.buf2 = this.lexer.getObj();
  34366. }
  34367. },
  34368. tryShift: function Parser_tryShift() {
  34369. try {
  34370. this.shift();
  34371. return true;
  34372. } catch (e) {
  34373. if (e instanceof MissingDataException) {
  34374. throw e;
  34375. }
  34376. return false;
  34377. }
  34378. },
  34379. getObj: function Parser_getObj(cipherTransform) {
  34380. var buf1 = this.buf1;
  34381. this.shift();
  34382. if (buf1 instanceof Cmd) {
  34383. switch (buf1.cmd) {
  34384. case 'BI':
  34385. return this.makeInlineImage(cipherTransform);
  34386. case '[':
  34387. var array = [];
  34388. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  34389. array.push(this.getObj(cipherTransform));
  34390. }
  34391. if (isEOF(this.buf1)) {
  34392. if (!this.recoveryMode) {
  34393. error('End of file inside array');
  34394. }
  34395. return array;
  34396. }
  34397. this.shift();
  34398. return array;
  34399. case '<<':
  34400. var dict = new Dict(this.xref);
  34401. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  34402. if (!isName(this.buf1)) {
  34403. info('Malformed dictionary: key must be a name object');
  34404. this.shift();
  34405. continue;
  34406. }
  34407. var key = this.buf1.name;
  34408. this.shift();
  34409. if (isEOF(this.buf1)) {
  34410. break;
  34411. }
  34412. dict.set(key, this.getObj(cipherTransform));
  34413. }
  34414. if (isEOF(this.buf1)) {
  34415. if (!this.recoveryMode) {
  34416. error('End of file inside dictionary');
  34417. }
  34418. return dict;
  34419. }
  34420. if (isCmd(this.buf2, 'stream')) {
  34421. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  34422. }
  34423. this.shift();
  34424. return dict;
  34425. default:
  34426. return buf1;
  34427. }
  34428. }
  34429. if (isInt(buf1)) {
  34430. var num = buf1;
  34431. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  34432. var ref = new Ref(num, this.buf1);
  34433. this.shift();
  34434. this.shift();
  34435. return ref;
  34436. }
  34437. return num;
  34438. }
  34439. if (isString(buf1)) {
  34440. var str = buf1;
  34441. if (cipherTransform) {
  34442. str = cipherTransform.decryptString(str);
  34443. }
  34444. return str;
  34445. }
  34446. return buf1;
  34447. },
  34448. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  34449. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  34450. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  34451. while ((ch = stream.getByte()) !== -1) {
  34452. if (state === 0) {
  34453. state = ch === E ? 1 : 0;
  34454. } else if (state === 1) {
  34455. state = ch === I ? 2 : 0;
  34456. } else {
  34457. assert(state === 2);
  34458. if (ch === SPACE || ch === LF || ch === CR) {
  34459. n = 5;
  34460. followingBytes = stream.peekBytes(n);
  34461. for (i = 0; i < n; i++) {
  34462. ch = followingBytes[i];
  34463. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  34464. state = 0;
  34465. break;
  34466. }
  34467. }
  34468. if (state === 2) {
  34469. break;
  34470. }
  34471. } else
  34472. {
  34473. state = 0;
  34474. }
  34475. }
  34476. }
  34477. return stream.pos - 4 - startPos;
  34478. },
  34479. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  34480. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  34481. while ((b = stream.getByte()) !== -1) {
  34482. if (b !== 0xFF) {
  34483. continue;
  34484. }
  34485. switch (stream.getByte()) {
  34486. case 0x00:
  34487. break;
  34488. case 0xFF:
  34489. stream.skip(-1);
  34490. break;
  34491. case 0xD9:
  34492. foundEOI = true;
  34493. break;
  34494. case 0xC0:
  34495. case 0xC1:
  34496. case 0xC2:
  34497. case 0xC3:
  34498. case 0xC5:
  34499. case 0xC6:
  34500. case 0xC7:
  34501. case 0xC9:
  34502. case 0xCA:
  34503. case 0xCB:
  34504. case 0xCD:
  34505. case 0xCE:
  34506. case 0xCF:
  34507. case 0xC4:
  34508. case 0xCC:
  34509. case 0xDA:
  34510. case 0xDB:
  34511. case 0xDC:
  34512. case 0xDD:
  34513. case 0xDE:
  34514. case 0xDF:
  34515. case 0xE0:
  34516. case 0xE1:
  34517. case 0xE2:
  34518. case 0xE3:
  34519. case 0xE4:
  34520. case 0xE5:
  34521. case 0xE6:
  34522. case 0xE7:
  34523. case 0xE8:
  34524. case 0xE9:
  34525. case 0xEA:
  34526. case 0xEB:
  34527. case 0xEC:
  34528. case 0xED:
  34529. case 0xEE:
  34530. case 0xEF:
  34531. case 0xFE:
  34532. markerLength = stream.getUint16();
  34533. if (markerLength > 2) {
  34534. stream.skip(markerLength - 2);
  34535. } else
  34536. {
  34537. stream.skip(-2);
  34538. }
  34539. break;
  34540. }
  34541. if (foundEOI) {
  34542. break;
  34543. }
  34544. }
  34545. length = stream.pos - startPos;
  34546. if (b === -1) {
  34547. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  34548. stream.skip(-length);
  34549. return this.findDefaultInlineStreamEnd(stream);
  34550. }
  34551. this.inlineStreamSkipEI(stream);
  34552. return length;
  34553. },
  34554. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  34555. var TILDE = 0x7E, GT = 0x3E;
  34556. var startPos = stream.pos, ch, length;
  34557. while ((ch = stream.getByte()) !== -1) {
  34558. if (ch === TILDE && stream.peekByte() === GT) {
  34559. stream.skip();
  34560. break;
  34561. }
  34562. }
  34563. length = stream.pos - startPos;
  34564. if (ch === -1) {
  34565. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  34566. stream.skip(-length);
  34567. return this.findDefaultInlineStreamEnd(stream);
  34568. }
  34569. this.inlineStreamSkipEI(stream);
  34570. return length;
  34571. },
  34572. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  34573. var GT = 0x3E;
  34574. var startPos = stream.pos, ch, length;
  34575. while ((ch = stream.getByte()) !== -1) {
  34576. if (ch === GT) {
  34577. break;
  34578. }
  34579. }
  34580. length = stream.pos - startPos;
  34581. if (ch === -1) {
  34582. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  34583. stream.skip(-length);
  34584. return this.findDefaultInlineStreamEnd(stream);
  34585. }
  34586. this.inlineStreamSkipEI(stream);
  34587. return length;
  34588. },
  34589. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  34590. var E = 0x45, I = 0x49;
  34591. var state = 0, ch;
  34592. while ((ch = stream.getByte()) !== -1) {
  34593. if (state === 0) {
  34594. state = ch === E ? 1 : 0;
  34595. } else if (state === 1) {
  34596. state = ch === I ? 2 : 0;
  34597. } else if (state === 2) {
  34598. break;
  34599. }
  34600. }
  34601. },
  34602. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  34603. var lexer = this.lexer;
  34604. var stream = lexer.stream;
  34605. var dict = new Dict(this.xref);
  34606. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  34607. if (!isName(this.buf1)) {
  34608. error('Dictionary key must be a name object');
  34609. }
  34610. var key = this.buf1.name;
  34611. this.shift();
  34612. if (isEOF(this.buf1)) {
  34613. break;
  34614. }
  34615. dict.set(key, this.getObj(cipherTransform));
  34616. }
  34617. var filter = dict.get('Filter', 'F'), filterName;
  34618. if (isName(filter)) {
  34619. filterName = filter.name;
  34620. } else if (isArray(filter) && isName(filter[0])) {
  34621. filterName = filter[0].name;
  34622. }
  34623. var startPos = stream.pos, length, i, ii;
  34624. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  34625. length = this.findDCTDecodeInlineStreamEnd(stream);
  34626. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  34627. length = this.findASCII85DecodeInlineStreamEnd(stream);
  34628. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  34629. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  34630. } else {
  34631. length = this.findDefaultInlineStreamEnd(stream);
  34632. }
  34633. var imageStream = stream.makeSubStream(startPos, length, dict);
  34634. var adler32;
  34635. if (length < MAX_LENGTH_TO_CACHE) {
  34636. var imageBytes = imageStream.getBytes();
  34637. imageStream.reset();
  34638. var a = 1;
  34639. var b = 0;
  34640. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  34641. a += imageBytes[i] & 0xff;
  34642. b += a;
  34643. }
  34644. adler32 = b % 65521 << 16 | a % 65521;
  34645. if (this.imageCache.adler32 === adler32) {
  34646. this.buf2 = Cmd.get('EI');
  34647. this.shift();
  34648. this.imageCache[adler32].reset();
  34649. return this.imageCache[adler32];
  34650. }
  34651. }
  34652. if (cipherTransform) {
  34653. imageStream = cipherTransform.createStream(imageStream, length);
  34654. }
  34655. imageStream = this.filter(imageStream, dict, length);
  34656. imageStream.dict = dict;
  34657. if (adler32 !== undefined) {
  34658. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  34659. this.imageCache[adler32] = imageStream;
  34660. }
  34661. this.buf2 = Cmd.get('EI');
  34662. this.shift();
  34663. return imageStream;
  34664. },
  34665. makeStream: function Parser_makeStream(dict, cipherTransform) {
  34666. var lexer = this.lexer;
  34667. var stream = lexer.stream;
  34668. lexer.skipToNextLine();
  34669. var pos = stream.pos - 1;
  34670. var length = dict.get('Length');
  34671. if (!isInt(length)) {
  34672. info('Bad ' + length + ' attribute in stream');
  34673. length = 0;
  34674. }
  34675. stream.pos = pos + length;
  34676. lexer.nextChar();
  34677. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  34678. this.shift();
  34679. } else
  34680. {
  34681. stream.pos = pos;
  34682. var SCAN_BLOCK_SIZE = 2048;
  34683. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  34684. var ENDSTREAM_SIGNATURE = [
  34685. 0x65,
  34686. 0x6E,
  34687. 0x64,
  34688. 0x73,
  34689. 0x74,
  34690. 0x72,
  34691. 0x65,
  34692. 0x61,
  34693. 0x6D
  34694. ];
  34695. var skipped = 0, found = false, i, j;
  34696. while (stream.pos < stream.end) {
  34697. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  34698. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  34699. if (scanLength <= 0) {
  34700. break;
  34701. }
  34702. found = false;
  34703. i = 0;
  34704. while (i < scanLength) {
  34705. j = 0;
  34706. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  34707. j++;
  34708. }
  34709. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  34710. found = true;
  34711. break;
  34712. }
  34713. i++;
  34714. }
  34715. if (found) {
  34716. skipped += i;
  34717. stream.pos += i;
  34718. break;
  34719. }
  34720. skipped += scanLength;
  34721. stream.pos += scanLength;
  34722. }
  34723. if (!found) {
  34724. error('Missing endstream');
  34725. }
  34726. length = skipped;
  34727. lexer.nextChar();
  34728. this.shift();
  34729. this.shift();
  34730. }
  34731. this.shift();
  34732. stream = stream.makeSubStream(pos, length, dict);
  34733. if (cipherTransform) {
  34734. stream = cipherTransform.createStream(stream, length);
  34735. }
  34736. stream = this.filter(stream, dict, length);
  34737. stream.dict = dict;
  34738. return stream;
  34739. },
  34740. filter: function Parser_filter(stream, dict, length) {
  34741. var filter = dict.get('Filter', 'F');
  34742. var params = dict.get('DecodeParms', 'DP');
  34743. if (isName(filter)) {
  34744. if (isArray(params)) {
  34745. params = params[0];
  34746. }
  34747. return this.makeFilter(stream, filter.name, length, params);
  34748. }
  34749. var maybeLength = length;
  34750. if (isArray(filter)) {
  34751. var filterArray = filter;
  34752. var paramsArray = params;
  34753. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  34754. filter = filterArray[i];
  34755. if (!isName(filter)) {
  34756. error('Bad filter name: ' + filter);
  34757. }
  34758. params = null;
  34759. if (isArray(paramsArray) && i in paramsArray) {
  34760. params = paramsArray[i];
  34761. }
  34762. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  34763. maybeLength = null;
  34764. }
  34765. }
  34766. return stream;
  34767. },
  34768. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  34769. if (maybeLength === 0) {
  34770. warn('Empty "' + name + '" stream.');
  34771. return new NullStream(stream);
  34772. }
  34773. try {
  34774. if (params && this.xref) {
  34775. params = this.xref.fetchIfRef(params);
  34776. }
  34777. var xrefStreamStats = this.xref.stats.streamTypes;
  34778. if (name === 'FlateDecode' || name === 'Fl') {
  34779. xrefStreamStats[StreamType.FLATE] = true;
  34780. if (params) {
  34781. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  34782. }
  34783. return new FlateStream(stream, maybeLength);
  34784. }
  34785. if (name === 'LZWDecode' || name === 'LZW') {
  34786. xrefStreamStats[StreamType.LZW] = true;
  34787. var earlyChange = 1;
  34788. if (params) {
  34789. if (params.has('EarlyChange')) {
  34790. earlyChange = params.get('EarlyChange');
  34791. }
  34792. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  34793. }
  34794. return new LZWStream(stream, maybeLength, earlyChange);
  34795. }
  34796. if (name === 'DCTDecode' || name === 'DCT') {
  34797. xrefStreamStats[StreamType.DCT] = true;
  34798. return new JpegStream(stream, maybeLength, stream.dict, params);
  34799. }
  34800. if (name === 'JPXDecode' || name === 'JPX') {
  34801. xrefStreamStats[StreamType.JPX] = true;
  34802. return new JpxStream(stream, maybeLength, stream.dict, params);
  34803. }
  34804. if (name === 'ASCII85Decode' || name === 'A85') {
  34805. xrefStreamStats[StreamType.A85] = true;
  34806. return new Ascii85Stream(stream, maybeLength);
  34807. }
  34808. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  34809. xrefStreamStats[StreamType.AHX] = true;
  34810. return new AsciiHexStream(stream, maybeLength);
  34811. }
  34812. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  34813. xrefStreamStats[StreamType.CCF] = true;
  34814. return new CCITTFaxStream(stream, maybeLength, params);
  34815. }
  34816. if (name === 'RunLengthDecode' || name === 'RL') {
  34817. xrefStreamStats[StreamType.RL] = true;
  34818. return new RunLengthStream(stream, maybeLength);
  34819. }
  34820. if (name === 'JBIG2Decode') {
  34821. xrefStreamStats[StreamType.JBIG] = true;
  34822. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  34823. }
  34824. warn('filter "' + name + '" not supported yet');
  34825. return stream;
  34826. } catch (ex) {
  34827. if (ex instanceof MissingDataException) {
  34828. throw ex;
  34829. }
  34830. warn('Invalid stream: \"' + ex + '\"');
  34831. return new NullStream(stream);
  34832. }
  34833. }
  34834. };
  34835. return Parser;
  34836. }();
  34837. var Lexer = function LexerClosure() {
  34838. function Lexer(stream, knownCommands) {
  34839. this.stream = stream;
  34840. this.nextChar();
  34841. this.strBuf = [];
  34842. this.knownCommands = knownCommands;
  34843. }
  34844. var specialChars = [
  34845. 1,
  34846. 0,
  34847. 0,
  34848. 0,
  34849. 0,
  34850. 0,
  34851. 0,
  34852. 0,
  34853. 0,
  34854. 1,
  34855. 1,
  34856. 0,
  34857. 1,
  34858. 1,
  34859. 0,
  34860. 0,
  34861. 0,
  34862. 0,
  34863. 0,
  34864. 0,
  34865. 0,
  34866. 0,
  34867. 0,
  34868. 0,
  34869. 0,
  34870. 0,
  34871. 0,
  34872. 0,
  34873. 0,
  34874. 0,
  34875. 0,
  34876. 0,
  34877. 1,
  34878. 0,
  34879. 0,
  34880. 0,
  34881. 0,
  34882. 2,
  34883. 0,
  34884. 0,
  34885. 2,
  34886. 2,
  34887. 0,
  34888. 0,
  34889. 0,
  34890. 0,
  34891. 0,
  34892. 2,
  34893. 0,
  34894. 0,
  34895. 0,
  34896. 0,
  34897. 0,
  34898. 0,
  34899. 0,
  34900. 0,
  34901. 0,
  34902. 0,
  34903. 0,
  34904. 0,
  34905. 2,
  34906. 0,
  34907. 2,
  34908. 0,
  34909. 0,
  34910. 0,
  34911. 0,
  34912. 0,
  34913. 0,
  34914. 0,
  34915. 0,
  34916. 0,
  34917. 0,
  34918. 0,
  34919. 0,
  34920. 0,
  34921. 0,
  34922. 0,
  34923. 0,
  34924. 0,
  34925. 0,
  34926. 0,
  34927. 0,
  34928. 0,
  34929. 0,
  34930. 0,
  34931. 0,
  34932. 0,
  34933. 0,
  34934. 0,
  34935. 0,
  34936. 2,
  34937. 0,
  34938. 2,
  34939. 0,
  34940. 0,
  34941. 0,
  34942. 0,
  34943. 0,
  34944. 0,
  34945. 0,
  34946. 0,
  34947. 0,
  34948. 0,
  34949. 0,
  34950. 0,
  34951. 0,
  34952. 0,
  34953. 0,
  34954. 0,
  34955. 0,
  34956. 0,
  34957. 0,
  34958. 0,
  34959. 0,
  34960. 0,
  34961. 0,
  34962. 0,
  34963. 0,
  34964. 0,
  34965. 0,
  34966. 0,
  34967. 0,
  34968. 2,
  34969. 0,
  34970. 2,
  34971. 0,
  34972. 0,
  34973. 0,
  34974. 0,
  34975. 0,
  34976. 0,
  34977. 0,
  34978. 0,
  34979. 0,
  34980. 0,
  34981. 0,
  34982. 0,
  34983. 0,
  34984. 0,
  34985. 0,
  34986. 0,
  34987. 0,
  34988. 0,
  34989. 0,
  34990. 0,
  34991. 0,
  34992. 0,
  34993. 0,
  34994. 0,
  34995. 0,
  34996. 0,
  34997. 0,
  34998. 0,
  34999. 0,
  35000. 0,
  35001. 0,
  35002. 0,
  35003. 0,
  35004. 0,
  35005. 0,
  35006. 0,
  35007. 0,
  35008. 0,
  35009. 0,
  35010. 0,
  35011. 0,
  35012. 0,
  35013. 0,
  35014. 0,
  35015. 0,
  35016. 0,
  35017. 0,
  35018. 0,
  35019. 0,
  35020. 0,
  35021. 0,
  35022. 0,
  35023. 0,
  35024. 0,
  35025. 0,
  35026. 0,
  35027. 0,
  35028. 0,
  35029. 0,
  35030. 0,
  35031. 0,
  35032. 0,
  35033. 0,
  35034. 0,
  35035. 0,
  35036. 0,
  35037. 0,
  35038. 0,
  35039. 0,
  35040. 0,
  35041. 0,
  35042. 0,
  35043. 0,
  35044. 0,
  35045. 0,
  35046. 0,
  35047. 0,
  35048. 0,
  35049. 0,
  35050. 0,
  35051. 0,
  35052. 0,
  35053. 0,
  35054. 0,
  35055. 0,
  35056. 0,
  35057. 0,
  35058. 0,
  35059. 0,
  35060. 0,
  35061. 0,
  35062. 0,
  35063. 0,
  35064. 0,
  35065. 0,
  35066. 0,
  35067. 0,
  35068. 0,
  35069. 0,
  35070. 0,
  35071. 0,
  35072. 0,
  35073. 0,
  35074. 0,
  35075. 0,
  35076. 0,
  35077. 0,
  35078. 0,
  35079. 0,
  35080. 0,
  35081. 0,
  35082. 0,
  35083. 0,
  35084. 0,
  35085. 0,
  35086. 0,
  35087. 0,
  35088. 0,
  35089. 0,
  35090. 0,
  35091. 0,
  35092. 0,
  35093. 0,
  35094. 0,
  35095. 0,
  35096. 0,
  35097. 0,
  35098. 0,
  35099. 0,
  35100. 0
  35101. ];
  35102. function toHexDigit(ch) {
  35103. if (ch >= 0x30 && ch <= 0x39) {
  35104. return ch & 0x0F;
  35105. }
  35106. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  35107. return (ch & 0x0F) + 9;
  35108. }
  35109. return -1;
  35110. }
  35111. Lexer.prototype = {
  35112. nextChar: function Lexer_nextChar() {
  35113. return this.currentChar = this.stream.getByte();
  35114. },
  35115. peekChar: function Lexer_peekChar() {
  35116. return this.stream.peekByte();
  35117. },
  35118. getNumber: function Lexer_getNumber() {
  35119. var ch = this.currentChar;
  35120. var eNotation = false;
  35121. var divideBy = 0;
  35122. var sign = 1;
  35123. if (ch === 0x2D) {
  35124. sign = -1;
  35125. ch = this.nextChar();
  35126. if (ch === 0x2D) {
  35127. ch = this.nextChar();
  35128. }
  35129. } else if (ch === 0x2B) {
  35130. ch = this.nextChar();
  35131. }
  35132. if (ch === 0x2E) {
  35133. divideBy = 10;
  35134. ch = this.nextChar();
  35135. }
  35136. if (ch < 0x30 || ch > 0x39) {
  35137. error('Invalid number: ' + String.fromCharCode(ch));
  35138. return 0;
  35139. }
  35140. var baseValue = ch - 0x30;
  35141. var powerValue = 0;
  35142. var powerValueSign = 1;
  35143. while ((ch = this.nextChar()) >= 0) {
  35144. if (0x30 <= ch && ch <= 0x39) {
  35145. var currentDigit = ch - 0x30;
  35146. if (eNotation) {
  35147. powerValue = powerValue * 10 + currentDigit;
  35148. } else {
  35149. if (divideBy !== 0) {
  35150. divideBy *= 10;
  35151. }
  35152. baseValue = baseValue * 10 + currentDigit;
  35153. }
  35154. } else if (ch === 0x2E) {
  35155. if (divideBy === 0) {
  35156. divideBy = 1;
  35157. } else {
  35158. break;
  35159. }
  35160. } else if (ch === 0x2D) {
  35161. warn('Badly formatted number');
  35162. } else if (ch === 0x45 || ch === 0x65) {
  35163. ch = this.peekChar();
  35164. if (ch === 0x2B || ch === 0x2D) {
  35165. powerValueSign = ch === 0x2D ? -1 : 1;
  35166. this.nextChar();
  35167. } else if (ch < 0x30 || ch > 0x39) {
  35168. break;
  35169. }
  35170. eNotation = true;
  35171. } else {
  35172. break;
  35173. }
  35174. }
  35175. if (divideBy !== 0) {
  35176. baseValue /= divideBy;
  35177. }
  35178. if (eNotation) {
  35179. baseValue *= Math.pow(10, powerValueSign * powerValue);
  35180. }
  35181. return sign * baseValue;
  35182. },
  35183. getString: function Lexer_getString() {
  35184. var numParen = 1;
  35185. var done = false;
  35186. var strBuf = this.strBuf;
  35187. strBuf.length = 0;
  35188. var ch = this.nextChar();
  35189. while (true) {
  35190. var charBuffered = false;
  35191. switch (ch | 0) {
  35192. case -1:
  35193. warn('Unterminated string');
  35194. done = true;
  35195. break;
  35196. case 0x28:
  35197. ++numParen;
  35198. strBuf.push('(');
  35199. break;
  35200. case 0x29:
  35201. if (--numParen === 0) {
  35202. this.nextChar();
  35203. done = true;
  35204. } else {
  35205. strBuf.push(')');
  35206. }
  35207. break;
  35208. case 0x5C:
  35209. ch = this.nextChar();
  35210. switch (ch) {
  35211. case -1:
  35212. warn('Unterminated string');
  35213. done = true;
  35214. break;
  35215. case 0x6E:
  35216. strBuf.push('\n');
  35217. break;
  35218. case 0x72:
  35219. strBuf.push('\r');
  35220. break;
  35221. case 0x74:
  35222. strBuf.push('\t');
  35223. break;
  35224. case 0x62:
  35225. strBuf.push('\b');
  35226. break;
  35227. case 0x66:
  35228. strBuf.push('\f');
  35229. break;
  35230. case 0x5C:
  35231. case 0x28:
  35232. case 0x29:
  35233. strBuf.push(String.fromCharCode(ch));
  35234. break;
  35235. case 0x30:
  35236. case 0x31:
  35237. case 0x32:
  35238. case 0x33:
  35239. case 0x34:
  35240. case 0x35:
  35241. case 0x36:
  35242. case 0x37:
  35243. var x = ch & 0x0F;
  35244. ch = this.nextChar();
  35245. charBuffered = true;
  35246. if (ch >= 0x30 && ch <= 0x37) {
  35247. x = (x << 3) + (ch & 0x0F);
  35248. ch = this.nextChar();
  35249. if (ch >= 0x30 && ch <= 0x37) {
  35250. charBuffered = false;
  35251. x = (x << 3) + (ch & 0x0F);
  35252. }
  35253. }
  35254. strBuf.push(String.fromCharCode(x));
  35255. break;
  35256. case 0x0D:
  35257. if (this.peekChar() === 0x0A) {
  35258. this.nextChar();
  35259. }
  35260. break;
  35261. case 0x0A:
  35262. break;
  35263. default:
  35264. strBuf.push(String.fromCharCode(ch));
  35265. break;
  35266. }
  35267. break;
  35268. default:
  35269. strBuf.push(String.fromCharCode(ch));
  35270. break;
  35271. }
  35272. if (done) {
  35273. break;
  35274. }
  35275. if (!charBuffered) {
  35276. ch = this.nextChar();
  35277. }
  35278. }
  35279. return strBuf.join('');
  35280. },
  35281. getName: function Lexer_getName() {
  35282. var ch, previousCh;
  35283. var strBuf = this.strBuf;
  35284. strBuf.length = 0;
  35285. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  35286. if (ch === 0x23) {
  35287. ch = this.nextChar();
  35288. if (specialChars[ch]) {
  35289. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  35290. strBuf.push('#');
  35291. break;
  35292. }
  35293. var x = toHexDigit(ch);
  35294. if (x !== -1) {
  35295. previousCh = ch;
  35296. ch = this.nextChar();
  35297. var x2 = toHexDigit(ch);
  35298. if (x2 === -1) {
  35299. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  35300. strBuf.push('#', String.fromCharCode(previousCh));
  35301. if (specialChars[ch]) {
  35302. break;
  35303. }
  35304. strBuf.push(String.fromCharCode(ch));
  35305. continue;
  35306. }
  35307. strBuf.push(String.fromCharCode(x << 4 | x2));
  35308. } else {
  35309. strBuf.push('#', String.fromCharCode(ch));
  35310. }
  35311. } else {
  35312. strBuf.push(String.fromCharCode(ch));
  35313. }
  35314. }
  35315. if (strBuf.length > 127) {
  35316. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  35317. }
  35318. return Name.get(strBuf.join(''));
  35319. },
  35320. getHexString: function Lexer_getHexString() {
  35321. var strBuf = this.strBuf;
  35322. strBuf.length = 0;
  35323. var ch = this.currentChar;
  35324. var isFirstHex = true;
  35325. var firstDigit;
  35326. var secondDigit;
  35327. while (true) {
  35328. if (ch < 0) {
  35329. warn('Unterminated hex string');
  35330. break;
  35331. } else if (ch === 0x3E) {
  35332. this.nextChar();
  35333. break;
  35334. } else if (specialChars[ch] === 1) {
  35335. ch = this.nextChar();
  35336. continue;
  35337. } else {
  35338. if (isFirstHex) {
  35339. firstDigit = toHexDigit(ch);
  35340. if (firstDigit === -1) {
  35341. warn('Ignoring invalid character "' + ch + '" in hex string');
  35342. ch = this.nextChar();
  35343. continue;
  35344. }
  35345. } else {
  35346. secondDigit = toHexDigit(ch);
  35347. if (secondDigit === -1) {
  35348. warn('Ignoring invalid character "' + ch + '" in hex string');
  35349. ch = this.nextChar();
  35350. continue;
  35351. }
  35352. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  35353. }
  35354. isFirstHex = !isFirstHex;
  35355. ch = this.nextChar();
  35356. }
  35357. }
  35358. return strBuf.join('');
  35359. },
  35360. getObj: function Lexer_getObj() {
  35361. var comment = false;
  35362. var ch = this.currentChar;
  35363. while (true) {
  35364. if (ch < 0) {
  35365. return EOF;
  35366. }
  35367. if (comment) {
  35368. if (ch === 0x0A || ch === 0x0D) {
  35369. comment = false;
  35370. }
  35371. } else if (ch === 0x25) {
  35372. comment = true;
  35373. } else if (specialChars[ch] !== 1) {
  35374. break;
  35375. }
  35376. ch = this.nextChar();
  35377. }
  35378. switch (ch | 0) {
  35379. case 0x30:
  35380. case 0x31:
  35381. case 0x32:
  35382. case 0x33:
  35383. case 0x34:
  35384. case 0x35:
  35385. case 0x36:
  35386. case 0x37:
  35387. case 0x38:
  35388. case 0x39:
  35389. case 0x2B:
  35390. case 0x2D:
  35391. case 0x2E:
  35392. return this.getNumber();
  35393. case 0x28:
  35394. return this.getString();
  35395. case 0x2F:
  35396. return this.getName();
  35397. case 0x5B:
  35398. this.nextChar();
  35399. return Cmd.get('[');
  35400. case 0x5D:
  35401. this.nextChar();
  35402. return Cmd.get(']');
  35403. case 0x3C:
  35404. ch = this.nextChar();
  35405. if (ch === 0x3C) {
  35406. this.nextChar();
  35407. return Cmd.get('<<');
  35408. }
  35409. return this.getHexString();
  35410. case 0x3E:
  35411. ch = this.nextChar();
  35412. if (ch === 0x3E) {
  35413. this.nextChar();
  35414. return Cmd.get('>>');
  35415. }
  35416. return Cmd.get('>');
  35417. case 0x7B:
  35418. this.nextChar();
  35419. return Cmd.get('{');
  35420. case 0x7D:
  35421. this.nextChar();
  35422. return Cmd.get('}');
  35423. case 0x29:
  35424. error('Illegal character: ' + ch);
  35425. break;
  35426. }
  35427. var str = String.fromCharCode(ch);
  35428. var knownCommands = this.knownCommands;
  35429. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  35430. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  35431. var possibleCommand = str + String.fromCharCode(ch);
  35432. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  35433. break;
  35434. }
  35435. if (str.length === 128) {
  35436. error('Command token too long: ' + str.length);
  35437. }
  35438. str = possibleCommand;
  35439. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  35440. }
  35441. if (str === 'true') {
  35442. return true;
  35443. }
  35444. if (str === 'false') {
  35445. return false;
  35446. }
  35447. if (str === 'null') {
  35448. return null;
  35449. }
  35450. return Cmd.get(str);
  35451. },
  35452. skipToNextLine: function Lexer_skipToNextLine() {
  35453. var ch = this.currentChar;
  35454. while (ch >= 0) {
  35455. if (ch === 0x0D) {
  35456. ch = this.nextChar();
  35457. if (ch === 0x0A) {
  35458. this.nextChar();
  35459. }
  35460. break;
  35461. } else if (ch === 0x0A) {
  35462. this.nextChar();
  35463. break;
  35464. }
  35465. ch = this.nextChar();
  35466. }
  35467. }
  35468. };
  35469. return Lexer;
  35470. }();
  35471. var Linearization = {
  35472. create: function LinearizationCreate(stream) {
  35473. function getInt(name, allowZeroValue) {
  35474. var obj = linDict.get(name);
  35475. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  35476. return obj;
  35477. }
  35478. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  35479. }
  35480. function getHints() {
  35481. var hints = linDict.get('H'), hintsLength, item;
  35482. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  35483. for (var index = 0; index < hintsLength; index++) {
  35484. if (!(isInt(item = hints[index]) && item > 0)) {
  35485. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  35486. }
  35487. }
  35488. return hints;
  35489. }
  35490. throw new Error('Hint array in the linearization dictionary is invalid.');
  35491. }
  35492. var parser = new Parser(new Lexer(stream), false, null);
  35493. var obj1 = parser.getObj();
  35494. var obj2 = parser.getObj();
  35495. var obj3 = parser.getObj();
  35496. var linDict = parser.getObj();
  35497. var obj, length;
  35498. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  35499. return null;
  35500. } else if ((length = getInt('L')) !== stream.length) {
  35501. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  35502. }
  35503. return {
  35504. length: length,
  35505. hints: getHints(),
  35506. objectNumberFirst: getInt('O'),
  35507. endFirst: getInt('E'),
  35508. numPages: getInt('N'),
  35509. mainXRefEntriesOffset: getInt('T'),
  35510. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  35511. };
  35512. }
  35513. };
  35514. exports.EOF = EOF;
  35515. exports.Lexer = Lexer;
  35516. exports.Linearization = Linearization;
  35517. exports.Parser = Parser;
  35518. exports.isEOF = isEOF;
  35519. }));
  35520. (function (root, factory) {
  35521. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  35522. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  35523. var warn = sharedUtil.warn;
  35524. var isSpace = sharedUtil.isSpace;
  35525. var Stream = coreStream.Stream;
  35526. var getEncoding = coreEncodings.getEncoding;
  35527. var HINTING_ENABLED = false;
  35528. var Type1CharString = function Type1CharStringClosure() {
  35529. var COMMAND_MAP = {
  35530. 'hstem': [1],
  35531. 'vstem': [3],
  35532. 'vmoveto': [4],
  35533. 'rlineto': [5],
  35534. 'hlineto': [6],
  35535. 'vlineto': [7],
  35536. 'rrcurveto': [8],
  35537. 'callsubr': [10],
  35538. 'flex': [
  35539. 12,
  35540. 35
  35541. ],
  35542. 'drop': [
  35543. 12,
  35544. 18
  35545. ],
  35546. 'endchar': [14],
  35547. 'rmoveto': [21],
  35548. 'hmoveto': [22],
  35549. 'vhcurveto': [30],
  35550. 'hvcurveto': [31]
  35551. };
  35552. function Type1CharString() {
  35553. this.width = 0;
  35554. this.lsb = 0;
  35555. this.flexing = false;
  35556. this.output = [];
  35557. this.stack = [];
  35558. }
  35559. Type1CharString.prototype = {
  35560. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  35561. var count = encoded.length;
  35562. var error = false;
  35563. var wx, sbx, subrNumber;
  35564. for (var i = 0; i < count; i++) {
  35565. var value = encoded[i];
  35566. if (value < 32) {
  35567. if (value === 12) {
  35568. value = (value << 8) + encoded[++i];
  35569. }
  35570. switch (value) {
  35571. case 1:
  35572. if (!HINTING_ENABLED) {
  35573. this.stack = [];
  35574. break;
  35575. }
  35576. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35577. break;
  35578. case 3:
  35579. if (!HINTING_ENABLED) {
  35580. this.stack = [];
  35581. break;
  35582. }
  35583. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35584. break;
  35585. case 4:
  35586. if (this.flexing) {
  35587. if (this.stack.length < 1) {
  35588. error = true;
  35589. break;
  35590. }
  35591. var dy = this.stack.pop();
  35592. this.stack.push(0, dy);
  35593. break;
  35594. }
  35595. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  35596. break;
  35597. case 5:
  35598. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  35599. break;
  35600. case 6:
  35601. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  35602. break;
  35603. case 7:
  35604. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  35605. break;
  35606. case 8:
  35607. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  35608. break;
  35609. case 9:
  35610. this.stack = [];
  35611. break;
  35612. case 10:
  35613. if (this.stack.length < 1) {
  35614. error = true;
  35615. break;
  35616. }
  35617. subrNumber = this.stack.pop();
  35618. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  35619. break;
  35620. case 11:
  35621. return error;
  35622. case 13:
  35623. if (this.stack.length < 2) {
  35624. error = true;
  35625. break;
  35626. }
  35627. wx = this.stack.pop();
  35628. sbx = this.stack.pop();
  35629. this.lsb = sbx;
  35630. this.width = wx;
  35631. this.stack.push(wx, sbx);
  35632. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  35633. break;
  35634. case 14:
  35635. this.output.push(COMMAND_MAP.endchar[0]);
  35636. break;
  35637. case 21:
  35638. if (this.flexing) {
  35639. break;
  35640. }
  35641. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  35642. break;
  35643. case 22:
  35644. if (this.flexing) {
  35645. this.stack.push(0);
  35646. break;
  35647. }
  35648. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  35649. break;
  35650. case 30:
  35651. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  35652. break;
  35653. case 31:
  35654. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  35655. break;
  35656. case (12 << 8) + 0:
  35657. this.stack = [];
  35658. break;
  35659. case (12 << 8) + 1:
  35660. if (!HINTING_ENABLED) {
  35661. this.stack = [];
  35662. break;
  35663. }
  35664. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35665. break;
  35666. case (12 << 8) + 2:
  35667. if (!HINTING_ENABLED) {
  35668. this.stack = [];
  35669. break;
  35670. }
  35671. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35672. break;
  35673. case (12 << 8) + 6:
  35674. if (seacAnalysisEnabled) {
  35675. this.seac = this.stack.splice(-4, 4);
  35676. error = this.executeCommand(0, COMMAND_MAP.endchar);
  35677. } else {
  35678. error = this.executeCommand(4, COMMAND_MAP.endchar);
  35679. }
  35680. break;
  35681. case (12 << 8) + 7:
  35682. if (this.stack.length < 4) {
  35683. error = true;
  35684. break;
  35685. }
  35686. var wy = this.stack.pop();
  35687. wx = this.stack.pop();
  35688. var sby = this.stack.pop();
  35689. sbx = this.stack.pop();
  35690. this.lsb = sbx;
  35691. this.width = wx;
  35692. this.stack.push(wx, sbx, sby);
  35693. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  35694. break;
  35695. case (12 << 8) + 12:
  35696. if (this.stack.length < 2) {
  35697. error = true;
  35698. break;
  35699. }
  35700. var num2 = this.stack.pop();
  35701. var num1 = this.stack.pop();
  35702. this.stack.push(num1 / num2);
  35703. break;
  35704. case (12 << 8) + 16:
  35705. if (this.stack.length < 2) {
  35706. error = true;
  35707. break;
  35708. }
  35709. subrNumber = this.stack.pop();
  35710. var numArgs = this.stack.pop();
  35711. if (subrNumber === 0 && numArgs === 3) {
  35712. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  35713. 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]);
  35714. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  35715. this.flexing = false;
  35716. this.stack.push(flexArgs[15], flexArgs[16]);
  35717. } else if (subrNumber === 1 && numArgs === 0) {
  35718. this.flexing = true;
  35719. }
  35720. break;
  35721. case (12 << 8) + 17:
  35722. break;
  35723. case (12 << 8) + 33:
  35724. this.stack = [];
  35725. break;
  35726. default:
  35727. warn('Unknown type 1 charstring command of "' + value + '"');
  35728. break;
  35729. }
  35730. if (error) {
  35731. break;
  35732. }
  35733. continue;
  35734. } else if (value <= 246) {
  35735. value = value - 139;
  35736. } else if (value <= 250) {
  35737. value = (value - 247) * 256 + encoded[++i] + 108;
  35738. } else if (value <= 254) {
  35739. value = -((value - 251) * 256) - encoded[++i] - 108;
  35740. } else {
  35741. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  35742. }
  35743. this.stack.push(value);
  35744. }
  35745. return error;
  35746. },
  35747. executeCommand: function (howManyArgs, command, keepStack) {
  35748. var stackLength = this.stack.length;
  35749. if (howManyArgs > stackLength) {
  35750. return true;
  35751. }
  35752. var start = stackLength - howManyArgs;
  35753. for (var i = start; i < stackLength; i++) {
  35754. var value = this.stack[i];
  35755. if (value === (value | 0)) {
  35756. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  35757. } else {
  35758. value = 65536 * value | 0;
  35759. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  35760. }
  35761. }
  35762. this.output.push.apply(this.output, command);
  35763. if (keepStack) {
  35764. this.stack.splice(start, howManyArgs);
  35765. } else {
  35766. this.stack.length = 0;
  35767. }
  35768. return false;
  35769. }
  35770. };
  35771. return Type1CharString;
  35772. }();
  35773. var Type1Parser = function Type1ParserClosure() {
  35774. var EEXEC_ENCRYPT_KEY = 55665;
  35775. var CHAR_STRS_ENCRYPT_KEY = 4330;
  35776. function isHexDigit(code) {
  35777. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  35778. }
  35779. function decrypt(data, key, discardNumber) {
  35780. if (discardNumber >= data.length) {
  35781. return new Uint8Array(0);
  35782. }
  35783. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  35784. for (i = 0; i < discardNumber; i++) {
  35785. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  35786. }
  35787. var count = data.length - discardNumber;
  35788. var decrypted = new Uint8Array(count);
  35789. for (i = discardNumber, j = 0; j < count; i++, j++) {
  35790. var value = data[i];
  35791. decrypted[j] = value ^ r >> 8;
  35792. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35793. }
  35794. return decrypted;
  35795. }
  35796. function decryptAscii(data, key, discardNumber) {
  35797. var r = key | 0, c1 = 52845, c2 = 22719;
  35798. var count = data.length, maybeLength = count >>> 1;
  35799. var decrypted = new Uint8Array(maybeLength);
  35800. var i, j;
  35801. for (i = 0, j = 0; i < count; i++) {
  35802. var digit1 = data[i];
  35803. if (!isHexDigit(digit1)) {
  35804. continue;
  35805. }
  35806. i++;
  35807. var digit2;
  35808. while (i < count && !isHexDigit(digit2 = data[i])) {
  35809. i++;
  35810. }
  35811. if (i < count) {
  35812. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  35813. decrypted[j++] = value ^ r >> 8;
  35814. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35815. }
  35816. }
  35817. return Array.prototype.slice.call(decrypted, discardNumber, j);
  35818. }
  35819. function isSpecial(c) {
  35820. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  35821. }
  35822. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  35823. if (encrypted) {
  35824. var data = stream.getBytes();
  35825. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  35826. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  35827. }
  35828. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  35829. this.stream = stream;
  35830. this.nextChar();
  35831. }
  35832. Type1Parser.prototype = {
  35833. readNumberArray: function Type1Parser_readNumberArray() {
  35834. this.getToken();
  35835. var array = [];
  35836. while (true) {
  35837. var token = this.getToken();
  35838. if (token === null || token === ']' || token === '}') {
  35839. break;
  35840. }
  35841. array.push(parseFloat(token || 0));
  35842. }
  35843. return array;
  35844. },
  35845. readNumber: function Type1Parser_readNumber() {
  35846. var token = this.getToken();
  35847. return parseFloat(token || 0);
  35848. },
  35849. readInt: function Type1Parser_readInt() {
  35850. var token = this.getToken();
  35851. return parseInt(token || 0, 10) | 0;
  35852. },
  35853. readBoolean: function Type1Parser_readBoolean() {
  35854. var token = this.getToken();
  35855. return token === 'true' ? 1 : 0;
  35856. },
  35857. nextChar: function Type1_nextChar() {
  35858. return this.currentChar = this.stream.getByte();
  35859. },
  35860. getToken: function Type1Parser_getToken() {
  35861. var comment = false;
  35862. var ch = this.currentChar;
  35863. while (true) {
  35864. if (ch === -1) {
  35865. return null;
  35866. }
  35867. if (comment) {
  35868. if (ch === 0x0A || ch === 0x0D) {
  35869. comment = false;
  35870. }
  35871. } else if (ch === 0x25) {
  35872. comment = true;
  35873. } else if (!isSpace(ch)) {
  35874. break;
  35875. }
  35876. ch = this.nextChar();
  35877. }
  35878. if (isSpecial(ch)) {
  35879. this.nextChar();
  35880. return String.fromCharCode(ch);
  35881. }
  35882. var token = '';
  35883. do {
  35884. token += String.fromCharCode(ch);
  35885. ch = this.nextChar();
  35886. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  35887. return token;
  35888. },
  35889. extractFontProgram: function Type1Parser_extractFontProgram() {
  35890. var stream = this.stream;
  35891. var subrs = [], charstrings = [];
  35892. var privateData = Object.create(null);
  35893. privateData['lenIV'] = 4;
  35894. var program = {
  35895. subrs: [],
  35896. charstrings: [],
  35897. properties: { 'privateData': privateData }
  35898. };
  35899. var token, length, data, lenIV, encoded;
  35900. while ((token = this.getToken()) !== null) {
  35901. if (token !== '/') {
  35902. continue;
  35903. }
  35904. token = this.getToken();
  35905. switch (token) {
  35906. case 'CharStrings':
  35907. this.getToken();
  35908. this.getToken();
  35909. this.getToken();
  35910. this.getToken();
  35911. while (true) {
  35912. token = this.getToken();
  35913. if (token === null || token === 'end') {
  35914. break;
  35915. }
  35916. if (token !== '/') {
  35917. continue;
  35918. }
  35919. var glyph = this.getToken();
  35920. length = this.readInt();
  35921. this.getToken();
  35922. data = stream.makeSubStream(stream.pos, length);
  35923. lenIV = program.properties.privateData['lenIV'];
  35924. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  35925. stream.skip(length);
  35926. this.nextChar();
  35927. token = this.getToken();
  35928. if (token === 'noaccess') {
  35929. this.getToken();
  35930. }
  35931. charstrings.push({
  35932. glyph: glyph,
  35933. encoded: encoded
  35934. });
  35935. }
  35936. break;
  35937. case 'Subrs':
  35938. var num = this.readInt();
  35939. this.getToken();
  35940. while ((token = this.getToken()) === 'dup') {
  35941. var index = this.readInt();
  35942. length = this.readInt();
  35943. this.getToken();
  35944. data = stream.makeSubStream(stream.pos, length);
  35945. lenIV = program.properties.privateData['lenIV'];
  35946. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  35947. stream.skip(length);
  35948. this.nextChar();
  35949. token = this.getToken();
  35950. if (token === 'noaccess') {
  35951. this.getToken();
  35952. }
  35953. subrs[index] = encoded;
  35954. }
  35955. break;
  35956. case 'BlueValues':
  35957. case 'OtherBlues':
  35958. case 'FamilyBlues':
  35959. case 'FamilyOtherBlues':
  35960. var blueArray = this.readNumberArray();
  35961. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  35962. program.properties.privateData[token] = blueArray;
  35963. }
  35964. break;
  35965. case 'StemSnapH':
  35966. case 'StemSnapV':
  35967. program.properties.privateData[token] = this.readNumberArray();
  35968. break;
  35969. case 'StdHW':
  35970. case 'StdVW':
  35971. program.properties.privateData[token] = this.readNumberArray()[0];
  35972. break;
  35973. case 'BlueShift':
  35974. case 'lenIV':
  35975. case 'BlueFuzz':
  35976. case 'BlueScale':
  35977. case 'LanguageGroup':
  35978. case 'ExpansionFactor':
  35979. program.properties.privateData[token] = this.readNumber();
  35980. break;
  35981. case 'ForceBold':
  35982. program.properties.privateData[token] = this.readBoolean();
  35983. break;
  35984. }
  35985. }
  35986. for (var i = 0; i < charstrings.length; i++) {
  35987. glyph = charstrings[i].glyph;
  35988. encoded = charstrings[i].encoded;
  35989. var charString = new Type1CharString();
  35990. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  35991. var output = charString.output;
  35992. if (error) {
  35993. output = [14];
  35994. }
  35995. program.charstrings.push({
  35996. glyphName: glyph,
  35997. charstring: output,
  35998. width: charString.width,
  35999. lsb: charString.lsb,
  36000. seac: charString.seac
  36001. });
  36002. }
  36003. return program;
  36004. },
  36005. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  36006. var token;
  36007. while ((token = this.getToken()) !== null) {
  36008. if (token !== '/') {
  36009. continue;
  36010. }
  36011. token = this.getToken();
  36012. switch (token) {
  36013. case 'FontMatrix':
  36014. var matrix = this.readNumberArray();
  36015. properties.fontMatrix = matrix;
  36016. break;
  36017. case 'Encoding':
  36018. var encodingArg = this.getToken();
  36019. var encoding;
  36020. if (!/^\d+$/.test(encodingArg)) {
  36021. encoding = getEncoding(encodingArg);
  36022. } else {
  36023. encoding = [];
  36024. var size = parseInt(encodingArg, 10) | 0;
  36025. this.getToken();
  36026. for (var j = 0; j < size; j++) {
  36027. token = this.getToken();
  36028. while (token !== 'dup' && token !== 'def') {
  36029. token = this.getToken();
  36030. if (token === null) {
  36031. return;
  36032. }
  36033. }
  36034. if (token === 'def') {
  36035. break;
  36036. }
  36037. var index = this.readInt();
  36038. this.getToken();
  36039. var glyph = this.getToken();
  36040. encoding[index] = glyph;
  36041. this.getToken();
  36042. }
  36043. }
  36044. properties.builtInEncoding = encoding;
  36045. break;
  36046. case 'FontBBox':
  36047. var fontBBox = this.readNumberArray();
  36048. properties.ascent = fontBBox[3];
  36049. properties.descent = fontBBox[1];
  36050. properties.ascentScaled = true;
  36051. break;
  36052. }
  36053. }
  36054. }
  36055. };
  36056. return Type1Parser;
  36057. }();
  36058. exports.Type1Parser = Type1Parser;
  36059. }));
  36060. (function (root, factory) {
  36061. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  36062. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  36063. var Util = sharedUtil.Util;
  36064. var assert = sharedUtil.assert;
  36065. var warn = sharedUtil.warn;
  36066. var error = sharedUtil.error;
  36067. var isInt = sharedUtil.isInt;
  36068. var isString = sharedUtil.isString;
  36069. var MissingDataException = sharedUtil.MissingDataException;
  36070. var isName = corePrimitives.isName;
  36071. var isCmd = corePrimitives.isCmd;
  36072. var isStream = corePrimitives.isStream;
  36073. var StringStream = coreStream.StringStream;
  36074. var Lexer = coreParser.Lexer;
  36075. var isEOF = coreParser.isEOF;
  36076. var BUILT_IN_CMAPS = [
  36077. 'Adobe-GB1-UCS2',
  36078. 'Adobe-CNS1-UCS2',
  36079. 'Adobe-Japan1-UCS2',
  36080. 'Adobe-Korea1-UCS2',
  36081. '78-EUC-H',
  36082. '78-EUC-V',
  36083. '78-H',
  36084. '78-RKSJ-H',
  36085. '78-RKSJ-V',
  36086. '78-V',
  36087. '78ms-RKSJ-H',
  36088. '78ms-RKSJ-V',
  36089. '83pv-RKSJ-H',
  36090. '90ms-RKSJ-H',
  36091. '90ms-RKSJ-V',
  36092. '90msp-RKSJ-H',
  36093. '90msp-RKSJ-V',
  36094. '90pv-RKSJ-H',
  36095. '90pv-RKSJ-V',
  36096. 'Add-H',
  36097. 'Add-RKSJ-H',
  36098. 'Add-RKSJ-V',
  36099. 'Add-V',
  36100. 'Adobe-CNS1-0',
  36101. 'Adobe-CNS1-1',
  36102. 'Adobe-CNS1-2',
  36103. 'Adobe-CNS1-3',
  36104. 'Adobe-CNS1-4',
  36105. 'Adobe-CNS1-5',
  36106. 'Adobe-CNS1-6',
  36107. 'Adobe-GB1-0',
  36108. 'Adobe-GB1-1',
  36109. 'Adobe-GB1-2',
  36110. 'Adobe-GB1-3',
  36111. 'Adobe-GB1-4',
  36112. 'Adobe-GB1-5',
  36113. 'Adobe-Japan1-0',
  36114. 'Adobe-Japan1-1',
  36115. 'Adobe-Japan1-2',
  36116. 'Adobe-Japan1-3',
  36117. 'Adobe-Japan1-4',
  36118. 'Adobe-Japan1-5',
  36119. 'Adobe-Japan1-6',
  36120. 'Adobe-Korea1-0',
  36121. 'Adobe-Korea1-1',
  36122. 'Adobe-Korea1-2',
  36123. 'B5-H',
  36124. 'B5-V',
  36125. 'B5pc-H',
  36126. 'B5pc-V',
  36127. 'CNS-EUC-H',
  36128. 'CNS-EUC-V',
  36129. 'CNS1-H',
  36130. 'CNS1-V',
  36131. 'CNS2-H',
  36132. 'CNS2-V',
  36133. 'ETHK-B5-H',
  36134. 'ETHK-B5-V',
  36135. 'ETen-B5-H',
  36136. 'ETen-B5-V',
  36137. 'ETenms-B5-H',
  36138. 'ETenms-B5-V',
  36139. 'EUC-H',
  36140. 'EUC-V',
  36141. 'Ext-H',
  36142. 'Ext-RKSJ-H',
  36143. 'Ext-RKSJ-V',
  36144. 'Ext-V',
  36145. 'GB-EUC-H',
  36146. 'GB-EUC-V',
  36147. 'GB-H',
  36148. 'GB-V',
  36149. 'GBK-EUC-H',
  36150. 'GBK-EUC-V',
  36151. 'GBK2K-H',
  36152. 'GBK2K-V',
  36153. 'GBKp-EUC-H',
  36154. 'GBKp-EUC-V',
  36155. 'GBT-EUC-H',
  36156. 'GBT-EUC-V',
  36157. 'GBT-H',
  36158. 'GBT-V',
  36159. 'GBTpc-EUC-H',
  36160. 'GBTpc-EUC-V',
  36161. 'GBpc-EUC-H',
  36162. 'GBpc-EUC-V',
  36163. 'H',
  36164. 'HKdla-B5-H',
  36165. 'HKdla-B5-V',
  36166. 'HKdlb-B5-H',
  36167. 'HKdlb-B5-V',
  36168. 'HKgccs-B5-H',
  36169. 'HKgccs-B5-V',
  36170. 'HKm314-B5-H',
  36171. 'HKm314-B5-V',
  36172. 'HKm471-B5-H',
  36173. 'HKm471-B5-V',
  36174. 'HKscs-B5-H',
  36175. 'HKscs-B5-V',
  36176. 'Hankaku',
  36177. 'Hiragana',
  36178. 'KSC-EUC-H',
  36179. 'KSC-EUC-V',
  36180. 'KSC-H',
  36181. 'KSC-Johab-H',
  36182. 'KSC-Johab-V',
  36183. 'KSC-V',
  36184. 'KSCms-UHC-H',
  36185. 'KSCms-UHC-HW-H',
  36186. 'KSCms-UHC-HW-V',
  36187. 'KSCms-UHC-V',
  36188. 'KSCpc-EUC-H',
  36189. 'KSCpc-EUC-V',
  36190. 'Katakana',
  36191. 'NWP-H',
  36192. 'NWP-V',
  36193. 'RKSJ-H',
  36194. 'RKSJ-V',
  36195. 'Roman',
  36196. 'UniCNS-UCS2-H',
  36197. 'UniCNS-UCS2-V',
  36198. 'UniCNS-UTF16-H',
  36199. 'UniCNS-UTF16-V',
  36200. 'UniCNS-UTF32-H',
  36201. 'UniCNS-UTF32-V',
  36202. 'UniCNS-UTF8-H',
  36203. 'UniCNS-UTF8-V',
  36204. 'UniGB-UCS2-H',
  36205. 'UniGB-UCS2-V',
  36206. 'UniGB-UTF16-H',
  36207. 'UniGB-UTF16-V',
  36208. 'UniGB-UTF32-H',
  36209. 'UniGB-UTF32-V',
  36210. 'UniGB-UTF8-H',
  36211. 'UniGB-UTF8-V',
  36212. 'UniJIS-UCS2-H',
  36213. 'UniJIS-UCS2-HW-H',
  36214. 'UniJIS-UCS2-HW-V',
  36215. 'UniJIS-UCS2-V',
  36216. 'UniJIS-UTF16-H',
  36217. 'UniJIS-UTF16-V',
  36218. 'UniJIS-UTF32-H',
  36219. 'UniJIS-UTF32-V',
  36220. 'UniJIS-UTF8-H',
  36221. 'UniJIS-UTF8-V',
  36222. 'UniJIS2004-UTF16-H',
  36223. 'UniJIS2004-UTF16-V',
  36224. 'UniJIS2004-UTF32-H',
  36225. 'UniJIS2004-UTF32-V',
  36226. 'UniJIS2004-UTF8-H',
  36227. 'UniJIS2004-UTF8-V',
  36228. 'UniJISPro-UCS2-HW-V',
  36229. 'UniJISPro-UCS2-V',
  36230. 'UniJISPro-UTF8-V',
  36231. 'UniJISX0213-UTF32-H',
  36232. 'UniJISX0213-UTF32-V',
  36233. 'UniJISX02132004-UTF32-H',
  36234. 'UniJISX02132004-UTF32-V',
  36235. 'UniKS-UCS2-H',
  36236. 'UniKS-UCS2-V',
  36237. 'UniKS-UTF16-H',
  36238. 'UniKS-UTF16-V',
  36239. 'UniKS-UTF32-H',
  36240. 'UniKS-UTF32-V',
  36241. 'UniKS-UTF8-H',
  36242. 'UniKS-UTF8-V',
  36243. 'V',
  36244. 'WP-Symbol'
  36245. ];
  36246. var CMap = function CMapClosure() {
  36247. function CMap(builtInCMap) {
  36248. this.codespaceRanges = [
  36249. [],
  36250. [],
  36251. [],
  36252. []
  36253. ];
  36254. this.numCodespaceRanges = 0;
  36255. this._map = [];
  36256. this.name = '';
  36257. this.vertical = false;
  36258. this.useCMap = null;
  36259. this.builtInCMap = builtInCMap;
  36260. }
  36261. CMap.prototype = {
  36262. addCodespaceRange: function (n, low, high) {
  36263. this.codespaceRanges[n - 1].push(low, high);
  36264. this.numCodespaceRanges++;
  36265. },
  36266. mapCidRange: function (low, high, dstLow) {
  36267. while (low <= high) {
  36268. this._map[low++] = dstLow++;
  36269. }
  36270. },
  36271. mapBfRange: function (low, high, dstLow) {
  36272. var lastByte = dstLow.length - 1;
  36273. while (low <= high) {
  36274. this._map[low++] = dstLow;
  36275. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  36276. }
  36277. },
  36278. mapBfRangeToArray: function (low, high, array) {
  36279. var i = 0, ii = array.length;
  36280. while (low <= high && i < ii) {
  36281. this._map[low] = array[i++];
  36282. ++low;
  36283. }
  36284. },
  36285. mapOne: function (src, dst) {
  36286. this._map[src] = dst;
  36287. },
  36288. lookup: function (code) {
  36289. return this._map[code];
  36290. },
  36291. contains: function (code) {
  36292. return this._map[code] !== undefined;
  36293. },
  36294. forEach: function (callback) {
  36295. var map = this._map;
  36296. var length = map.length;
  36297. var i;
  36298. if (length <= 0x10000) {
  36299. for (i = 0; i < length; i++) {
  36300. if (map[i] !== undefined) {
  36301. callback(i, map[i]);
  36302. }
  36303. }
  36304. } else {
  36305. for (i in this._map) {
  36306. callback(i, map[i]);
  36307. }
  36308. }
  36309. },
  36310. charCodeOf: function (value) {
  36311. return this._map.indexOf(value);
  36312. },
  36313. getMap: function () {
  36314. return this._map;
  36315. },
  36316. readCharCode: function (str, offset, out) {
  36317. var c = 0;
  36318. var codespaceRanges = this.codespaceRanges;
  36319. var codespaceRangesLen = this.codespaceRanges.length;
  36320. for (var n = 0; n < codespaceRangesLen; n++) {
  36321. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  36322. var codespaceRange = codespaceRanges[n];
  36323. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  36324. var low = codespaceRange[k++];
  36325. var high = codespaceRange[k++];
  36326. if (c >= low && c <= high) {
  36327. out.charcode = c;
  36328. out.length = n + 1;
  36329. return;
  36330. }
  36331. }
  36332. }
  36333. out.charcode = 0;
  36334. out.length = 1;
  36335. },
  36336. get length() {
  36337. return this._map.length;
  36338. },
  36339. get isIdentityCMap() {
  36340. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  36341. return false;
  36342. }
  36343. if (this._map.length !== 0x10000) {
  36344. return false;
  36345. }
  36346. for (var i = 0; i < 0x10000; i++) {
  36347. if (this._map[i] !== i) {
  36348. return false;
  36349. }
  36350. }
  36351. return true;
  36352. }
  36353. };
  36354. return CMap;
  36355. }();
  36356. var IdentityCMap = function IdentityCMapClosure() {
  36357. function IdentityCMap(vertical, n) {
  36358. CMap.call(this);
  36359. this.vertical = vertical;
  36360. this.addCodespaceRange(n, 0, 0xffff);
  36361. }
  36362. Util.inherit(IdentityCMap, CMap, {});
  36363. IdentityCMap.prototype = {
  36364. addCodespaceRange: CMap.prototype.addCodespaceRange,
  36365. mapCidRange: function (low, high, dstLow) {
  36366. error('should not call mapCidRange');
  36367. },
  36368. mapBfRange: function (low, high, dstLow) {
  36369. error('should not call mapBfRange');
  36370. },
  36371. mapBfRangeToArray: function (low, high, array) {
  36372. error('should not call mapBfRangeToArray');
  36373. },
  36374. mapOne: function (src, dst) {
  36375. error('should not call mapCidOne');
  36376. },
  36377. lookup: function (code) {
  36378. return isInt(code) && code <= 0xffff ? code : undefined;
  36379. },
  36380. contains: function (code) {
  36381. return isInt(code) && code <= 0xffff;
  36382. },
  36383. forEach: function (callback) {
  36384. for (var i = 0; i <= 0xffff; i++) {
  36385. callback(i, i);
  36386. }
  36387. },
  36388. charCodeOf: function (value) {
  36389. return isInt(value) && value <= 0xffff ? value : -1;
  36390. },
  36391. getMap: function () {
  36392. var map = new Array(0x10000);
  36393. for (var i = 0; i <= 0xffff; i++) {
  36394. map[i] = i;
  36395. }
  36396. return map;
  36397. },
  36398. readCharCode: CMap.prototype.readCharCode,
  36399. get length() {
  36400. return 0x10000;
  36401. },
  36402. get isIdentityCMap() {
  36403. error('should not access .isIdentityCMap');
  36404. }
  36405. };
  36406. return IdentityCMap;
  36407. }();
  36408. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  36409. function fetchBinaryData(url) {
  36410. return new Promise(function (resolve, reject) {
  36411. var request = new XMLHttpRequest();
  36412. request.open('GET', url, true);
  36413. request.responseType = 'arraybuffer';
  36414. request.onreadystatechange = function () {
  36415. if (request.readyState === XMLHttpRequest.DONE) {
  36416. if (!request.response || request.status !== 200 && request.status !== 0) {
  36417. reject(new Error('Unable to get binary cMap at: ' + url));
  36418. } else {
  36419. resolve(new Uint8Array(request.response));
  36420. }
  36421. }
  36422. };
  36423. request.send(null);
  36424. });
  36425. }
  36426. function hexToInt(a, size) {
  36427. var n = 0;
  36428. for (var i = 0; i <= size; i++) {
  36429. n = n << 8 | a[i];
  36430. }
  36431. return n >>> 0;
  36432. }
  36433. function hexToStr(a, size) {
  36434. if (size === 1) {
  36435. return String.fromCharCode(a[0], a[1]);
  36436. }
  36437. if (size === 3) {
  36438. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  36439. }
  36440. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  36441. }
  36442. function addHex(a, b, size) {
  36443. var c = 0;
  36444. for (var i = size; i >= 0; i--) {
  36445. c += a[i] + b[i];
  36446. a[i] = c & 255;
  36447. c >>= 8;
  36448. }
  36449. }
  36450. function incHex(a, size) {
  36451. var c = 1;
  36452. for (var i = size; i >= 0 && c > 0; i--) {
  36453. c += a[i];
  36454. a[i] = c & 255;
  36455. c >>= 8;
  36456. }
  36457. }
  36458. var MAX_NUM_SIZE = 16;
  36459. var MAX_ENCODED_NUM_SIZE = 19;
  36460. function BinaryCMapStream(data) {
  36461. this.buffer = data;
  36462. this.pos = 0;
  36463. this.end = data.length;
  36464. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  36465. }
  36466. BinaryCMapStream.prototype = {
  36467. readByte: function () {
  36468. if (this.pos >= this.end) {
  36469. return -1;
  36470. }
  36471. return this.buffer[this.pos++];
  36472. },
  36473. readNumber: function () {
  36474. var n = 0;
  36475. var last;
  36476. do {
  36477. var b = this.readByte();
  36478. if (b < 0) {
  36479. error('unexpected EOF in bcmap');
  36480. }
  36481. last = !(b & 0x80);
  36482. n = n << 7 | b & 0x7F;
  36483. } while (!last);
  36484. return n;
  36485. },
  36486. readSigned: function () {
  36487. var n = this.readNumber();
  36488. return n & 1 ? ~(n >>> 1) : n >>> 1;
  36489. },
  36490. readHex: function (num, size) {
  36491. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  36492. this.pos += size + 1;
  36493. },
  36494. readHexNumber: function (num, size) {
  36495. var last;
  36496. var stack = this.tmpBuf, sp = 0;
  36497. do {
  36498. var b = this.readByte();
  36499. if (b < 0) {
  36500. error('unexpected EOF in bcmap');
  36501. }
  36502. last = !(b & 0x80);
  36503. stack[sp++] = b & 0x7F;
  36504. } while (!last);
  36505. var i = size, buffer = 0, bufferSize = 0;
  36506. while (i >= 0) {
  36507. while (bufferSize < 8 && stack.length > 0) {
  36508. buffer = stack[--sp] << bufferSize | buffer;
  36509. bufferSize += 7;
  36510. }
  36511. num[i] = buffer & 255;
  36512. i--;
  36513. buffer >>= 8;
  36514. bufferSize -= 8;
  36515. }
  36516. },
  36517. readHexSigned: function (num, size) {
  36518. this.readHexNumber(num, size);
  36519. var sign = num[size] & 1 ? 255 : 0;
  36520. var c = 0;
  36521. for (var i = 0; i <= size; i++) {
  36522. c = (c & 1) << 8 | num[i];
  36523. num[i] = c >> 1 ^ sign;
  36524. }
  36525. },
  36526. readString: function () {
  36527. var len = this.readNumber();
  36528. var s = '';
  36529. for (var i = 0; i < len; i++) {
  36530. s += String.fromCharCode(this.readNumber());
  36531. }
  36532. return s;
  36533. }
  36534. };
  36535. function processBinaryCMap(url, cMap, extend) {
  36536. return fetchBinaryData(url).then(function (data) {
  36537. var stream = new BinaryCMapStream(data);
  36538. var header = stream.readByte();
  36539. cMap.vertical = !!(header & 1);
  36540. var useCMap = null;
  36541. var start = new Uint8Array(MAX_NUM_SIZE);
  36542. var end = new Uint8Array(MAX_NUM_SIZE);
  36543. var char = new Uint8Array(MAX_NUM_SIZE);
  36544. var charCode = new Uint8Array(MAX_NUM_SIZE);
  36545. var tmp = new Uint8Array(MAX_NUM_SIZE);
  36546. var code;
  36547. var b;
  36548. while ((b = stream.readByte()) >= 0) {
  36549. var type = b >> 5;
  36550. if (type === 7) {
  36551. switch (b & 0x1F) {
  36552. case 0:
  36553. stream.readString();
  36554. break;
  36555. case 1:
  36556. useCMap = stream.readString();
  36557. break;
  36558. }
  36559. continue;
  36560. }
  36561. var sequence = !!(b & 0x10);
  36562. var dataSize = b & 15;
  36563. assert(dataSize + 1 <= MAX_NUM_SIZE);
  36564. var ucs2DataSize = 1;
  36565. var subitemsCount = stream.readNumber();
  36566. var i;
  36567. switch (type) {
  36568. case 0:
  36569. stream.readHex(start, dataSize);
  36570. stream.readHexNumber(end, dataSize);
  36571. addHex(end, start, dataSize);
  36572. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  36573. for (i = 1; i < subitemsCount; i++) {
  36574. incHex(end, dataSize);
  36575. stream.readHexNumber(start, dataSize);
  36576. addHex(start, end, dataSize);
  36577. stream.readHexNumber(end, dataSize);
  36578. addHex(end, start, dataSize);
  36579. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  36580. }
  36581. break;
  36582. case 1:
  36583. stream.readHex(start, dataSize);
  36584. stream.readHexNumber(end, dataSize);
  36585. addHex(end, start, dataSize);
  36586. code = stream.readNumber();
  36587. for (i = 1; i < subitemsCount; i++) {
  36588. incHex(end, dataSize);
  36589. stream.readHexNumber(start, dataSize);
  36590. addHex(start, end, dataSize);
  36591. stream.readHexNumber(end, dataSize);
  36592. addHex(end, start, dataSize);
  36593. code = stream.readNumber();
  36594. }
  36595. break;
  36596. case 2:
  36597. stream.readHex(char, dataSize);
  36598. code = stream.readNumber();
  36599. cMap.mapOne(hexToInt(char, dataSize), code);
  36600. for (i = 1; i < subitemsCount; i++) {
  36601. incHex(char, dataSize);
  36602. if (!sequence) {
  36603. stream.readHexNumber(tmp, dataSize);
  36604. addHex(char, tmp, dataSize);
  36605. }
  36606. code = stream.readSigned() + (code + 1);
  36607. cMap.mapOne(hexToInt(char, dataSize), code);
  36608. }
  36609. break;
  36610. case 3:
  36611. stream.readHex(start, dataSize);
  36612. stream.readHexNumber(end, dataSize);
  36613. addHex(end, start, dataSize);
  36614. code = stream.readNumber();
  36615. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  36616. for (i = 1; i < subitemsCount; i++) {
  36617. incHex(end, dataSize);
  36618. if (!sequence) {
  36619. stream.readHexNumber(start, dataSize);
  36620. addHex(start, end, dataSize);
  36621. } else {
  36622. start.set(end);
  36623. }
  36624. stream.readHexNumber(end, dataSize);
  36625. addHex(end, start, dataSize);
  36626. code = stream.readNumber();
  36627. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  36628. }
  36629. break;
  36630. case 4:
  36631. stream.readHex(char, ucs2DataSize);
  36632. stream.readHex(charCode, dataSize);
  36633. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  36634. for (i = 1; i < subitemsCount; i++) {
  36635. incHex(char, ucs2DataSize);
  36636. if (!sequence) {
  36637. stream.readHexNumber(tmp, ucs2DataSize);
  36638. addHex(char, tmp, ucs2DataSize);
  36639. }
  36640. incHex(charCode, dataSize);
  36641. stream.readHexSigned(tmp, dataSize);
  36642. addHex(charCode, tmp, dataSize);
  36643. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  36644. }
  36645. break;
  36646. case 5:
  36647. stream.readHex(start, ucs2DataSize);
  36648. stream.readHexNumber(end, ucs2DataSize);
  36649. addHex(end, start, ucs2DataSize);
  36650. stream.readHex(charCode, dataSize);
  36651. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  36652. for (i = 1; i < subitemsCount; i++) {
  36653. incHex(end, ucs2DataSize);
  36654. if (!sequence) {
  36655. stream.readHexNumber(start, ucs2DataSize);
  36656. addHex(start, end, ucs2DataSize);
  36657. } else {
  36658. start.set(end);
  36659. }
  36660. stream.readHexNumber(end, ucs2DataSize);
  36661. addHex(end, start, ucs2DataSize);
  36662. stream.readHex(charCode, dataSize);
  36663. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  36664. }
  36665. break;
  36666. default:
  36667. error('Unknown type: ' + type);
  36668. break;
  36669. }
  36670. }
  36671. if (useCMap) {
  36672. return extend(useCMap);
  36673. }
  36674. return cMap;
  36675. });
  36676. }
  36677. function BinaryCMapReader() {
  36678. }
  36679. BinaryCMapReader.prototype = { read: processBinaryCMap };
  36680. return BinaryCMapReader;
  36681. }();
  36682. var CMapFactory = function CMapFactoryClosure() {
  36683. function strToInt(str) {
  36684. var a = 0;
  36685. for (var i = 0; i < str.length; i++) {
  36686. a = a << 8 | str.charCodeAt(i);
  36687. }
  36688. return a >>> 0;
  36689. }
  36690. function expectString(obj) {
  36691. if (!isString(obj)) {
  36692. error('Malformed CMap: expected string.');
  36693. }
  36694. }
  36695. function expectInt(obj) {
  36696. if (!isInt(obj)) {
  36697. error('Malformed CMap: expected int.');
  36698. }
  36699. }
  36700. function parseBfChar(cMap, lexer) {
  36701. while (true) {
  36702. var obj = lexer.getObj();
  36703. if (isEOF(obj)) {
  36704. break;
  36705. }
  36706. if (isCmd(obj, 'endbfchar')) {
  36707. return;
  36708. }
  36709. expectString(obj);
  36710. var src = strToInt(obj);
  36711. obj = lexer.getObj();
  36712. expectString(obj);
  36713. var dst = obj;
  36714. cMap.mapOne(src, dst);
  36715. }
  36716. }
  36717. function parseBfRange(cMap, lexer) {
  36718. while (true) {
  36719. var obj = lexer.getObj();
  36720. if (isEOF(obj)) {
  36721. break;
  36722. }
  36723. if (isCmd(obj, 'endbfrange')) {
  36724. return;
  36725. }
  36726. expectString(obj);
  36727. var low = strToInt(obj);
  36728. obj = lexer.getObj();
  36729. expectString(obj);
  36730. var high = strToInt(obj);
  36731. obj = lexer.getObj();
  36732. if (isInt(obj) || isString(obj)) {
  36733. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  36734. cMap.mapBfRange(low, high, dstLow);
  36735. } else if (isCmd(obj, '[')) {
  36736. obj = lexer.getObj();
  36737. var array = [];
  36738. while (!isCmd(obj, ']') && !isEOF(obj)) {
  36739. array.push(obj);
  36740. obj = lexer.getObj();
  36741. }
  36742. cMap.mapBfRangeToArray(low, high, array);
  36743. } else {
  36744. break;
  36745. }
  36746. }
  36747. error('Invalid bf range.');
  36748. }
  36749. function parseCidChar(cMap, lexer) {
  36750. while (true) {
  36751. var obj = lexer.getObj();
  36752. if (isEOF(obj)) {
  36753. break;
  36754. }
  36755. if (isCmd(obj, 'endcidchar')) {
  36756. return;
  36757. }
  36758. expectString(obj);
  36759. var src = strToInt(obj);
  36760. obj = lexer.getObj();
  36761. expectInt(obj);
  36762. var dst = obj;
  36763. cMap.mapOne(src, dst);
  36764. }
  36765. }
  36766. function parseCidRange(cMap, lexer) {
  36767. while (true) {
  36768. var obj = lexer.getObj();
  36769. if (isEOF(obj)) {
  36770. break;
  36771. }
  36772. if (isCmd(obj, 'endcidrange')) {
  36773. return;
  36774. }
  36775. expectString(obj);
  36776. var low = strToInt(obj);
  36777. obj = lexer.getObj();
  36778. expectString(obj);
  36779. var high = strToInt(obj);
  36780. obj = lexer.getObj();
  36781. expectInt(obj);
  36782. var dstLow = obj;
  36783. cMap.mapCidRange(low, high, dstLow);
  36784. }
  36785. }
  36786. function parseCodespaceRange(cMap, lexer) {
  36787. while (true) {
  36788. var obj = lexer.getObj();
  36789. if (isEOF(obj)) {
  36790. break;
  36791. }
  36792. if (isCmd(obj, 'endcodespacerange')) {
  36793. return;
  36794. }
  36795. if (!isString(obj)) {
  36796. break;
  36797. }
  36798. var low = strToInt(obj);
  36799. obj = lexer.getObj();
  36800. if (!isString(obj)) {
  36801. break;
  36802. }
  36803. var high = strToInt(obj);
  36804. cMap.addCodespaceRange(obj.length, low, high);
  36805. }
  36806. error('Invalid codespace range.');
  36807. }
  36808. function parseWMode(cMap, lexer) {
  36809. var obj = lexer.getObj();
  36810. if (isInt(obj)) {
  36811. cMap.vertical = !!obj;
  36812. }
  36813. }
  36814. function parseCMapName(cMap, lexer) {
  36815. var obj = lexer.getObj();
  36816. if (isName(obj) && isString(obj.name)) {
  36817. cMap.name = obj.name;
  36818. }
  36819. }
  36820. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  36821. var previous;
  36822. var embededUseCMap;
  36823. objLoop:
  36824. while (true) {
  36825. try {
  36826. var obj = lexer.getObj();
  36827. if (isEOF(obj)) {
  36828. break;
  36829. } else if (isName(obj)) {
  36830. if (obj.name === 'WMode') {
  36831. parseWMode(cMap, lexer);
  36832. } else if (obj.name === 'CMapName') {
  36833. parseCMapName(cMap, lexer);
  36834. }
  36835. previous = obj;
  36836. } else if (isCmd(obj)) {
  36837. switch (obj.cmd) {
  36838. case 'endcmap':
  36839. break objLoop;
  36840. case 'usecmap':
  36841. if (isName(previous)) {
  36842. embededUseCMap = previous.name;
  36843. }
  36844. break;
  36845. case 'begincodespacerange':
  36846. parseCodespaceRange(cMap, lexer);
  36847. break;
  36848. case 'beginbfchar':
  36849. parseBfChar(cMap, lexer);
  36850. break;
  36851. case 'begincidchar':
  36852. parseCidChar(cMap, lexer);
  36853. break;
  36854. case 'beginbfrange':
  36855. parseBfRange(cMap, lexer);
  36856. break;
  36857. case 'begincidrange':
  36858. parseCidRange(cMap, lexer);
  36859. break;
  36860. }
  36861. }
  36862. } catch (ex) {
  36863. if (ex instanceof MissingDataException) {
  36864. throw ex;
  36865. }
  36866. warn('Invalid cMap data: ' + ex);
  36867. continue;
  36868. }
  36869. }
  36870. if (!useCMap && embededUseCMap) {
  36871. useCMap = embededUseCMap;
  36872. }
  36873. if (useCMap) {
  36874. return extendCMap(cMap, builtInCMapParams, useCMap);
  36875. }
  36876. return Promise.resolve(cMap);
  36877. }
  36878. function extendCMap(cMap, builtInCMapParams, useCMap) {
  36879. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  36880. cMap.useCMap = newCMap;
  36881. if (cMap.numCodespaceRanges === 0) {
  36882. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  36883. for (var i = 0; i < useCodespaceRanges.length; i++) {
  36884. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  36885. }
  36886. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  36887. }
  36888. cMap.useCMap.forEach(function (key, value) {
  36889. if (!cMap.contains(key)) {
  36890. cMap.mapOne(key, cMap.useCMap.lookup(key));
  36891. }
  36892. });
  36893. return cMap;
  36894. });
  36895. }
  36896. function parseBinaryCMap(name, builtInCMapParams) {
  36897. var url = builtInCMapParams.url + name + '.bcmap';
  36898. var cMap = new CMap(true);
  36899. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  36900. return extendCMap(cMap, builtInCMapParams, useCMap);
  36901. });
  36902. }
  36903. function createBuiltInCMap(name, builtInCMapParams) {
  36904. if (name === 'Identity-H') {
  36905. return Promise.resolve(new IdentityCMap(false, 2));
  36906. } else if (name === 'Identity-V') {
  36907. return Promise.resolve(new IdentityCMap(true, 2));
  36908. }
  36909. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  36910. return Promise.reject(new Error('Unknown cMap name: ' + name));
  36911. }
  36912. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  36913. if (builtInCMapParams.packed) {
  36914. return parseBinaryCMap(name, builtInCMapParams);
  36915. }
  36916. return new Promise(function (resolve, reject) {
  36917. var url = builtInCMapParams.url + name;
  36918. var request = new XMLHttpRequest();
  36919. request.onreadystatechange = function () {
  36920. if (request.readyState === XMLHttpRequest.DONE) {
  36921. if (request.status === 200 || request.status === 0) {
  36922. var cMap = new CMap(true);
  36923. var lexer = new Lexer(new StringStream(request.responseText));
  36924. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  36925. resolve(parsedCMap);
  36926. });
  36927. } else {
  36928. reject(new Error('Unable to get cMap at: ' + url));
  36929. }
  36930. }
  36931. };
  36932. request.open('GET', url, true);
  36933. request.send(null);
  36934. });
  36935. }
  36936. return {
  36937. create: function (encoding, builtInCMapParams, useCMap) {
  36938. if (isName(encoding)) {
  36939. return createBuiltInCMap(encoding.name, builtInCMapParams);
  36940. } else if (isStream(encoding)) {
  36941. var cMap = new CMap();
  36942. var lexer = new Lexer(encoding);
  36943. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  36944. if (parsedCMap.isIdentityCMap) {
  36945. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  36946. }
  36947. return parsedCMap;
  36948. });
  36949. }
  36950. return Promise.reject(new Error('Encoding required.'));
  36951. }
  36952. };
  36953. }();
  36954. exports.CMap = CMap;
  36955. exports.CMapFactory = CMapFactory;
  36956. exports.IdentityCMap = IdentityCMap;
  36957. }));
  36958. (function (root, factory) {
  36959. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  36960. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  36961. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  36962. var FontType = sharedUtil.FontType;
  36963. var assert = sharedUtil.assert;
  36964. var bytesToString = sharedUtil.bytesToString;
  36965. var error = sharedUtil.error;
  36966. var info = sharedUtil.info;
  36967. var isArray = sharedUtil.isArray;
  36968. var isInt = sharedUtil.isInt;
  36969. var isNum = sharedUtil.isNum;
  36970. var readUint32 = sharedUtil.readUint32;
  36971. var shadow = sharedUtil.shadow;
  36972. var string32 = sharedUtil.string32;
  36973. var warn = sharedUtil.warn;
  36974. var MissingDataException = sharedUtil.MissingDataException;
  36975. var isSpace = sharedUtil.isSpace;
  36976. var Stream = coreStream.Stream;
  36977. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36978. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  36979. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  36980. var StandardEncoding = coreEncodings.StandardEncoding;
  36981. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  36982. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  36983. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  36984. var getEncoding = coreEncodings.getEncoding;
  36985. var getStdFontMap = coreStandardFonts.getStdFontMap;
  36986. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  36987. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  36988. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  36989. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  36990. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  36991. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  36992. var Type1Parser = coreType1Parser.Type1Parser;
  36993. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  36994. var CFFParser = coreCFFParser.CFFParser;
  36995. var CFFCompiler = coreCFFParser.CFFCompiler;
  36996. var CFF = coreCFFParser.CFF;
  36997. var CFFHeader = coreCFFParser.CFFHeader;
  36998. var CFFTopDict = coreCFFParser.CFFTopDict;
  36999. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  37000. var CFFStrings = coreCFFParser.CFFStrings;
  37001. var CFFIndex = coreCFFParser.CFFIndex;
  37002. var CFFCharset = coreCFFParser.CFFCharset;
  37003. var PRIVATE_USE_OFFSET_START = 0xE000;
  37004. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  37005. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  37006. var PDF_GLYPH_SPACE_UNITS = 1000;
  37007. var SEAC_ANALYSIS_ENABLED = false;
  37008. var FontFlags = {
  37009. FixedPitch: 1,
  37010. Serif: 2,
  37011. Symbolic: 4,
  37012. Script: 8,
  37013. Nonsymbolic: 32,
  37014. Italic: 64,
  37015. AllCap: 65536,
  37016. SmallCap: 131072,
  37017. ForceBold: 262144
  37018. };
  37019. var MacStandardGlyphOrdering = [
  37020. '.notdef',
  37021. '.null',
  37022. 'nonmarkingreturn',
  37023. 'space',
  37024. 'exclam',
  37025. 'quotedbl',
  37026. 'numbersign',
  37027. 'dollar',
  37028. 'percent',
  37029. 'ampersand',
  37030. 'quotesingle',
  37031. 'parenleft',
  37032. 'parenright',
  37033. 'asterisk',
  37034. 'plus',
  37035. 'comma',
  37036. 'hyphen',
  37037. 'period',
  37038. 'slash',
  37039. 'zero',
  37040. 'one',
  37041. 'two',
  37042. 'three',
  37043. 'four',
  37044. 'five',
  37045. 'six',
  37046. 'seven',
  37047. 'eight',
  37048. 'nine',
  37049. 'colon',
  37050. 'semicolon',
  37051. 'less',
  37052. 'equal',
  37053. 'greater',
  37054. 'question',
  37055. 'at',
  37056. 'A',
  37057. 'B',
  37058. 'C',
  37059. 'D',
  37060. 'E',
  37061. 'F',
  37062. 'G',
  37063. 'H',
  37064. 'I',
  37065. 'J',
  37066. 'K',
  37067. 'L',
  37068. 'M',
  37069. 'N',
  37070. 'O',
  37071. 'P',
  37072. 'Q',
  37073. 'R',
  37074. 'S',
  37075. 'T',
  37076. 'U',
  37077. 'V',
  37078. 'W',
  37079. 'X',
  37080. 'Y',
  37081. 'Z',
  37082. 'bracketleft',
  37083. 'backslash',
  37084. 'bracketright',
  37085. 'asciicircum',
  37086. 'underscore',
  37087. 'grave',
  37088. 'a',
  37089. 'b',
  37090. 'c',
  37091. 'd',
  37092. 'e',
  37093. 'f',
  37094. 'g',
  37095. 'h',
  37096. 'i',
  37097. 'j',
  37098. 'k',
  37099. 'l',
  37100. 'm',
  37101. 'n',
  37102. 'o',
  37103. 'p',
  37104. 'q',
  37105. 'r',
  37106. 's',
  37107. 't',
  37108. 'u',
  37109. 'v',
  37110. 'w',
  37111. 'x',
  37112. 'y',
  37113. 'z',
  37114. 'braceleft',
  37115. 'bar',
  37116. 'braceright',
  37117. 'asciitilde',
  37118. 'Adieresis',
  37119. 'Aring',
  37120. 'Ccedilla',
  37121. 'Eacute',
  37122. 'Ntilde',
  37123. 'Odieresis',
  37124. 'Udieresis',
  37125. 'aacute',
  37126. 'agrave',
  37127. 'acircumflex',
  37128. 'adieresis',
  37129. 'atilde',
  37130. 'aring',
  37131. 'ccedilla',
  37132. 'eacute',
  37133. 'egrave',
  37134. 'ecircumflex',
  37135. 'edieresis',
  37136. 'iacute',
  37137. 'igrave',
  37138. 'icircumflex',
  37139. 'idieresis',
  37140. 'ntilde',
  37141. 'oacute',
  37142. 'ograve',
  37143. 'ocircumflex',
  37144. 'odieresis',
  37145. 'otilde',
  37146. 'uacute',
  37147. 'ugrave',
  37148. 'ucircumflex',
  37149. 'udieresis',
  37150. 'dagger',
  37151. 'degree',
  37152. 'cent',
  37153. 'sterling',
  37154. 'section',
  37155. 'bullet',
  37156. 'paragraph',
  37157. 'germandbls',
  37158. 'registered',
  37159. 'copyright',
  37160. 'trademark',
  37161. 'acute',
  37162. 'dieresis',
  37163. 'notequal',
  37164. 'AE',
  37165. 'Oslash',
  37166. 'infinity',
  37167. 'plusminus',
  37168. 'lessequal',
  37169. 'greaterequal',
  37170. 'yen',
  37171. 'mu',
  37172. 'partialdiff',
  37173. 'summation',
  37174. 'product',
  37175. 'pi',
  37176. 'integral',
  37177. 'ordfeminine',
  37178. 'ordmasculine',
  37179. 'Omega',
  37180. 'ae',
  37181. 'oslash',
  37182. 'questiondown',
  37183. 'exclamdown',
  37184. 'logicalnot',
  37185. 'radical',
  37186. 'florin',
  37187. 'approxequal',
  37188. 'Delta',
  37189. 'guillemotleft',
  37190. 'guillemotright',
  37191. 'ellipsis',
  37192. 'nonbreakingspace',
  37193. 'Agrave',
  37194. 'Atilde',
  37195. 'Otilde',
  37196. 'OE',
  37197. 'oe',
  37198. 'endash',
  37199. 'emdash',
  37200. 'quotedblleft',
  37201. 'quotedblright',
  37202. 'quoteleft',
  37203. 'quoteright',
  37204. 'divide',
  37205. 'lozenge',
  37206. 'ydieresis',
  37207. 'Ydieresis',
  37208. 'fraction',
  37209. 'currency',
  37210. 'guilsinglleft',
  37211. 'guilsinglright',
  37212. 'fi',
  37213. 'fl',
  37214. 'daggerdbl',
  37215. 'periodcentered',
  37216. 'quotesinglbase',
  37217. 'quotedblbase',
  37218. 'perthousand',
  37219. 'Acircumflex',
  37220. 'Ecircumflex',
  37221. 'Aacute',
  37222. 'Edieresis',
  37223. 'Egrave',
  37224. 'Iacute',
  37225. 'Icircumflex',
  37226. 'Idieresis',
  37227. 'Igrave',
  37228. 'Oacute',
  37229. 'Ocircumflex',
  37230. 'apple',
  37231. 'Ograve',
  37232. 'Uacute',
  37233. 'Ucircumflex',
  37234. 'Ugrave',
  37235. 'dotlessi',
  37236. 'circumflex',
  37237. 'tilde',
  37238. 'macron',
  37239. 'breve',
  37240. 'dotaccent',
  37241. 'ring',
  37242. 'cedilla',
  37243. 'hungarumlaut',
  37244. 'ogonek',
  37245. 'caron',
  37246. 'Lslash',
  37247. 'lslash',
  37248. 'Scaron',
  37249. 'scaron',
  37250. 'Zcaron',
  37251. 'zcaron',
  37252. 'brokenbar',
  37253. 'Eth',
  37254. 'eth',
  37255. 'Yacute',
  37256. 'yacute',
  37257. 'Thorn',
  37258. 'thorn',
  37259. 'minus',
  37260. 'multiply',
  37261. 'onesuperior',
  37262. 'twosuperior',
  37263. 'threesuperior',
  37264. 'onehalf',
  37265. 'onequarter',
  37266. 'threequarters',
  37267. 'franc',
  37268. 'Gbreve',
  37269. 'gbreve',
  37270. 'Idotaccent',
  37271. 'Scedilla',
  37272. 'scedilla',
  37273. 'Cacute',
  37274. 'cacute',
  37275. 'Ccaron',
  37276. 'ccaron',
  37277. 'dcroat'
  37278. ];
  37279. function adjustWidths(properties) {
  37280. if (!properties.fontMatrix) {
  37281. return;
  37282. }
  37283. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  37284. return;
  37285. }
  37286. var scale = 0.001 / properties.fontMatrix[0];
  37287. var glyphsWidths = properties.widths;
  37288. for (var glyph in glyphsWidths) {
  37289. glyphsWidths[glyph] *= scale;
  37290. }
  37291. properties.defaultWidth *= scale;
  37292. }
  37293. function adjustToUnicode(properties, builtInEncoding) {
  37294. if (properties.hasIncludedToUnicodeMap) {
  37295. return;
  37296. }
  37297. if (properties.hasEncoding) {
  37298. return;
  37299. }
  37300. if (builtInEncoding === properties.defaultEncoding) {
  37301. return;
  37302. }
  37303. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  37304. return;
  37305. }
  37306. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  37307. for (var charCode in builtInEncoding) {
  37308. var glyphName = builtInEncoding[charCode];
  37309. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  37310. if (unicode !== -1) {
  37311. toUnicode[charCode] = String.fromCharCode(unicode);
  37312. }
  37313. }
  37314. properties.toUnicode.amend(toUnicode);
  37315. }
  37316. function getFontType(type, subtype) {
  37317. switch (type) {
  37318. case 'Type1':
  37319. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  37320. case 'CIDFontType0':
  37321. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  37322. case 'OpenType':
  37323. return FontType.OPENTYPE;
  37324. case 'TrueType':
  37325. return FontType.TRUETYPE;
  37326. case 'CIDFontType2':
  37327. return FontType.CIDFONTTYPE2;
  37328. case 'MMType1':
  37329. return FontType.MMTYPE1;
  37330. case 'Type0':
  37331. return FontType.TYPE0;
  37332. default:
  37333. return FontType.UNKNOWN;
  37334. }
  37335. }
  37336. function recoverGlyphName(name, glyphsUnicodeMap) {
  37337. if (glyphsUnicodeMap[name] !== undefined) {
  37338. return name;
  37339. }
  37340. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  37341. if (unicode !== -1) {
  37342. for (var key in glyphsUnicodeMap) {
  37343. if (glyphsUnicodeMap[key] === unicode) {
  37344. return key;
  37345. }
  37346. }
  37347. }
  37348. info('Unable to recover a standard glyph name for: ' + name);
  37349. return name;
  37350. }
  37351. var Glyph = function GlyphClosure() {
  37352. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  37353. this.fontChar = fontChar;
  37354. this.unicode = unicode;
  37355. this.accent = accent;
  37356. this.width = width;
  37357. this.vmetric = vmetric;
  37358. this.operatorListId = operatorListId;
  37359. this.isSpace = isSpace;
  37360. this.isInFont = isInFont;
  37361. }
  37362. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  37363. 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;
  37364. };
  37365. return Glyph;
  37366. }();
  37367. var ToUnicodeMap = function ToUnicodeMapClosure() {
  37368. function ToUnicodeMap(cmap) {
  37369. this._map = cmap;
  37370. }
  37371. ToUnicodeMap.prototype = {
  37372. get length() {
  37373. return this._map.length;
  37374. },
  37375. forEach: function (callback) {
  37376. for (var charCode in this._map) {
  37377. callback(charCode, this._map[charCode].charCodeAt(0));
  37378. }
  37379. },
  37380. has: function (i) {
  37381. return this._map[i] !== undefined;
  37382. },
  37383. get: function (i) {
  37384. return this._map[i];
  37385. },
  37386. charCodeOf: function (v) {
  37387. return this._map.indexOf(v);
  37388. },
  37389. amend: function (map) {
  37390. for (var charCode in map) {
  37391. this._map[charCode] = map[charCode];
  37392. }
  37393. }
  37394. };
  37395. return ToUnicodeMap;
  37396. }();
  37397. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  37398. function IdentityToUnicodeMap(firstChar, lastChar) {
  37399. this.firstChar = firstChar;
  37400. this.lastChar = lastChar;
  37401. }
  37402. IdentityToUnicodeMap.prototype = {
  37403. get length() {
  37404. return this.lastChar + 1 - this.firstChar;
  37405. },
  37406. forEach: function (callback) {
  37407. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  37408. callback(i, i);
  37409. }
  37410. },
  37411. has: function (i) {
  37412. return this.firstChar <= i && i <= this.lastChar;
  37413. },
  37414. get: function (i) {
  37415. if (this.firstChar <= i && i <= this.lastChar) {
  37416. return String.fromCharCode(i);
  37417. }
  37418. return undefined;
  37419. },
  37420. charCodeOf: function (v) {
  37421. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  37422. },
  37423. amend: function (map) {
  37424. error('Should not call amend()');
  37425. }
  37426. };
  37427. return IdentityToUnicodeMap;
  37428. }();
  37429. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  37430. function writeInt16(dest, offset, num) {
  37431. dest[offset] = num >> 8 & 0xFF;
  37432. dest[offset + 1] = num & 0xFF;
  37433. }
  37434. function writeInt32(dest, offset, num) {
  37435. dest[offset] = num >> 24 & 0xFF;
  37436. dest[offset + 1] = num >> 16 & 0xFF;
  37437. dest[offset + 2] = num >> 8 & 0xFF;
  37438. dest[offset + 3] = num & 0xFF;
  37439. }
  37440. function writeData(dest, offset, data) {
  37441. var i, ii;
  37442. if (data instanceof Uint8Array) {
  37443. dest.set(data, offset);
  37444. } else if (typeof data === 'string') {
  37445. for (i = 0, ii = data.length; i < ii; i++) {
  37446. dest[offset++] = data.charCodeAt(i) & 0xFF;
  37447. }
  37448. } else {
  37449. for (i = 0, ii = data.length; i < ii; i++) {
  37450. dest[offset++] = data[i] & 0xFF;
  37451. }
  37452. }
  37453. }
  37454. function OpenTypeFileBuilder(sfnt) {
  37455. this.sfnt = sfnt;
  37456. this.tables = Object.create(null);
  37457. }
  37458. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  37459. var maxPower2 = 1, log2 = 0;
  37460. while ((maxPower2 ^ entriesCount) > maxPower2) {
  37461. maxPower2 <<= 1;
  37462. log2++;
  37463. }
  37464. var searchRange = maxPower2 * entrySize;
  37465. return {
  37466. range: searchRange,
  37467. entry: log2,
  37468. rangeShift: entrySize * entriesCount - searchRange
  37469. };
  37470. };
  37471. var OTF_HEADER_SIZE = 12;
  37472. var OTF_TABLE_ENTRY_SIZE = 16;
  37473. OpenTypeFileBuilder.prototype = {
  37474. toArray: function OpenTypeFileBuilder_toArray() {
  37475. var sfnt = this.sfnt;
  37476. var tables = this.tables;
  37477. var tablesNames = Object.keys(tables);
  37478. tablesNames.sort();
  37479. var numTables = tablesNames.length;
  37480. var i, j, jj, table, tableName;
  37481. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  37482. var tableOffsets = [offset];
  37483. for (i = 0; i < numTables; i++) {
  37484. table = tables[tablesNames[i]];
  37485. var paddedLength = (table.length + 3 & ~3) >>> 0;
  37486. offset += paddedLength;
  37487. tableOffsets.push(offset);
  37488. }
  37489. var file = new Uint8Array(offset);
  37490. for (i = 0; i < numTables; i++) {
  37491. table = tables[tablesNames[i]];
  37492. writeData(file, tableOffsets[i], table);
  37493. }
  37494. if (sfnt === 'true') {
  37495. sfnt = string32(0x00010000);
  37496. }
  37497. file[0] = sfnt.charCodeAt(0) & 0xFF;
  37498. file[1] = sfnt.charCodeAt(1) & 0xFF;
  37499. file[2] = sfnt.charCodeAt(2) & 0xFF;
  37500. file[3] = sfnt.charCodeAt(3) & 0xFF;
  37501. writeInt16(file, 4, numTables);
  37502. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  37503. writeInt16(file, 6, searchParams.range);
  37504. writeInt16(file, 8, searchParams.entry);
  37505. writeInt16(file, 10, searchParams.rangeShift);
  37506. offset = OTF_HEADER_SIZE;
  37507. for (i = 0; i < numTables; i++) {
  37508. tableName = tablesNames[i];
  37509. file[offset] = tableName.charCodeAt(0) & 0xFF;
  37510. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  37511. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  37512. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  37513. var checksum = 0;
  37514. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  37515. var quad = readUint32(file, j);
  37516. checksum = checksum + quad >>> 0;
  37517. }
  37518. writeInt32(file, offset + 4, checksum);
  37519. writeInt32(file, offset + 8, tableOffsets[i]);
  37520. writeInt32(file, offset + 12, tables[tableName].length);
  37521. offset += OTF_TABLE_ENTRY_SIZE;
  37522. }
  37523. return file;
  37524. },
  37525. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  37526. if (tag in this.tables) {
  37527. throw new Error('Table ' + tag + ' already exists');
  37528. }
  37529. this.tables[tag] = data;
  37530. }
  37531. };
  37532. return OpenTypeFileBuilder;
  37533. }();
  37534. var ProblematicCharRanges = new Int32Array([
  37535. 0x0000,
  37536. 0x0020,
  37537. 0x007F,
  37538. 0x00A1,
  37539. 0x00AD,
  37540. 0x00AE,
  37541. 0x0600,
  37542. 0x0780,
  37543. 0x08A0,
  37544. 0x10A0,
  37545. 0x1780,
  37546. 0x1800,
  37547. 0x1C00,
  37548. 0x1C50,
  37549. 0x2000,
  37550. 0x2010,
  37551. 0x2011,
  37552. 0x2012,
  37553. 0x2028,
  37554. 0x2030,
  37555. 0x205F,
  37556. 0x2070,
  37557. 0x25CC,
  37558. 0x25CD,
  37559. 0x3000,
  37560. 0x3001,
  37561. 0xAA60,
  37562. 0xAA80,
  37563. 0xFFF0,
  37564. 0x10000
  37565. ]);
  37566. var Font = function FontClosure() {
  37567. function Font(name, file, properties) {
  37568. var charCode, glyphName, unicode;
  37569. this.name = name;
  37570. this.loadedName = properties.loadedName;
  37571. this.isType3Font = properties.isType3Font;
  37572. this.sizes = [];
  37573. this.missingFile = false;
  37574. this.glyphCache = Object.create(null);
  37575. var names = name.split('+');
  37576. names = names.length > 1 ? names[1] : names[0];
  37577. names = names.split(/[-,_]/g)[0];
  37578. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  37579. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  37580. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  37581. var type = properties.type;
  37582. var subtype = properties.subtype;
  37583. this.type = type;
  37584. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  37585. this.differences = properties.differences;
  37586. this.widths = properties.widths;
  37587. this.defaultWidth = properties.defaultWidth;
  37588. this.composite = properties.composite;
  37589. this.wideChars = properties.wideChars;
  37590. this.cMap = properties.cMap;
  37591. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  37592. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  37593. this.fontMatrix = properties.fontMatrix;
  37594. this.bbox = properties.bbox;
  37595. this.toUnicode = properties.toUnicode;
  37596. this.toFontChar = [];
  37597. if (properties.type === 'Type3') {
  37598. for (charCode = 0; charCode < 256; charCode++) {
  37599. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  37600. }
  37601. this.fontType = FontType.TYPE3;
  37602. return;
  37603. }
  37604. this.cidEncoding = properties.cidEncoding;
  37605. this.vertical = properties.vertical;
  37606. if (this.vertical) {
  37607. this.vmetrics = properties.vmetrics;
  37608. this.defaultVMetrics = properties.defaultVMetrics;
  37609. }
  37610. var glyphsUnicodeMap;
  37611. if (!file || file.isEmpty) {
  37612. if (file) {
  37613. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  37614. }
  37615. this.missingFile = true;
  37616. var fontName = name.replace(/[,_]/g, '-');
  37617. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  37618. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  37619. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  37620. this.bold = fontName.search(/bold/gi) !== -1;
  37621. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  37622. this.black = name.search(/Black/g) !== -1;
  37623. this.remeasure = Object.keys(this.widths).length > 0;
  37624. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  37625. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  37626. var map = [];
  37627. for (charCode in GlyphMapForStandardFonts) {
  37628. map[+charCode] = GlyphMapForStandardFonts[charCode];
  37629. }
  37630. if (/Arial-?Black/i.test(name)) {
  37631. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  37632. for (charCode in SupplementalGlyphMapForArialBlack) {
  37633. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  37634. }
  37635. }
  37636. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  37637. if (!isIdentityUnicode) {
  37638. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  37639. map[+charCode] = unicodeCharCode;
  37640. });
  37641. }
  37642. this.toFontChar = map;
  37643. this.toUnicode = new ToUnicodeMap(map);
  37644. } else if (/Symbol/i.test(fontName)) {
  37645. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  37646. } else if (/Dingbats/i.test(fontName)) {
  37647. if (/Wingdings/i.test(name)) {
  37648. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  37649. }
  37650. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  37651. } else if (isStandardFont) {
  37652. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  37653. } else {
  37654. glyphsUnicodeMap = getGlyphsUnicode();
  37655. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  37656. if (!this.composite) {
  37657. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  37658. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  37659. if (unicode !== -1) {
  37660. unicodeCharCode = unicode;
  37661. }
  37662. }
  37663. this.toFontChar[charCode] = unicodeCharCode;
  37664. }.bind(this));
  37665. }
  37666. this.loadedName = fontName.split('-')[0];
  37667. this.loading = false;
  37668. this.fontType = getFontType(type, subtype);
  37669. return;
  37670. }
  37671. if (subtype === 'Type1C') {
  37672. if (type !== 'Type1' && type !== 'MMType1') {
  37673. if (isTrueTypeFile(file)) {
  37674. subtype = 'TrueType';
  37675. } else {
  37676. type = 'Type1';
  37677. }
  37678. } else if (isOpenTypeFile(file)) {
  37679. type = subtype = 'OpenType';
  37680. }
  37681. }
  37682. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  37683. type = 'CIDFontType0';
  37684. }
  37685. if (subtype === 'OpenType') {
  37686. type = 'OpenType';
  37687. }
  37688. if (type === 'CIDFontType0') {
  37689. if (isType1File(file)) {
  37690. subtype = 'CIDFontType0';
  37691. } else if (isOpenTypeFile(file)) {
  37692. type = subtype = 'OpenType';
  37693. } else {
  37694. subtype = 'CIDFontType0C';
  37695. }
  37696. }
  37697. var data;
  37698. switch (type) {
  37699. case 'MMType1':
  37700. info('MMType1 font (' + name + '), falling back to Type1.');
  37701. case 'Type1':
  37702. case 'CIDFontType0':
  37703. this.mimetype = 'font/opentype';
  37704. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  37705. adjustWidths(properties);
  37706. data = this.convert(name, cff, properties);
  37707. break;
  37708. case 'OpenType':
  37709. case 'TrueType':
  37710. case 'CIDFontType2':
  37711. this.mimetype = 'font/opentype';
  37712. data = this.checkAndRepair(name, file, properties);
  37713. if (this.isOpenType) {
  37714. adjustWidths(properties);
  37715. type = 'OpenType';
  37716. }
  37717. break;
  37718. default:
  37719. error('Font ' + type + ' is not supported');
  37720. break;
  37721. }
  37722. this.data = data;
  37723. this.fontType = getFontType(type, subtype);
  37724. this.fontMatrix = properties.fontMatrix;
  37725. this.widths = properties.widths;
  37726. this.defaultWidth = properties.defaultWidth;
  37727. this.toUnicode = properties.toUnicode;
  37728. this.encoding = properties.baseEncoding;
  37729. this.seacMap = properties.seacMap;
  37730. this.loading = true;
  37731. }
  37732. Font.getFontID = function () {
  37733. var ID = 1;
  37734. return function Font_getFontID() {
  37735. return String(ID++);
  37736. };
  37737. }();
  37738. function int16(b0, b1) {
  37739. return (b0 << 8) + b1;
  37740. }
  37741. function signedInt16(b0, b1) {
  37742. var value = (b0 << 8) + b1;
  37743. return value & 1 << 15 ? value - 0x10000 : value;
  37744. }
  37745. function int32(b0, b1, b2, b3) {
  37746. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  37747. }
  37748. function string16(value) {
  37749. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  37750. }
  37751. function safeString16(value) {
  37752. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  37753. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  37754. }
  37755. function isTrueTypeFile(file) {
  37756. var header = file.peekBytes(4);
  37757. return readUint32(header, 0) === 0x00010000;
  37758. }
  37759. function isOpenTypeFile(file) {
  37760. var header = file.peekBytes(4);
  37761. return bytesToString(header) === 'OTTO';
  37762. }
  37763. function isType1File(file) {
  37764. var header = file.peekBytes(2);
  37765. if (header[0] === 0x25 && header[1] === 0x21) {
  37766. return true;
  37767. }
  37768. if (header[0] === 0x80 && header[1] === 0x01) {
  37769. return true;
  37770. }
  37771. return false;
  37772. }
  37773. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  37774. var toFontChar = [], unicode;
  37775. for (var i = 0, ii = encoding.length; i < ii; i++) {
  37776. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  37777. if (unicode !== -1) {
  37778. toFontChar[i] = unicode;
  37779. }
  37780. }
  37781. for (var charCode in differences) {
  37782. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  37783. if (unicode !== -1) {
  37784. toFontChar[+charCode] = unicode;
  37785. }
  37786. }
  37787. return toFontChar;
  37788. }
  37789. function isProblematicUnicodeLocation(code) {
  37790. var i = 0, j = ProblematicCharRanges.length - 1;
  37791. while (i < j) {
  37792. var c = i + j + 1 >> 1;
  37793. if (code < ProblematicCharRanges[c]) {
  37794. j = c - 1;
  37795. } else {
  37796. i = c;
  37797. }
  37798. }
  37799. return !(i & 1);
  37800. }
  37801. function adjustMapping(charCodeToGlyphId, properties) {
  37802. var toUnicode = properties.toUnicode;
  37803. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  37804. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  37805. var newMap = Object.create(null);
  37806. var toFontChar = [];
  37807. var usedFontCharCodes = [];
  37808. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  37809. for (var originalCharCode in charCodeToGlyphId) {
  37810. originalCharCode |= 0;
  37811. var glyphId = charCodeToGlyphId[originalCharCode];
  37812. var fontCharCode = originalCharCode;
  37813. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  37814. var unicode = toUnicode.get(fontCharCode);
  37815. if (unicode.length === 1) {
  37816. fontCharCode = unicode.charCodeAt(0);
  37817. }
  37818. }
  37819. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && isIdentityUnicode) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  37820. do {
  37821. fontCharCode = nextAvailableFontCharCode++;
  37822. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  37823. fontCharCode = 0xF020;
  37824. nextAvailableFontCharCode = fontCharCode + 1;
  37825. }
  37826. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  37827. }
  37828. newMap[fontCharCode] = glyphId;
  37829. toFontChar[originalCharCode] = fontCharCode;
  37830. usedFontCharCodes[fontCharCode] = true;
  37831. }
  37832. return {
  37833. toFontChar: toFontChar,
  37834. charCodeToGlyphId: newMap,
  37835. nextAvailableFontCharCode: nextAvailableFontCharCode
  37836. };
  37837. }
  37838. function getRanges(glyphs, numGlyphs) {
  37839. var codes = [];
  37840. for (var charCode in glyphs) {
  37841. if (glyphs[charCode] >= numGlyphs) {
  37842. continue;
  37843. }
  37844. codes.push({
  37845. fontCharCode: charCode | 0,
  37846. glyphId: glyphs[charCode]
  37847. });
  37848. }
  37849. codes.sort(function fontGetRangesSort(a, b) {
  37850. return a.fontCharCode - b.fontCharCode;
  37851. });
  37852. var ranges = [];
  37853. var length = codes.length;
  37854. for (var n = 0; n < length;) {
  37855. var start = codes[n].fontCharCode;
  37856. var codeIndices = [codes[n].glyphId];
  37857. ++n;
  37858. var end = start;
  37859. while (n < length && end + 1 === codes[n].fontCharCode) {
  37860. codeIndices.push(codes[n].glyphId);
  37861. ++end;
  37862. ++n;
  37863. if (end === 0xFFFF) {
  37864. break;
  37865. }
  37866. }
  37867. ranges.push([
  37868. start,
  37869. end,
  37870. codeIndices
  37871. ]);
  37872. }
  37873. return ranges;
  37874. }
  37875. function createCmapTable(glyphs, numGlyphs) {
  37876. var ranges = getRanges(glyphs, numGlyphs);
  37877. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  37878. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  37879. var i, ii, j, jj;
  37880. for (i = ranges.length - 1; i >= 0; --i) {
  37881. if (ranges[i][0] <= 0xFFFF) {
  37882. break;
  37883. }
  37884. }
  37885. var bmpLength = i + 1;
  37886. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  37887. ranges[i][1] = 0xFFFE;
  37888. }
  37889. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  37890. var segCount = bmpLength + trailingRangesCount;
  37891. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  37892. var startCount = '';
  37893. var endCount = '';
  37894. var idDeltas = '';
  37895. var idRangeOffsets = '';
  37896. var glyphsIds = '';
  37897. var bias = 0;
  37898. var range, start, end, codes;
  37899. for (i = 0, ii = bmpLength; i < ii; i++) {
  37900. range = ranges[i];
  37901. start = range[0];
  37902. end = range[1];
  37903. startCount += string16(start);
  37904. endCount += string16(end);
  37905. codes = range[2];
  37906. var contiguous = true;
  37907. for (j = 1, jj = codes.length; j < jj; ++j) {
  37908. if (codes[j] !== codes[j - 1] + 1) {
  37909. contiguous = false;
  37910. break;
  37911. }
  37912. }
  37913. if (!contiguous) {
  37914. var offset = (segCount - i) * 2 + bias * 2;
  37915. bias += end - start + 1;
  37916. idDeltas += string16(0);
  37917. idRangeOffsets += string16(offset);
  37918. for (j = 0, jj = codes.length; j < jj; ++j) {
  37919. glyphsIds += string16(codes[j]);
  37920. }
  37921. } else {
  37922. var startCode = codes[0];
  37923. idDeltas += string16(startCode - start & 0xFFFF);
  37924. idRangeOffsets += string16(0);
  37925. }
  37926. }
  37927. if (trailingRangesCount > 0) {
  37928. endCount += '\xFF\xFF';
  37929. startCount += '\xFF\xFF';
  37930. idDeltas += '\x00\x01';
  37931. idRangeOffsets += '\x00\x00';
  37932. }
  37933. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  37934. var format31012 = '';
  37935. var header31012 = '';
  37936. if (numTables > 1) {
  37937. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  37938. format31012 = '';
  37939. for (i = 0, ii = ranges.length; i < ii; i++) {
  37940. range = ranges[i];
  37941. start = range[0];
  37942. codes = range[2];
  37943. var code = codes[0];
  37944. for (j = 1, jj = codes.length; j < jj; ++j) {
  37945. if (codes[j] !== codes[j - 1] + 1) {
  37946. end = range[0] + j - 1;
  37947. format31012 += string32(start) + string32(end) + string32(code);
  37948. start = end + 1;
  37949. code = codes[j];
  37950. }
  37951. }
  37952. format31012 += string32(start) + string32(range[1]) + string32(code);
  37953. }
  37954. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  37955. }
  37956. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  37957. }
  37958. function validateOS2Table(os2) {
  37959. var stream = new Stream(os2.data);
  37960. var version = stream.getUint16();
  37961. stream.getBytes(60);
  37962. var selection = stream.getUint16();
  37963. if (version < 4 && selection & 0x0300) {
  37964. return false;
  37965. }
  37966. var firstChar = stream.getUint16();
  37967. var lastChar = stream.getUint16();
  37968. if (firstChar > lastChar) {
  37969. return false;
  37970. }
  37971. stream.getBytes(6);
  37972. var usWinAscent = stream.getUint16();
  37973. if (usWinAscent === 0) {
  37974. return false;
  37975. }
  37976. os2.data[8] = os2.data[9] = 0;
  37977. return true;
  37978. }
  37979. function createOS2Table(properties, charstrings, override) {
  37980. override = override || {
  37981. unitsPerEm: 0,
  37982. yMax: 0,
  37983. yMin: 0,
  37984. ascent: 0,
  37985. descent: 0
  37986. };
  37987. var ulUnicodeRange1 = 0;
  37988. var ulUnicodeRange2 = 0;
  37989. var ulUnicodeRange3 = 0;
  37990. var ulUnicodeRange4 = 0;
  37991. var firstCharIndex = null;
  37992. var lastCharIndex = 0;
  37993. if (charstrings) {
  37994. for (var code in charstrings) {
  37995. code |= 0;
  37996. if (firstCharIndex > code || !firstCharIndex) {
  37997. firstCharIndex = code;
  37998. }
  37999. if (lastCharIndex < code) {
  38000. lastCharIndex = code;
  38001. }
  38002. var position = getUnicodeRangeFor(code);
  38003. if (position < 32) {
  38004. ulUnicodeRange1 |= 1 << position;
  38005. } else if (position < 64) {
  38006. ulUnicodeRange2 |= 1 << position - 32;
  38007. } else if (position < 96) {
  38008. ulUnicodeRange3 |= 1 << position - 64;
  38009. } else if (position < 123) {
  38010. ulUnicodeRange4 |= 1 << position - 96;
  38011. } else {
  38012. error('Unicode ranges Bits > 123 are reserved for internal usage');
  38013. }
  38014. }
  38015. } else {
  38016. firstCharIndex = 0;
  38017. lastCharIndex = 255;
  38018. }
  38019. var bbox = properties.bbox || [
  38020. 0,
  38021. 0,
  38022. 0,
  38023. 0
  38024. ];
  38025. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  38026. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  38027. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  38028. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  38029. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  38030. typoDescent = -typoDescent;
  38031. }
  38032. var winAscent = override.yMax || typoAscent;
  38033. var winDescent = -override.yMin || -typoDescent;
  38034. 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';
  38035. }
  38036. function createPostTable(properties) {
  38037. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  38038. 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';
  38039. }
  38040. function createNameTable(name, proto) {
  38041. if (!proto) {
  38042. proto = [
  38043. [],
  38044. []
  38045. ];
  38046. }
  38047. var strings = [
  38048. proto[0][0] || 'Original licence',
  38049. proto[0][1] || name,
  38050. proto[0][2] || 'Unknown',
  38051. proto[0][3] || 'uniqueID',
  38052. proto[0][4] || name,
  38053. proto[0][5] || 'Version 0.11',
  38054. proto[0][6] || '',
  38055. proto[0][7] || 'Unknown',
  38056. proto[0][8] || 'Unknown',
  38057. proto[0][9] || 'Unknown'
  38058. ];
  38059. var stringsUnicode = [];
  38060. var i, ii, j, jj, str;
  38061. for (i = 0, ii = strings.length; i < ii; i++) {
  38062. str = proto[1][i] || strings[i];
  38063. var strBufUnicode = [];
  38064. for (j = 0, jj = str.length; j < jj; j++) {
  38065. strBufUnicode.push(string16(str.charCodeAt(j)));
  38066. }
  38067. stringsUnicode.push(strBufUnicode.join(''));
  38068. }
  38069. var names = [
  38070. strings,
  38071. stringsUnicode
  38072. ];
  38073. var platforms = [
  38074. '\x00\x01',
  38075. '\x00\x03'
  38076. ];
  38077. var encodings = [
  38078. '\x00\x00',
  38079. '\x00\x01'
  38080. ];
  38081. var languages = [
  38082. '\x00\x00',
  38083. '\x04\x09'
  38084. ];
  38085. var namesRecordCount = strings.length * platforms.length;
  38086. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  38087. var strOffset = 0;
  38088. for (i = 0, ii = platforms.length; i < ii; i++) {
  38089. var strs = names[i];
  38090. for (j = 0, jj = strs.length; j < jj; j++) {
  38091. str = strs[j];
  38092. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  38093. nameTable += nameRecord;
  38094. strOffset += str.length;
  38095. }
  38096. }
  38097. nameTable += strings.join('') + stringsUnicode.join('');
  38098. return nameTable;
  38099. }
  38100. Font.prototype = {
  38101. name: null,
  38102. font: null,
  38103. mimetype: null,
  38104. encoding: null,
  38105. get renderer() {
  38106. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  38107. return shadow(this, 'renderer', renderer);
  38108. },
  38109. exportData: function Font_exportData() {
  38110. var data = {};
  38111. for (var i in this) {
  38112. if (this.hasOwnProperty(i)) {
  38113. data[i] = this[i];
  38114. }
  38115. }
  38116. return data;
  38117. },
  38118. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  38119. function readTableEntry(file) {
  38120. var tag = bytesToString(file.getBytes(4));
  38121. var checksum = file.getInt32() >>> 0;
  38122. var offset = file.getInt32() >>> 0;
  38123. var length = file.getInt32() >>> 0;
  38124. var previousPosition = file.pos;
  38125. file.pos = file.start ? file.start : 0;
  38126. file.skip(offset);
  38127. var data = file.getBytes(length);
  38128. file.pos = previousPosition;
  38129. if (tag === 'head') {
  38130. data[8] = data[9] = data[10] = data[11] = 0;
  38131. data[17] |= 0x20;
  38132. }
  38133. return {
  38134. tag: tag,
  38135. checksum: checksum,
  38136. length: length,
  38137. offset: offset,
  38138. data: data
  38139. };
  38140. }
  38141. function readOpenTypeHeader(ttf) {
  38142. return {
  38143. version: bytesToString(ttf.getBytes(4)),
  38144. numTables: ttf.getUint16(),
  38145. searchRange: ttf.getUint16(),
  38146. entrySelector: ttf.getUint16(),
  38147. rangeShift: ttf.getUint16()
  38148. };
  38149. }
  38150. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  38151. if (!cmap) {
  38152. warn('No cmap table available.');
  38153. return {
  38154. platformId: -1,
  38155. encodingId: -1,
  38156. mappings: [],
  38157. hasShortCmap: false
  38158. };
  38159. }
  38160. var segment;
  38161. var start = (font.start ? font.start : 0) + cmap.offset;
  38162. font.pos = start;
  38163. var version = font.getUint16();
  38164. var numTables = font.getUint16();
  38165. var potentialTable;
  38166. var canBreak = false;
  38167. for (var i = 0; i < numTables; i++) {
  38168. var platformId = font.getUint16();
  38169. var encodingId = font.getUint16();
  38170. var offset = font.getInt32() >>> 0;
  38171. var useTable = false;
  38172. if (platformId === 0 && encodingId === 0) {
  38173. useTable = true;
  38174. } else if (platformId === 1 && encodingId === 0) {
  38175. useTable = true;
  38176. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  38177. useTable = true;
  38178. if (!isSymbolicFont) {
  38179. canBreak = true;
  38180. }
  38181. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  38182. useTable = true;
  38183. canBreak = true;
  38184. }
  38185. if (useTable) {
  38186. potentialTable = {
  38187. platformId: platformId,
  38188. encodingId: encodingId,
  38189. offset: offset
  38190. };
  38191. }
  38192. if (canBreak) {
  38193. break;
  38194. }
  38195. }
  38196. if (potentialTable) {
  38197. font.pos = start + potentialTable.offset;
  38198. }
  38199. if (!potentialTable || font.peekByte() === -1) {
  38200. warn('Could not find a preferred cmap table.');
  38201. return {
  38202. platformId: -1,
  38203. encodingId: -1,
  38204. mappings: [],
  38205. hasShortCmap: false
  38206. };
  38207. }
  38208. var format = font.getUint16();
  38209. var length = font.getUint16();
  38210. var language = font.getUint16();
  38211. var hasShortCmap = false;
  38212. var mappings = [];
  38213. var j, glyphId;
  38214. if (format === 0) {
  38215. for (j = 0; j < 256; j++) {
  38216. var index = font.getByte();
  38217. if (!index) {
  38218. continue;
  38219. }
  38220. mappings.push({
  38221. charCode: j,
  38222. glyphId: index
  38223. });
  38224. }
  38225. hasShortCmap = true;
  38226. } else if (format === 4) {
  38227. var segCount = font.getUint16() >> 1;
  38228. font.getBytes(6);
  38229. var segIndex, segments = [];
  38230. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38231. segments.push({ end: font.getUint16() });
  38232. }
  38233. font.getUint16();
  38234. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38235. segments[segIndex].start = font.getUint16();
  38236. }
  38237. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38238. segments[segIndex].delta = font.getUint16();
  38239. }
  38240. var offsetsCount = 0;
  38241. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38242. segment = segments[segIndex];
  38243. var rangeOffset = font.getUint16();
  38244. if (!rangeOffset) {
  38245. segment.offsetIndex = -1;
  38246. continue;
  38247. }
  38248. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  38249. segment.offsetIndex = offsetIndex;
  38250. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  38251. }
  38252. var offsets = [];
  38253. for (j = 0; j < offsetsCount; j++) {
  38254. offsets.push(font.getUint16());
  38255. }
  38256. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38257. segment = segments[segIndex];
  38258. start = segment.start;
  38259. var end = segment.end;
  38260. var delta = segment.delta;
  38261. offsetIndex = segment.offsetIndex;
  38262. for (j = start; j <= end; j++) {
  38263. if (j === 0xFFFF) {
  38264. continue;
  38265. }
  38266. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  38267. glyphId = glyphId + delta & 0xFFFF;
  38268. if (glyphId === 0) {
  38269. continue;
  38270. }
  38271. mappings.push({
  38272. charCode: j,
  38273. glyphId: glyphId
  38274. });
  38275. }
  38276. }
  38277. } else if (format === 6) {
  38278. var firstCode = font.getUint16();
  38279. var entryCount = font.getUint16();
  38280. for (j = 0; j < entryCount; j++) {
  38281. glyphId = font.getUint16();
  38282. var charCode = firstCode + j;
  38283. mappings.push({
  38284. charCode: charCode,
  38285. glyphId: glyphId
  38286. });
  38287. }
  38288. } else {
  38289. warn('cmap table has unsupported format: ' + format);
  38290. return {
  38291. platformId: -1,
  38292. encodingId: -1,
  38293. mappings: [],
  38294. hasShortCmap: false
  38295. };
  38296. }
  38297. mappings.sort(function (a, b) {
  38298. return a.charCode - b.charCode;
  38299. });
  38300. for (i = 1; i < mappings.length; i++) {
  38301. if (mappings[i - 1].charCode === mappings[i].charCode) {
  38302. mappings.splice(i, 1);
  38303. i--;
  38304. }
  38305. }
  38306. return {
  38307. platformId: potentialTable.platformId,
  38308. encodingId: potentialTable.encodingId,
  38309. mappings: mappings,
  38310. hasShortCmap: hasShortCmap
  38311. };
  38312. }
  38313. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  38314. if (!header) {
  38315. if (metrics) {
  38316. metrics.data = null;
  38317. }
  38318. return;
  38319. }
  38320. font.pos = (font.start ? font.start : 0) + header.offset;
  38321. font.pos += header.length - 2;
  38322. var numOfMetrics = font.getUint16();
  38323. if (numOfMetrics > numGlyphs) {
  38324. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  38325. numOfMetrics = numGlyphs;
  38326. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  38327. header.data[35] = numOfMetrics & 0x00ff;
  38328. }
  38329. var numOfSidebearings = numGlyphs - numOfMetrics;
  38330. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  38331. if (numMissing > 0) {
  38332. var entries = new Uint8Array(metrics.length + numMissing * 2);
  38333. entries.set(metrics.data);
  38334. metrics.data = entries;
  38335. }
  38336. }
  38337. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  38338. if (sourceEnd - sourceStart <= 12) {
  38339. return 0;
  38340. }
  38341. var glyf = source.subarray(sourceStart, sourceEnd);
  38342. var contoursCount = glyf[0] << 8 | glyf[1];
  38343. if (contoursCount & 0x8000) {
  38344. dest.set(glyf, destStart);
  38345. return glyf.length;
  38346. }
  38347. var i, j = 10, flagsCount = 0;
  38348. for (i = 0; i < contoursCount; i++) {
  38349. var endPoint = glyf[j] << 8 | glyf[j + 1];
  38350. flagsCount = endPoint + 1;
  38351. j += 2;
  38352. }
  38353. var instructionsStart = j;
  38354. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  38355. j += 2 + instructionsLength;
  38356. var instructionsEnd = j;
  38357. var coordinatesLength = 0;
  38358. for (i = 0; i < flagsCount; i++) {
  38359. var flag = glyf[j++];
  38360. if (flag & 0xC0) {
  38361. glyf[j - 1] = flag & 0x3F;
  38362. }
  38363. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  38364. coordinatesLength += xyLength;
  38365. if (flag & 8) {
  38366. var repeat = glyf[j++];
  38367. i += repeat;
  38368. coordinatesLength += repeat * xyLength;
  38369. }
  38370. }
  38371. if (coordinatesLength === 0) {
  38372. return 0;
  38373. }
  38374. var glyphDataLength = j + coordinatesLength;
  38375. if (glyphDataLength > glyf.length) {
  38376. return 0;
  38377. }
  38378. if (!hintsValid && instructionsLength > 0) {
  38379. dest.set(glyf.subarray(0, instructionsStart), destStart);
  38380. dest.set([
  38381. 0,
  38382. 0
  38383. ], destStart + instructionsStart);
  38384. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  38385. glyphDataLength -= instructionsLength;
  38386. if (glyf.length - glyphDataLength > 3) {
  38387. glyphDataLength = glyphDataLength + 3 & ~3;
  38388. }
  38389. return glyphDataLength;
  38390. }
  38391. if (glyf.length - glyphDataLength > 3) {
  38392. glyphDataLength = glyphDataLength + 3 & ~3;
  38393. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  38394. return glyphDataLength;
  38395. }
  38396. dest.set(glyf, destStart);
  38397. return glyf.length;
  38398. }
  38399. function sanitizeHead(head, numGlyphs, locaLength) {
  38400. var data = head.data;
  38401. var version = int32(data[0], data[1], data[2], data[3]);
  38402. if (version >> 16 !== 1) {
  38403. info('Attempting to fix invalid version in head table: ' + version);
  38404. data[0] = 0;
  38405. data[1] = 1;
  38406. data[2] = 0;
  38407. data[3] = 0;
  38408. }
  38409. var indexToLocFormat = int16(data[50], data[51]);
  38410. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  38411. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  38412. var numGlyphsPlusOne = numGlyphs + 1;
  38413. if (locaLength === numGlyphsPlusOne << 1) {
  38414. data[50] = 0;
  38415. data[51] = 0;
  38416. } else if (locaLength === numGlyphsPlusOne << 2) {
  38417. data[50] = 0;
  38418. data[51] = 1;
  38419. } else {
  38420. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  38421. }
  38422. }
  38423. }
  38424. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  38425. var itemSize, itemDecode, itemEncode;
  38426. if (isGlyphLocationsLong) {
  38427. itemSize = 4;
  38428. itemDecode = function fontItemDecodeLong(data, offset) {
  38429. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  38430. };
  38431. itemEncode = function fontItemEncodeLong(data, offset, value) {
  38432. data[offset] = value >>> 24 & 0xFF;
  38433. data[offset + 1] = value >> 16 & 0xFF;
  38434. data[offset + 2] = value >> 8 & 0xFF;
  38435. data[offset + 3] = value & 0xFF;
  38436. };
  38437. } else {
  38438. itemSize = 2;
  38439. itemDecode = function fontItemDecode(data, offset) {
  38440. return data[offset] << 9 | data[offset + 1] << 1;
  38441. };
  38442. itemEncode = function fontItemEncode(data, offset, value) {
  38443. data[offset] = value >> 9 & 0xFF;
  38444. data[offset + 1] = value >> 1 & 0xFF;
  38445. };
  38446. }
  38447. var locaData = loca.data;
  38448. var locaDataSize = itemSize * (1 + numGlyphs);
  38449. if (locaData.length !== locaDataSize) {
  38450. locaData = new Uint8Array(locaDataSize);
  38451. locaData.set(loca.data.subarray(0, locaDataSize));
  38452. loca.data = locaData;
  38453. }
  38454. var oldGlyfData = glyf.data;
  38455. var oldGlyfDataLength = oldGlyfData.length;
  38456. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  38457. var startOffset = itemDecode(locaData, 0);
  38458. var writeOffset = 0;
  38459. var missingGlyphData = Object.create(null);
  38460. itemEncode(locaData, 0, writeOffset);
  38461. var i, j;
  38462. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  38463. var endOffset = itemDecode(locaData, j);
  38464. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  38465. endOffset = oldGlyfDataLength;
  38466. }
  38467. if (endOffset > oldGlyfDataLength) {
  38468. itemEncode(locaData, j, writeOffset);
  38469. startOffset = endOffset;
  38470. continue;
  38471. }
  38472. if (startOffset === endOffset) {
  38473. missingGlyphData[i] = true;
  38474. }
  38475. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  38476. writeOffset += newLength;
  38477. itemEncode(locaData, j, writeOffset);
  38478. startOffset = endOffset;
  38479. }
  38480. if (writeOffset === 0) {
  38481. var simpleGlyph = new Uint8Array([
  38482. 0,
  38483. 1,
  38484. 0,
  38485. 0,
  38486. 0,
  38487. 0,
  38488. 0,
  38489. 0,
  38490. 0,
  38491. 0,
  38492. 0,
  38493. 0,
  38494. 0,
  38495. 0,
  38496. 49,
  38497. 0
  38498. ]);
  38499. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  38500. itemEncode(locaData, j, simpleGlyph.length);
  38501. }
  38502. glyf.data = simpleGlyph;
  38503. return missingGlyphData;
  38504. }
  38505. if (dupFirstEntry) {
  38506. var firstEntryLength = itemDecode(locaData, itemSize);
  38507. if (newGlyfData.length > firstEntryLength + writeOffset) {
  38508. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  38509. } else {
  38510. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  38511. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  38512. }
  38513. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  38514. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  38515. } else {
  38516. glyf.data = newGlyfData.subarray(0, writeOffset);
  38517. }
  38518. return missingGlyphData;
  38519. }
  38520. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  38521. var start = (font.start ? font.start : 0) + post.offset;
  38522. font.pos = start;
  38523. var length = post.length, end = start + length;
  38524. var version = font.getInt32();
  38525. font.getBytes(28);
  38526. var glyphNames;
  38527. var valid = true;
  38528. var i;
  38529. switch (version) {
  38530. case 0x00010000:
  38531. glyphNames = MacStandardGlyphOrdering;
  38532. break;
  38533. case 0x00020000:
  38534. var numGlyphs = font.getUint16();
  38535. if (numGlyphs !== maxpNumGlyphs) {
  38536. valid = false;
  38537. break;
  38538. }
  38539. var glyphNameIndexes = [];
  38540. for (i = 0; i < numGlyphs; ++i) {
  38541. var index = font.getUint16();
  38542. if (index >= 32768) {
  38543. valid = false;
  38544. break;
  38545. }
  38546. glyphNameIndexes.push(index);
  38547. }
  38548. if (!valid) {
  38549. break;
  38550. }
  38551. var customNames = [];
  38552. var strBuf = [];
  38553. while (font.pos < end) {
  38554. var stringLength = font.getByte();
  38555. strBuf.length = stringLength;
  38556. for (i = 0; i < stringLength; ++i) {
  38557. strBuf[i] = String.fromCharCode(font.getByte());
  38558. }
  38559. customNames.push(strBuf.join(''));
  38560. }
  38561. glyphNames = [];
  38562. for (i = 0; i < numGlyphs; ++i) {
  38563. var j = glyphNameIndexes[i];
  38564. if (j < 258) {
  38565. glyphNames.push(MacStandardGlyphOrdering[j]);
  38566. continue;
  38567. }
  38568. glyphNames.push(customNames[j - 258]);
  38569. }
  38570. break;
  38571. case 0x00030000:
  38572. break;
  38573. default:
  38574. warn('Unknown/unsupported post table version ' + version);
  38575. valid = false;
  38576. if (properties.defaultEncoding) {
  38577. glyphNames = properties.defaultEncoding;
  38578. }
  38579. break;
  38580. }
  38581. properties.glyphNames = glyphNames;
  38582. return valid;
  38583. }
  38584. function readNameTable(nameTable) {
  38585. var start = (font.start ? font.start : 0) + nameTable.offset;
  38586. font.pos = start;
  38587. var names = [
  38588. [],
  38589. []
  38590. ];
  38591. var length = nameTable.length, end = start + length;
  38592. var format = font.getUint16();
  38593. var FORMAT_0_HEADER_LENGTH = 6;
  38594. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  38595. return names;
  38596. }
  38597. var numRecords = font.getUint16();
  38598. var stringsStart = font.getUint16();
  38599. var records = [];
  38600. var NAME_RECORD_LENGTH = 12;
  38601. var i, ii;
  38602. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  38603. var r = {
  38604. platform: font.getUint16(),
  38605. encoding: font.getUint16(),
  38606. language: font.getUint16(),
  38607. name: font.getUint16(),
  38608. length: font.getUint16(),
  38609. offset: font.getUint16()
  38610. };
  38611. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  38612. records.push(r);
  38613. }
  38614. }
  38615. for (i = 0, ii = records.length; i < ii; i++) {
  38616. var record = records[i];
  38617. if (record.length <= 0) {
  38618. continue;
  38619. }
  38620. var pos = start + stringsStart + record.offset;
  38621. if (pos + record.length > end) {
  38622. continue;
  38623. }
  38624. font.pos = pos;
  38625. var nameIndex = record.name;
  38626. if (record.encoding) {
  38627. var str = '';
  38628. for (var j = 0, jj = record.length; j < jj; j += 2) {
  38629. str += String.fromCharCode(font.getUint16());
  38630. }
  38631. names[1][nameIndex] = str;
  38632. } else {
  38633. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  38634. }
  38635. }
  38636. return names;
  38637. }
  38638. var TTOpsStackDeltas = [
  38639. 0,
  38640. 0,
  38641. 0,
  38642. 0,
  38643. 0,
  38644. 0,
  38645. 0,
  38646. 0,
  38647. -2,
  38648. -2,
  38649. -2,
  38650. -2,
  38651. 0,
  38652. 0,
  38653. -2,
  38654. -5,
  38655. -1,
  38656. -1,
  38657. -1,
  38658. -1,
  38659. -1,
  38660. -1,
  38661. -1,
  38662. -1,
  38663. 0,
  38664. 0,
  38665. -1,
  38666. 0,
  38667. -1,
  38668. -1,
  38669. -1,
  38670. -1,
  38671. 1,
  38672. -1,
  38673. -999,
  38674. 0,
  38675. 1,
  38676. 0,
  38677. -1,
  38678. -2,
  38679. 0,
  38680. -1,
  38681. -2,
  38682. -1,
  38683. -1,
  38684. 0,
  38685. -1,
  38686. -1,
  38687. 0,
  38688. 0,
  38689. -999,
  38690. -999,
  38691. -1,
  38692. -1,
  38693. -1,
  38694. -1,
  38695. -2,
  38696. -999,
  38697. -2,
  38698. -2,
  38699. -999,
  38700. 0,
  38701. -2,
  38702. -2,
  38703. 0,
  38704. 0,
  38705. -2,
  38706. 0,
  38707. -2,
  38708. 0,
  38709. 0,
  38710. 0,
  38711. -2,
  38712. -1,
  38713. -1,
  38714. 1,
  38715. 1,
  38716. 0,
  38717. 0,
  38718. -1,
  38719. -1,
  38720. -1,
  38721. -1,
  38722. -1,
  38723. -1,
  38724. -1,
  38725. 0,
  38726. 0,
  38727. -1,
  38728. 0,
  38729. -1,
  38730. -1,
  38731. 0,
  38732. -999,
  38733. -1,
  38734. -1,
  38735. -1,
  38736. -1,
  38737. -1,
  38738. -1,
  38739. 0,
  38740. 0,
  38741. 0,
  38742. 0,
  38743. 0,
  38744. 0,
  38745. 0,
  38746. 0,
  38747. 0,
  38748. 0,
  38749. 0,
  38750. 0,
  38751. -2,
  38752. -999,
  38753. -999,
  38754. -999,
  38755. -999,
  38756. -999,
  38757. -1,
  38758. -1,
  38759. -2,
  38760. -2,
  38761. 0,
  38762. 0,
  38763. 0,
  38764. 0,
  38765. -1,
  38766. -1,
  38767. -999,
  38768. -2,
  38769. -2,
  38770. 0,
  38771. 0,
  38772. -1,
  38773. -2,
  38774. -2,
  38775. 0,
  38776. 0,
  38777. 0,
  38778. -1,
  38779. -1,
  38780. -1,
  38781. -2
  38782. ];
  38783. function sanitizeTTProgram(table, ttContext) {
  38784. var data = table.data;
  38785. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  38786. var stack = [];
  38787. var callstack = [];
  38788. var functionsCalled = [];
  38789. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  38790. var inFDEF = false, ifLevel = 0, inELSE = 0;
  38791. for (var ii = data.length; i < ii;) {
  38792. var op = data[i++];
  38793. if (op === 0x40) {
  38794. n = data[i++];
  38795. if (inFDEF || inELSE) {
  38796. i += n;
  38797. } else {
  38798. for (j = 0; j < n; j++) {
  38799. stack.push(data[i++]);
  38800. }
  38801. }
  38802. } else if (op === 0x41) {
  38803. n = data[i++];
  38804. if (inFDEF || inELSE) {
  38805. i += n * 2;
  38806. } else {
  38807. for (j = 0; j < n; j++) {
  38808. b = data[i++];
  38809. stack.push(b << 8 | data[i++]);
  38810. }
  38811. }
  38812. } else if ((op & 0xF8) === 0xB0) {
  38813. n = op - 0xB0 + 1;
  38814. if (inFDEF || inELSE) {
  38815. i += n;
  38816. } else {
  38817. for (j = 0; j < n; j++) {
  38818. stack.push(data[i++]);
  38819. }
  38820. }
  38821. } else if ((op & 0xF8) === 0xB8) {
  38822. n = op - 0xB8 + 1;
  38823. if (inFDEF || inELSE) {
  38824. i += n * 2;
  38825. } else {
  38826. for (j = 0; j < n; j++) {
  38827. b = data[i++];
  38828. stack.push(b << 8 | data[i++]);
  38829. }
  38830. }
  38831. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  38832. if (!inFDEF && !inELSE) {
  38833. funcId = stack[stack.length - 1];
  38834. ttContext.functionsUsed[funcId] = true;
  38835. if (funcId in ttContext.functionsStackDeltas) {
  38836. stack.length += ttContext.functionsStackDeltas[funcId];
  38837. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  38838. callstack.push({
  38839. data: data,
  38840. i: i,
  38841. stackTop: stack.length - 1
  38842. });
  38843. functionsCalled.push(funcId);
  38844. pc = ttContext.functionsDefined[funcId];
  38845. if (!pc) {
  38846. warn('TT: CALL non-existent function');
  38847. ttContext.hintsValid = false;
  38848. return;
  38849. }
  38850. data = pc.data;
  38851. i = pc.i;
  38852. }
  38853. }
  38854. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  38855. if (inFDEF || inELSE) {
  38856. warn('TT: nested FDEFs not allowed');
  38857. tooComplexToFollowFunctions = true;
  38858. }
  38859. inFDEF = true;
  38860. lastDeff = i;
  38861. funcId = stack.pop();
  38862. ttContext.functionsDefined[funcId] = {
  38863. data: data,
  38864. i: i
  38865. };
  38866. } else if (op === 0x2D) {
  38867. if (inFDEF) {
  38868. inFDEF = false;
  38869. lastEndf = i;
  38870. } else {
  38871. pc = callstack.pop();
  38872. if (!pc) {
  38873. warn('TT: ENDF bad stack');
  38874. ttContext.hintsValid = false;
  38875. return;
  38876. }
  38877. funcId = functionsCalled.pop();
  38878. data = pc.data;
  38879. i = pc.i;
  38880. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  38881. }
  38882. } else if (op === 0x89) {
  38883. if (inFDEF || inELSE) {
  38884. warn('TT: nested IDEFs not allowed');
  38885. tooComplexToFollowFunctions = true;
  38886. }
  38887. inFDEF = true;
  38888. lastDeff = i;
  38889. } else if (op === 0x58) {
  38890. ++ifLevel;
  38891. } else if (op === 0x1B) {
  38892. inELSE = ifLevel;
  38893. } else if (op === 0x59) {
  38894. if (inELSE === ifLevel) {
  38895. inELSE = 0;
  38896. }
  38897. --ifLevel;
  38898. } else if (op === 0x1C) {
  38899. if (!inFDEF && !inELSE) {
  38900. var offset = stack[stack.length - 1];
  38901. if (offset > 0) {
  38902. i += offset - 1;
  38903. }
  38904. }
  38905. }
  38906. if (!inFDEF && !inELSE) {
  38907. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  38908. if (op >= 0x71 && op <= 0x75) {
  38909. n = stack.pop();
  38910. if (n === n) {
  38911. stackDelta = -n * 2;
  38912. }
  38913. }
  38914. while (stackDelta < 0 && stack.length > 0) {
  38915. stack.pop();
  38916. stackDelta++;
  38917. }
  38918. while (stackDelta > 0) {
  38919. stack.push(NaN);
  38920. stackDelta--;
  38921. }
  38922. }
  38923. }
  38924. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  38925. var content = [data];
  38926. if (i > data.length) {
  38927. content.push(new Uint8Array(i - data.length));
  38928. }
  38929. if (lastDeff > lastEndf) {
  38930. warn('TT: complementing a missing function tail');
  38931. content.push(new Uint8Array([
  38932. 0x22,
  38933. 0x2D
  38934. ]));
  38935. }
  38936. foldTTTable(table, content);
  38937. }
  38938. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  38939. if (ttContext.tooComplexToFollowFunctions) {
  38940. return;
  38941. }
  38942. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  38943. warn('TT: more functions defined than expected');
  38944. ttContext.hintsValid = false;
  38945. return;
  38946. }
  38947. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  38948. if (j > maxFunctionDefs) {
  38949. warn('TT: invalid function id: ' + j);
  38950. ttContext.hintsValid = false;
  38951. return;
  38952. }
  38953. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  38954. warn('TT: undefined function: ' + j);
  38955. ttContext.hintsValid = false;
  38956. return;
  38957. }
  38958. }
  38959. }
  38960. function foldTTTable(table, content) {
  38961. if (content.length > 1) {
  38962. var newLength = 0;
  38963. var j, jj;
  38964. for (j = 0, jj = content.length; j < jj; j++) {
  38965. newLength += content[j].length;
  38966. }
  38967. newLength = newLength + 3 & ~3;
  38968. var result = new Uint8Array(newLength);
  38969. var pos = 0;
  38970. for (j = 0, jj = content.length; j < jj; j++) {
  38971. result.set(content[j], pos);
  38972. pos += content[j].length;
  38973. }
  38974. table.data = result;
  38975. table.length = newLength;
  38976. }
  38977. }
  38978. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  38979. var ttContext = {
  38980. functionsDefined: [],
  38981. functionsUsed: [],
  38982. functionsStackDeltas: [],
  38983. tooComplexToFollowFunctions: false,
  38984. hintsValid: true
  38985. };
  38986. if (fpgm) {
  38987. sanitizeTTProgram(fpgm, ttContext);
  38988. }
  38989. if (prep) {
  38990. sanitizeTTProgram(prep, ttContext);
  38991. }
  38992. if (fpgm) {
  38993. checkInvalidFunctions(ttContext, maxFunctionDefs);
  38994. }
  38995. if (cvt && cvt.length & 1) {
  38996. var cvtData = new Uint8Array(cvt.length + 1);
  38997. cvtData.set(cvt.data);
  38998. cvt.data = cvtData;
  38999. }
  39000. return ttContext.hintsValid;
  39001. }
  39002. font = new Stream(new Uint8Array(font.getBytes()));
  39003. var VALID_TABLES = [
  39004. 'OS/2',
  39005. 'cmap',
  39006. 'head',
  39007. 'hhea',
  39008. 'hmtx',
  39009. 'maxp',
  39010. 'name',
  39011. 'post',
  39012. 'loca',
  39013. 'glyf',
  39014. 'fpgm',
  39015. 'prep',
  39016. 'cvt ',
  39017. 'CFF '
  39018. ];
  39019. var header = readOpenTypeHeader(font);
  39020. var numTables = header.numTables;
  39021. var cff, cffFile;
  39022. var tables = Object.create(null);
  39023. tables['OS/2'] = null;
  39024. tables['cmap'] = null;
  39025. tables['head'] = null;
  39026. tables['hhea'] = null;
  39027. tables['hmtx'] = null;
  39028. tables['maxp'] = null;
  39029. tables['name'] = null;
  39030. tables['post'] = null;
  39031. var table;
  39032. for (var i = 0; i < numTables; i++) {
  39033. table = readTableEntry(font);
  39034. if (VALID_TABLES.indexOf(table.tag) < 0) {
  39035. continue;
  39036. }
  39037. if (table.length === 0) {
  39038. continue;
  39039. }
  39040. tables[table.tag] = table;
  39041. }
  39042. var isTrueType = !tables['CFF '];
  39043. if (!isTrueType) {
  39044. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  39045. cffFile = new Stream(tables['CFF '].data);
  39046. cff = new CFFFont(cffFile, properties);
  39047. adjustWidths(properties);
  39048. return this.convert(name, cff, properties);
  39049. }
  39050. delete tables['glyf'];
  39051. delete tables['loca'];
  39052. delete tables['fpgm'];
  39053. delete tables['prep'];
  39054. delete tables['cvt '];
  39055. this.isOpenType = true;
  39056. } else {
  39057. if (!tables['loca']) {
  39058. error('Required "loca" table is not found');
  39059. }
  39060. if (!tables['glyf']) {
  39061. warn('Required "glyf" table is not found -- trying to recover.');
  39062. tables['glyf'] = {
  39063. tag: 'glyf',
  39064. data: new Uint8Array(0)
  39065. };
  39066. }
  39067. this.isOpenType = false;
  39068. }
  39069. if (!tables['maxp']) {
  39070. error('Required "maxp" table is not found');
  39071. }
  39072. font.pos = (font.start || 0) + tables['maxp'].offset;
  39073. var version = font.getInt32();
  39074. var numGlyphs = font.getUint16();
  39075. var maxFunctionDefs = 0;
  39076. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  39077. font.pos += 8;
  39078. var maxZones = font.getUint16();
  39079. if (maxZones > 2) {
  39080. tables['maxp'].data[14] = 0;
  39081. tables['maxp'].data[15] = 2;
  39082. }
  39083. font.pos += 4;
  39084. maxFunctionDefs = font.getUint16();
  39085. }
  39086. var dupFirstEntry = false;
  39087. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  39088. dupFirstEntry = true;
  39089. numGlyphs++;
  39090. tables['maxp'].data[4] = numGlyphs >> 8;
  39091. tables['maxp'].data[5] = numGlyphs & 255;
  39092. }
  39093. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  39094. if (!hintsValid) {
  39095. delete tables['fpgm'];
  39096. delete tables['prep'];
  39097. delete tables['cvt '];
  39098. }
  39099. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  39100. if (!tables['head']) {
  39101. error('Required "head" table is not found');
  39102. }
  39103. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  39104. var missingGlyphs = Object.create(null);
  39105. if (isTrueType) {
  39106. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  39107. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  39108. }
  39109. if (!tables['hhea']) {
  39110. error('Required "hhea" table is not found');
  39111. }
  39112. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  39113. tables['hhea'].data[10] = 0xFF;
  39114. tables['hhea'].data[11] = 0xFF;
  39115. }
  39116. var metricsOverride = {
  39117. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  39118. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  39119. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  39120. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  39121. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  39122. };
  39123. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  39124. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  39125. if (tables['post']) {
  39126. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  39127. if (!valid) {
  39128. tables['post'] = null;
  39129. }
  39130. }
  39131. var charCodeToGlyphId = [], charCode;
  39132. var toUnicode = properties.toUnicode, widths = properties.widths;
  39133. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  39134. function hasGlyph(glyphId, charCode, widthCode) {
  39135. if (!missingGlyphs[glyphId]) {
  39136. return true;
  39137. }
  39138. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  39139. return true;
  39140. }
  39141. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  39142. return true;
  39143. }
  39144. return false;
  39145. }
  39146. if (properties.type === 'CIDFontType2') {
  39147. var cidToGidMap = properties.cidToGidMap || [];
  39148. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  39149. properties.cMap.forEach(function (charCode, cid) {
  39150. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  39151. var glyphId = -1;
  39152. if (isCidToGidMapEmpty) {
  39153. glyphId = cid;
  39154. } else if (cidToGidMap[cid] !== undefined) {
  39155. glyphId = cidToGidMap[cid];
  39156. }
  39157. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  39158. charCodeToGlyphId[charCode] = glyphId;
  39159. }
  39160. });
  39161. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  39162. charCodeToGlyphId[0] = numGlyphs - 1;
  39163. }
  39164. } else {
  39165. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  39166. var cmapPlatformId = cmapTable.platformId;
  39167. var cmapEncodingId = cmapTable.encodingId;
  39168. var cmapMappings = cmapTable.mappings;
  39169. var cmapMappingsLength = cmapMappings.length;
  39170. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  39171. var baseEncoding = [];
  39172. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  39173. baseEncoding = getEncoding(properties.baseEncodingName);
  39174. }
  39175. var glyphsUnicodeMap = getGlyphsUnicode();
  39176. for (charCode = 0; charCode < 256; charCode++) {
  39177. var glyphName, standardGlyphName;
  39178. if (this.differences && charCode in this.differences) {
  39179. glyphName = this.differences[charCode];
  39180. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  39181. glyphName = baseEncoding[charCode];
  39182. } else {
  39183. glyphName = StandardEncoding[charCode];
  39184. }
  39185. if (!glyphName) {
  39186. continue;
  39187. }
  39188. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  39189. var unicodeOrCharCode, isUnicode = false;
  39190. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  39191. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  39192. isUnicode = true;
  39193. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  39194. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  39195. }
  39196. var found = false;
  39197. for (i = 0; i < cmapMappingsLength; ++i) {
  39198. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  39199. continue;
  39200. }
  39201. var code = isUnicode ? charCode : unicodeOrCharCode;
  39202. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  39203. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  39204. found = true;
  39205. break;
  39206. }
  39207. }
  39208. if (!found && properties.glyphNames) {
  39209. var glyphId = properties.glyphNames.indexOf(glyphName);
  39210. if (glyphId === -1 && standardGlyphName !== glyphName) {
  39211. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  39212. }
  39213. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  39214. charCodeToGlyphId[charCode] = glyphId;
  39215. found = true;
  39216. }
  39217. }
  39218. if (!found) {
  39219. charCodeToGlyphId[charCode] = 0;
  39220. }
  39221. }
  39222. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  39223. for (i = 0; i < cmapMappingsLength; ++i) {
  39224. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  39225. }
  39226. } else {
  39227. for (i = 0; i < cmapMappingsLength; ++i) {
  39228. charCode = cmapMappings[i].charCode & 0xFF;
  39229. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  39230. }
  39231. }
  39232. }
  39233. if (charCodeToGlyphId.length === 0) {
  39234. charCodeToGlyphId[0] = 0;
  39235. }
  39236. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  39237. this.toFontChar = newMapping.toFontChar;
  39238. tables['cmap'] = {
  39239. tag: 'cmap',
  39240. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  39241. };
  39242. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  39243. tables['OS/2'] = {
  39244. tag: 'OS/2',
  39245. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  39246. };
  39247. }
  39248. if (!tables['post']) {
  39249. tables['post'] = {
  39250. tag: 'post',
  39251. data: createPostTable(properties)
  39252. };
  39253. }
  39254. if (!isTrueType) {
  39255. try {
  39256. cffFile = new Stream(tables['CFF '].data);
  39257. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  39258. cff = parser.parse();
  39259. var compiler = new CFFCompiler(cff);
  39260. tables['CFF '].data = compiler.compile();
  39261. } catch (e) {
  39262. warn('Failed to compile font ' + properties.loadedName);
  39263. }
  39264. }
  39265. if (!tables['name']) {
  39266. tables['name'] = {
  39267. tag: 'name',
  39268. data: createNameTable(this.name)
  39269. };
  39270. } else {
  39271. var namePrototype = readNameTable(tables['name']);
  39272. tables['name'].data = createNameTable(name, namePrototype);
  39273. }
  39274. var builder = new OpenTypeFileBuilder(header.version);
  39275. for (var tableTag in tables) {
  39276. builder.addTable(tableTag, tables[tableTag].data);
  39277. }
  39278. return builder.toArray();
  39279. },
  39280. convert: function Font_convert(fontName, font, properties) {
  39281. properties.fixedPitch = false;
  39282. if (properties.builtInEncoding) {
  39283. adjustToUnicode(properties, properties.builtInEncoding);
  39284. }
  39285. var mapping = font.getGlyphMapping(properties);
  39286. var newMapping = adjustMapping(mapping, properties);
  39287. this.toFontChar = newMapping.toFontChar;
  39288. var numGlyphs = font.numGlyphs;
  39289. function getCharCodes(charCodeToGlyphId, glyphId) {
  39290. var charCodes = null;
  39291. for (var charCode in charCodeToGlyphId) {
  39292. if (glyphId === charCodeToGlyphId[charCode]) {
  39293. if (!charCodes) {
  39294. charCodes = [];
  39295. }
  39296. charCodes.push(charCode | 0);
  39297. }
  39298. }
  39299. return charCodes;
  39300. }
  39301. function createCharCode(charCodeToGlyphId, glyphId) {
  39302. for (var charCode in charCodeToGlyphId) {
  39303. if (glyphId === charCodeToGlyphId[charCode]) {
  39304. return charCode | 0;
  39305. }
  39306. }
  39307. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  39308. return newMapping.nextAvailableFontCharCode++;
  39309. }
  39310. var seacs = font.seacs;
  39311. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  39312. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  39313. var charset = font.getCharset();
  39314. var seacMap = Object.create(null);
  39315. for (var glyphId in seacs) {
  39316. glyphId |= 0;
  39317. var seac = seacs[glyphId];
  39318. var baseGlyphName = StandardEncoding[seac[2]];
  39319. var accentGlyphName = StandardEncoding[seac[3]];
  39320. var baseGlyphId = charset.indexOf(baseGlyphName);
  39321. var accentGlyphId = charset.indexOf(accentGlyphName);
  39322. if (baseGlyphId < 0 || accentGlyphId < 0) {
  39323. continue;
  39324. }
  39325. var accentOffset = {
  39326. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  39327. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  39328. };
  39329. var charCodes = getCharCodes(mapping, glyphId);
  39330. if (!charCodes) {
  39331. continue;
  39332. }
  39333. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  39334. var charCode = charCodes[i];
  39335. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  39336. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  39337. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  39338. seacMap[charCode] = {
  39339. baseFontCharCode: baseFontCharCode,
  39340. accentFontCharCode: accentFontCharCode,
  39341. accentOffset: accentOffset
  39342. };
  39343. }
  39344. }
  39345. properties.seacMap = seacMap;
  39346. }
  39347. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  39348. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  39349. builder.addTable('CFF ', font.data);
  39350. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  39351. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  39352. 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');
  39353. 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));
  39354. builder.addTable('hmtx', function fontFieldsHmtx() {
  39355. var charstrings = font.charstrings;
  39356. var cffWidths = font.cff ? font.cff.widths : null;
  39357. var hmtx = '\x00\x00\x00\x00';
  39358. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  39359. var width = 0;
  39360. if (charstrings) {
  39361. var charstring = charstrings[i - 1];
  39362. width = 'width' in charstring ? charstring.width : 0;
  39363. } else if (cffWidths) {
  39364. width = Math.ceil(cffWidths[i] || 0);
  39365. }
  39366. hmtx += string16(width) + string16(0);
  39367. }
  39368. return hmtx;
  39369. }());
  39370. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  39371. builder.addTable('name', createNameTable(fontName));
  39372. builder.addTable('post', createPostTable(properties));
  39373. return builder.toArray();
  39374. },
  39375. get spaceWidth() {
  39376. if ('_shadowWidth' in this) {
  39377. return this._shadowWidth;
  39378. }
  39379. var possibleSpaceReplacements = [
  39380. 'space',
  39381. 'minus',
  39382. 'one',
  39383. 'i',
  39384. 'I'
  39385. ];
  39386. var width;
  39387. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  39388. var glyphName = possibleSpaceReplacements[i];
  39389. if (glyphName in this.widths) {
  39390. width = this.widths[glyphName];
  39391. break;
  39392. }
  39393. var glyphsUnicodeMap = getGlyphsUnicode();
  39394. var glyphUnicode = glyphsUnicodeMap[glyphName];
  39395. var charcode = 0;
  39396. if (this.composite) {
  39397. if (this.cMap.contains(glyphUnicode)) {
  39398. charcode = this.cMap.lookup(glyphUnicode);
  39399. }
  39400. }
  39401. if (!charcode && this.toUnicode) {
  39402. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  39403. }
  39404. if (charcode <= 0) {
  39405. charcode = glyphUnicode;
  39406. }
  39407. width = this.widths[charcode];
  39408. if (width) {
  39409. break;
  39410. }
  39411. }
  39412. width = width || this.defaultWidth;
  39413. this._shadowWidth = width;
  39414. return width;
  39415. },
  39416. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  39417. var fontCharCode, width, operatorListId;
  39418. var widthCode = charcode;
  39419. if (this.cMap && this.cMap.contains(charcode)) {
  39420. widthCode = this.cMap.lookup(charcode);
  39421. }
  39422. width = this.widths[widthCode];
  39423. width = isNum(width) ? width : this.defaultWidth;
  39424. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  39425. var unicode = this.toUnicode.get(charcode) || charcode;
  39426. if (typeof unicode === 'number') {
  39427. unicode = String.fromCharCode(unicode);
  39428. }
  39429. var isInFont = charcode in this.toFontChar;
  39430. fontCharCode = this.toFontChar[charcode] || charcode;
  39431. if (this.missingFile) {
  39432. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  39433. }
  39434. if (this.isType3Font) {
  39435. operatorListId = fontCharCode;
  39436. }
  39437. var accent = null;
  39438. if (this.seacMap && this.seacMap[charcode]) {
  39439. isInFont = true;
  39440. var seac = this.seacMap[charcode];
  39441. fontCharCode = seac.baseFontCharCode;
  39442. accent = {
  39443. fontChar: String.fromCharCode(seac.accentFontCharCode),
  39444. offset: seac.accentOffset
  39445. };
  39446. }
  39447. var fontChar = String.fromCharCode(fontCharCode);
  39448. var glyph = this.glyphCache[charcode];
  39449. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  39450. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  39451. this.glyphCache[charcode] = glyph;
  39452. }
  39453. return glyph;
  39454. },
  39455. charsToGlyphs: function Font_charsToGlyphs(chars) {
  39456. var charsCache = this.charsCache;
  39457. var glyphs, glyph, charcode;
  39458. if (charsCache) {
  39459. glyphs = charsCache[chars];
  39460. if (glyphs) {
  39461. return glyphs;
  39462. }
  39463. }
  39464. if (!charsCache) {
  39465. charsCache = this.charsCache = Object.create(null);
  39466. }
  39467. glyphs = [];
  39468. var charsCacheKey = chars;
  39469. var i = 0, ii;
  39470. if (this.cMap) {
  39471. var c = Object.create(null);
  39472. while (i < chars.length) {
  39473. this.cMap.readCharCode(chars, i, c);
  39474. charcode = c.charcode;
  39475. var length = c.length;
  39476. i += length;
  39477. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  39478. glyph = this.charToGlyph(charcode, isSpace);
  39479. glyphs.push(glyph);
  39480. }
  39481. } else {
  39482. for (i = 0, ii = chars.length; i < ii; ++i) {
  39483. charcode = chars.charCodeAt(i);
  39484. glyph = this.charToGlyph(charcode, charcode === 0x20);
  39485. glyphs.push(glyph);
  39486. }
  39487. }
  39488. return charsCache[charsCacheKey] = glyphs;
  39489. }
  39490. };
  39491. return Font;
  39492. }();
  39493. var ErrorFont = function ErrorFontClosure() {
  39494. function ErrorFont(error) {
  39495. this.error = error;
  39496. this.loadedName = 'g_font_error';
  39497. this.loading = false;
  39498. }
  39499. ErrorFont.prototype = {
  39500. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  39501. return [];
  39502. },
  39503. exportData: function ErrorFont_exportData() {
  39504. return { error: this.error };
  39505. }
  39506. };
  39507. return ErrorFont;
  39508. }();
  39509. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  39510. var charCodeToGlyphId = Object.create(null);
  39511. var glyphId, charCode, baseEncoding;
  39512. if (properties.baseEncodingName) {
  39513. baseEncoding = getEncoding(properties.baseEncodingName);
  39514. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  39515. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  39516. if (glyphId >= 0) {
  39517. charCodeToGlyphId[charCode] = glyphId;
  39518. } else {
  39519. charCodeToGlyphId[charCode] = 0;
  39520. }
  39521. }
  39522. } else if (!!(properties.flags & FontFlags.Symbolic)) {
  39523. for (charCode in builtInEncoding) {
  39524. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  39525. }
  39526. } else {
  39527. baseEncoding = StandardEncoding;
  39528. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  39529. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  39530. if (glyphId >= 0) {
  39531. charCodeToGlyphId[charCode] = glyphId;
  39532. } else {
  39533. charCodeToGlyphId[charCode] = 0;
  39534. }
  39535. }
  39536. }
  39537. var differences = properties.differences, glyphsUnicodeMap;
  39538. if (differences) {
  39539. for (charCode in differences) {
  39540. var glyphName = differences[charCode];
  39541. glyphId = glyphNames.indexOf(glyphName);
  39542. if (glyphId === -1) {
  39543. if (!glyphsUnicodeMap) {
  39544. glyphsUnicodeMap = getGlyphsUnicode();
  39545. }
  39546. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  39547. if (standardGlyphName !== glyphName) {
  39548. glyphId = glyphNames.indexOf(standardGlyphName);
  39549. }
  39550. }
  39551. if (glyphId >= 0) {
  39552. charCodeToGlyphId[charCode] = glyphId;
  39553. } else {
  39554. charCodeToGlyphId[charCode] = 0;
  39555. }
  39556. }
  39557. }
  39558. return charCodeToGlyphId;
  39559. }
  39560. var Type1Font = function Type1FontClosure() {
  39561. function findBlock(streamBytes, signature, startIndex) {
  39562. var streamBytesLength = streamBytes.length;
  39563. var signatureLength = signature.length;
  39564. var scanLength = streamBytesLength - signatureLength;
  39565. var i = startIndex, j, found = false;
  39566. while (i < scanLength) {
  39567. j = 0;
  39568. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  39569. j++;
  39570. }
  39571. if (j >= signatureLength) {
  39572. i += j;
  39573. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  39574. i++;
  39575. }
  39576. found = true;
  39577. break;
  39578. }
  39579. i++;
  39580. }
  39581. return {
  39582. found: found,
  39583. length: i
  39584. };
  39585. }
  39586. function getHeaderBlock(stream, suggestedLength) {
  39587. var EEXEC_SIGNATURE = [
  39588. 0x65,
  39589. 0x65,
  39590. 0x78,
  39591. 0x65,
  39592. 0x63
  39593. ];
  39594. var streamStartPos = stream.pos;
  39595. var headerBytes, headerBytesLength, block;
  39596. try {
  39597. headerBytes = stream.getBytes(suggestedLength);
  39598. headerBytesLength = headerBytes.length;
  39599. } catch (ex) {
  39600. if (ex instanceof MissingDataException) {
  39601. throw ex;
  39602. }
  39603. }
  39604. if (headerBytesLength === suggestedLength) {
  39605. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  39606. if (block.found && block.length === suggestedLength) {
  39607. return {
  39608. stream: new Stream(headerBytes),
  39609. length: suggestedLength
  39610. };
  39611. }
  39612. }
  39613. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  39614. stream.pos = streamStartPos;
  39615. var SCAN_BLOCK_LENGTH = 2048;
  39616. var actualLength;
  39617. while (true) {
  39618. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  39619. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  39620. if (block.length === 0) {
  39621. break;
  39622. }
  39623. stream.pos += block.length;
  39624. if (block.found) {
  39625. actualLength = stream.pos - streamStartPos;
  39626. break;
  39627. }
  39628. }
  39629. stream.pos = streamStartPos;
  39630. if (actualLength) {
  39631. return {
  39632. stream: new Stream(stream.getBytes(actualLength)),
  39633. length: actualLength
  39634. };
  39635. }
  39636. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  39637. return {
  39638. stream: new Stream(stream.getBytes(suggestedLength)),
  39639. length: suggestedLength
  39640. };
  39641. }
  39642. function getEexecBlock(stream, suggestedLength) {
  39643. var eexecBytes = stream.getBytes();
  39644. return {
  39645. stream: new Stream(eexecBytes),
  39646. length: eexecBytes.length
  39647. };
  39648. }
  39649. function Type1Font(name, file, properties) {
  39650. var PFB_HEADER_SIZE = 6;
  39651. var headerBlockLength = properties.length1;
  39652. var eexecBlockLength = properties.length2;
  39653. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  39654. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  39655. if (pfbHeaderPresent) {
  39656. file.skip(PFB_HEADER_SIZE);
  39657. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  39658. }
  39659. var headerBlock = getHeaderBlock(file, headerBlockLength);
  39660. headerBlockLength = headerBlock.length;
  39661. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  39662. headerBlockParser.extractFontHeader(properties);
  39663. if (pfbHeaderPresent) {
  39664. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  39665. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  39666. }
  39667. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  39668. eexecBlockLength = eexecBlock.length;
  39669. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  39670. var data = eexecBlockParser.extractFontProgram();
  39671. for (var info in data.properties) {
  39672. properties[info] = data.properties[info];
  39673. }
  39674. var charstrings = data.charstrings;
  39675. var type2Charstrings = this.getType2Charstrings(charstrings);
  39676. var subrs = this.getType2Subrs(data.subrs);
  39677. this.charstrings = charstrings;
  39678. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  39679. this.seacs = this.getSeacs(data.charstrings);
  39680. }
  39681. Type1Font.prototype = {
  39682. get numGlyphs() {
  39683. return this.charstrings.length + 1;
  39684. },
  39685. getCharset: function Type1Font_getCharset() {
  39686. var charset = ['.notdef'];
  39687. var charstrings = this.charstrings;
  39688. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  39689. charset.push(charstrings[glyphId].glyphName);
  39690. }
  39691. return charset;
  39692. },
  39693. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  39694. var charstrings = this.charstrings;
  39695. var glyphNames = ['.notdef'], glyphId;
  39696. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  39697. glyphNames.push(charstrings[glyphId].glyphName);
  39698. }
  39699. var encoding = properties.builtInEncoding;
  39700. if (encoding) {
  39701. var builtInEncoding = Object.create(null);
  39702. for (var charCode in encoding) {
  39703. glyphId = glyphNames.indexOf(encoding[charCode]);
  39704. if (glyphId >= 0) {
  39705. builtInEncoding[charCode] = glyphId;
  39706. }
  39707. }
  39708. }
  39709. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  39710. },
  39711. getSeacs: function Type1Font_getSeacs(charstrings) {
  39712. var i, ii;
  39713. var seacMap = [];
  39714. for (i = 0, ii = charstrings.length; i < ii; i++) {
  39715. var charstring = charstrings[i];
  39716. if (charstring.seac) {
  39717. seacMap[i + 1] = charstring.seac;
  39718. }
  39719. }
  39720. return seacMap;
  39721. },
  39722. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  39723. var type2Charstrings = [];
  39724. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  39725. type2Charstrings.push(type1Charstrings[i].charstring);
  39726. }
  39727. return type2Charstrings;
  39728. },
  39729. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  39730. var bias = 0;
  39731. var count = type1Subrs.length;
  39732. if (count < 1133) {
  39733. bias = 107;
  39734. } else if (count < 33769) {
  39735. bias = 1131;
  39736. } else {
  39737. bias = 32768;
  39738. }
  39739. var type2Subrs = [];
  39740. var i;
  39741. for (i = 0; i < bias; i++) {
  39742. type2Subrs.push([0x0B]);
  39743. }
  39744. for (i = 0; i < count; i++) {
  39745. type2Subrs.push(type1Subrs[i]);
  39746. }
  39747. return type2Subrs;
  39748. },
  39749. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  39750. var cff = new CFF();
  39751. cff.header = new CFFHeader(1, 0, 4, 4);
  39752. cff.names = [name];
  39753. var topDict = new CFFTopDict();
  39754. topDict.setByName('version', 391);
  39755. topDict.setByName('Notice', 392);
  39756. topDict.setByName('FullName', 393);
  39757. topDict.setByName('FamilyName', 394);
  39758. topDict.setByName('Weight', 395);
  39759. topDict.setByName('Encoding', null);
  39760. topDict.setByName('FontMatrix', properties.fontMatrix);
  39761. topDict.setByName('FontBBox', properties.bbox);
  39762. topDict.setByName('charset', null);
  39763. topDict.setByName('CharStrings', null);
  39764. topDict.setByName('Private', null);
  39765. cff.topDict = topDict;
  39766. var strings = new CFFStrings();
  39767. strings.add('Version 0.11');
  39768. strings.add('See original notice');
  39769. strings.add(name);
  39770. strings.add(name);
  39771. strings.add('Medium');
  39772. cff.strings = strings;
  39773. cff.globalSubrIndex = new CFFIndex();
  39774. var count = glyphs.length;
  39775. var charsetArray = [0];
  39776. var i, ii;
  39777. for (i = 0; i < count; i++) {
  39778. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  39779. if (index === -1) {
  39780. index = 0;
  39781. }
  39782. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  39783. }
  39784. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  39785. var charStringsIndex = new CFFIndex();
  39786. charStringsIndex.add([
  39787. 0x8B,
  39788. 0x0E
  39789. ]);
  39790. for (i = 0; i < count; i++) {
  39791. var glyph = glyphs[i];
  39792. if (glyph.length === 0) {
  39793. charStringsIndex.add([
  39794. 0x8B,
  39795. 0x0E
  39796. ]);
  39797. continue;
  39798. }
  39799. charStringsIndex.add(glyph);
  39800. }
  39801. cff.charStrings = charStringsIndex;
  39802. var privateDict = new CFFPrivateDict();
  39803. privateDict.setByName('Subrs', null);
  39804. var fields = [
  39805. 'BlueValues',
  39806. 'OtherBlues',
  39807. 'FamilyBlues',
  39808. 'FamilyOtherBlues',
  39809. 'StemSnapH',
  39810. 'StemSnapV',
  39811. 'BlueShift',
  39812. 'BlueFuzz',
  39813. 'BlueScale',
  39814. 'LanguageGroup',
  39815. 'ExpansionFactor',
  39816. 'ForceBold',
  39817. 'StdHW',
  39818. 'StdVW'
  39819. ];
  39820. for (i = 0, ii = fields.length; i < ii; i++) {
  39821. var field = fields[i];
  39822. if (!(field in properties.privateData)) {
  39823. continue;
  39824. }
  39825. var value = properties.privateData[field];
  39826. if (isArray(value)) {
  39827. for (var j = value.length - 1; j > 0; j--) {
  39828. value[j] -= value[j - 1];
  39829. }
  39830. }
  39831. privateDict.setByName(field, value);
  39832. }
  39833. cff.topDict.privateDict = privateDict;
  39834. var subrIndex = new CFFIndex();
  39835. for (i = 0, ii = subrs.length; i < ii; i++) {
  39836. subrIndex.add(subrs[i]);
  39837. }
  39838. privateDict.subrsIndex = subrIndex;
  39839. var compiler = new CFFCompiler(cff);
  39840. return compiler.compile();
  39841. }
  39842. };
  39843. return Type1Font;
  39844. }();
  39845. var CFFFont = function CFFFontClosure() {
  39846. function CFFFont(file, properties) {
  39847. this.properties = properties;
  39848. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  39849. this.cff = parser.parse();
  39850. var compiler = new CFFCompiler(this.cff);
  39851. this.seacs = this.cff.seacs;
  39852. try {
  39853. this.data = compiler.compile();
  39854. } catch (e) {
  39855. warn('Failed to compile font ' + properties.loadedName);
  39856. this.data = file;
  39857. }
  39858. }
  39859. CFFFont.prototype = {
  39860. get numGlyphs() {
  39861. return this.cff.charStrings.count;
  39862. },
  39863. getCharset: function CFFFont_getCharset() {
  39864. return this.cff.charset.charset;
  39865. },
  39866. getGlyphMapping: function CFFFont_getGlyphMapping() {
  39867. var cff = this.cff;
  39868. var properties = this.properties;
  39869. var charsets = cff.charset.charset;
  39870. var charCodeToGlyphId;
  39871. var glyphId;
  39872. if (properties.composite) {
  39873. charCodeToGlyphId = Object.create(null);
  39874. if (cff.isCIDFont) {
  39875. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  39876. var cid = charsets[glyphId];
  39877. var charCode = properties.cMap.charCodeOf(cid);
  39878. charCodeToGlyphId[charCode] = glyphId;
  39879. }
  39880. } else {
  39881. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  39882. charCodeToGlyphId[glyphId] = glyphId;
  39883. }
  39884. }
  39885. return charCodeToGlyphId;
  39886. }
  39887. var encoding = cff.encoding ? cff.encoding.encoding : null;
  39888. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  39889. return charCodeToGlyphId;
  39890. }
  39891. };
  39892. return CFFFont;
  39893. }();
  39894. (function checkSeacSupport() {
  39895. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  39896. SEAC_ANALYSIS_ENABLED = true;
  39897. }
  39898. }());
  39899. (function checkChromeWindows() {
  39900. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  39901. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  39902. }
  39903. }());
  39904. exports.ErrorFont = ErrorFont;
  39905. exports.Font = Font;
  39906. exports.FontFlags = FontFlags;
  39907. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  39908. exports.ToUnicodeMap = ToUnicodeMap;
  39909. exports.getFontType = getFontType;
  39910. }));
  39911. (function (root, factory) {
  39912. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  39913. }(this, function (exports, sharedUtil, coreParser) {
  39914. var error = sharedUtil.error;
  39915. var isSpace = sharedUtil.isSpace;
  39916. var EOF = coreParser.EOF;
  39917. var PostScriptParser = function PostScriptParserClosure() {
  39918. function PostScriptParser(lexer) {
  39919. this.lexer = lexer;
  39920. this.operators = [];
  39921. this.token = null;
  39922. this.prev = null;
  39923. }
  39924. PostScriptParser.prototype = {
  39925. nextToken: function PostScriptParser_nextToken() {
  39926. this.prev = this.token;
  39927. this.token = this.lexer.getToken();
  39928. },
  39929. accept: function PostScriptParser_accept(type) {
  39930. if (this.token.type === type) {
  39931. this.nextToken();
  39932. return true;
  39933. }
  39934. return false;
  39935. },
  39936. expect: function PostScriptParser_expect(type) {
  39937. if (this.accept(type)) {
  39938. return true;
  39939. }
  39940. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  39941. },
  39942. parse: function PostScriptParser_parse() {
  39943. this.nextToken();
  39944. this.expect(PostScriptTokenTypes.LBRACE);
  39945. this.parseBlock();
  39946. this.expect(PostScriptTokenTypes.RBRACE);
  39947. return this.operators;
  39948. },
  39949. parseBlock: function PostScriptParser_parseBlock() {
  39950. while (true) {
  39951. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  39952. this.operators.push(this.prev.value);
  39953. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  39954. this.operators.push(this.prev.value);
  39955. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  39956. this.parseCondition();
  39957. } else {
  39958. return;
  39959. }
  39960. }
  39961. },
  39962. parseCondition: function PostScriptParser_parseCondition() {
  39963. var conditionLocation = this.operators.length;
  39964. this.operators.push(null, null);
  39965. this.parseBlock();
  39966. this.expect(PostScriptTokenTypes.RBRACE);
  39967. if (this.accept(PostScriptTokenTypes.IF)) {
  39968. this.operators[conditionLocation] = this.operators.length;
  39969. this.operators[conditionLocation + 1] = 'jz';
  39970. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  39971. var jumpLocation = this.operators.length;
  39972. this.operators.push(null, null);
  39973. var endOfTrue = this.operators.length;
  39974. this.parseBlock();
  39975. this.expect(PostScriptTokenTypes.RBRACE);
  39976. this.expect(PostScriptTokenTypes.IFELSE);
  39977. this.operators[jumpLocation] = this.operators.length;
  39978. this.operators[jumpLocation + 1] = 'j';
  39979. this.operators[conditionLocation] = endOfTrue;
  39980. this.operators[conditionLocation + 1] = 'jz';
  39981. } else {
  39982. error('PS Function: error parsing conditional.');
  39983. }
  39984. }
  39985. };
  39986. return PostScriptParser;
  39987. }();
  39988. var PostScriptTokenTypes = {
  39989. LBRACE: 0,
  39990. RBRACE: 1,
  39991. NUMBER: 2,
  39992. OPERATOR: 3,
  39993. IF: 4,
  39994. IFELSE: 5
  39995. };
  39996. var PostScriptToken = function PostScriptTokenClosure() {
  39997. function PostScriptToken(type, value) {
  39998. this.type = type;
  39999. this.value = value;
  40000. }
  40001. var opCache = Object.create(null);
  40002. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  40003. var opValue = opCache[op];
  40004. if (opValue) {
  40005. return opValue;
  40006. }
  40007. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  40008. };
  40009. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  40010. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  40011. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  40012. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  40013. return PostScriptToken;
  40014. }();
  40015. var PostScriptLexer = function PostScriptLexerClosure() {
  40016. function PostScriptLexer(stream) {
  40017. this.stream = stream;
  40018. this.nextChar();
  40019. this.strBuf = [];
  40020. }
  40021. PostScriptLexer.prototype = {
  40022. nextChar: function PostScriptLexer_nextChar() {
  40023. return this.currentChar = this.stream.getByte();
  40024. },
  40025. getToken: function PostScriptLexer_getToken() {
  40026. var comment = false;
  40027. var ch = this.currentChar;
  40028. while (true) {
  40029. if (ch < 0) {
  40030. return EOF;
  40031. }
  40032. if (comment) {
  40033. if (ch === 0x0A || ch === 0x0D) {
  40034. comment = false;
  40035. }
  40036. } else if (ch === 0x25) {
  40037. comment = true;
  40038. } else if (!isSpace(ch)) {
  40039. break;
  40040. }
  40041. ch = this.nextChar();
  40042. }
  40043. switch (ch | 0) {
  40044. case 0x30:
  40045. case 0x31:
  40046. case 0x32:
  40047. case 0x33:
  40048. case 0x34:
  40049. case 0x35:
  40050. case 0x36:
  40051. case 0x37:
  40052. case 0x38:
  40053. case 0x39:
  40054. case 0x2B:
  40055. case 0x2D:
  40056. case 0x2E:
  40057. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  40058. case 0x7B:
  40059. this.nextChar();
  40060. return PostScriptToken.LBRACE;
  40061. case 0x7D:
  40062. this.nextChar();
  40063. return PostScriptToken.RBRACE;
  40064. }
  40065. var strBuf = this.strBuf;
  40066. strBuf.length = 0;
  40067. strBuf[0] = String.fromCharCode(ch);
  40068. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  40069. strBuf.push(String.fromCharCode(ch));
  40070. }
  40071. var str = strBuf.join('');
  40072. switch (str.toLowerCase()) {
  40073. case 'if':
  40074. return PostScriptToken.IF;
  40075. case 'ifelse':
  40076. return PostScriptToken.IFELSE;
  40077. default:
  40078. return PostScriptToken.getOperator(str);
  40079. }
  40080. },
  40081. getNumber: function PostScriptLexer_getNumber() {
  40082. var ch = this.currentChar;
  40083. var strBuf = this.strBuf;
  40084. strBuf.length = 0;
  40085. strBuf[0] = String.fromCharCode(ch);
  40086. while ((ch = this.nextChar()) >= 0) {
  40087. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  40088. strBuf.push(String.fromCharCode(ch));
  40089. } else {
  40090. break;
  40091. }
  40092. }
  40093. var value = parseFloat(strBuf.join(''));
  40094. if (isNaN(value)) {
  40095. error('Invalid floating point number: ' + value);
  40096. }
  40097. return value;
  40098. }
  40099. };
  40100. return PostScriptLexer;
  40101. }();
  40102. exports.PostScriptLexer = PostScriptLexer;
  40103. exports.PostScriptParser = PostScriptParser;
  40104. }));
  40105. (function (root, factory) {
  40106. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  40107. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  40108. var error = sharedUtil.error;
  40109. var info = sharedUtil.info;
  40110. var isArray = sharedUtil.isArray;
  40111. var isBool = sharedUtil.isBool;
  40112. var isDict = corePrimitives.isDict;
  40113. var isStream = corePrimitives.isStream;
  40114. var PostScriptLexer = corePsParser.PostScriptLexer;
  40115. var PostScriptParser = corePsParser.PostScriptParser;
  40116. var PDFFunction = function PDFFunctionClosure() {
  40117. var CONSTRUCT_SAMPLED = 0;
  40118. var CONSTRUCT_INTERPOLATED = 2;
  40119. var CONSTRUCT_STICHED = 3;
  40120. var CONSTRUCT_POSTSCRIPT = 4;
  40121. return {
  40122. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  40123. var i, ii;
  40124. var length = 1;
  40125. for (i = 0, ii = size.length; i < ii; i++) {
  40126. length *= size[i];
  40127. }
  40128. length *= outputSize;
  40129. var array = new Array(length);
  40130. var codeSize = 0;
  40131. var codeBuf = 0;
  40132. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  40133. var strBytes = str.getBytes((length * bps + 7) / 8);
  40134. var strIdx = 0;
  40135. for (i = 0; i < length; i++) {
  40136. while (codeSize < bps) {
  40137. codeBuf <<= 8;
  40138. codeBuf |= strBytes[strIdx++];
  40139. codeSize += 8;
  40140. }
  40141. codeSize -= bps;
  40142. array[i] = (codeBuf >> codeSize) * sampleMul;
  40143. codeBuf &= (1 << codeSize) - 1;
  40144. }
  40145. return array;
  40146. },
  40147. getIR: function PDFFunction_getIR(xref, fn) {
  40148. var dict = fn.dict;
  40149. if (!dict) {
  40150. dict = fn;
  40151. }
  40152. var types = [
  40153. this.constructSampled,
  40154. null,
  40155. this.constructInterpolated,
  40156. this.constructStiched,
  40157. this.constructPostScript
  40158. ];
  40159. var typeNum = dict.get('FunctionType');
  40160. var typeFn = types[typeNum];
  40161. if (!typeFn) {
  40162. error('Unknown type of function');
  40163. }
  40164. return typeFn.call(this, fn, dict, xref);
  40165. },
  40166. fromIR: function PDFFunction_fromIR(IR) {
  40167. var type = IR[0];
  40168. switch (type) {
  40169. case CONSTRUCT_SAMPLED:
  40170. return this.constructSampledFromIR(IR);
  40171. case CONSTRUCT_INTERPOLATED:
  40172. return this.constructInterpolatedFromIR(IR);
  40173. case CONSTRUCT_STICHED:
  40174. return this.constructStichedFromIR(IR);
  40175. default:
  40176. return this.constructPostScriptFromIR(IR);
  40177. }
  40178. },
  40179. parse: function PDFFunction_parse(xref, fn) {
  40180. var IR = this.getIR(xref, fn);
  40181. return this.fromIR(IR);
  40182. },
  40183. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  40184. if (!isArray(fnObj)) {
  40185. return this.parse(xref, fnObj);
  40186. }
  40187. var fnArray = [];
  40188. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  40189. var obj = xref.fetchIfRef(fnObj[j]);
  40190. fnArray.push(PDFFunction.parse(xref, obj));
  40191. }
  40192. return function (src, srcOffset, dest, destOffset) {
  40193. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  40194. fnArray[i](src, srcOffset, dest, destOffset + i);
  40195. }
  40196. };
  40197. },
  40198. constructSampled: function PDFFunction_constructSampled(str, dict) {
  40199. function toMultiArray(arr) {
  40200. var inputLength = arr.length;
  40201. var out = [];
  40202. var index = 0;
  40203. for (var i = 0; i < inputLength; i += 2) {
  40204. out[index] = [
  40205. arr[i],
  40206. arr[i + 1]
  40207. ];
  40208. ++index;
  40209. }
  40210. return out;
  40211. }
  40212. var domain = dict.getArray('Domain');
  40213. var range = dict.getArray('Range');
  40214. if (!domain || !range) {
  40215. error('No domain or range');
  40216. }
  40217. var inputSize = domain.length / 2;
  40218. var outputSize = range.length / 2;
  40219. domain = toMultiArray(domain);
  40220. range = toMultiArray(range);
  40221. var size = dict.get('Size');
  40222. var bps = dict.get('BitsPerSample');
  40223. var order = dict.get('Order') || 1;
  40224. if (order !== 1) {
  40225. info('No support for cubic spline interpolation: ' + order);
  40226. }
  40227. var encode = dict.getArray('Encode');
  40228. if (!encode) {
  40229. encode = [];
  40230. for (var i = 0; i < inputSize; ++i) {
  40231. encode.push(0);
  40232. encode.push(size[i] - 1);
  40233. }
  40234. }
  40235. encode = toMultiArray(encode);
  40236. var decode = dict.getArray('Decode');
  40237. if (!decode) {
  40238. decode = range;
  40239. } else {
  40240. decode = toMultiArray(decode);
  40241. }
  40242. var samples = this.getSampleArray(size, outputSize, bps, str);
  40243. return [
  40244. CONSTRUCT_SAMPLED,
  40245. inputSize,
  40246. domain,
  40247. encode,
  40248. decode,
  40249. samples,
  40250. size,
  40251. outputSize,
  40252. Math.pow(2, bps) - 1,
  40253. range
  40254. ];
  40255. },
  40256. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  40257. function interpolate(x, xmin, xmax, ymin, ymax) {
  40258. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  40259. }
  40260. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  40261. var m = IR[1];
  40262. var domain = IR[2];
  40263. var encode = IR[3];
  40264. var decode = IR[4];
  40265. var samples = IR[5];
  40266. var size = IR[6];
  40267. var n = IR[7];
  40268. var range = IR[9];
  40269. var cubeVertices = 1 << m;
  40270. var cubeN = new Float64Array(cubeVertices);
  40271. var cubeVertex = new Uint32Array(cubeVertices);
  40272. var i, j;
  40273. for (j = 0; j < cubeVertices; j++) {
  40274. cubeN[j] = 1;
  40275. }
  40276. var k = n, pos = 1;
  40277. for (i = 0; i < m; ++i) {
  40278. var domain_2i = domain[i][0];
  40279. var domain_2i_1 = domain[i][1];
  40280. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  40281. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  40282. var size_i = size[i];
  40283. e = Math.min(Math.max(e, 0), size_i - 1);
  40284. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  40285. var n0 = e0 + 1 - e;
  40286. var n1 = e - e0;
  40287. var offset0 = e0 * k;
  40288. var offset1 = offset0 + k;
  40289. for (j = 0; j < cubeVertices; j++) {
  40290. if (j & pos) {
  40291. cubeN[j] *= n1;
  40292. cubeVertex[j] += offset1;
  40293. } else {
  40294. cubeN[j] *= n0;
  40295. cubeVertex[j] += offset0;
  40296. }
  40297. }
  40298. k *= size_i;
  40299. pos <<= 1;
  40300. }
  40301. for (j = 0; j < n; ++j) {
  40302. var rj = 0;
  40303. for (i = 0; i < cubeVertices; i++) {
  40304. rj += samples[cubeVertex[i] + j] * cubeN[i];
  40305. }
  40306. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  40307. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  40308. }
  40309. };
  40310. },
  40311. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  40312. var c0 = dict.getArray('C0') || [0];
  40313. var c1 = dict.getArray('C1') || [1];
  40314. var n = dict.get('N');
  40315. if (!isArray(c0) || !isArray(c1)) {
  40316. error('Illegal dictionary for interpolated function');
  40317. }
  40318. var length = c0.length;
  40319. var diff = [];
  40320. for (var i = 0; i < length; ++i) {
  40321. diff.push(c1[i] - c0[i]);
  40322. }
  40323. return [
  40324. CONSTRUCT_INTERPOLATED,
  40325. c0,
  40326. diff,
  40327. n
  40328. ];
  40329. },
  40330. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  40331. var c0 = IR[1];
  40332. var diff = IR[2];
  40333. var n = IR[3];
  40334. var length = diff.length;
  40335. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  40336. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  40337. for (var j = 0; j < length; ++j) {
  40338. dest[destOffset + j] = c0[j] + x * diff[j];
  40339. }
  40340. };
  40341. },
  40342. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  40343. var domain = dict.getArray('Domain');
  40344. if (!domain) {
  40345. error('No domain');
  40346. }
  40347. var inputSize = domain.length / 2;
  40348. if (inputSize !== 1) {
  40349. error('Bad domain for stiched function');
  40350. }
  40351. var fnRefs = dict.get('Functions');
  40352. var fns = [];
  40353. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  40354. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  40355. }
  40356. var bounds = dict.getArray('Bounds');
  40357. var encode = dict.getArray('Encode');
  40358. return [
  40359. CONSTRUCT_STICHED,
  40360. domain,
  40361. bounds,
  40362. encode,
  40363. fns
  40364. ];
  40365. },
  40366. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  40367. var domain = IR[1];
  40368. var bounds = IR[2];
  40369. var encode = IR[3];
  40370. var fnsIR = IR[4];
  40371. var fns = [];
  40372. var tmpBuf = new Float32Array(1);
  40373. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  40374. fns.push(PDFFunction.fromIR(fnsIR[i]));
  40375. }
  40376. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  40377. var clip = function constructStichedFromIRClip(v, min, max) {
  40378. if (v > max) {
  40379. v = max;
  40380. } else if (v < min) {
  40381. v = min;
  40382. }
  40383. return v;
  40384. };
  40385. var v = clip(src[srcOffset], domain[0], domain[1]);
  40386. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  40387. if (v < bounds[i]) {
  40388. break;
  40389. }
  40390. }
  40391. var dmin = domain[0];
  40392. if (i > 0) {
  40393. dmin = bounds[i - 1];
  40394. }
  40395. var dmax = domain[1];
  40396. if (i < bounds.length) {
  40397. dmax = bounds[i];
  40398. }
  40399. var rmin = encode[2 * i];
  40400. var rmax = encode[2 * i + 1];
  40401. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  40402. fns[i](tmpBuf, 0, dest, destOffset);
  40403. };
  40404. },
  40405. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  40406. var domain = dict.getArray('Domain');
  40407. var range = dict.getArray('Range');
  40408. if (!domain) {
  40409. error('No domain.');
  40410. }
  40411. if (!range) {
  40412. error('No range.');
  40413. }
  40414. var lexer = new PostScriptLexer(fn);
  40415. var parser = new PostScriptParser(lexer);
  40416. var code = parser.parse();
  40417. return [
  40418. CONSTRUCT_POSTSCRIPT,
  40419. domain,
  40420. range,
  40421. code
  40422. ];
  40423. },
  40424. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  40425. var domain = IR[1];
  40426. var range = IR[2];
  40427. var code = IR[3];
  40428. var compiled = new PostScriptCompiler().compile(code, domain, range);
  40429. if (compiled) {
  40430. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  40431. }
  40432. info('Unable to compile PS function');
  40433. var numOutputs = range.length >> 1;
  40434. var numInputs = domain.length >> 1;
  40435. var evaluator = new PostScriptEvaluator(code);
  40436. var cache = Object.create(null);
  40437. var MAX_CACHE_SIZE = 2048 * 4;
  40438. var cache_available = MAX_CACHE_SIZE;
  40439. var tmpBuf = new Float32Array(numInputs);
  40440. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  40441. var i, value;
  40442. var key = '';
  40443. var input = tmpBuf;
  40444. for (i = 0; i < numInputs; i++) {
  40445. value = src[srcOffset + i];
  40446. input[i] = value;
  40447. key += value + '_';
  40448. }
  40449. var cachedValue = cache[key];
  40450. if (cachedValue !== undefined) {
  40451. dest.set(cachedValue, destOffset);
  40452. return;
  40453. }
  40454. var output = new Float32Array(numOutputs);
  40455. var stack = evaluator.execute(input);
  40456. var stackIndex = stack.length - numOutputs;
  40457. for (i = 0; i < numOutputs; i++) {
  40458. value = stack[stackIndex + i];
  40459. var bound = range[i * 2];
  40460. if (value < bound) {
  40461. value = bound;
  40462. } else {
  40463. bound = range[i * 2 + 1];
  40464. if (value > bound) {
  40465. value = bound;
  40466. }
  40467. }
  40468. output[i] = value;
  40469. }
  40470. if (cache_available > 0) {
  40471. cache_available--;
  40472. cache[key] = output;
  40473. }
  40474. dest.set(output, destOffset);
  40475. };
  40476. }
  40477. };
  40478. }();
  40479. function isPDFFunction(v) {
  40480. var fnDict;
  40481. if (typeof v !== 'object') {
  40482. return false;
  40483. } else if (isDict(v)) {
  40484. fnDict = v;
  40485. } else if (isStream(v)) {
  40486. fnDict = v.dict;
  40487. } else {
  40488. return false;
  40489. }
  40490. return fnDict.has('FunctionType');
  40491. }
  40492. var PostScriptStack = function PostScriptStackClosure() {
  40493. var MAX_STACK_SIZE = 100;
  40494. function PostScriptStack(initialStack) {
  40495. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  40496. }
  40497. PostScriptStack.prototype = {
  40498. push: function PostScriptStack_push(value) {
  40499. if (this.stack.length >= MAX_STACK_SIZE) {
  40500. error('PostScript function stack overflow.');
  40501. }
  40502. this.stack.push(value);
  40503. },
  40504. pop: function PostScriptStack_pop() {
  40505. if (this.stack.length <= 0) {
  40506. error('PostScript function stack underflow.');
  40507. }
  40508. return this.stack.pop();
  40509. },
  40510. copy: function PostScriptStack_copy(n) {
  40511. if (this.stack.length + n >= MAX_STACK_SIZE) {
  40512. error('PostScript function stack overflow.');
  40513. }
  40514. var stack = this.stack;
  40515. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  40516. stack.push(stack[i]);
  40517. }
  40518. },
  40519. index: function PostScriptStack_index(n) {
  40520. this.push(this.stack[this.stack.length - n - 1]);
  40521. },
  40522. roll: function PostScriptStack_roll(n, p) {
  40523. var stack = this.stack;
  40524. var l = stack.length - n;
  40525. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  40526. for (i = l, j = r; i < j; i++, j--) {
  40527. t = stack[i];
  40528. stack[i] = stack[j];
  40529. stack[j] = t;
  40530. }
  40531. for (i = l, j = c - 1; i < j; i++, j--) {
  40532. t = stack[i];
  40533. stack[i] = stack[j];
  40534. stack[j] = t;
  40535. }
  40536. for (i = c, j = r; i < j; i++, j--) {
  40537. t = stack[i];
  40538. stack[i] = stack[j];
  40539. stack[j] = t;
  40540. }
  40541. }
  40542. };
  40543. return PostScriptStack;
  40544. }();
  40545. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  40546. function PostScriptEvaluator(operators) {
  40547. this.operators = operators;
  40548. }
  40549. PostScriptEvaluator.prototype = {
  40550. execute: function PostScriptEvaluator_execute(initialStack) {
  40551. var stack = new PostScriptStack(initialStack);
  40552. var counter = 0;
  40553. var operators = this.operators;
  40554. var length = operators.length;
  40555. var operator, a, b;
  40556. while (counter < length) {
  40557. operator = operators[counter++];
  40558. if (typeof operator === 'number') {
  40559. stack.push(operator);
  40560. continue;
  40561. }
  40562. switch (operator) {
  40563. case 'jz':
  40564. b = stack.pop();
  40565. a = stack.pop();
  40566. if (!a) {
  40567. counter = b;
  40568. }
  40569. break;
  40570. case 'j':
  40571. a = stack.pop();
  40572. counter = a;
  40573. break;
  40574. case 'abs':
  40575. a = stack.pop();
  40576. stack.push(Math.abs(a));
  40577. break;
  40578. case 'add':
  40579. b = stack.pop();
  40580. a = stack.pop();
  40581. stack.push(a + b);
  40582. break;
  40583. case 'and':
  40584. b = stack.pop();
  40585. a = stack.pop();
  40586. if (isBool(a) && isBool(b)) {
  40587. stack.push(a && b);
  40588. } else {
  40589. stack.push(a & b);
  40590. }
  40591. break;
  40592. case 'atan':
  40593. a = stack.pop();
  40594. stack.push(Math.atan(a));
  40595. break;
  40596. case 'bitshift':
  40597. b = stack.pop();
  40598. a = stack.pop();
  40599. if (a > 0) {
  40600. stack.push(a << b);
  40601. } else {
  40602. stack.push(a >> b);
  40603. }
  40604. break;
  40605. case 'ceiling':
  40606. a = stack.pop();
  40607. stack.push(Math.ceil(a));
  40608. break;
  40609. case 'copy':
  40610. a = stack.pop();
  40611. stack.copy(a);
  40612. break;
  40613. case 'cos':
  40614. a = stack.pop();
  40615. stack.push(Math.cos(a));
  40616. break;
  40617. case 'cvi':
  40618. a = stack.pop() | 0;
  40619. stack.push(a);
  40620. break;
  40621. case 'cvr':
  40622. break;
  40623. case 'div':
  40624. b = stack.pop();
  40625. a = stack.pop();
  40626. stack.push(a / b);
  40627. break;
  40628. case 'dup':
  40629. stack.copy(1);
  40630. break;
  40631. case 'eq':
  40632. b = stack.pop();
  40633. a = stack.pop();
  40634. stack.push(a === b);
  40635. break;
  40636. case 'exch':
  40637. stack.roll(2, 1);
  40638. break;
  40639. case 'exp':
  40640. b = stack.pop();
  40641. a = stack.pop();
  40642. stack.push(Math.pow(a, b));
  40643. break;
  40644. case 'false':
  40645. stack.push(false);
  40646. break;
  40647. case 'floor':
  40648. a = stack.pop();
  40649. stack.push(Math.floor(a));
  40650. break;
  40651. case 'ge':
  40652. b = stack.pop();
  40653. a = stack.pop();
  40654. stack.push(a >= b);
  40655. break;
  40656. case 'gt':
  40657. b = stack.pop();
  40658. a = stack.pop();
  40659. stack.push(a > b);
  40660. break;
  40661. case 'idiv':
  40662. b = stack.pop();
  40663. a = stack.pop();
  40664. stack.push(a / b | 0);
  40665. break;
  40666. case 'index':
  40667. a = stack.pop();
  40668. stack.index(a);
  40669. break;
  40670. case 'le':
  40671. b = stack.pop();
  40672. a = stack.pop();
  40673. stack.push(a <= b);
  40674. break;
  40675. case 'ln':
  40676. a = stack.pop();
  40677. stack.push(Math.log(a));
  40678. break;
  40679. case 'log':
  40680. a = stack.pop();
  40681. stack.push(Math.log(a) / Math.LN10);
  40682. break;
  40683. case 'lt':
  40684. b = stack.pop();
  40685. a = stack.pop();
  40686. stack.push(a < b);
  40687. break;
  40688. case 'mod':
  40689. b = stack.pop();
  40690. a = stack.pop();
  40691. stack.push(a % b);
  40692. break;
  40693. case 'mul':
  40694. b = stack.pop();
  40695. a = stack.pop();
  40696. stack.push(a * b);
  40697. break;
  40698. case 'ne':
  40699. b = stack.pop();
  40700. a = stack.pop();
  40701. stack.push(a !== b);
  40702. break;
  40703. case 'neg':
  40704. a = stack.pop();
  40705. stack.push(-a);
  40706. break;
  40707. case 'not':
  40708. a = stack.pop();
  40709. if (isBool(a)) {
  40710. stack.push(!a);
  40711. } else {
  40712. stack.push(~a);
  40713. }
  40714. break;
  40715. case 'or':
  40716. b = stack.pop();
  40717. a = stack.pop();
  40718. if (isBool(a) && isBool(b)) {
  40719. stack.push(a || b);
  40720. } else {
  40721. stack.push(a | b);
  40722. }
  40723. break;
  40724. case 'pop':
  40725. stack.pop();
  40726. break;
  40727. case 'roll':
  40728. b = stack.pop();
  40729. a = stack.pop();
  40730. stack.roll(a, b);
  40731. break;
  40732. case 'round':
  40733. a = stack.pop();
  40734. stack.push(Math.round(a));
  40735. break;
  40736. case 'sin':
  40737. a = stack.pop();
  40738. stack.push(Math.sin(a));
  40739. break;
  40740. case 'sqrt':
  40741. a = stack.pop();
  40742. stack.push(Math.sqrt(a));
  40743. break;
  40744. case 'sub':
  40745. b = stack.pop();
  40746. a = stack.pop();
  40747. stack.push(a - b);
  40748. break;
  40749. case 'true':
  40750. stack.push(true);
  40751. break;
  40752. case 'truncate':
  40753. a = stack.pop();
  40754. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  40755. stack.push(a);
  40756. break;
  40757. case 'xor':
  40758. b = stack.pop();
  40759. a = stack.pop();
  40760. if (isBool(a) && isBool(b)) {
  40761. stack.push(a !== b);
  40762. } else {
  40763. stack.push(a ^ b);
  40764. }
  40765. break;
  40766. default:
  40767. error('Unknown operator ' + operator);
  40768. break;
  40769. }
  40770. }
  40771. return stack.stack;
  40772. }
  40773. };
  40774. return PostScriptEvaluator;
  40775. }();
  40776. var PostScriptCompiler = function PostScriptCompilerClosure() {
  40777. function AstNode(type) {
  40778. this.type = type;
  40779. }
  40780. AstNode.prototype.visit = function (visitor) {
  40781. throw new Error('abstract method');
  40782. };
  40783. function AstArgument(index, min, max) {
  40784. AstNode.call(this, 'args');
  40785. this.index = index;
  40786. this.min = min;
  40787. this.max = max;
  40788. }
  40789. AstArgument.prototype = Object.create(AstNode.prototype);
  40790. AstArgument.prototype.visit = function (visitor) {
  40791. visitor.visitArgument(this);
  40792. };
  40793. function AstLiteral(number) {
  40794. AstNode.call(this, 'literal');
  40795. this.number = number;
  40796. this.min = number;
  40797. this.max = number;
  40798. }
  40799. AstLiteral.prototype = Object.create(AstNode.prototype);
  40800. AstLiteral.prototype.visit = function (visitor) {
  40801. visitor.visitLiteral(this);
  40802. };
  40803. function AstBinaryOperation(op, arg1, arg2, min, max) {
  40804. AstNode.call(this, 'binary');
  40805. this.op = op;
  40806. this.arg1 = arg1;
  40807. this.arg2 = arg2;
  40808. this.min = min;
  40809. this.max = max;
  40810. }
  40811. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  40812. AstBinaryOperation.prototype.visit = function (visitor) {
  40813. visitor.visitBinaryOperation(this);
  40814. };
  40815. function AstMin(arg, max) {
  40816. AstNode.call(this, 'max');
  40817. this.arg = arg;
  40818. this.min = arg.min;
  40819. this.max = max;
  40820. }
  40821. AstMin.prototype = Object.create(AstNode.prototype);
  40822. AstMin.prototype.visit = function (visitor) {
  40823. visitor.visitMin(this);
  40824. };
  40825. function AstVariable(index, min, max) {
  40826. AstNode.call(this, 'var');
  40827. this.index = index;
  40828. this.min = min;
  40829. this.max = max;
  40830. }
  40831. AstVariable.prototype = Object.create(AstNode.prototype);
  40832. AstVariable.prototype.visit = function (visitor) {
  40833. visitor.visitVariable(this);
  40834. };
  40835. function AstVariableDefinition(variable, arg) {
  40836. AstNode.call(this, 'definition');
  40837. this.variable = variable;
  40838. this.arg = arg;
  40839. }
  40840. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  40841. AstVariableDefinition.prototype.visit = function (visitor) {
  40842. visitor.visitVariableDefinition(this);
  40843. };
  40844. function ExpressionBuilderVisitor() {
  40845. this.parts = [];
  40846. }
  40847. ExpressionBuilderVisitor.prototype = {
  40848. visitArgument: function (arg) {
  40849. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  40850. },
  40851. visitVariable: function (variable) {
  40852. this.parts.push('v', variable.index);
  40853. },
  40854. visitLiteral: function (literal) {
  40855. this.parts.push(literal.number);
  40856. },
  40857. visitBinaryOperation: function (operation) {
  40858. this.parts.push('(');
  40859. operation.arg1.visit(this);
  40860. this.parts.push(' ', operation.op, ' ');
  40861. operation.arg2.visit(this);
  40862. this.parts.push(')');
  40863. },
  40864. visitVariableDefinition: function (definition) {
  40865. this.parts.push('var ');
  40866. definition.variable.visit(this);
  40867. this.parts.push(' = ');
  40868. definition.arg.visit(this);
  40869. this.parts.push(';');
  40870. },
  40871. visitMin: function (max) {
  40872. this.parts.push('Math.min(');
  40873. max.arg.visit(this);
  40874. this.parts.push(', ', max.max, ')');
  40875. },
  40876. toString: function () {
  40877. return this.parts.join('');
  40878. }
  40879. };
  40880. function buildAddOperation(num1, num2) {
  40881. if (num2.type === 'literal' && num2.number === 0) {
  40882. return num1;
  40883. }
  40884. if (num1.type === 'literal' && num1.number === 0) {
  40885. return num2;
  40886. }
  40887. if (num2.type === 'literal' && num1.type === 'literal') {
  40888. return new AstLiteral(num1.number + num2.number);
  40889. }
  40890. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  40891. }
  40892. function buildMulOperation(num1, num2) {
  40893. if (num2.type === 'literal') {
  40894. if (num2.number === 0) {
  40895. return new AstLiteral(0);
  40896. } else if (num2.number === 1) {
  40897. return num1;
  40898. } else if (num1.type === 'literal') {
  40899. return new AstLiteral(num1.number * num2.number);
  40900. }
  40901. }
  40902. if (num1.type === 'literal') {
  40903. if (num1.number === 0) {
  40904. return new AstLiteral(0);
  40905. } else if (num1.number === 1) {
  40906. return num2;
  40907. }
  40908. }
  40909. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  40910. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  40911. return new AstBinaryOperation('*', num1, num2, min, max);
  40912. }
  40913. function buildSubOperation(num1, num2) {
  40914. if (num2.type === 'literal') {
  40915. if (num2.number === 0) {
  40916. return num1;
  40917. } else if (num1.type === 'literal') {
  40918. return new AstLiteral(num1.number - num2.number);
  40919. }
  40920. }
  40921. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  40922. return num2.arg2;
  40923. }
  40924. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  40925. }
  40926. function buildMinOperation(num1, max) {
  40927. if (num1.min >= max) {
  40928. return new AstLiteral(max);
  40929. } else if (num1.max <= max) {
  40930. return num1;
  40931. }
  40932. return new AstMin(num1, max);
  40933. }
  40934. function PostScriptCompiler() {
  40935. }
  40936. PostScriptCompiler.prototype = {
  40937. compile: function PostScriptCompiler_compile(code, domain, range) {
  40938. var stack = [];
  40939. var i, ii;
  40940. var instructions = [];
  40941. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  40942. var lastRegister = 0;
  40943. var n, j;
  40944. var num1, num2, ast1, ast2, tmpVar, item;
  40945. for (i = 0; i < inputSize; i++) {
  40946. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  40947. }
  40948. for (i = 0, ii = code.length; i < ii; i++) {
  40949. item = code[i];
  40950. if (typeof item === 'number') {
  40951. stack.push(new AstLiteral(item));
  40952. continue;
  40953. }
  40954. switch (item) {
  40955. case 'add':
  40956. if (stack.length < 2) {
  40957. return null;
  40958. }
  40959. num2 = stack.pop();
  40960. num1 = stack.pop();
  40961. stack.push(buildAddOperation(num1, num2));
  40962. break;
  40963. case 'cvr':
  40964. if (stack.length < 1) {
  40965. return null;
  40966. }
  40967. break;
  40968. case 'mul':
  40969. if (stack.length < 2) {
  40970. return null;
  40971. }
  40972. num2 = stack.pop();
  40973. num1 = stack.pop();
  40974. stack.push(buildMulOperation(num1, num2));
  40975. break;
  40976. case 'sub':
  40977. if (stack.length < 2) {
  40978. return null;
  40979. }
  40980. num2 = stack.pop();
  40981. num1 = stack.pop();
  40982. stack.push(buildSubOperation(num1, num2));
  40983. break;
  40984. case 'exch':
  40985. if (stack.length < 2) {
  40986. return null;
  40987. }
  40988. ast1 = stack.pop();
  40989. ast2 = stack.pop();
  40990. stack.push(ast1, ast2);
  40991. break;
  40992. case 'pop':
  40993. if (stack.length < 1) {
  40994. return null;
  40995. }
  40996. stack.pop();
  40997. break;
  40998. case 'index':
  40999. if (stack.length < 1) {
  41000. return null;
  41001. }
  41002. num1 = stack.pop();
  41003. if (num1.type !== 'literal') {
  41004. return null;
  41005. }
  41006. n = num1.number;
  41007. if (n < 0 || (n | 0) !== n || stack.length < n) {
  41008. return null;
  41009. }
  41010. ast1 = stack[stack.length - n - 1];
  41011. if (ast1.type === 'literal' || ast1.type === 'var') {
  41012. stack.push(ast1);
  41013. break;
  41014. }
  41015. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41016. stack[stack.length - n - 1] = tmpVar;
  41017. stack.push(tmpVar);
  41018. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41019. break;
  41020. case 'dup':
  41021. if (stack.length < 1) {
  41022. return null;
  41023. }
  41024. 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]) {
  41025. num1 = stack.pop();
  41026. stack.push(buildMinOperation(num1, code[i + 1]));
  41027. i += 6;
  41028. break;
  41029. }
  41030. ast1 = stack[stack.length - 1];
  41031. if (ast1.type === 'literal' || ast1.type === 'var') {
  41032. stack.push(ast1);
  41033. break;
  41034. }
  41035. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41036. stack[stack.length - 1] = tmpVar;
  41037. stack.push(tmpVar);
  41038. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41039. break;
  41040. case 'roll':
  41041. if (stack.length < 2) {
  41042. return null;
  41043. }
  41044. num2 = stack.pop();
  41045. num1 = stack.pop();
  41046. if (num2.type !== 'literal' || num1.type !== 'literal') {
  41047. return null;
  41048. }
  41049. j = num2.number;
  41050. n = num1.number;
  41051. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  41052. return null;
  41053. }
  41054. j = (j % n + n) % n;
  41055. if (j === 0) {
  41056. break;
  41057. }
  41058. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  41059. break;
  41060. default:
  41061. return null;
  41062. }
  41063. }
  41064. if (stack.length !== outputSize) {
  41065. return null;
  41066. }
  41067. var result = [];
  41068. instructions.forEach(function (instruction) {
  41069. var statementBuilder = new ExpressionBuilderVisitor();
  41070. instruction.visit(statementBuilder);
  41071. result.push(statementBuilder.toString());
  41072. });
  41073. stack.forEach(function (expr, i) {
  41074. var statementBuilder = new ExpressionBuilderVisitor();
  41075. expr.visit(statementBuilder);
  41076. var min = range[i * 2], max = range[i * 2 + 1];
  41077. var out = [statementBuilder.toString()];
  41078. if (min > expr.min) {
  41079. out.unshift('Math.max(', min, ', ');
  41080. out.push(')');
  41081. }
  41082. if (max < expr.max) {
  41083. out.unshift('Math.min(', max, ', ');
  41084. out.push(')');
  41085. }
  41086. out.unshift('dest[destOffset + ', i, '] = ');
  41087. out.push(';');
  41088. result.push(out.join(''));
  41089. });
  41090. return result.join('\n');
  41091. }
  41092. };
  41093. return PostScriptCompiler;
  41094. }();
  41095. exports.isPDFFunction = isPDFFunction;
  41096. exports.PDFFunction = PDFFunction;
  41097. exports.PostScriptEvaluator = PostScriptEvaluator;
  41098. exports.PostScriptCompiler = PostScriptCompiler;
  41099. }));
  41100. (function (root, factory) {
  41101. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  41102. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  41103. var error = sharedUtil.error;
  41104. var info = sharedUtil.info;
  41105. var isArray = sharedUtil.isArray;
  41106. var isString = sharedUtil.isString;
  41107. var shadow = sharedUtil.shadow;
  41108. var warn = sharedUtil.warn;
  41109. var isDict = corePrimitives.isDict;
  41110. var isName = corePrimitives.isName;
  41111. var isStream = corePrimitives.isStream;
  41112. var PDFFunction = coreFunction.PDFFunction;
  41113. var ColorSpace = function ColorSpaceClosure() {
  41114. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  41115. var COMPONENTS = 3;
  41116. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  41117. var xRatio = w1 / w2;
  41118. var yRatio = h1 / h2;
  41119. var i, j, py, newIndex = 0, oldIndex;
  41120. var xScaled = new Uint16Array(w2);
  41121. var w1Scanline = w1 * COMPONENTS;
  41122. for (i = 0; i < w2; i++) {
  41123. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  41124. }
  41125. for (i = 0; i < h2; i++) {
  41126. py = Math.floor(i * yRatio) * w1Scanline;
  41127. for (j = 0; j < w2; j++) {
  41128. oldIndex = py + xScaled[j];
  41129. dest[newIndex++] = src[oldIndex++];
  41130. dest[newIndex++] = src[oldIndex++];
  41131. dest[newIndex++] = src[oldIndex++];
  41132. newIndex += alpha01;
  41133. }
  41134. }
  41135. }
  41136. function ColorSpace() {
  41137. error('should not call ColorSpace constructor');
  41138. }
  41139. ColorSpace.prototype = {
  41140. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  41141. var rgb = new Uint8Array(3);
  41142. this.getRgbItem(src, srcOffset, rgb, 0);
  41143. return rgb;
  41144. },
  41145. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  41146. error('Should not call ColorSpace.getRgbItem');
  41147. },
  41148. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41149. error('Should not call ColorSpace.getRgbBuffer');
  41150. },
  41151. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  41152. error('Should not call ColorSpace.getOutputLength');
  41153. },
  41154. isPassthrough: function ColorSpace_isPassthrough(bits) {
  41155. return false;
  41156. },
  41157. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  41158. var count = originalWidth * originalHeight;
  41159. var rgbBuf = null;
  41160. var numComponentColors = 1 << bpc;
  41161. var needsResizing = originalHeight !== height || originalWidth !== width;
  41162. var i, ii;
  41163. if (this.isPassthrough(bpc)) {
  41164. rgbBuf = comps;
  41165. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  41166. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  41167. var key;
  41168. for (i = 0; i < numComponentColors; i++) {
  41169. allColors[i] = i;
  41170. }
  41171. var colorMap = new Uint8Array(numComponentColors * 3);
  41172. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  41173. var destPos, rgbPos;
  41174. if (!needsResizing) {
  41175. destPos = 0;
  41176. for (i = 0; i < count; ++i) {
  41177. key = comps[i] * 3;
  41178. dest[destPos++] = colorMap[key];
  41179. dest[destPos++] = colorMap[key + 1];
  41180. dest[destPos++] = colorMap[key + 2];
  41181. destPos += alpha01;
  41182. }
  41183. } else {
  41184. rgbBuf = new Uint8Array(count * 3);
  41185. rgbPos = 0;
  41186. for (i = 0; i < count; ++i) {
  41187. key = comps[i] * 3;
  41188. rgbBuf[rgbPos++] = colorMap[key];
  41189. rgbBuf[rgbPos++] = colorMap[key + 1];
  41190. rgbBuf[rgbPos++] = colorMap[key + 2];
  41191. }
  41192. }
  41193. } else {
  41194. if (!needsResizing) {
  41195. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  41196. } else {
  41197. rgbBuf = new Uint8Array(count * 3);
  41198. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  41199. }
  41200. }
  41201. if (rgbBuf) {
  41202. if (needsResizing) {
  41203. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  41204. } else {
  41205. rgbPos = 0;
  41206. destPos = 0;
  41207. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  41208. dest[destPos++] = rgbBuf[rgbPos++];
  41209. dest[destPos++] = rgbBuf[rgbPos++];
  41210. dest[destPos++] = rgbBuf[rgbPos++];
  41211. destPos += alpha01;
  41212. }
  41213. }
  41214. }
  41215. },
  41216. usesZeroToOneRange: true
  41217. };
  41218. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  41219. var IR = ColorSpace.parseToIR(cs, xref, res);
  41220. if (IR instanceof AlternateCS) {
  41221. return IR;
  41222. }
  41223. return ColorSpace.fromIR(IR);
  41224. };
  41225. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  41226. var name = isArray(IR) ? IR[0] : IR;
  41227. var whitePoint, blackPoint, gamma;
  41228. switch (name) {
  41229. case 'DeviceGrayCS':
  41230. return this.singletons.gray;
  41231. case 'DeviceRgbCS':
  41232. return this.singletons.rgb;
  41233. case 'DeviceCmykCS':
  41234. return this.singletons.cmyk;
  41235. case 'CalGrayCS':
  41236. whitePoint = IR[1];
  41237. blackPoint = IR[2];
  41238. gamma = IR[3];
  41239. return new CalGrayCS(whitePoint, blackPoint, gamma);
  41240. case 'CalRGBCS':
  41241. whitePoint = IR[1];
  41242. blackPoint = IR[2];
  41243. gamma = IR[3];
  41244. var matrix = IR[4];
  41245. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  41246. case 'PatternCS':
  41247. var basePatternCS = IR[1];
  41248. if (basePatternCS) {
  41249. basePatternCS = ColorSpace.fromIR(basePatternCS);
  41250. }
  41251. return new PatternCS(basePatternCS);
  41252. case 'IndexedCS':
  41253. var baseIndexedCS = IR[1];
  41254. var hiVal = IR[2];
  41255. var lookup = IR[3];
  41256. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  41257. case 'AlternateCS':
  41258. var numComps = IR[1];
  41259. var alt = IR[2];
  41260. var tintFnIR = IR[3];
  41261. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  41262. case 'LabCS':
  41263. whitePoint = IR[1];
  41264. blackPoint = IR[2];
  41265. var range = IR[3];
  41266. return new LabCS(whitePoint, blackPoint, range);
  41267. default:
  41268. error('Unknown name ' + name);
  41269. }
  41270. return null;
  41271. };
  41272. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  41273. if (isName(cs)) {
  41274. var colorSpaces = res.get('ColorSpace');
  41275. if (isDict(colorSpaces)) {
  41276. var refcs = colorSpaces.get(cs.name);
  41277. if (refcs) {
  41278. cs = refcs;
  41279. }
  41280. }
  41281. }
  41282. cs = xref.fetchIfRef(cs);
  41283. if (isName(cs)) {
  41284. switch (cs.name) {
  41285. case 'DeviceGray':
  41286. case 'G':
  41287. return 'DeviceGrayCS';
  41288. case 'DeviceRGB':
  41289. case 'RGB':
  41290. return 'DeviceRgbCS';
  41291. case 'DeviceCMYK':
  41292. case 'CMYK':
  41293. return 'DeviceCmykCS';
  41294. case 'Pattern':
  41295. return [
  41296. 'PatternCS',
  41297. null
  41298. ];
  41299. default:
  41300. error('unrecognized colorspace ' + cs.name);
  41301. }
  41302. } else if (isArray(cs)) {
  41303. var mode = xref.fetchIfRef(cs[0]).name;
  41304. var numComps, params, alt, whitePoint, blackPoint, gamma;
  41305. switch (mode) {
  41306. case 'DeviceGray':
  41307. case 'G':
  41308. return 'DeviceGrayCS';
  41309. case 'DeviceRGB':
  41310. case 'RGB':
  41311. return 'DeviceRgbCS';
  41312. case 'DeviceCMYK':
  41313. case 'CMYK':
  41314. return 'DeviceCmykCS';
  41315. case 'CalGray':
  41316. params = xref.fetchIfRef(cs[1]);
  41317. whitePoint = params.getArray('WhitePoint');
  41318. blackPoint = params.getArray('BlackPoint');
  41319. gamma = params.get('Gamma');
  41320. return [
  41321. 'CalGrayCS',
  41322. whitePoint,
  41323. blackPoint,
  41324. gamma
  41325. ];
  41326. case 'CalRGB':
  41327. params = xref.fetchIfRef(cs[1]);
  41328. whitePoint = params.getArray('WhitePoint');
  41329. blackPoint = params.getArray('BlackPoint');
  41330. gamma = params.getArray('Gamma');
  41331. var matrix = params.getArray('Matrix');
  41332. return [
  41333. 'CalRGBCS',
  41334. whitePoint,
  41335. blackPoint,
  41336. gamma,
  41337. matrix
  41338. ];
  41339. case 'ICCBased':
  41340. var stream = xref.fetchIfRef(cs[1]);
  41341. var dict = stream.dict;
  41342. numComps = dict.get('N');
  41343. alt = dict.get('Alternate');
  41344. if (alt) {
  41345. var altIR = ColorSpace.parseToIR(alt, xref, res);
  41346. var altCS = ColorSpace.fromIR(altIR);
  41347. if (altCS.numComps === numComps) {
  41348. return altIR;
  41349. }
  41350. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  41351. }
  41352. if (numComps === 1) {
  41353. return 'DeviceGrayCS';
  41354. } else if (numComps === 3) {
  41355. return 'DeviceRgbCS';
  41356. } else if (numComps === 4) {
  41357. return 'DeviceCmykCS';
  41358. }
  41359. break;
  41360. case 'Pattern':
  41361. var basePatternCS = cs[1] || null;
  41362. if (basePatternCS) {
  41363. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  41364. }
  41365. return [
  41366. 'PatternCS',
  41367. basePatternCS
  41368. ];
  41369. case 'Indexed':
  41370. case 'I':
  41371. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  41372. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  41373. var lookup = xref.fetchIfRef(cs[3]);
  41374. if (isStream(lookup)) {
  41375. lookup = lookup.getBytes();
  41376. }
  41377. return [
  41378. 'IndexedCS',
  41379. baseIndexedCS,
  41380. hiVal,
  41381. lookup
  41382. ];
  41383. case 'Separation':
  41384. case 'DeviceN':
  41385. var name = xref.fetchIfRef(cs[1]);
  41386. numComps = isArray(name) ? name.length : 1;
  41387. alt = ColorSpace.parseToIR(cs[2], xref, res);
  41388. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  41389. return [
  41390. 'AlternateCS',
  41391. numComps,
  41392. alt,
  41393. tintFnIR
  41394. ];
  41395. case 'Lab':
  41396. params = xref.fetchIfRef(cs[1]);
  41397. whitePoint = params.getArray('WhitePoint');
  41398. blackPoint = params.getArray('BlackPoint');
  41399. var range = params.getArray('Range');
  41400. return [
  41401. 'LabCS',
  41402. whitePoint,
  41403. blackPoint,
  41404. range
  41405. ];
  41406. default:
  41407. error('unimplemented color space object "' + mode + '"');
  41408. }
  41409. } else {
  41410. error('unrecognized color space object: "' + cs + '"');
  41411. }
  41412. return null;
  41413. };
  41414. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  41415. if (!isArray(decode)) {
  41416. return true;
  41417. }
  41418. if (n * 2 !== decode.length) {
  41419. warn('The decode map is not the correct length');
  41420. return true;
  41421. }
  41422. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  41423. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  41424. return false;
  41425. }
  41426. }
  41427. return true;
  41428. };
  41429. ColorSpace.singletons = {
  41430. get gray() {
  41431. return shadow(this, 'gray', new DeviceGrayCS());
  41432. },
  41433. get rgb() {
  41434. return shadow(this, 'rgb', new DeviceRgbCS());
  41435. },
  41436. get cmyk() {
  41437. return shadow(this, 'cmyk', new DeviceCmykCS());
  41438. }
  41439. };
  41440. return ColorSpace;
  41441. }();
  41442. var AlternateCS = function AlternateCSClosure() {
  41443. function AlternateCS(numComps, base, tintFn) {
  41444. this.name = 'Alternate';
  41445. this.numComps = numComps;
  41446. this.defaultColor = new Float32Array(numComps);
  41447. for (var i = 0; i < numComps; ++i) {
  41448. this.defaultColor[i] = 1;
  41449. }
  41450. this.base = base;
  41451. this.tintFn = tintFn;
  41452. this.tmpBuf = new Float32Array(base.numComps);
  41453. }
  41454. AlternateCS.prototype = {
  41455. getRgb: ColorSpace.prototype.getRgb,
  41456. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41457. var tmpBuf = this.tmpBuf;
  41458. this.tintFn(src, srcOffset, tmpBuf, 0);
  41459. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  41460. },
  41461. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41462. var tintFn = this.tintFn;
  41463. var base = this.base;
  41464. var scale = 1 / ((1 << bits) - 1);
  41465. var baseNumComps = base.numComps;
  41466. var usesZeroToOneRange = base.usesZeroToOneRange;
  41467. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  41468. var pos = isPassthrough ? destOffset : 0;
  41469. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  41470. var numComps = this.numComps;
  41471. var scaled = new Float32Array(numComps);
  41472. var tinted = new Float32Array(baseNumComps);
  41473. var i, j;
  41474. for (i = 0; i < count; i++) {
  41475. for (j = 0; j < numComps; j++) {
  41476. scaled[j] = src[srcOffset++] * scale;
  41477. }
  41478. tintFn(scaled, 0, tinted, 0);
  41479. if (usesZeroToOneRange) {
  41480. for (j = 0; j < baseNumComps; j++) {
  41481. baseBuf[pos++] = tinted[j] * 255;
  41482. }
  41483. } else {
  41484. base.getRgbItem(tinted, 0, baseBuf, pos);
  41485. pos += baseNumComps;
  41486. }
  41487. }
  41488. if (!isPassthrough) {
  41489. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  41490. }
  41491. },
  41492. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  41493. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  41494. },
  41495. isPassthrough: ColorSpace.prototype.isPassthrough,
  41496. fillRgb: ColorSpace.prototype.fillRgb,
  41497. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  41498. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41499. },
  41500. usesZeroToOneRange: true
  41501. };
  41502. return AlternateCS;
  41503. }();
  41504. var PatternCS = function PatternCSClosure() {
  41505. function PatternCS(baseCS) {
  41506. this.name = 'Pattern';
  41507. this.base = baseCS;
  41508. }
  41509. PatternCS.prototype = {};
  41510. return PatternCS;
  41511. }();
  41512. var IndexedCS = function IndexedCSClosure() {
  41513. function IndexedCS(base, highVal, lookup) {
  41514. this.name = 'Indexed';
  41515. this.numComps = 1;
  41516. this.defaultColor = new Uint8Array(this.numComps);
  41517. this.base = base;
  41518. this.highVal = highVal;
  41519. var baseNumComps = base.numComps;
  41520. var length = baseNumComps * highVal;
  41521. if (isStream(lookup)) {
  41522. this.lookup = new Uint8Array(length);
  41523. var bytes = lookup.getBytes(length);
  41524. this.lookup.set(bytes);
  41525. } else if (isString(lookup)) {
  41526. this.lookup = new Uint8Array(length);
  41527. for (var i = 0; i < length; ++i) {
  41528. this.lookup[i] = lookup.charCodeAt(i);
  41529. }
  41530. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  41531. this.lookup = lookup;
  41532. } else {
  41533. error('Unrecognized lookup table: ' + lookup);
  41534. }
  41535. }
  41536. IndexedCS.prototype = {
  41537. getRgb: ColorSpace.prototype.getRgb,
  41538. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41539. var numComps = this.base.numComps;
  41540. var start = src[srcOffset] * numComps;
  41541. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  41542. },
  41543. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41544. var base = this.base;
  41545. var numComps = base.numComps;
  41546. var outputDelta = base.getOutputLength(numComps, alpha01);
  41547. var lookup = this.lookup;
  41548. for (var i = 0; i < count; ++i) {
  41549. var lookupPos = src[srcOffset++] * numComps;
  41550. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  41551. destOffset += outputDelta;
  41552. }
  41553. },
  41554. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  41555. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  41556. },
  41557. isPassthrough: ColorSpace.prototype.isPassthrough,
  41558. fillRgb: ColorSpace.prototype.fillRgb,
  41559. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  41560. return true;
  41561. },
  41562. usesZeroToOneRange: true
  41563. };
  41564. return IndexedCS;
  41565. }();
  41566. var DeviceGrayCS = function DeviceGrayCSClosure() {
  41567. function DeviceGrayCS() {
  41568. this.name = 'DeviceGray';
  41569. this.numComps = 1;
  41570. this.defaultColor = new Float32Array(this.numComps);
  41571. }
  41572. DeviceGrayCS.prototype = {
  41573. getRgb: ColorSpace.prototype.getRgb,
  41574. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41575. var c = src[srcOffset] * 255 | 0;
  41576. c = c < 0 ? 0 : c > 255 ? 255 : c;
  41577. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  41578. },
  41579. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41580. var scale = 255 / ((1 << bits) - 1);
  41581. var j = srcOffset, q = destOffset;
  41582. for (var i = 0; i < count; ++i) {
  41583. var c = scale * src[j++] | 0;
  41584. dest[q++] = c;
  41585. dest[q++] = c;
  41586. dest[q++] = c;
  41587. q += alpha01;
  41588. }
  41589. },
  41590. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  41591. return inputLength * (3 + alpha01);
  41592. },
  41593. isPassthrough: ColorSpace.prototype.isPassthrough,
  41594. fillRgb: ColorSpace.prototype.fillRgb,
  41595. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  41596. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41597. },
  41598. usesZeroToOneRange: true
  41599. };
  41600. return DeviceGrayCS;
  41601. }();
  41602. var DeviceRgbCS = function DeviceRgbCSClosure() {
  41603. function DeviceRgbCS() {
  41604. this.name = 'DeviceRGB';
  41605. this.numComps = 3;
  41606. this.defaultColor = new Float32Array(this.numComps);
  41607. }
  41608. DeviceRgbCS.prototype = {
  41609. getRgb: ColorSpace.prototype.getRgb,
  41610. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41611. var r = src[srcOffset] * 255 | 0;
  41612. var g = src[srcOffset + 1] * 255 | 0;
  41613. var b = src[srcOffset + 2] * 255 | 0;
  41614. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  41615. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  41616. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  41617. },
  41618. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41619. if (bits === 8 && alpha01 === 0) {
  41620. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  41621. return;
  41622. }
  41623. var scale = 255 / ((1 << bits) - 1);
  41624. var j = srcOffset, q = destOffset;
  41625. for (var i = 0; i < count; ++i) {
  41626. dest[q++] = scale * src[j++] | 0;
  41627. dest[q++] = scale * src[j++] | 0;
  41628. dest[q++] = scale * src[j++] | 0;
  41629. q += alpha01;
  41630. }
  41631. },
  41632. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  41633. return inputLength * (3 + alpha01) / 3 | 0;
  41634. },
  41635. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  41636. return bits === 8;
  41637. },
  41638. fillRgb: ColorSpace.prototype.fillRgb,
  41639. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  41640. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41641. },
  41642. usesZeroToOneRange: true
  41643. };
  41644. return DeviceRgbCS;
  41645. }();
  41646. var DeviceCmykCS = function DeviceCmykCSClosure() {
  41647. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  41648. var c = src[srcOffset + 0] * srcScale;
  41649. var m = src[srcOffset + 1] * srcScale;
  41650. var y = src[srcOffset + 2] * srcScale;
  41651. var k = src[srcOffset + 3] * srcScale;
  41652. 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;
  41653. 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;
  41654. 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;
  41655. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  41656. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  41657. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  41658. }
  41659. function DeviceCmykCS() {
  41660. this.name = 'DeviceCMYK';
  41661. this.numComps = 4;
  41662. this.defaultColor = new Float32Array(this.numComps);
  41663. this.defaultColor[3] = 1;
  41664. }
  41665. DeviceCmykCS.prototype = {
  41666. getRgb: ColorSpace.prototype.getRgb,
  41667. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41668. convertToRgb(src, srcOffset, 1, dest, destOffset);
  41669. },
  41670. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41671. var scale = 1 / ((1 << bits) - 1);
  41672. for (var i = 0; i < count; i++) {
  41673. convertToRgb(src, srcOffset, scale, dest, destOffset);
  41674. srcOffset += 4;
  41675. destOffset += 3 + alpha01;
  41676. }
  41677. },
  41678. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  41679. return inputLength / 4 * (3 + alpha01) | 0;
  41680. },
  41681. isPassthrough: ColorSpace.prototype.isPassthrough,
  41682. fillRgb: ColorSpace.prototype.fillRgb,
  41683. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  41684. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41685. },
  41686. usesZeroToOneRange: true
  41687. };
  41688. return DeviceCmykCS;
  41689. }();
  41690. var CalGrayCS = function CalGrayCSClosure() {
  41691. function CalGrayCS(whitePoint, blackPoint, gamma) {
  41692. this.name = 'CalGray';
  41693. this.numComps = 1;
  41694. this.defaultColor = new Float32Array(this.numComps);
  41695. if (!whitePoint) {
  41696. error('WhitePoint missing - required for color space CalGray');
  41697. }
  41698. blackPoint = blackPoint || [
  41699. 0,
  41700. 0,
  41701. 0
  41702. ];
  41703. gamma = gamma || 1;
  41704. this.XW = whitePoint[0];
  41705. this.YW = whitePoint[1];
  41706. this.ZW = whitePoint[2];
  41707. this.XB = blackPoint[0];
  41708. this.YB = blackPoint[1];
  41709. this.ZB = blackPoint[2];
  41710. this.G = gamma;
  41711. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  41712. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41713. }
  41714. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  41715. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  41716. this.XB = this.YB = this.ZB = 0;
  41717. }
  41718. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  41719. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  41720. }
  41721. if (this.G < 1) {
  41722. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  41723. this.G = 1;
  41724. }
  41725. }
  41726. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  41727. var A = src[srcOffset] * scale;
  41728. var AG = Math.pow(A, cs.G);
  41729. var L = cs.YW * AG;
  41730. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  41731. dest[destOffset] = val;
  41732. dest[destOffset + 1] = val;
  41733. dest[destOffset + 2] = val;
  41734. }
  41735. CalGrayCS.prototype = {
  41736. getRgb: ColorSpace.prototype.getRgb,
  41737. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41738. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  41739. },
  41740. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41741. var scale = 1 / ((1 << bits) - 1);
  41742. for (var i = 0; i < count; ++i) {
  41743. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  41744. srcOffset += 1;
  41745. destOffset += 3 + alpha01;
  41746. }
  41747. },
  41748. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  41749. return inputLength * (3 + alpha01);
  41750. },
  41751. isPassthrough: ColorSpace.prototype.isPassthrough,
  41752. fillRgb: ColorSpace.prototype.fillRgb,
  41753. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  41754. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41755. },
  41756. usesZeroToOneRange: true
  41757. };
  41758. return CalGrayCS;
  41759. }();
  41760. var CalRGBCS = function CalRGBCSClosure() {
  41761. var BRADFORD_SCALE_MATRIX = new Float32Array([
  41762. 0.8951,
  41763. 0.2664,
  41764. -0.1614,
  41765. -0.7502,
  41766. 1.7135,
  41767. 0.0367,
  41768. 0.0389,
  41769. -0.0685,
  41770. 1.0296
  41771. ]);
  41772. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  41773. 0.9869929,
  41774. -0.1470543,
  41775. 0.1599627,
  41776. 0.4323053,
  41777. 0.5183603,
  41778. 0.0492912,
  41779. -0.0085287,
  41780. 0.0400428,
  41781. 0.9684867
  41782. ]);
  41783. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  41784. 3.2404542,
  41785. -1.5371385,
  41786. -0.4985314,
  41787. -0.9692660,
  41788. 1.8760108,
  41789. 0.0415560,
  41790. 0.0556434,
  41791. -0.2040259,
  41792. 1.0572252
  41793. ]);
  41794. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  41795. 1,
  41796. 1,
  41797. 1
  41798. ]);
  41799. var tempNormalizeMatrix = new Float32Array(3);
  41800. var tempConvertMatrix1 = new Float32Array(3);
  41801. var tempConvertMatrix2 = new Float32Array(3);
  41802. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  41803. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  41804. this.name = 'CalRGB';
  41805. this.numComps = 3;
  41806. this.defaultColor = new Float32Array(this.numComps);
  41807. if (!whitePoint) {
  41808. error('WhitePoint missing - required for color space CalRGB');
  41809. }
  41810. blackPoint = blackPoint || new Float32Array(3);
  41811. gamma = gamma || new Float32Array([
  41812. 1,
  41813. 1,
  41814. 1
  41815. ]);
  41816. matrix = matrix || new Float32Array([
  41817. 1,
  41818. 0,
  41819. 0,
  41820. 0,
  41821. 1,
  41822. 0,
  41823. 0,
  41824. 0,
  41825. 1
  41826. ]);
  41827. var XW = whitePoint[0];
  41828. var YW = whitePoint[1];
  41829. var ZW = whitePoint[2];
  41830. this.whitePoint = whitePoint;
  41831. var XB = blackPoint[0];
  41832. var YB = blackPoint[1];
  41833. var ZB = blackPoint[2];
  41834. this.blackPoint = blackPoint;
  41835. this.GR = gamma[0];
  41836. this.GG = gamma[1];
  41837. this.GB = gamma[2];
  41838. this.MXA = matrix[0];
  41839. this.MYA = matrix[1];
  41840. this.MZA = matrix[2];
  41841. this.MXB = matrix[3];
  41842. this.MYB = matrix[4];
  41843. this.MZB = matrix[5];
  41844. this.MXC = matrix[6];
  41845. this.MYC = matrix[7];
  41846. this.MZC = matrix[8];
  41847. if (XW < 0 || ZW < 0 || YW !== 1) {
  41848. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41849. }
  41850. if (XB < 0 || YB < 0 || ZB < 0) {
  41851. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  41852. this.blackPoint = new Float32Array(3);
  41853. }
  41854. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  41855. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  41856. this.GR = this.GG = this.GB = 1;
  41857. }
  41858. 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) {
  41859. 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');
  41860. this.MXA = this.MYB = this.MZC = 1;
  41861. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  41862. }
  41863. }
  41864. function matrixProduct(a, b, result) {
  41865. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  41866. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  41867. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  41868. }
  41869. function convertToFlat(sourceWhitePoint, LMS, result) {
  41870. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  41871. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  41872. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  41873. }
  41874. function convertToD65(sourceWhitePoint, LMS, result) {
  41875. var D65X = 0.95047;
  41876. var D65Y = 1;
  41877. var D65Z = 1.08883;
  41878. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  41879. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  41880. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  41881. }
  41882. function sRGBTransferFunction(color) {
  41883. if (color <= 0.0031308) {
  41884. return adjustToRange(0, 1, 12.92 * color);
  41885. }
  41886. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  41887. }
  41888. function adjustToRange(min, max, value) {
  41889. return Math.max(min, Math.min(max, value));
  41890. }
  41891. function decodeL(L) {
  41892. if (L < 0) {
  41893. return -decodeL(-L);
  41894. }
  41895. if (L > 8.0) {
  41896. return Math.pow((L + 16) / 116, 3);
  41897. }
  41898. return L * DECODE_L_CONSTANT;
  41899. }
  41900. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  41901. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  41902. result[0] = XYZ_Flat[0];
  41903. result[1] = XYZ_Flat[1];
  41904. result[2] = XYZ_Flat[2];
  41905. return;
  41906. }
  41907. var zeroDecodeL = decodeL(0);
  41908. var X_DST = zeroDecodeL;
  41909. var X_SRC = decodeL(sourceBlackPoint[0]);
  41910. var Y_DST = zeroDecodeL;
  41911. var Y_SRC = decodeL(sourceBlackPoint[1]);
  41912. var Z_DST = zeroDecodeL;
  41913. var Z_SRC = decodeL(sourceBlackPoint[2]);
  41914. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  41915. var X_Offset = 1 - X_Scale;
  41916. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  41917. var Y_Offset = 1 - Y_Scale;
  41918. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  41919. var Z_Offset = 1 - Z_Scale;
  41920. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  41921. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  41922. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  41923. }
  41924. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  41925. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  41926. result[0] = XYZ_In[0];
  41927. result[1] = XYZ_In[1];
  41928. result[2] = XYZ_In[2];
  41929. return;
  41930. }
  41931. var LMS = result;
  41932. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  41933. var LMS_Flat = tempNormalizeMatrix;
  41934. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  41935. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  41936. }
  41937. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  41938. var LMS = result;
  41939. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  41940. var LMS_D65 = tempNormalizeMatrix;
  41941. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  41942. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  41943. }
  41944. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  41945. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  41946. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  41947. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  41948. var AGR = Math.pow(A, cs.GR);
  41949. var BGG = Math.pow(B, cs.GG);
  41950. var CGB = Math.pow(C, cs.GB);
  41951. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  41952. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  41953. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  41954. var XYZ = tempConvertMatrix1;
  41955. XYZ[0] = X;
  41956. XYZ[1] = Y;
  41957. XYZ[2] = Z;
  41958. var XYZ_Flat = tempConvertMatrix2;
  41959. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  41960. var XYZ_Black = tempConvertMatrix1;
  41961. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  41962. var XYZ_D65 = tempConvertMatrix2;
  41963. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  41964. var SRGB = tempConvertMatrix1;
  41965. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  41966. var sR = sRGBTransferFunction(SRGB[0]);
  41967. var sG = sRGBTransferFunction(SRGB[1]);
  41968. var sB = sRGBTransferFunction(SRGB[2]);
  41969. dest[destOffset] = Math.round(sR * 255);
  41970. dest[destOffset + 1] = Math.round(sG * 255);
  41971. dest[destOffset + 2] = Math.round(sB * 255);
  41972. }
  41973. CalRGBCS.prototype = {
  41974. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  41975. var rgb = new Uint8Array(3);
  41976. this.getRgbItem(src, srcOffset, rgb, 0);
  41977. return rgb;
  41978. },
  41979. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41980. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  41981. },
  41982. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41983. var scale = 1 / ((1 << bits) - 1);
  41984. for (var i = 0; i < count; ++i) {
  41985. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  41986. srcOffset += 3;
  41987. destOffset += 3 + alpha01;
  41988. }
  41989. },
  41990. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  41991. return inputLength * (3 + alpha01) / 3 | 0;
  41992. },
  41993. isPassthrough: ColorSpace.prototype.isPassthrough,
  41994. fillRgb: ColorSpace.prototype.fillRgb,
  41995. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  41996. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41997. },
  41998. usesZeroToOneRange: true
  41999. };
  42000. return CalRGBCS;
  42001. }();
  42002. var LabCS = function LabCSClosure() {
  42003. function LabCS(whitePoint, blackPoint, range) {
  42004. this.name = 'Lab';
  42005. this.numComps = 3;
  42006. this.defaultColor = new Float32Array(this.numComps);
  42007. if (!whitePoint) {
  42008. error('WhitePoint missing - required for color space Lab');
  42009. }
  42010. blackPoint = blackPoint || [
  42011. 0,
  42012. 0,
  42013. 0
  42014. ];
  42015. range = range || [
  42016. -100,
  42017. 100,
  42018. -100,
  42019. 100
  42020. ];
  42021. this.XW = whitePoint[0];
  42022. this.YW = whitePoint[1];
  42023. this.ZW = whitePoint[2];
  42024. this.amin = range[0];
  42025. this.amax = range[1];
  42026. this.bmin = range[2];
  42027. this.bmax = range[3];
  42028. this.XB = blackPoint[0];
  42029. this.YB = blackPoint[1];
  42030. this.ZB = blackPoint[2];
  42031. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  42032. error('Invalid WhitePoint components, no fallback available');
  42033. }
  42034. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  42035. info('Invalid BlackPoint, falling back to default');
  42036. this.XB = this.YB = this.ZB = 0;
  42037. }
  42038. if (this.amin > this.amax || this.bmin > this.bmax) {
  42039. info('Invalid Range, falling back to defaults');
  42040. this.amin = -100;
  42041. this.amax = 100;
  42042. this.bmin = -100;
  42043. this.bmax = 100;
  42044. }
  42045. }
  42046. function fn_g(x) {
  42047. if (x >= 6 / 29) {
  42048. return x * x * x;
  42049. } else {
  42050. return 108 / 841 * (x - 4 / 29);
  42051. }
  42052. }
  42053. function decode(value, high1, low2, high2) {
  42054. return low2 + value * (high2 - low2) / high1;
  42055. }
  42056. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  42057. var Ls = src[srcOffset];
  42058. var as = src[srcOffset + 1];
  42059. var bs = src[srcOffset + 2];
  42060. if (maxVal !== false) {
  42061. Ls = decode(Ls, maxVal, 0, 100);
  42062. as = decode(as, maxVal, cs.amin, cs.amax);
  42063. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  42064. }
  42065. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  42066. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  42067. var M = (Ls + 16) / 116;
  42068. var L = M + as / 500;
  42069. var N = M - bs / 200;
  42070. var X = cs.XW * fn_g(L);
  42071. var Y = cs.YW * fn_g(M);
  42072. var Z = cs.ZW * fn_g(N);
  42073. var r, g, b;
  42074. if (cs.ZW < 1) {
  42075. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  42076. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  42077. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  42078. } else {
  42079. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  42080. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  42081. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  42082. }
  42083. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  42084. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  42085. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  42086. }
  42087. LabCS.prototype = {
  42088. getRgb: ColorSpace.prototype.getRgb,
  42089. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42090. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  42091. },
  42092. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42093. var maxVal = (1 << bits) - 1;
  42094. for (var i = 0; i < count; i++) {
  42095. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  42096. srcOffset += 3;
  42097. destOffset += 3 + alpha01;
  42098. }
  42099. },
  42100. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  42101. return inputLength * (3 + alpha01) / 3 | 0;
  42102. },
  42103. isPassthrough: ColorSpace.prototype.isPassthrough,
  42104. fillRgb: ColorSpace.prototype.fillRgb,
  42105. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  42106. return true;
  42107. },
  42108. usesZeroToOneRange: false
  42109. };
  42110. return LabCS;
  42111. }();
  42112. exports.ColorSpace = ColorSpace;
  42113. }));
  42114. (function (root, factory) {
  42115. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  42116. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  42117. var ImageKind = sharedUtil.ImageKind;
  42118. var assert = sharedUtil.assert;
  42119. var error = sharedUtil.error;
  42120. var info = sharedUtil.info;
  42121. var isArray = sharedUtil.isArray;
  42122. var warn = sharedUtil.warn;
  42123. var Name = corePrimitives.Name;
  42124. var isStream = corePrimitives.isStream;
  42125. var ColorSpace = coreColorSpace.ColorSpace;
  42126. var DecodeStream = coreStream.DecodeStream;
  42127. var JpegStream = coreStream.JpegStream;
  42128. var JpxImage = coreJpx.JpxImage;
  42129. var PDFImage = function PDFImageClosure() {
  42130. function handleImageData(image, nativeDecoder) {
  42131. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  42132. return nativeDecoder.decode(image);
  42133. } else {
  42134. return Promise.resolve(image);
  42135. }
  42136. }
  42137. function decodeAndClamp(value, addend, coefficient, max) {
  42138. value = addend + value * coefficient;
  42139. return value < 0 ? 0 : value > max ? max : value;
  42140. }
  42141. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  42142. var length = w2 * h2;
  42143. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42144. var xRatio = w1 / w2;
  42145. var yRatio = h1 / h2;
  42146. var i, j, py, newIndex = 0, oldIndex;
  42147. var xScaled = new Uint16Array(w2);
  42148. var w1Scanline = w1;
  42149. for (i = 0; i < w2; i++) {
  42150. xScaled[i] = Math.floor(i * xRatio);
  42151. }
  42152. for (i = 0; i < h2; i++) {
  42153. py = Math.floor(i * yRatio) * w1Scanline;
  42154. for (j = 0; j < w2; j++) {
  42155. oldIndex = py + xScaled[j];
  42156. dest[newIndex++] = src[oldIndex];
  42157. }
  42158. }
  42159. return dest;
  42160. }
  42161. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  42162. this.image = image;
  42163. var dict = image.dict;
  42164. if (dict.has('Filter')) {
  42165. var filter = dict.get('Filter').name;
  42166. if (filter === 'JPXDecode') {
  42167. var jpxImage = new JpxImage();
  42168. jpxImage.parseImageProperties(image.stream);
  42169. image.stream.reset();
  42170. image.bitsPerComponent = jpxImage.bitsPerComponent;
  42171. image.numComps = jpxImage.componentsCount;
  42172. } else if (filter === 'JBIG2Decode') {
  42173. image.bitsPerComponent = 1;
  42174. image.numComps = 1;
  42175. }
  42176. }
  42177. this.width = dict.get('Width', 'W');
  42178. this.height = dict.get('Height', 'H');
  42179. if (this.width < 1 || this.height < 1) {
  42180. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  42181. }
  42182. this.interpolate = dict.get('Interpolate', 'I') || false;
  42183. this.imageMask = dict.get('ImageMask', 'IM') || false;
  42184. this.matte = dict.get('Matte') || false;
  42185. var bitsPerComponent = image.bitsPerComponent;
  42186. if (!bitsPerComponent) {
  42187. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  42188. if (!bitsPerComponent) {
  42189. if (this.imageMask) {
  42190. bitsPerComponent = 1;
  42191. } else {
  42192. error('Bits per component missing in image: ' + this.imageMask);
  42193. }
  42194. }
  42195. }
  42196. this.bpc = bitsPerComponent;
  42197. if (!this.imageMask) {
  42198. var colorSpace = dict.get('ColorSpace', 'CS');
  42199. if (!colorSpace) {
  42200. info('JPX images (which do not require color spaces)');
  42201. switch (image.numComps) {
  42202. case 1:
  42203. colorSpace = Name.get('DeviceGray');
  42204. break;
  42205. case 3:
  42206. colorSpace = Name.get('DeviceRGB');
  42207. break;
  42208. case 4:
  42209. colorSpace = Name.get('DeviceCMYK');
  42210. break;
  42211. default:
  42212. error('JPX images with ' + this.numComps + ' color components not supported.');
  42213. }
  42214. }
  42215. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  42216. this.numComps = this.colorSpace.numComps;
  42217. }
  42218. this.decode = dict.getArray('Decode', 'D');
  42219. this.needsDecode = false;
  42220. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  42221. this.needsDecode = true;
  42222. var max = (1 << bitsPerComponent) - 1;
  42223. this.decodeCoefficients = [];
  42224. this.decodeAddends = [];
  42225. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  42226. var dmin = this.decode[i];
  42227. var dmax = this.decode[i + 1];
  42228. this.decodeCoefficients[j] = dmax - dmin;
  42229. this.decodeAddends[j] = max * dmin;
  42230. }
  42231. }
  42232. if (smask) {
  42233. this.smask = new PDFImage(xref, res, smask, false);
  42234. } else if (mask) {
  42235. if (isStream(mask)) {
  42236. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  42237. if (!imageMask) {
  42238. warn('Ignoring /Mask in image without /ImageMask.');
  42239. } else {
  42240. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  42241. }
  42242. } else {
  42243. this.mask = mask;
  42244. }
  42245. }
  42246. }
  42247. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  42248. var imagePromise = handleImageData(image, nativeDecoder);
  42249. var smaskPromise;
  42250. var maskPromise;
  42251. var smask = image.dict.get('SMask');
  42252. var mask = image.dict.get('Mask');
  42253. if (smask) {
  42254. smaskPromise = handleImageData(smask, nativeDecoder);
  42255. maskPromise = Promise.resolve(null);
  42256. } else {
  42257. smaskPromise = Promise.resolve(null);
  42258. if (mask) {
  42259. if (isStream(mask)) {
  42260. maskPromise = handleImageData(mask, nativeDecoder);
  42261. } else if (isArray(mask)) {
  42262. maskPromise = Promise.resolve(mask);
  42263. } else {
  42264. warn('Unsupported mask format.');
  42265. maskPromise = Promise.resolve(null);
  42266. }
  42267. } else {
  42268. maskPromise = Promise.resolve(null);
  42269. }
  42270. }
  42271. return Promise.all([
  42272. imagePromise,
  42273. smaskPromise,
  42274. maskPromise
  42275. ]).then(function (results) {
  42276. var imageData = results[0];
  42277. var smaskData = results[1];
  42278. var maskData = results[2];
  42279. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  42280. });
  42281. };
  42282. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  42283. var computedLength = (width + 7 >> 3) * height;
  42284. var actualLength = imgArray.byteLength;
  42285. var haveFullData = computedLength === actualLength;
  42286. var data, i;
  42287. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  42288. data = imgArray;
  42289. } else if (!inverseDecode) {
  42290. data = new Uint8Array(actualLength);
  42291. data.set(imgArray);
  42292. } else {
  42293. data = new Uint8Array(computedLength);
  42294. data.set(imgArray);
  42295. for (i = actualLength; i < computedLength; i++) {
  42296. data[i] = 0xff;
  42297. }
  42298. }
  42299. if (inverseDecode) {
  42300. for (i = 0; i < actualLength; i++) {
  42301. data[i] = ~data[i];
  42302. }
  42303. }
  42304. return {
  42305. data: data,
  42306. width: width,
  42307. height: height
  42308. };
  42309. };
  42310. PDFImage.prototype = {
  42311. get drawWidth() {
  42312. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  42313. },
  42314. get drawHeight() {
  42315. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  42316. },
  42317. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  42318. var bpc = this.bpc;
  42319. var numComps = this.numComps;
  42320. var decodeAddends = this.decodeAddends;
  42321. var decodeCoefficients = this.decodeCoefficients;
  42322. var max = (1 << bpc) - 1;
  42323. var i, ii;
  42324. if (bpc === 1) {
  42325. for (i = 0, ii = buffer.length; i < ii; i++) {
  42326. buffer[i] = +!buffer[i];
  42327. }
  42328. return;
  42329. }
  42330. var index = 0;
  42331. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  42332. for (var j = 0; j < numComps; j++) {
  42333. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  42334. index++;
  42335. }
  42336. }
  42337. },
  42338. getComponents: function PDFImage_getComponents(buffer) {
  42339. var bpc = this.bpc;
  42340. if (bpc === 8) {
  42341. return buffer;
  42342. }
  42343. var width = this.width;
  42344. var height = this.height;
  42345. var numComps = this.numComps;
  42346. var length = width * height * numComps;
  42347. var bufferPos = 0;
  42348. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42349. var rowComps = width * numComps;
  42350. var max = (1 << bpc) - 1;
  42351. var i = 0, ii, buf;
  42352. if (bpc === 1) {
  42353. var mask, loop1End, loop2End;
  42354. for (var j = 0; j < height; j++) {
  42355. loop1End = i + (rowComps & ~7);
  42356. loop2End = i + rowComps;
  42357. while (i < loop1End) {
  42358. buf = buffer[bufferPos++];
  42359. output[i] = buf >> 7 & 1;
  42360. output[i + 1] = buf >> 6 & 1;
  42361. output[i + 2] = buf >> 5 & 1;
  42362. output[i + 3] = buf >> 4 & 1;
  42363. output[i + 4] = buf >> 3 & 1;
  42364. output[i + 5] = buf >> 2 & 1;
  42365. output[i + 6] = buf >> 1 & 1;
  42366. output[i + 7] = buf & 1;
  42367. i += 8;
  42368. }
  42369. if (i < loop2End) {
  42370. buf = buffer[bufferPos++];
  42371. mask = 128;
  42372. while (i < loop2End) {
  42373. output[i++] = +!!(buf & mask);
  42374. mask >>= 1;
  42375. }
  42376. }
  42377. }
  42378. } else {
  42379. var bits = 0;
  42380. buf = 0;
  42381. for (i = 0, ii = length; i < ii; ++i) {
  42382. if (i % rowComps === 0) {
  42383. buf = 0;
  42384. bits = 0;
  42385. }
  42386. while (bits < bpc) {
  42387. buf = buf << 8 | buffer[bufferPos++];
  42388. bits += 8;
  42389. }
  42390. var remainingBits = bits - bpc;
  42391. var value = buf >> remainingBits;
  42392. output[i] = value < 0 ? 0 : value > max ? max : value;
  42393. buf = buf & (1 << remainingBits) - 1;
  42394. bits = remainingBits;
  42395. }
  42396. }
  42397. return output;
  42398. },
  42399. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  42400. var smask = this.smask;
  42401. var mask = this.mask;
  42402. var alphaBuf, sw, sh, i, ii, j;
  42403. if (smask) {
  42404. sw = smask.width;
  42405. sh = smask.height;
  42406. alphaBuf = new Uint8Array(sw * sh);
  42407. smask.fillGrayBuffer(alphaBuf);
  42408. if (sw !== width || sh !== height) {
  42409. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  42410. }
  42411. } else if (mask) {
  42412. if (mask instanceof PDFImage) {
  42413. sw = mask.width;
  42414. sh = mask.height;
  42415. alphaBuf = new Uint8Array(sw * sh);
  42416. mask.numComps = 1;
  42417. mask.fillGrayBuffer(alphaBuf);
  42418. for (i = 0, ii = sw * sh; i < ii; ++i) {
  42419. alphaBuf[i] = 255 - alphaBuf[i];
  42420. }
  42421. if (sw !== width || sh !== height) {
  42422. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  42423. }
  42424. } else if (isArray(mask)) {
  42425. alphaBuf = new Uint8Array(width * height);
  42426. var numComps = this.numComps;
  42427. for (i = 0, ii = width * height; i < ii; ++i) {
  42428. var opacity = 0;
  42429. var imageOffset = i * numComps;
  42430. for (j = 0; j < numComps; ++j) {
  42431. var color = image[imageOffset + j];
  42432. var maskOffset = j * 2;
  42433. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  42434. opacity = 255;
  42435. break;
  42436. }
  42437. }
  42438. alphaBuf[i] = opacity;
  42439. }
  42440. } else {
  42441. error('Unknown mask format.');
  42442. }
  42443. }
  42444. if (alphaBuf) {
  42445. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42446. rgbaBuf[j] = alphaBuf[i];
  42447. }
  42448. } else {
  42449. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42450. rgbaBuf[j] = 255;
  42451. }
  42452. }
  42453. },
  42454. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  42455. var matte = this.smask && this.smask.matte;
  42456. if (!matte) {
  42457. return;
  42458. }
  42459. var matteRgb = this.colorSpace.getRgb(matte, 0);
  42460. var matteR = matteRgb[0];
  42461. var matteG = matteRgb[1];
  42462. var matteB = matteRgb[2];
  42463. var length = width * height * 4;
  42464. var r, g, b;
  42465. for (var i = 0; i < length; i += 4) {
  42466. var alpha = buffer[i + 3];
  42467. if (alpha === 0) {
  42468. buffer[i] = 255;
  42469. buffer[i + 1] = 255;
  42470. buffer[i + 2] = 255;
  42471. continue;
  42472. }
  42473. var k = 255 / alpha;
  42474. r = (buffer[i] - matteR) * k + matteR;
  42475. g = (buffer[i + 1] - matteG) * k + matteG;
  42476. b = (buffer[i + 2] - matteB) * k + matteB;
  42477. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  42478. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  42479. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  42480. }
  42481. },
  42482. createImageData: function PDFImage_createImageData(forceRGBA) {
  42483. var drawWidth = this.drawWidth;
  42484. var drawHeight = this.drawHeight;
  42485. var imgData = {
  42486. width: drawWidth,
  42487. height: drawHeight
  42488. };
  42489. var numComps = this.numComps;
  42490. var originalWidth = this.width;
  42491. var originalHeight = this.height;
  42492. var bpc = this.bpc;
  42493. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  42494. var imgArray;
  42495. if (!forceRGBA) {
  42496. var kind;
  42497. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  42498. kind = ImageKind.GRAYSCALE_1BPP;
  42499. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  42500. kind = ImageKind.RGB_24BPP;
  42501. }
  42502. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  42503. imgData.kind = kind;
  42504. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42505. if (this.image instanceof DecodeStream) {
  42506. imgData.data = imgArray;
  42507. } else {
  42508. var newArray = new Uint8Array(imgArray.length);
  42509. newArray.set(imgArray);
  42510. imgData.data = newArray;
  42511. }
  42512. if (this.needsDecode) {
  42513. assert(kind === ImageKind.GRAYSCALE_1BPP);
  42514. var buffer = imgData.data;
  42515. for (var i = 0, ii = buffer.length; i < ii; i++) {
  42516. buffer[i] ^= 0xff;
  42517. }
  42518. }
  42519. return imgData;
  42520. }
  42521. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  42522. imgData.kind = ImageKind.RGB_24BPP;
  42523. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  42524. return imgData;
  42525. }
  42526. }
  42527. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42528. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  42529. var comps = this.getComponents(imgArray);
  42530. var alpha01, maybeUndoPreblend;
  42531. if (!forceRGBA && !this.smask && !this.mask) {
  42532. imgData.kind = ImageKind.RGB_24BPP;
  42533. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  42534. alpha01 = 0;
  42535. maybeUndoPreblend = false;
  42536. } else {
  42537. imgData.kind = ImageKind.RGBA_32BPP;
  42538. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  42539. alpha01 = 1;
  42540. maybeUndoPreblend = true;
  42541. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  42542. }
  42543. if (this.needsDecode) {
  42544. this.decodeBuffer(comps);
  42545. }
  42546. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  42547. if (maybeUndoPreblend) {
  42548. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  42549. }
  42550. return imgData;
  42551. },
  42552. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  42553. var numComps = this.numComps;
  42554. if (numComps !== 1) {
  42555. error('Reading gray scale from a color image: ' + numComps);
  42556. }
  42557. var width = this.width;
  42558. var height = this.height;
  42559. var bpc = this.bpc;
  42560. var rowBytes = width * numComps * bpc + 7 >> 3;
  42561. var imgArray = this.getImageBytes(height * rowBytes);
  42562. var comps = this.getComponents(imgArray);
  42563. var i, length;
  42564. if (bpc === 1) {
  42565. length = width * height;
  42566. if (this.needsDecode) {
  42567. for (i = 0; i < length; ++i) {
  42568. buffer[i] = comps[i] - 1 & 255;
  42569. }
  42570. } else {
  42571. for (i = 0; i < length; ++i) {
  42572. buffer[i] = -comps[i] & 255;
  42573. }
  42574. }
  42575. return;
  42576. }
  42577. if (this.needsDecode) {
  42578. this.decodeBuffer(comps);
  42579. }
  42580. length = width * height;
  42581. var scale = 255 / ((1 << bpc) - 1);
  42582. for (i = 0; i < length; ++i) {
  42583. buffer[i] = scale * comps[i] | 0;
  42584. }
  42585. },
  42586. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  42587. this.image.reset();
  42588. this.image.drawWidth = drawWidth || this.width;
  42589. this.image.drawHeight = drawHeight || this.height;
  42590. this.image.forceRGB = !!forceRGB;
  42591. return this.image.getBytes(length);
  42592. }
  42593. };
  42594. return PDFImage;
  42595. }();
  42596. exports.PDFImage = PDFImage;
  42597. }));
  42598. (function (root, factory) {
  42599. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  42600. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  42601. var InvalidPDFException = sharedUtil.InvalidPDFException;
  42602. var MissingDataException = sharedUtil.MissingDataException;
  42603. var XRefParseException = sharedUtil.XRefParseException;
  42604. var assert = sharedUtil.assert;
  42605. var bytesToString = sharedUtil.bytesToString;
  42606. var createPromiseCapability = sharedUtil.createPromiseCapability;
  42607. var error = sharedUtil.error;
  42608. var info = sharedUtil.info;
  42609. var isArray = sharedUtil.isArray;
  42610. var isBool = sharedUtil.isBool;
  42611. var isInt = sharedUtil.isInt;
  42612. var isString = sharedUtil.isString;
  42613. var shadow = sharedUtil.shadow;
  42614. var stringToPDFString = sharedUtil.stringToPDFString;
  42615. var stringToUTF8String = sharedUtil.stringToUTF8String;
  42616. var warn = sharedUtil.warn;
  42617. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  42618. var Util = sharedUtil.Util;
  42619. var Ref = corePrimitives.Ref;
  42620. var RefSet = corePrimitives.RefSet;
  42621. var RefSetCache = corePrimitives.RefSetCache;
  42622. var isName = corePrimitives.isName;
  42623. var isCmd = corePrimitives.isCmd;
  42624. var isDict = corePrimitives.isDict;
  42625. var isRef = corePrimitives.isRef;
  42626. var isRefsEqual = corePrimitives.isRefsEqual;
  42627. var isStream = corePrimitives.isStream;
  42628. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  42629. var Lexer = coreParser.Lexer;
  42630. var Parser = coreParser.Parser;
  42631. var ChunkedStream = coreChunkedStream.ChunkedStream;
  42632. var ColorSpace = coreColorSpace.ColorSpace;
  42633. var Catalog = function CatalogClosure() {
  42634. function Catalog(pdfManager, xref, pageFactory) {
  42635. this.pdfManager = pdfManager;
  42636. this.xref = xref;
  42637. this.catDict = xref.getCatalogObj();
  42638. this.fontCache = new RefSetCache();
  42639. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  42640. this.pageFactory = pageFactory;
  42641. this.pagePromises = [];
  42642. }
  42643. Catalog.prototype = {
  42644. get metadata() {
  42645. var streamRef = this.catDict.getRaw('Metadata');
  42646. if (!isRef(streamRef)) {
  42647. return shadow(this, 'metadata', null);
  42648. }
  42649. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  42650. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  42651. var metadata;
  42652. if (stream && isDict(stream.dict)) {
  42653. var type = stream.dict.get('Type');
  42654. var subtype = stream.dict.get('Subtype');
  42655. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  42656. try {
  42657. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  42658. } catch (e) {
  42659. info('Skipping invalid metadata.');
  42660. }
  42661. }
  42662. }
  42663. return shadow(this, 'metadata', metadata);
  42664. },
  42665. get toplevelPagesDict() {
  42666. var pagesObj = this.catDict.get('Pages');
  42667. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  42668. return shadow(this, 'toplevelPagesDict', pagesObj);
  42669. },
  42670. get documentOutline() {
  42671. var obj = null;
  42672. try {
  42673. obj = this.readDocumentOutline();
  42674. } catch (ex) {
  42675. if (ex instanceof MissingDataException) {
  42676. throw ex;
  42677. }
  42678. warn('Unable to read document outline');
  42679. }
  42680. return shadow(this, 'documentOutline', obj);
  42681. },
  42682. readDocumentOutline: function Catalog_readDocumentOutline() {
  42683. var obj = this.catDict.get('Outlines');
  42684. if (!isDict(obj)) {
  42685. return null;
  42686. }
  42687. obj = obj.getRaw('First');
  42688. if (!isRef(obj)) {
  42689. return null;
  42690. }
  42691. var root = { items: [] };
  42692. var queue = [{
  42693. obj: obj,
  42694. parent: root
  42695. }];
  42696. var processed = new RefSet();
  42697. processed.put(obj);
  42698. var xref = this.xref, blackColor = new Uint8Array(3);
  42699. while (queue.length > 0) {
  42700. var i = queue.shift();
  42701. var outlineDict = xref.fetchIfRef(i.obj);
  42702. if (outlineDict === null) {
  42703. continue;
  42704. }
  42705. assert(outlineDict.has('Title'), 'Invalid outline item');
  42706. var data = {
  42707. url: null,
  42708. dest: null
  42709. };
  42710. Catalog.parseDestDictionary({
  42711. destDict: outlineDict,
  42712. resultObj: data,
  42713. docBaseUrl: this.pdfManager.docBaseUrl
  42714. });
  42715. var title = outlineDict.get('Title');
  42716. var flags = outlineDict.get('F') || 0;
  42717. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  42718. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  42719. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  42720. }
  42721. var outlineItem = {
  42722. dest: data.dest,
  42723. url: data.url,
  42724. unsafeUrl: data.unsafeUrl,
  42725. newWindow: data.newWindow,
  42726. title: stringToPDFString(title),
  42727. color: rgbColor,
  42728. count: outlineDict.get('Count'),
  42729. bold: !!(flags & 2),
  42730. italic: !!(flags & 1),
  42731. items: []
  42732. };
  42733. i.parent.items.push(outlineItem);
  42734. obj = outlineDict.getRaw('First');
  42735. if (isRef(obj) && !processed.has(obj)) {
  42736. queue.push({
  42737. obj: obj,
  42738. parent: outlineItem
  42739. });
  42740. processed.put(obj);
  42741. }
  42742. obj = outlineDict.getRaw('Next');
  42743. if (isRef(obj) && !processed.has(obj)) {
  42744. queue.push({
  42745. obj: obj,
  42746. parent: i.parent
  42747. });
  42748. processed.put(obj);
  42749. }
  42750. }
  42751. return root.items.length > 0 ? root.items : null;
  42752. },
  42753. get numPages() {
  42754. var obj = this.toplevelPagesDict.get('Count');
  42755. assert(isInt(obj), 'page count in top level pages object is not an integer');
  42756. return shadow(this, 'num', obj);
  42757. },
  42758. get destinations() {
  42759. function fetchDestination(dest) {
  42760. return isDict(dest) ? dest.get('D') : dest;
  42761. }
  42762. var xref = this.xref;
  42763. var dests = {}, nameTreeRef, nameDictionaryRef;
  42764. var obj = this.catDict.get('Names');
  42765. if (obj && obj.has('Dests')) {
  42766. nameTreeRef = obj.getRaw('Dests');
  42767. } else if (this.catDict.has('Dests')) {
  42768. nameDictionaryRef = this.catDict.get('Dests');
  42769. }
  42770. if (nameDictionaryRef) {
  42771. obj = nameDictionaryRef;
  42772. obj.forEach(function catalogForEach(key, value) {
  42773. if (!value) {
  42774. return;
  42775. }
  42776. dests[key] = fetchDestination(value);
  42777. });
  42778. }
  42779. if (nameTreeRef) {
  42780. var nameTree = new NameTree(nameTreeRef, xref);
  42781. var names = nameTree.getAll();
  42782. for (var name in names) {
  42783. dests[name] = fetchDestination(names[name]);
  42784. }
  42785. }
  42786. return shadow(this, 'destinations', dests);
  42787. },
  42788. getDestination: function Catalog_getDestination(destinationId) {
  42789. function fetchDestination(dest) {
  42790. return isDict(dest) ? dest.get('D') : dest;
  42791. }
  42792. var xref = this.xref;
  42793. var dest = null, nameTreeRef, nameDictionaryRef;
  42794. var obj = this.catDict.get('Names');
  42795. if (obj && obj.has('Dests')) {
  42796. nameTreeRef = obj.getRaw('Dests');
  42797. } else if (this.catDict.has('Dests')) {
  42798. nameDictionaryRef = this.catDict.get('Dests');
  42799. }
  42800. if (nameDictionaryRef) {
  42801. var value = nameDictionaryRef.get(destinationId);
  42802. if (value) {
  42803. dest = fetchDestination(value);
  42804. }
  42805. }
  42806. if (nameTreeRef) {
  42807. var nameTree = new NameTree(nameTreeRef, xref);
  42808. dest = fetchDestination(nameTree.get(destinationId));
  42809. }
  42810. return dest;
  42811. },
  42812. get pageLabels() {
  42813. var obj = null;
  42814. try {
  42815. obj = this.readPageLabels();
  42816. } catch (ex) {
  42817. if (ex instanceof MissingDataException) {
  42818. throw ex;
  42819. }
  42820. warn('Unable to read page labels.');
  42821. }
  42822. return shadow(this, 'pageLabels', obj);
  42823. },
  42824. readPageLabels: function Catalog_readPageLabels() {
  42825. var obj = this.catDict.getRaw('PageLabels');
  42826. if (!obj) {
  42827. return null;
  42828. }
  42829. var pageLabels = new Array(this.numPages);
  42830. var style = null;
  42831. var prefix = '';
  42832. var numberTree = new NumberTree(obj, this.xref);
  42833. var nums = numberTree.getAll();
  42834. var currentLabel = '', currentIndex = 1;
  42835. for (var i = 0, ii = this.numPages; i < ii; i++) {
  42836. if (i in nums) {
  42837. var labelDict = nums[i];
  42838. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  42839. var type = labelDict.get('Type');
  42840. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  42841. var s = labelDict.get('S');
  42842. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  42843. style = s ? s.name : null;
  42844. var p = labelDict.get('P');
  42845. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  42846. prefix = p ? stringToPDFString(p) : '';
  42847. var st = labelDict.get('St');
  42848. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  42849. currentIndex = st || 1;
  42850. }
  42851. switch (style) {
  42852. case 'D':
  42853. currentLabel = currentIndex;
  42854. break;
  42855. case 'R':
  42856. case 'r':
  42857. currentLabel = Util.toRoman(currentIndex, style === 'r');
  42858. break;
  42859. case 'A':
  42860. case 'a':
  42861. var LIMIT = 26;
  42862. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  42863. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  42864. var letterIndex = currentIndex - 1;
  42865. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  42866. var charBuf = [];
  42867. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  42868. charBuf.push(character);
  42869. }
  42870. currentLabel = charBuf.join('');
  42871. break;
  42872. default:
  42873. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  42874. }
  42875. pageLabels[i] = prefix + currentLabel;
  42876. currentLabel = '';
  42877. currentIndex++;
  42878. }
  42879. return pageLabels;
  42880. },
  42881. get attachments() {
  42882. var xref = this.xref;
  42883. var attachments = null, nameTreeRef;
  42884. var obj = this.catDict.get('Names');
  42885. if (obj) {
  42886. nameTreeRef = obj.getRaw('EmbeddedFiles');
  42887. }
  42888. if (nameTreeRef) {
  42889. var nameTree = new NameTree(nameTreeRef, xref);
  42890. var names = nameTree.getAll();
  42891. for (var name in names) {
  42892. var fs = new FileSpec(names[name], xref);
  42893. if (!attachments) {
  42894. attachments = Object.create(null);
  42895. }
  42896. attachments[stringToPDFString(name)] = fs.serializable;
  42897. }
  42898. }
  42899. return shadow(this, 'attachments', attachments);
  42900. },
  42901. get javaScript() {
  42902. var xref = this.xref;
  42903. var obj = this.catDict.get('Names');
  42904. var javaScript = [];
  42905. function appendIfJavaScriptDict(jsDict) {
  42906. var type = jsDict.get('S');
  42907. if (!isName(type, 'JavaScript')) {
  42908. return;
  42909. }
  42910. var js = jsDict.get('JS');
  42911. if (isStream(js)) {
  42912. js = bytesToString(js.getBytes());
  42913. } else if (!isString(js)) {
  42914. return;
  42915. }
  42916. javaScript.push(stringToPDFString(js));
  42917. }
  42918. if (obj && obj.has('JavaScript')) {
  42919. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  42920. var names = nameTree.getAll();
  42921. for (var name in names) {
  42922. var jsDict = names[name];
  42923. if (isDict(jsDict)) {
  42924. appendIfJavaScriptDict(jsDict);
  42925. }
  42926. }
  42927. }
  42928. var openactionDict = this.catDict.get('OpenAction');
  42929. if (isDict(openactionDict, 'Action')) {
  42930. var actionType = openactionDict.get('S');
  42931. if (isName(actionType, 'Named')) {
  42932. var action = openactionDict.get('N');
  42933. if (isName(action, 'Print')) {
  42934. javaScript.push('print({});');
  42935. }
  42936. } else {
  42937. appendIfJavaScriptDict(openactionDict);
  42938. }
  42939. }
  42940. return shadow(this, 'javaScript', javaScript);
  42941. },
  42942. cleanup: function Catalog_cleanup() {
  42943. var promises = [];
  42944. this.fontCache.forEach(function (promise) {
  42945. promises.push(promise);
  42946. });
  42947. return Promise.all(promises).then(function (translatedFonts) {
  42948. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  42949. var font = translatedFonts[i].dict;
  42950. delete font.translated;
  42951. }
  42952. this.fontCache.clear();
  42953. }.bind(this));
  42954. },
  42955. getPage: function Catalog_getPage(pageIndex) {
  42956. if (!(pageIndex in this.pagePromises)) {
  42957. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  42958. var dict = a[0];
  42959. var ref = a[1];
  42960. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  42961. }.bind(this));
  42962. }
  42963. return this.pagePromises[pageIndex];
  42964. },
  42965. getPageDict: function Catalog_getPageDict(pageIndex) {
  42966. var capability = createPromiseCapability();
  42967. var nodesToVisit = [this.catDict.getRaw('Pages')];
  42968. var currentPageIndex = 0;
  42969. var xref = this.xref;
  42970. var checkAllKids = false;
  42971. function next() {
  42972. while (nodesToVisit.length) {
  42973. var currentNode = nodesToVisit.pop();
  42974. if (isRef(currentNode)) {
  42975. xref.fetchAsync(currentNode).then(function (obj) {
  42976. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  42977. if (pageIndex === currentPageIndex) {
  42978. capability.resolve([
  42979. obj,
  42980. currentNode
  42981. ]);
  42982. } else {
  42983. currentPageIndex++;
  42984. next();
  42985. }
  42986. return;
  42987. }
  42988. nodesToVisit.push(obj);
  42989. next();
  42990. }, capability.reject);
  42991. return;
  42992. }
  42993. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  42994. var count = currentNode.get('Count');
  42995. if (count === 0) {
  42996. checkAllKids = true;
  42997. }
  42998. if (currentPageIndex + count <= pageIndex) {
  42999. currentPageIndex += count;
  43000. continue;
  43001. }
  43002. var kids = currentNode.get('Kids');
  43003. assert(isArray(kids), 'page dictionary kids object is not an array');
  43004. if (!checkAllKids && count === kids.length) {
  43005. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  43006. currentPageIndex = pageIndex;
  43007. continue;
  43008. } else {
  43009. for (var last = kids.length - 1; last >= 0; last--) {
  43010. nodesToVisit.push(kids[last]);
  43011. }
  43012. }
  43013. }
  43014. capability.reject('Page index ' + pageIndex + ' not found.');
  43015. }
  43016. next();
  43017. return capability.promise;
  43018. },
  43019. getPageIndex: function Catalog_getPageIndex(pageRef) {
  43020. var xref = this.xref;
  43021. function pagesBeforeRef(kidRef) {
  43022. var total = 0;
  43023. var parentRef;
  43024. return xref.fetchAsync(kidRef).then(function (node) {
  43025. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  43026. throw new Error('The reference does not point to a /Page Dict.');
  43027. }
  43028. if (!node) {
  43029. return null;
  43030. }
  43031. assert(isDict(node), 'node must be a Dict.');
  43032. parentRef = node.getRaw('Parent');
  43033. return node.getAsync('Parent');
  43034. }).then(function (parent) {
  43035. if (!parent) {
  43036. return null;
  43037. }
  43038. assert(isDict(parent), 'parent must be a Dict.');
  43039. return parent.getAsync('Kids');
  43040. }).then(function (kids) {
  43041. if (!kids) {
  43042. return null;
  43043. }
  43044. var kidPromises = [];
  43045. var found = false;
  43046. for (var i = 0; i < kids.length; i++) {
  43047. var kid = kids[i];
  43048. assert(isRef(kid), 'kid must be a Ref.');
  43049. if (kid.num === kidRef.num) {
  43050. found = true;
  43051. break;
  43052. }
  43053. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  43054. if (kid.has('Count')) {
  43055. var count = kid.get('Count');
  43056. total += count;
  43057. } else {
  43058. total++;
  43059. }
  43060. }));
  43061. }
  43062. if (!found) {
  43063. error('kid ref not found in parents kids');
  43064. }
  43065. return Promise.all(kidPromises).then(function () {
  43066. return [
  43067. total,
  43068. parentRef
  43069. ];
  43070. });
  43071. });
  43072. }
  43073. var total = 0;
  43074. function next(ref) {
  43075. return pagesBeforeRef(ref).then(function (args) {
  43076. if (!args) {
  43077. return total;
  43078. }
  43079. var count = args[0];
  43080. var parentRef = args[1];
  43081. total += count;
  43082. return next(parentRef);
  43083. });
  43084. }
  43085. return next(pageRef);
  43086. }
  43087. };
  43088. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  43089. function addDefaultProtocolToUrl(url) {
  43090. if (url.indexOf('www.') === 0) {
  43091. return 'http://' + url;
  43092. }
  43093. return url;
  43094. }
  43095. function tryConvertUrlEncoding(url) {
  43096. try {
  43097. return stringToUTF8String(url);
  43098. } catch (e) {
  43099. return url;
  43100. }
  43101. }
  43102. var destDict = params.destDict;
  43103. if (!isDict(destDict)) {
  43104. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  43105. return;
  43106. }
  43107. var resultObj = params.resultObj;
  43108. if (typeof resultObj !== 'object') {
  43109. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  43110. return;
  43111. }
  43112. var docBaseUrl = params.docBaseUrl || null;
  43113. var action = destDict.get('A'), url, dest;
  43114. if (isDict(action)) {
  43115. var linkType = action.get('S').name;
  43116. switch (linkType) {
  43117. case 'URI':
  43118. url = action.get('URI');
  43119. if (isName(url)) {
  43120. url = '/' + url.name;
  43121. } else if (isString(url)) {
  43122. url = addDefaultProtocolToUrl(url);
  43123. }
  43124. break;
  43125. case 'GoTo':
  43126. dest = action.get('D');
  43127. break;
  43128. case 'Launch':
  43129. case 'GoToR':
  43130. var urlDict = action.get('F');
  43131. if (isDict(urlDict)) {
  43132. url = urlDict.get('F') || null;
  43133. } else if (isString(urlDict)) {
  43134. url = urlDict;
  43135. }
  43136. var remoteDest = action.get('D');
  43137. if (remoteDest) {
  43138. if (isName(remoteDest)) {
  43139. remoteDest = remoteDest.name;
  43140. }
  43141. if (isString(url)) {
  43142. var baseUrl = url.split('#')[0];
  43143. if (isString(remoteDest)) {
  43144. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  43145. } else if (isArray(remoteDest)) {
  43146. url = baseUrl + '#' + JSON.stringify(remoteDest);
  43147. }
  43148. }
  43149. }
  43150. var newWindow = action.get('NewWindow');
  43151. if (isBool(newWindow)) {
  43152. resultObj.newWindow = newWindow;
  43153. }
  43154. break;
  43155. case 'Named':
  43156. var namedAction = action.get('N');
  43157. if (isName(namedAction)) {
  43158. resultObj.action = namedAction.name;
  43159. }
  43160. break;
  43161. case 'JavaScript':
  43162. var jsAction = action.get('JS'), js;
  43163. if (isStream(jsAction)) {
  43164. js = bytesToString(jsAction.getBytes());
  43165. } else if (isString(jsAction)) {
  43166. js = jsAction;
  43167. }
  43168. if (js) {
  43169. var URL_OPEN_METHODS = [
  43170. 'app.launchURL',
  43171. 'window.open'
  43172. ];
  43173. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  43174. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  43175. if (jsUrl && jsUrl[1]) {
  43176. url = jsUrl[1];
  43177. break;
  43178. }
  43179. }
  43180. default:
  43181. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  43182. break;
  43183. }
  43184. } else if (destDict.has('Dest')) {
  43185. dest = destDict.get('Dest');
  43186. }
  43187. if (isString(url)) {
  43188. url = tryConvertUrlEncoding(url);
  43189. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  43190. if (absoluteUrl) {
  43191. resultObj.url = absoluteUrl.href;
  43192. }
  43193. resultObj.unsafeUrl = url;
  43194. }
  43195. if (dest) {
  43196. if (isName(dest)) {
  43197. dest = dest.name;
  43198. }
  43199. if (isString(dest) || isArray(dest)) {
  43200. resultObj.dest = dest;
  43201. }
  43202. }
  43203. };
  43204. return Catalog;
  43205. }();
  43206. var XRef = function XRefClosure() {
  43207. function XRef(stream, password) {
  43208. this.stream = stream;
  43209. this.entries = [];
  43210. this.xrefstms = Object.create(null);
  43211. this.cache = [];
  43212. this.password = password;
  43213. this.stats = {
  43214. streamTypes: [],
  43215. fontTypes: []
  43216. };
  43217. }
  43218. XRef.prototype = {
  43219. setStartXRef: function XRef_setStartXRef(startXRef) {
  43220. this.startXRefQueue = [startXRef];
  43221. },
  43222. parse: function XRef_parse(recoveryMode) {
  43223. var trailerDict;
  43224. if (!recoveryMode) {
  43225. trailerDict = this.readXRef();
  43226. } else {
  43227. warn('Indexing all PDF objects');
  43228. trailerDict = this.indexObjects();
  43229. }
  43230. trailerDict.assignXref(this);
  43231. this.trailer = trailerDict;
  43232. var encrypt = trailerDict.get('Encrypt');
  43233. if (encrypt) {
  43234. var ids = trailerDict.get('ID');
  43235. var fileId = ids && ids.length ? ids[0] : '';
  43236. encrypt.suppressEncryption = true;
  43237. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  43238. }
  43239. if (!(this.root = trailerDict.get('Root'))) {
  43240. error('Invalid root reference');
  43241. }
  43242. },
  43243. processXRefTable: function XRef_processXRefTable(parser) {
  43244. if (!('tableState' in this)) {
  43245. this.tableState = {
  43246. entryNum: 0,
  43247. streamPos: parser.lexer.stream.pos,
  43248. parserBuf1: parser.buf1,
  43249. parserBuf2: parser.buf2
  43250. };
  43251. }
  43252. var obj = this.readXRefTable(parser);
  43253. if (!isCmd(obj, 'trailer')) {
  43254. error('Invalid XRef table: could not find trailer dictionary');
  43255. }
  43256. var dict = parser.getObj();
  43257. if (!isDict(dict) && dict.dict) {
  43258. dict = dict.dict;
  43259. }
  43260. if (!isDict(dict)) {
  43261. error('Invalid XRef table: could not parse trailer dictionary');
  43262. }
  43263. delete this.tableState;
  43264. return dict;
  43265. },
  43266. readXRefTable: function XRef_readXRefTable(parser) {
  43267. var stream = parser.lexer.stream;
  43268. var tableState = this.tableState;
  43269. stream.pos = tableState.streamPos;
  43270. parser.buf1 = tableState.parserBuf1;
  43271. parser.buf2 = tableState.parserBuf2;
  43272. var obj;
  43273. while (true) {
  43274. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  43275. if (isCmd(obj = parser.getObj(), 'trailer')) {
  43276. break;
  43277. }
  43278. tableState.firstEntryNum = obj;
  43279. tableState.entryCount = parser.getObj();
  43280. }
  43281. var first = tableState.firstEntryNum;
  43282. var count = tableState.entryCount;
  43283. if (!isInt(first) || !isInt(count)) {
  43284. error('Invalid XRef table: wrong types in subsection header');
  43285. }
  43286. for (var i = tableState.entryNum; i < count; i++) {
  43287. tableState.streamPos = stream.pos;
  43288. tableState.entryNum = i;
  43289. tableState.parserBuf1 = parser.buf1;
  43290. tableState.parserBuf2 = parser.buf2;
  43291. var entry = {};
  43292. entry.offset = parser.getObj();
  43293. entry.gen = parser.getObj();
  43294. var type = parser.getObj();
  43295. if (isCmd(type, 'f')) {
  43296. entry.free = true;
  43297. } else if (isCmd(type, 'n')) {
  43298. entry.uncompressed = true;
  43299. }
  43300. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  43301. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  43302. }
  43303. if (i === 0 && entry.free && first === 1) {
  43304. first = 0;
  43305. }
  43306. if (!this.entries[i + first]) {
  43307. this.entries[i + first] = entry;
  43308. }
  43309. }
  43310. tableState.entryNum = 0;
  43311. tableState.streamPos = stream.pos;
  43312. tableState.parserBuf1 = parser.buf1;
  43313. tableState.parserBuf2 = parser.buf2;
  43314. delete tableState.firstEntryNum;
  43315. delete tableState.entryCount;
  43316. }
  43317. if (this.entries[0] && !this.entries[0].free) {
  43318. error('Invalid XRef table: unexpected first object');
  43319. }
  43320. return obj;
  43321. },
  43322. processXRefStream: function XRef_processXRefStream(stream) {
  43323. if (!('streamState' in this)) {
  43324. var streamParameters = stream.dict;
  43325. var byteWidths = streamParameters.get('W');
  43326. var range = streamParameters.get('Index');
  43327. if (!range) {
  43328. range = [
  43329. 0,
  43330. streamParameters.get('Size')
  43331. ];
  43332. }
  43333. this.streamState = {
  43334. entryRanges: range,
  43335. byteWidths: byteWidths,
  43336. entryNum: 0,
  43337. streamPos: stream.pos
  43338. };
  43339. }
  43340. this.readXRefStream(stream);
  43341. delete this.streamState;
  43342. return stream.dict;
  43343. },
  43344. readXRefStream: function XRef_readXRefStream(stream) {
  43345. var i, j;
  43346. var streamState = this.streamState;
  43347. stream.pos = streamState.streamPos;
  43348. var byteWidths = streamState.byteWidths;
  43349. var typeFieldWidth = byteWidths[0];
  43350. var offsetFieldWidth = byteWidths[1];
  43351. var generationFieldWidth = byteWidths[2];
  43352. var entryRanges = streamState.entryRanges;
  43353. while (entryRanges.length > 0) {
  43354. var first = entryRanges[0];
  43355. var n = entryRanges[1];
  43356. if (!isInt(first) || !isInt(n)) {
  43357. error('Invalid XRef range fields: ' + first + ', ' + n);
  43358. }
  43359. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  43360. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  43361. }
  43362. for (i = streamState.entryNum; i < n; ++i) {
  43363. streamState.entryNum = i;
  43364. streamState.streamPos = stream.pos;
  43365. var type = 0, offset = 0, generation = 0;
  43366. for (j = 0; j < typeFieldWidth; ++j) {
  43367. type = type << 8 | stream.getByte();
  43368. }
  43369. if (typeFieldWidth === 0) {
  43370. type = 1;
  43371. }
  43372. for (j = 0; j < offsetFieldWidth; ++j) {
  43373. offset = offset << 8 | stream.getByte();
  43374. }
  43375. for (j = 0; j < generationFieldWidth; ++j) {
  43376. generation = generation << 8 | stream.getByte();
  43377. }
  43378. var entry = {};
  43379. entry.offset = offset;
  43380. entry.gen = generation;
  43381. switch (type) {
  43382. case 0:
  43383. entry.free = true;
  43384. break;
  43385. case 1:
  43386. entry.uncompressed = true;
  43387. break;
  43388. case 2:
  43389. break;
  43390. default:
  43391. error('Invalid XRef entry type: ' + type);
  43392. }
  43393. if (!this.entries[first + i]) {
  43394. this.entries[first + i] = entry;
  43395. }
  43396. }
  43397. streamState.entryNum = 0;
  43398. streamState.streamPos = stream.pos;
  43399. entryRanges.splice(0, 2);
  43400. }
  43401. },
  43402. indexObjects: function XRef_indexObjects() {
  43403. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  43404. var PERCENT = 0x25, LT = 0x3C;
  43405. function readToken(data, offset) {
  43406. var token = '', ch = data[offset];
  43407. while (ch !== LF && ch !== CR && ch !== LT) {
  43408. if (++offset >= data.length) {
  43409. break;
  43410. }
  43411. token += String.fromCharCode(ch);
  43412. ch = data[offset];
  43413. }
  43414. return token;
  43415. }
  43416. function skipUntil(data, offset, what) {
  43417. var length = what.length, dataLength = data.length;
  43418. var skipped = 0;
  43419. while (offset < dataLength) {
  43420. var i = 0;
  43421. while (i < length && data[offset + i] === what[i]) {
  43422. ++i;
  43423. }
  43424. if (i >= length) {
  43425. break;
  43426. }
  43427. offset++;
  43428. skipped++;
  43429. }
  43430. return skipped;
  43431. }
  43432. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  43433. var trailerBytes = new Uint8Array([
  43434. 116,
  43435. 114,
  43436. 97,
  43437. 105,
  43438. 108,
  43439. 101,
  43440. 114
  43441. ]);
  43442. var startxrefBytes = new Uint8Array([
  43443. 115,
  43444. 116,
  43445. 97,
  43446. 114,
  43447. 116,
  43448. 120,
  43449. 114,
  43450. 101,
  43451. 102
  43452. ]);
  43453. var endobjBytes = new Uint8Array([
  43454. 101,
  43455. 110,
  43456. 100,
  43457. 111,
  43458. 98,
  43459. 106
  43460. ]);
  43461. var xrefBytes = new Uint8Array([
  43462. 47,
  43463. 88,
  43464. 82,
  43465. 101,
  43466. 102
  43467. ]);
  43468. this.entries.length = 0;
  43469. var stream = this.stream;
  43470. stream.pos = 0;
  43471. var buffer = stream.getBytes();
  43472. var position = stream.start, length = buffer.length;
  43473. var trailers = [], xrefStms = [];
  43474. while (position < length) {
  43475. var ch = buffer[position];
  43476. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  43477. ++position;
  43478. continue;
  43479. }
  43480. if (ch === PERCENT) {
  43481. do {
  43482. ++position;
  43483. if (position >= length) {
  43484. break;
  43485. }
  43486. ch = buffer[position];
  43487. } while (ch !== LF && ch !== CR);
  43488. continue;
  43489. }
  43490. var token = readToken(buffer, position);
  43491. var m;
  43492. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  43493. position += skipUntil(buffer, position, trailerBytes);
  43494. trailers.push(position);
  43495. position += skipUntil(buffer, position, startxrefBytes);
  43496. } else if (m = objRegExp.exec(token)) {
  43497. if (typeof this.entries[m[1]] === 'undefined') {
  43498. this.entries[m[1]] = {
  43499. offset: position - stream.start,
  43500. gen: m[2] | 0,
  43501. uncompressed: true
  43502. };
  43503. }
  43504. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  43505. var content = buffer.subarray(position, position + contentLength);
  43506. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  43507. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  43508. xrefStms.push(position - stream.start);
  43509. this.xrefstms[position - stream.start] = 1;
  43510. }
  43511. position += contentLength;
  43512. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  43513. trailers.push(position);
  43514. position += skipUntil(buffer, position, startxrefBytes);
  43515. } else {
  43516. position += token.length + 1;
  43517. }
  43518. }
  43519. var i, ii;
  43520. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  43521. this.startXRefQueue.push(xrefStms[i]);
  43522. this.readXRef(true);
  43523. }
  43524. var dict;
  43525. for (i = 0, ii = trailers.length; i < ii; ++i) {
  43526. stream.pos = trailers[i];
  43527. var parser = new Parser(new Lexer(stream), true, this, true);
  43528. var obj = parser.getObj();
  43529. if (!isCmd(obj, 'trailer')) {
  43530. continue;
  43531. }
  43532. dict = parser.getObj();
  43533. if (!isDict(dict)) {
  43534. continue;
  43535. }
  43536. if (dict.has('ID')) {
  43537. return dict;
  43538. }
  43539. }
  43540. if (dict) {
  43541. return dict;
  43542. }
  43543. throw new InvalidPDFException('Invalid PDF structure');
  43544. },
  43545. readXRef: function XRef_readXRef(recoveryMode) {
  43546. var stream = this.stream;
  43547. try {
  43548. while (this.startXRefQueue.length) {
  43549. var startXRef = this.startXRefQueue[0];
  43550. stream.pos = startXRef + stream.start;
  43551. var parser = new Parser(new Lexer(stream), true, this);
  43552. var obj = parser.getObj();
  43553. var dict;
  43554. if (isCmd(obj, 'xref')) {
  43555. dict = this.processXRefTable(parser);
  43556. if (!this.topDict) {
  43557. this.topDict = dict;
  43558. }
  43559. obj = dict.get('XRefStm');
  43560. if (isInt(obj)) {
  43561. var pos = obj;
  43562. if (!(pos in this.xrefstms)) {
  43563. this.xrefstms[pos] = 1;
  43564. this.startXRefQueue.push(pos);
  43565. }
  43566. }
  43567. } else if (isInt(obj)) {
  43568. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  43569. error('Invalid XRef stream');
  43570. }
  43571. dict = this.processXRefStream(obj);
  43572. if (!this.topDict) {
  43573. this.topDict = dict;
  43574. }
  43575. if (!dict) {
  43576. error('Failed to read XRef stream');
  43577. }
  43578. } else {
  43579. error('Invalid XRef stream header');
  43580. }
  43581. obj = dict.get('Prev');
  43582. if (isInt(obj)) {
  43583. this.startXRefQueue.push(obj);
  43584. } else if (isRef(obj)) {
  43585. this.startXRefQueue.push(obj.num);
  43586. }
  43587. this.startXRefQueue.shift();
  43588. }
  43589. return this.topDict;
  43590. } catch (e) {
  43591. if (e instanceof MissingDataException) {
  43592. throw e;
  43593. }
  43594. info('(while reading XRef): ' + e);
  43595. }
  43596. if (recoveryMode) {
  43597. return;
  43598. }
  43599. throw new XRefParseException();
  43600. },
  43601. getEntry: function XRef_getEntry(i) {
  43602. var xrefEntry = this.entries[i];
  43603. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  43604. return xrefEntry;
  43605. }
  43606. return null;
  43607. },
  43608. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  43609. if (!isRef(obj)) {
  43610. return obj;
  43611. }
  43612. return this.fetch(obj, suppressEncryption);
  43613. },
  43614. fetch: function XRef_fetch(ref, suppressEncryption) {
  43615. assert(isRef(ref), 'ref object is not a reference');
  43616. var num = ref.num;
  43617. if (num in this.cache) {
  43618. var cacheEntry = this.cache[num];
  43619. return cacheEntry;
  43620. }
  43621. var xrefEntry = this.getEntry(num);
  43622. if (xrefEntry === null) {
  43623. return this.cache[num] = null;
  43624. }
  43625. if (xrefEntry.uncompressed) {
  43626. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  43627. } else {
  43628. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  43629. }
  43630. if (isDict(xrefEntry)) {
  43631. xrefEntry.objId = ref.toString();
  43632. } else if (isStream(xrefEntry)) {
  43633. xrefEntry.dict.objId = ref.toString();
  43634. }
  43635. return xrefEntry;
  43636. },
  43637. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  43638. var gen = ref.gen;
  43639. var num = ref.num;
  43640. if (xrefEntry.gen !== gen) {
  43641. error('inconsistent generation in XRef');
  43642. }
  43643. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  43644. var parser = new Parser(new Lexer(stream), true, this);
  43645. var obj1 = parser.getObj();
  43646. var obj2 = parser.getObj();
  43647. var obj3 = parser.getObj();
  43648. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  43649. error('bad XRef entry');
  43650. }
  43651. if (!isCmd(obj3, 'obj')) {
  43652. if (obj3.cmd.indexOf('obj') === 0) {
  43653. num = parseInt(obj3.cmd.substring(3), 10);
  43654. if (!isNaN(num)) {
  43655. return num;
  43656. }
  43657. }
  43658. error('bad XRef entry');
  43659. }
  43660. if (this.encrypt && !suppressEncryption) {
  43661. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  43662. } else {
  43663. xrefEntry = parser.getObj();
  43664. }
  43665. if (!isStream(xrefEntry)) {
  43666. this.cache[num] = xrefEntry;
  43667. }
  43668. return xrefEntry;
  43669. },
  43670. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  43671. var tableOffset = xrefEntry.offset;
  43672. var stream = this.fetch(new Ref(tableOffset, 0));
  43673. if (!isStream(stream)) {
  43674. error('bad ObjStm stream');
  43675. }
  43676. var first = stream.dict.get('First');
  43677. var n = stream.dict.get('N');
  43678. if (!isInt(first) || !isInt(n)) {
  43679. error('invalid first and n parameters for ObjStm stream');
  43680. }
  43681. var parser = new Parser(new Lexer(stream), false, this);
  43682. parser.allowStreams = true;
  43683. var i, entries = [], num, nums = [];
  43684. for (i = 0; i < n; ++i) {
  43685. num = parser.getObj();
  43686. if (!isInt(num)) {
  43687. error('invalid object number in the ObjStm stream: ' + num);
  43688. }
  43689. nums.push(num);
  43690. var offset = parser.getObj();
  43691. if (!isInt(offset)) {
  43692. error('invalid object offset in the ObjStm stream: ' + offset);
  43693. }
  43694. }
  43695. for (i = 0; i < n; ++i) {
  43696. entries.push(parser.getObj());
  43697. if (isCmd(parser.buf1, 'endobj')) {
  43698. parser.shift();
  43699. }
  43700. num = nums[i];
  43701. var entry = this.entries[num];
  43702. if (entry && entry.offset === tableOffset && entry.gen === i) {
  43703. this.cache[num] = entries[i];
  43704. }
  43705. }
  43706. xrefEntry = entries[xrefEntry.gen];
  43707. if (xrefEntry === undefined) {
  43708. error('bad XRef entry for compressed object');
  43709. }
  43710. return xrefEntry;
  43711. },
  43712. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  43713. if (!isRef(obj)) {
  43714. return Promise.resolve(obj);
  43715. }
  43716. return this.fetchAsync(obj, suppressEncryption);
  43717. },
  43718. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  43719. var streamManager = this.stream.manager;
  43720. var xref = this;
  43721. return new Promise(function tryFetch(resolve, reject) {
  43722. try {
  43723. resolve(xref.fetch(ref, suppressEncryption));
  43724. } catch (e) {
  43725. if (e instanceof MissingDataException) {
  43726. streamManager.requestRange(e.begin, e.end).then(function () {
  43727. tryFetch(resolve, reject);
  43728. }, reject);
  43729. return;
  43730. }
  43731. reject(e);
  43732. }
  43733. });
  43734. },
  43735. getCatalogObj: function XRef_getCatalogObj() {
  43736. return this.root;
  43737. }
  43738. };
  43739. return XRef;
  43740. }();
  43741. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  43742. function NameOrNumberTree(root, xref) {
  43743. throw new Error('Cannot initialize NameOrNumberTree.');
  43744. }
  43745. NameOrNumberTree.prototype = {
  43746. getAll: function NameOrNumberTree_getAll() {
  43747. var dict = Object.create(null);
  43748. if (!this.root) {
  43749. return dict;
  43750. }
  43751. var xref = this.xref;
  43752. var processed = new RefSet();
  43753. processed.put(this.root);
  43754. var queue = [this.root];
  43755. while (queue.length > 0) {
  43756. var i, n;
  43757. var obj = xref.fetchIfRef(queue.shift());
  43758. if (!isDict(obj)) {
  43759. continue;
  43760. }
  43761. if (obj.has('Kids')) {
  43762. var kids = obj.get('Kids');
  43763. for (i = 0, n = kids.length; i < n; i++) {
  43764. var kid = kids[i];
  43765. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  43766. queue.push(kid);
  43767. processed.put(kid);
  43768. }
  43769. continue;
  43770. }
  43771. var entries = obj.get(this._type);
  43772. if (isArray(entries)) {
  43773. for (i = 0, n = entries.length; i < n; i += 2) {
  43774. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  43775. }
  43776. }
  43777. }
  43778. return dict;
  43779. },
  43780. get: function NameOrNumberTree_get(key) {
  43781. if (!this.root) {
  43782. return null;
  43783. }
  43784. var xref = this.xref;
  43785. var kidsOrEntries = xref.fetchIfRef(this.root);
  43786. var loopCount = 0;
  43787. var MAX_LEVELS = 10;
  43788. var l, r, m;
  43789. while (kidsOrEntries.has('Kids')) {
  43790. if (++loopCount > MAX_LEVELS) {
  43791. warn('Search depth limit reached for "' + this._type + '" tree.');
  43792. return null;
  43793. }
  43794. var kids = kidsOrEntries.get('Kids');
  43795. if (!isArray(kids)) {
  43796. return null;
  43797. }
  43798. l = 0;
  43799. r = kids.length - 1;
  43800. while (l <= r) {
  43801. m = l + r >> 1;
  43802. var kid = xref.fetchIfRef(kids[m]);
  43803. var limits = kid.get('Limits');
  43804. if (key < xref.fetchIfRef(limits[0])) {
  43805. r = m - 1;
  43806. } else if (key > xref.fetchIfRef(limits[1])) {
  43807. l = m + 1;
  43808. } else {
  43809. kidsOrEntries = xref.fetchIfRef(kids[m]);
  43810. break;
  43811. }
  43812. }
  43813. if (l > r) {
  43814. return null;
  43815. }
  43816. }
  43817. var entries = kidsOrEntries.get(this._type);
  43818. if (isArray(entries)) {
  43819. l = 0;
  43820. r = entries.length - 2;
  43821. while (l <= r) {
  43822. m = l + r & ~1;
  43823. var currentKey = xref.fetchIfRef(entries[m]);
  43824. if (key < currentKey) {
  43825. r = m - 2;
  43826. } else if (key > currentKey) {
  43827. l = m + 2;
  43828. } else {
  43829. return xref.fetchIfRef(entries[m + 1]);
  43830. }
  43831. }
  43832. }
  43833. return null;
  43834. }
  43835. };
  43836. return NameOrNumberTree;
  43837. }();
  43838. var NameTree = function NameTreeClosure() {
  43839. function NameTree(root, xref) {
  43840. this.root = root;
  43841. this.xref = xref;
  43842. this._type = 'Names';
  43843. }
  43844. Util.inherit(NameTree, NameOrNumberTree, {});
  43845. return NameTree;
  43846. }();
  43847. var NumberTree = function NumberTreeClosure() {
  43848. function NumberTree(root, xref) {
  43849. this.root = root;
  43850. this.xref = xref;
  43851. this._type = 'Nums';
  43852. }
  43853. Util.inherit(NumberTree, NameOrNumberTree, {});
  43854. return NumberTree;
  43855. }();
  43856. var FileSpec = function FileSpecClosure() {
  43857. function FileSpec(root, xref) {
  43858. if (!root || !isDict(root)) {
  43859. return;
  43860. }
  43861. this.xref = xref;
  43862. this.root = root;
  43863. if (root.has('FS')) {
  43864. this.fs = root.get('FS');
  43865. }
  43866. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  43867. if (root.has('RF')) {
  43868. warn('Related file specifications are not supported');
  43869. }
  43870. this.contentAvailable = true;
  43871. if (!root.has('EF')) {
  43872. this.contentAvailable = false;
  43873. warn('Non-embedded file specifications are not supported');
  43874. }
  43875. }
  43876. function pickPlatformItem(dict) {
  43877. if (dict.has('UF')) {
  43878. return dict.get('UF');
  43879. } else if (dict.has('F')) {
  43880. return dict.get('F');
  43881. } else if (dict.has('Unix')) {
  43882. return dict.get('Unix');
  43883. } else if (dict.has('Mac')) {
  43884. return dict.get('Mac');
  43885. } else if (dict.has('DOS')) {
  43886. return dict.get('DOS');
  43887. } else {
  43888. return null;
  43889. }
  43890. }
  43891. FileSpec.prototype = {
  43892. get filename() {
  43893. if (!this._filename && this.root) {
  43894. var filename = pickPlatformItem(this.root) || 'unnamed';
  43895. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  43896. }
  43897. return this._filename;
  43898. },
  43899. get content() {
  43900. if (!this.contentAvailable) {
  43901. return null;
  43902. }
  43903. if (!this.contentRef && this.root) {
  43904. this.contentRef = pickPlatformItem(this.root.get('EF'));
  43905. }
  43906. var content = null;
  43907. if (this.contentRef) {
  43908. var xref = this.xref;
  43909. var fileObj = xref.fetchIfRef(this.contentRef);
  43910. if (fileObj && isStream(fileObj)) {
  43911. content = fileObj.getBytes();
  43912. } else {
  43913. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  43914. }
  43915. } else {
  43916. warn('Embedded file specification does not have a content');
  43917. }
  43918. return content;
  43919. },
  43920. get serializable() {
  43921. return {
  43922. filename: this.filename,
  43923. content: this.content
  43924. };
  43925. }
  43926. };
  43927. return FileSpec;
  43928. }();
  43929. var ObjectLoader = function () {
  43930. function mayHaveChildren(value) {
  43931. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  43932. }
  43933. function addChildren(node, nodesToVisit) {
  43934. var value;
  43935. if (isDict(node) || isStream(node)) {
  43936. var map;
  43937. if (isDict(node)) {
  43938. map = node.map;
  43939. } else {
  43940. map = node.dict.map;
  43941. }
  43942. for (var key in map) {
  43943. value = map[key];
  43944. if (mayHaveChildren(value)) {
  43945. nodesToVisit.push(value);
  43946. }
  43947. }
  43948. } else if (isArray(node)) {
  43949. for (var i = 0, ii = node.length; i < ii; i++) {
  43950. value = node[i];
  43951. if (mayHaveChildren(value)) {
  43952. nodesToVisit.push(value);
  43953. }
  43954. }
  43955. }
  43956. }
  43957. function ObjectLoader(obj, keys, xref) {
  43958. this.obj = obj;
  43959. this.keys = keys;
  43960. this.xref = xref;
  43961. this.refSet = null;
  43962. this.capability = null;
  43963. }
  43964. ObjectLoader.prototype = {
  43965. load: function ObjectLoader_load() {
  43966. var keys = this.keys;
  43967. this.capability = createPromiseCapability();
  43968. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  43969. this.capability.resolve();
  43970. return this.capability.promise;
  43971. }
  43972. this.refSet = new RefSet();
  43973. var nodesToVisit = [];
  43974. for (var i = 0; i < keys.length; i++) {
  43975. nodesToVisit.push(this.obj[keys[i]]);
  43976. }
  43977. this._walk(nodesToVisit);
  43978. return this.capability.promise;
  43979. },
  43980. _walk: function ObjectLoader_walk(nodesToVisit) {
  43981. var nodesToRevisit = [];
  43982. var pendingRequests = [];
  43983. while (nodesToVisit.length) {
  43984. var currentNode = nodesToVisit.pop();
  43985. if (isRef(currentNode)) {
  43986. if (this.refSet.has(currentNode)) {
  43987. continue;
  43988. }
  43989. try {
  43990. var ref = currentNode;
  43991. this.refSet.put(ref);
  43992. currentNode = this.xref.fetch(currentNode);
  43993. } catch (e) {
  43994. if (!(e instanceof MissingDataException)) {
  43995. throw e;
  43996. }
  43997. nodesToRevisit.push(currentNode);
  43998. pendingRequests.push({
  43999. begin: e.begin,
  44000. end: e.end
  44001. });
  44002. }
  44003. }
  44004. if (currentNode && currentNode.getBaseStreams) {
  44005. var baseStreams = currentNode.getBaseStreams();
  44006. var foundMissingData = false;
  44007. for (var i = 0; i < baseStreams.length; i++) {
  44008. var stream = baseStreams[i];
  44009. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  44010. foundMissingData = true;
  44011. pendingRequests.push({
  44012. begin: stream.start,
  44013. end: stream.end
  44014. });
  44015. }
  44016. }
  44017. if (foundMissingData) {
  44018. nodesToRevisit.push(currentNode);
  44019. }
  44020. }
  44021. addChildren(currentNode, nodesToVisit);
  44022. }
  44023. if (pendingRequests.length) {
  44024. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  44025. nodesToVisit = nodesToRevisit;
  44026. for (var i = 0; i < nodesToRevisit.length; i++) {
  44027. var node = nodesToRevisit[i];
  44028. if (isRef(node)) {
  44029. this.refSet.remove(node);
  44030. }
  44031. }
  44032. this._walk(nodesToVisit);
  44033. }.bind(this), this.capability.reject);
  44034. return;
  44035. }
  44036. this.refSet = null;
  44037. this.capability.resolve();
  44038. }
  44039. };
  44040. return ObjectLoader;
  44041. }();
  44042. exports.Catalog = Catalog;
  44043. exports.ObjectLoader = ObjectLoader;
  44044. exports.XRef = XRef;
  44045. exports.FileSpec = FileSpec;
  44046. }));
  44047. (function (root, factory) {
  44048. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  44049. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  44050. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  44051. var MissingDataException = sharedUtil.MissingDataException;
  44052. var Util = sharedUtil.Util;
  44053. var assert = sharedUtil.assert;
  44054. var error = sharedUtil.error;
  44055. var info = sharedUtil.info;
  44056. var warn = sharedUtil.warn;
  44057. var isStream = corePrimitives.isStream;
  44058. var PDFFunction = coreFunction.PDFFunction;
  44059. var ColorSpace = coreColorSpace.ColorSpace;
  44060. var ShadingType = {
  44061. FUNCTION_BASED: 1,
  44062. AXIAL: 2,
  44063. RADIAL: 3,
  44064. FREE_FORM_MESH: 4,
  44065. LATTICE_FORM_MESH: 5,
  44066. COONS_PATCH_MESH: 6,
  44067. TENSOR_PATCH_MESH: 7
  44068. };
  44069. var Pattern = function PatternClosure() {
  44070. function Pattern() {
  44071. error('should not call Pattern constructor');
  44072. }
  44073. Pattern.prototype = {
  44074. getPattern: function Pattern_getPattern(ctx) {
  44075. error('Should not call Pattern.getStyle: ' + ctx);
  44076. }
  44077. };
  44078. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  44079. var dict = isStream(shading) ? shading.dict : shading;
  44080. var type = dict.get('ShadingType');
  44081. try {
  44082. switch (type) {
  44083. case ShadingType.AXIAL:
  44084. case ShadingType.RADIAL:
  44085. return new Shadings.RadialAxial(dict, matrix, xref, res);
  44086. case ShadingType.FREE_FORM_MESH:
  44087. case ShadingType.LATTICE_FORM_MESH:
  44088. case ShadingType.COONS_PATCH_MESH:
  44089. case ShadingType.TENSOR_PATCH_MESH:
  44090. return new Shadings.Mesh(shading, matrix, xref, res);
  44091. default:
  44092. throw new Error('Unsupported ShadingType: ' + type);
  44093. }
  44094. } catch (ex) {
  44095. if (ex instanceof MissingDataException) {
  44096. throw ex;
  44097. }
  44098. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  44099. warn(ex);
  44100. return new Shadings.Dummy();
  44101. }
  44102. };
  44103. return Pattern;
  44104. }();
  44105. var Shadings = {};
  44106. Shadings.SMALL_NUMBER = 1e-6;
  44107. Shadings.RadialAxial = function RadialAxialClosure() {
  44108. function RadialAxial(dict, matrix, xref, res) {
  44109. this.matrix = matrix;
  44110. this.coordsArr = dict.getArray('Coords');
  44111. this.shadingType = dict.get('ShadingType');
  44112. this.type = 'Pattern';
  44113. var cs = dict.get('ColorSpace', 'CS');
  44114. cs = ColorSpace.parse(cs, xref, res);
  44115. this.cs = cs;
  44116. var t0 = 0.0, t1 = 1.0;
  44117. if (dict.has('Domain')) {
  44118. var domainArr = dict.getArray('Domain');
  44119. t0 = domainArr[0];
  44120. t1 = domainArr[1];
  44121. }
  44122. var extendStart = false, extendEnd = false;
  44123. if (dict.has('Extend')) {
  44124. var extendArr = dict.getArray('Extend');
  44125. extendStart = extendArr[0];
  44126. extendEnd = extendArr[1];
  44127. }
  44128. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  44129. var x1 = this.coordsArr[0];
  44130. var y1 = this.coordsArr[1];
  44131. var r1 = this.coordsArr[2];
  44132. var x2 = this.coordsArr[3];
  44133. var y2 = this.coordsArr[4];
  44134. var r2 = this.coordsArr[5];
  44135. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  44136. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  44137. warn('Unsupported radial gradient.');
  44138. }
  44139. }
  44140. this.extendStart = extendStart;
  44141. this.extendEnd = extendEnd;
  44142. var fnObj = dict.get('Function');
  44143. var fn = PDFFunction.parseArray(xref, fnObj);
  44144. var diff = t1 - t0;
  44145. var step = diff / 10;
  44146. var colorStops = this.colorStops = [];
  44147. if (t0 >= t1 || step <= 0) {
  44148. info('Bad shading domain.');
  44149. return;
  44150. }
  44151. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  44152. var rgbColor;
  44153. for (var i = t0; i <= t1; i += step) {
  44154. ratio[0] = i;
  44155. fn(ratio, 0, color, 0);
  44156. rgbColor = cs.getRgb(color, 0);
  44157. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44158. colorStops.push([
  44159. (i - t0) / diff,
  44160. cssColor
  44161. ]);
  44162. }
  44163. var background = 'transparent';
  44164. if (dict.has('Background')) {
  44165. rgbColor = cs.getRgb(dict.get('Background'), 0);
  44166. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44167. }
  44168. if (!extendStart) {
  44169. colorStops.unshift([
  44170. 0,
  44171. background
  44172. ]);
  44173. colorStops[1][0] += Shadings.SMALL_NUMBER;
  44174. }
  44175. if (!extendEnd) {
  44176. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  44177. colorStops.push([
  44178. 1,
  44179. background
  44180. ]);
  44181. }
  44182. this.colorStops = colorStops;
  44183. }
  44184. RadialAxial.prototype = {
  44185. getIR: function RadialAxial_getIR() {
  44186. var coordsArr = this.coordsArr;
  44187. var shadingType = this.shadingType;
  44188. var type, p0, p1, r0, r1;
  44189. if (shadingType === ShadingType.AXIAL) {
  44190. p0 = [
  44191. coordsArr[0],
  44192. coordsArr[1]
  44193. ];
  44194. p1 = [
  44195. coordsArr[2],
  44196. coordsArr[3]
  44197. ];
  44198. r0 = null;
  44199. r1 = null;
  44200. type = 'axial';
  44201. } else if (shadingType === ShadingType.RADIAL) {
  44202. p0 = [
  44203. coordsArr[0],
  44204. coordsArr[1]
  44205. ];
  44206. p1 = [
  44207. coordsArr[3],
  44208. coordsArr[4]
  44209. ];
  44210. r0 = coordsArr[2];
  44211. r1 = coordsArr[5];
  44212. type = 'radial';
  44213. } else {
  44214. error('getPattern type unknown: ' + shadingType);
  44215. }
  44216. var matrix = this.matrix;
  44217. if (matrix) {
  44218. p0 = Util.applyTransform(p0, matrix);
  44219. p1 = Util.applyTransform(p1, matrix);
  44220. if (shadingType === ShadingType.RADIAL) {
  44221. var scale = Util.singularValueDecompose2dScale(matrix);
  44222. r0 *= scale[0];
  44223. r1 *= scale[1];
  44224. }
  44225. }
  44226. return [
  44227. 'RadialAxial',
  44228. type,
  44229. this.colorStops,
  44230. p0,
  44231. p1,
  44232. r0,
  44233. r1
  44234. ];
  44235. }
  44236. };
  44237. return RadialAxial;
  44238. }();
  44239. Shadings.Mesh = function MeshClosure() {
  44240. function MeshStreamReader(stream, context) {
  44241. this.stream = stream;
  44242. this.context = context;
  44243. this.buffer = 0;
  44244. this.bufferLength = 0;
  44245. var numComps = context.numComps;
  44246. this.tmpCompsBuf = new Float32Array(numComps);
  44247. var csNumComps = context.colorSpace.numComps;
  44248. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  44249. }
  44250. MeshStreamReader.prototype = {
  44251. get hasData() {
  44252. if (this.stream.end) {
  44253. return this.stream.pos < this.stream.end;
  44254. }
  44255. if (this.bufferLength > 0) {
  44256. return true;
  44257. }
  44258. var nextByte = this.stream.getByte();
  44259. if (nextByte < 0) {
  44260. return false;
  44261. }
  44262. this.buffer = nextByte;
  44263. this.bufferLength = 8;
  44264. return true;
  44265. },
  44266. readBits: function MeshStreamReader_readBits(n) {
  44267. var buffer = this.buffer;
  44268. var bufferLength = this.bufferLength;
  44269. if (n === 32) {
  44270. if (bufferLength === 0) {
  44271. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  44272. }
  44273. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  44274. var nextByte = this.stream.getByte();
  44275. this.buffer = nextByte & (1 << bufferLength) - 1;
  44276. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  44277. }
  44278. if (n === 8 && bufferLength === 0) {
  44279. return this.stream.getByte();
  44280. }
  44281. while (bufferLength < n) {
  44282. buffer = buffer << 8 | this.stream.getByte();
  44283. bufferLength += 8;
  44284. }
  44285. bufferLength -= n;
  44286. this.bufferLength = bufferLength;
  44287. this.buffer = buffer & (1 << bufferLength) - 1;
  44288. return buffer >> bufferLength;
  44289. },
  44290. align: function MeshStreamReader_align() {
  44291. this.buffer = 0;
  44292. this.bufferLength = 0;
  44293. },
  44294. readFlag: function MeshStreamReader_readFlag() {
  44295. return this.readBits(this.context.bitsPerFlag);
  44296. },
  44297. readCoordinate: function MeshStreamReader_readCoordinate() {
  44298. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  44299. var xi = this.readBits(bitsPerCoordinate);
  44300. var yi = this.readBits(bitsPerCoordinate);
  44301. var decode = this.context.decode;
  44302. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  44303. return [
  44304. xi * scale * (decode[1] - decode[0]) + decode[0],
  44305. yi * scale * (decode[3] - decode[2]) + decode[2]
  44306. ];
  44307. },
  44308. readComponents: function MeshStreamReader_readComponents() {
  44309. var numComps = this.context.numComps;
  44310. var bitsPerComponent = this.context.bitsPerComponent;
  44311. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  44312. var decode = this.context.decode;
  44313. var components = this.tmpCompsBuf;
  44314. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  44315. var ci = this.readBits(bitsPerComponent);
  44316. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  44317. }
  44318. var color = this.tmpCsCompsBuf;
  44319. if (this.context.colorFn) {
  44320. this.context.colorFn(components, 0, color, 0);
  44321. }
  44322. return this.context.colorSpace.getRgb(color, 0);
  44323. }
  44324. };
  44325. function decodeType4Shading(mesh, reader) {
  44326. var coords = mesh.coords;
  44327. var colors = mesh.colors;
  44328. var operators = [];
  44329. var ps = [];
  44330. var verticesLeft = 0;
  44331. while (reader.hasData) {
  44332. var f = reader.readFlag();
  44333. var coord = reader.readCoordinate();
  44334. var color = reader.readComponents();
  44335. if (verticesLeft === 0) {
  44336. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  44337. switch (f) {
  44338. case 0:
  44339. verticesLeft = 3;
  44340. break;
  44341. case 1:
  44342. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  44343. verticesLeft = 1;
  44344. break;
  44345. case 2:
  44346. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  44347. verticesLeft = 1;
  44348. break;
  44349. }
  44350. operators.push(f);
  44351. }
  44352. ps.push(coords.length);
  44353. coords.push(coord);
  44354. colors.push(color);
  44355. verticesLeft--;
  44356. reader.align();
  44357. }
  44358. mesh.figures.push({
  44359. type: 'triangles',
  44360. coords: new Int32Array(ps),
  44361. colors: new Int32Array(ps)
  44362. });
  44363. }
  44364. function decodeType5Shading(mesh, reader, verticesPerRow) {
  44365. var coords = mesh.coords;
  44366. var colors = mesh.colors;
  44367. var ps = [];
  44368. while (reader.hasData) {
  44369. var coord = reader.readCoordinate();
  44370. var color = reader.readComponents();
  44371. ps.push(coords.length);
  44372. coords.push(coord);
  44373. colors.push(color);
  44374. }
  44375. mesh.figures.push({
  44376. type: 'lattice',
  44377. coords: new Int32Array(ps),
  44378. colors: new Int32Array(ps),
  44379. verticesPerRow: verticesPerRow
  44380. });
  44381. }
  44382. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  44383. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  44384. var TRIANGLE_DENSITY = 20;
  44385. var getB = function getBClosure() {
  44386. function buildB(count) {
  44387. var lut = [];
  44388. for (var i = 0; i <= count; i++) {
  44389. var t = i / count, t_ = 1 - t;
  44390. lut.push(new Float32Array([
  44391. t_ * t_ * t_,
  44392. 3 * t * t_ * t_,
  44393. 3 * t * t * t_,
  44394. t * t * t
  44395. ]));
  44396. }
  44397. return lut;
  44398. }
  44399. var cache = [];
  44400. return function getB(count) {
  44401. if (!cache[count]) {
  44402. cache[count] = buildB(count);
  44403. }
  44404. return cache[count];
  44405. };
  44406. }();
  44407. function buildFigureFromPatch(mesh, index) {
  44408. var figure = mesh.figures[index];
  44409. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  44410. var coords = mesh.coords, colors = mesh.colors;
  44411. var pi = figure.coords;
  44412. var ci = figure.colors;
  44413. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44414. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44415. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44416. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44417. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  44418. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  44419. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  44420. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  44421. var verticesPerRow = splitXBy + 1;
  44422. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  44423. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  44424. var k = 0;
  44425. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  44426. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  44427. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  44428. for (var row = 0; row <= splitYBy; row++) {
  44429. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  44430. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  44431. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  44432. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  44433. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  44434. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  44435. for (var col = 0; col <= splitXBy; col++, k++) {
  44436. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  44437. continue;
  44438. }
  44439. var x = 0, y = 0;
  44440. var q = 0;
  44441. for (var i = 0; i <= 3; i++) {
  44442. for (var j = 0; j <= 3; j++, q++) {
  44443. var m = bRow[row][i] * bCol[col][j];
  44444. x += coords[pi[q]][0] * m;
  44445. y += coords[pi[q]][1] * m;
  44446. }
  44447. }
  44448. figureCoords[k] = coords.length;
  44449. coords.push([
  44450. x,
  44451. y
  44452. ]);
  44453. figureColors[k] = colors.length;
  44454. var newColor = new Uint8Array(3);
  44455. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  44456. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  44457. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  44458. colors.push(newColor);
  44459. }
  44460. }
  44461. figureCoords[0] = pi[0];
  44462. figureColors[0] = ci[0];
  44463. figureCoords[splitXBy] = pi[3];
  44464. figureColors[splitXBy] = ci[1];
  44465. figureCoords[verticesPerRow * splitYBy] = pi[12];
  44466. figureColors[verticesPerRow * splitYBy] = ci[2];
  44467. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  44468. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  44469. mesh.figures[index] = {
  44470. type: 'lattice',
  44471. coords: figureCoords,
  44472. colors: figureColors,
  44473. verticesPerRow: verticesPerRow
  44474. };
  44475. }
  44476. function decodeType6Shading(mesh, reader) {
  44477. var coords = mesh.coords;
  44478. var colors = mesh.colors;
  44479. var ps = new Int32Array(16);
  44480. var cs = new Int32Array(4);
  44481. while (reader.hasData) {
  44482. var f = reader.readFlag();
  44483. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  44484. var i, ii;
  44485. var pi = coords.length;
  44486. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  44487. coords.push(reader.readCoordinate());
  44488. }
  44489. var ci = colors.length;
  44490. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44491. colors.push(reader.readComponents());
  44492. }
  44493. var tmp1, tmp2, tmp3, tmp4;
  44494. switch (f) {
  44495. case 0:
  44496. ps[12] = pi + 3;
  44497. ps[13] = pi + 4;
  44498. ps[14] = pi + 5;
  44499. ps[15] = pi + 6;
  44500. ps[8] = pi + 2;
  44501. ps[11] = pi + 7;
  44502. ps[4] = pi + 1;
  44503. ps[7] = pi + 8;
  44504. ps[0] = pi;
  44505. ps[1] = pi + 11;
  44506. ps[2] = pi + 10;
  44507. ps[3] = pi + 9;
  44508. cs[2] = ci + 1;
  44509. cs[3] = ci + 2;
  44510. cs[0] = ci;
  44511. cs[1] = ci + 3;
  44512. break;
  44513. case 1:
  44514. tmp1 = ps[12];
  44515. tmp2 = ps[13];
  44516. tmp3 = ps[14];
  44517. tmp4 = ps[15];
  44518. ps[12] = tmp4;
  44519. ps[13] = pi + 0;
  44520. ps[14] = pi + 1;
  44521. ps[15] = pi + 2;
  44522. ps[8] = tmp3;
  44523. ps[11] = pi + 3;
  44524. ps[4] = tmp2;
  44525. ps[7] = pi + 4;
  44526. ps[0] = tmp1;
  44527. ps[1] = pi + 7;
  44528. ps[2] = pi + 6;
  44529. ps[3] = pi + 5;
  44530. tmp1 = cs[2];
  44531. tmp2 = cs[3];
  44532. cs[2] = tmp2;
  44533. cs[3] = ci;
  44534. cs[0] = tmp1;
  44535. cs[1] = ci + 1;
  44536. break;
  44537. case 2:
  44538. tmp1 = ps[15];
  44539. tmp2 = ps[11];
  44540. ps[12] = ps[3];
  44541. ps[13] = pi + 0;
  44542. ps[14] = pi + 1;
  44543. ps[15] = pi + 2;
  44544. ps[8] = ps[7];
  44545. ps[11] = pi + 3;
  44546. ps[4] = tmp2;
  44547. ps[7] = pi + 4;
  44548. ps[0] = tmp1;
  44549. ps[1] = pi + 7;
  44550. ps[2] = pi + 6;
  44551. ps[3] = pi + 5;
  44552. tmp1 = cs[3];
  44553. cs[2] = cs[1];
  44554. cs[3] = ci;
  44555. cs[0] = tmp1;
  44556. cs[1] = ci + 1;
  44557. break;
  44558. case 3:
  44559. ps[12] = ps[0];
  44560. ps[13] = pi + 0;
  44561. ps[14] = pi + 1;
  44562. ps[15] = pi + 2;
  44563. ps[8] = ps[1];
  44564. ps[11] = pi + 3;
  44565. ps[4] = ps[2];
  44566. ps[7] = pi + 4;
  44567. ps[0] = ps[3];
  44568. ps[1] = pi + 7;
  44569. ps[2] = pi + 6;
  44570. ps[3] = pi + 5;
  44571. cs[2] = cs[0];
  44572. cs[3] = ci;
  44573. cs[0] = cs[1];
  44574. cs[1] = ci + 1;
  44575. break;
  44576. }
  44577. ps[5] = coords.length;
  44578. coords.push([
  44579. (-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,
  44580. (-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
  44581. ]);
  44582. ps[6] = coords.length;
  44583. coords.push([
  44584. (-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,
  44585. (-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
  44586. ]);
  44587. ps[9] = coords.length;
  44588. coords.push([
  44589. (-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,
  44590. (-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
  44591. ]);
  44592. ps[10] = coords.length;
  44593. coords.push([
  44594. (-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,
  44595. (-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
  44596. ]);
  44597. mesh.figures.push({
  44598. type: 'patch',
  44599. coords: new Int32Array(ps),
  44600. colors: new Int32Array(cs)
  44601. });
  44602. }
  44603. }
  44604. function decodeType7Shading(mesh, reader) {
  44605. var coords = mesh.coords;
  44606. var colors = mesh.colors;
  44607. var ps = new Int32Array(16);
  44608. var cs = new Int32Array(4);
  44609. while (reader.hasData) {
  44610. var f = reader.readFlag();
  44611. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  44612. var i, ii;
  44613. var pi = coords.length;
  44614. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  44615. coords.push(reader.readCoordinate());
  44616. }
  44617. var ci = colors.length;
  44618. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44619. colors.push(reader.readComponents());
  44620. }
  44621. var tmp1, tmp2, tmp3, tmp4;
  44622. switch (f) {
  44623. case 0:
  44624. ps[12] = pi + 3;
  44625. ps[13] = pi + 4;
  44626. ps[14] = pi + 5;
  44627. ps[15] = pi + 6;
  44628. ps[8] = pi + 2;
  44629. ps[9] = pi + 13;
  44630. ps[10] = pi + 14;
  44631. ps[11] = pi + 7;
  44632. ps[4] = pi + 1;
  44633. ps[5] = pi + 12;
  44634. ps[6] = pi + 15;
  44635. ps[7] = pi + 8;
  44636. ps[0] = pi;
  44637. ps[1] = pi + 11;
  44638. ps[2] = pi + 10;
  44639. ps[3] = pi + 9;
  44640. cs[2] = ci + 1;
  44641. cs[3] = ci + 2;
  44642. cs[0] = ci;
  44643. cs[1] = ci + 3;
  44644. break;
  44645. case 1:
  44646. tmp1 = ps[12];
  44647. tmp2 = ps[13];
  44648. tmp3 = ps[14];
  44649. tmp4 = ps[15];
  44650. ps[12] = tmp4;
  44651. ps[13] = pi + 0;
  44652. ps[14] = pi + 1;
  44653. ps[15] = pi + 2;
  44654. ps[8] = tmp3;
  44655. ps[9] = pi + 9;
  44656. ps[10] = pi + 10;
  44657. ps[11] = pi + 3;
  44658. ps[4] = tmp2;
  44659. ps[5] = pi + 8;
  44660. ps[6] = pi + 11;
  44661. ps[7] = pi + 4;
  44662. ps[0] = tmp1;
  44663. ps[1] = pi + 7;
  44664. ps[2] = pi + 6;
  44665. ps[3] = pi + 5;
  44666. tmp1 = cs[2];
  44667. tmp2 = cs[3];
  44668. cs[2] = tmp2;
  44669. cs[3] = ci;
  44670. cs[0] = tmp1;
  44671. cs[1] = ci + 1;
  44672. break;
  44673. case 2:
  44674. tmp1 = ps[15];
  44675. tmp2 = ps[11];
  44676. ps[12] = ps[3];
  44677. ps[13] = pi + 0;
  44678. ps[14] = pi + 1;
  44679. ps[15] = pi + 2;
  44680. ps[8] = ps[7];
  44681. ps[9] = pi + 9;
  44682. ps[10] = pi + 10;
  44683. ps[11] = pi + 3;
  44684. ps[4] = tmp2;
  44685. ps[5] = pi + 8;
  44686. ps[6] = pi + 11;
  44687. ps[7] = pi + 4;
  44688. ps[0] = tmp1;
  44689. ps[1] = pi + 7;
  44690. ps[2] = pi + 6;
  44691. ps[3] = pi + 5;
  44692. tmp1 = cs[3];
  44693. cs[2] = cs[1];
  44694. cs[3] = ci;
  44695. cs[0] = tmp1;
  44696. cs[1] = ci + 1;
  44697. break;
  44698. case 3:
  44699. ps[12] = ps[0];
  44700. ps[13] = pi + 0;
  44701. ps[14] = pi + 1;
  44702. ps[15] = pi + 2;
  44703. ps[8] = ps[1];
  44704. ps[9] = pi + 9;
  44705. ps[10] = pi + 10;
  44706. ps[11] = pi + 3;
  44707. ps[4] = ps[2];
  44708. ps[5] = pi + 8;
  44709. ps[6] = pi + 11;
  44710. ps[7] = pi + 4;
  44711. ps[0] = ps[3];
  44712. ps[1] = pi + 7;
  44713. ps[2] = pi + 6;
  44714. ps[3] = pi + 5;
  44715. cs[2] = cs[0];
  44716. cs[3] = ci;
  44717. cs[0] = cs[1];
  44718. cs[1] = ci + 1;
  44719. break;
  44720. }
  44721. mesh.figures.push({
  44722. type: 'patch',
  44723. coords: new Int32Array(ps),
  44724. colors: new Int32Array(cs)
  44725. });
  44726. }
  44727. }
  44728. function updateBounds(mesh) {
  44729. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  44730. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  44731. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  44732. minX = minX > x ? x : minX;
  44733. minY = minY > y ? y : minY;
  44734. maxX = maxX < x ? x : maxX;
  44735. maxY = maxY < y ? y : maxY;
  44736. }
  44737. mesh.bounds = [
  44738. minX,
  44739. minY,
  44740. maxX,
  44741. maxY
  44742. ];
  44743. }
  44744. function packData(mesh) {
  44745. var i, ii, j, jj;
  44746. var coords = mesh.coords;
  44747. var coordsPacked = new Float32Array(coords.length * 2);
  44748. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  44749. var xy = coords[i];
  44750. coordsPacked[j++] = xy[0];
  44751. coordsPacked[j++] = xy[1];
  44752. }
  44753. mesh.coords = coordsPacked;
  44754. var colors = mesh.colors;
  44755. var colorsPacked = new Uint8Array(colors.length * 3);
  44756. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  44757. var c = colors[i];
  44758. colorsPacked[j++] = c[0];
  44759. colorsPacked[j++] = c[1];
  44760. colorsPacked[j++] = c[2];
  44761. }
  44762. mesh.colors = colorsPacked;
  44763. var figures = mesh.figures;
  44764. for (i = 0, ii = figures.length; i < ii; i++) {
  44765. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  44766. for (j = 0, jj = ps.length; j < jj; j++) {
  44767. ps[j] *= 2;
  44768. cs[j] *= 3;
  44769. }
  44770. }
  44771. }
  44772. function Mesh(stream, matrix, xref, res) {
  44773. assert(isStream(stream), 'Mesh data is not a stream');
  44774. var dict = stream.dict;
  44775. this.matrix = matrix;
  44776. this.shadingType = dict.get('ShadingType');
  44777. this.type = 'Pattern';
  44778. this.bbox = dict.getArray('BBox');
  44779. var cs = dict.get('ColorSpace', 'CS');
  44780. cs = ColorSpace.parse(cs, xref, res);
  44781. this.cs = cs;
  44782. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  44783. var fnObj = dict.get('Function');
  44784. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  44785. this.coords = [];
  44786. this.colors = [];
  44787. this.figures = [];
  44788. var decodeContext = {
  44789. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  44790. bitsPerComponent: dict.get('BitsPerComponent'),
  44791. bitsPerFlag: dict.get('BitsPerFlag'),
  44792. decode: dict.getArray('Decode'),
  44793. colorFn: fn,
  44794. colorSpace: cs,
  44795. numComps: fn ? 1 : cs.numComps
  44796. };
  44797. var reader = new MeshStreamReader(stream, decodeContext);
  44798. var patchMesh = false;
  44799. switch (this.shadingType) {
  44800. case ShadingType.FREE_FORM_MESH:
  44801. decodeType4Shading(this, reader);
  44802. break;
  44803. case ShadingType.LATTICE_FORM_MESH:
  44804. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  44805. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  44806. decodeType5Shading(this, reader, verticesPerRow);
  44807. break;
  44808. case ShadingType.COONS_PATCH_MESH:
  44809. decodeType6Shading(this, reader);
  44810. patchMesh = true;
  44811. break;
  44812. case ShadingType.TENSOR_PATCH_MESH:
  44813. decodeType7Shading(this, reader);
  44814. patchMesh = true;
  44815. break;
  44816. default:
  44817. error('Unsupported mesh type.');
  44818. break;
  44819. }
  44820. if (patchMesh) {
  44821. updateBounds(this);
  44822. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  44823. buildFigureFromPatch(this, i);
  44824. }
  44825. }
  44826. updateBounds(this);
  44827. packData(this);
  44828. }
  44829. Mesh.prototype = {
  44830. getIR: function Mesh_getIR() {
  44831. return [
  44832. 'Mesh',
  44833. this.shadingType,
  44834. this.coords,
  44835. this.colors,
  44836. this.figures,
  44837. this.bounds,
  44838. this.matrix,
  44839. this.bbox,
  44840. this.background
  44841. ];
  44842. }
  44843. };
  44844. return Mesh;
  44845. }();
  44846. Shadings.Dummy = function DummyClosure() {
  44847. function Dummy() {
  44848. this.type = 'Pattern';
  44849. }
  44850. Dummy.prototype = {
  44851. getIR: function Dummy_getIR() {
  44852. return ['Dummy'];
  44853. }
  44854. };
  44855. return Dummy;
  44856. }();
  44857. function getTilingPatternIR(operatorList, dict, args) {
  44858. var matrix = dict.getArray('Matrix');
  44859. var bbox = dict.getArray('BBox');
  44860. var xstep = dict.get('XStep');
  44861. var ystep = dict.get('YStep');
  44862. var paintType = dict.get('PaintType');
  44863. var tilingType = dict.get('TilingType');
  44864. return [
  44865. 'TilingPattern',
  44866. args,
  44867. operatorList,
  44868. matrix,
  44869. bbox,
  44870. xstep,
  44871. ystep,
  44872. paintType,
  44873. tilingType
  44874. ];
  44875. }
  44876. exports.Pattern = Pattern;
  44877. exports.getTilingPatternIR = getTilingPatternIR;
  44878. }));
  44879. (function (root, factory) {
  44880. 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);
  44881. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  44882. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  44883. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  44884. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  44885. var ImageKind = sharedUtil.ImageKind;
  44886. var OPS = sharedUtil.OPS;
  44887. var TextRenderingMode = sharedUtil.TextRenderingMode;
  44888. var Util = sharedUtil.Util;
  44889. var assert = sharedUtil.assert;
  44890. var createPromiseCapability = sharedUtil.createPromiseCapability;
  44891. var error = sharedUtil.error;
  44892. var info = sharedUtil.info;
  44893. var isArray = sharedUtil.isArray;
  44894. var isNum = sharedUtil.isNum;
  44895. var isString = sharedUtil.isString;
  44896. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  44897. var warn = sharedUtil.warn;
  44898. var Dict = corePrimitives.Dict;
  44899. var Name = corePrimitives.Name;
  44900. var isCmd = corePrimitives.isCmd;
  44901. var isDict = corePrimitives.isDict;
  44902. var isName = corePrimitives.isName;
  44903. var isRef = corePrimitives.isRef;
  44904. var isStream = corePrimitives.isStream;
  44905. var DecodeStream = coreStream.DecodeStream;
  44906. var JpegStream = coreStream.JpegStream;
  44907. var Stream = coreStream.Stream;
  44908. var Lexer = coreParser.Lexer;
  44909. var Parser = coreParser.Parser;
  44910. var isEOF = coreParser.isEOF;
  44911. var PDFImage = coreImage.PDFImage;
  44912. var ColorSpace = coreColorSpace.ColorSpace;
  44913. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  44914. var ErrorFont = coreFonts.ErrorFont;
  44915. var FontFlags = coreFonts.FontFlags;
  44916. var Font = coreFonts.Font;
  44917. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  44918. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  44919. var getFontType = coreFonts.getFontType;
  44920. var isPDFFunction = coreFunction.isPDFFunction;
  44921. var PDFFunction = coreFunction.PDFFunction;
  44922. var Pattern = corePattern.Pattern;
  44923. var getTilingPatternIR = corePattern.getTilingPatternIR;
  44924. var CMapFactory = coreCMap.CMapFactory;
  44925. var IdentityCMap = coreCMap.IdentityCMap;
  44926. var getMetrics = coreMetrics.getMetrics;
  44927. var bidi = coreBidi.bidi;
  44928. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  44929. var StandardEncoding = coreEncodings.StandardEncoding;
  44930. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  44931. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  44932. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  44933. var getEncoding = coreEncodings.getEncoding;
  44934. var getStdFontMap = coreStandardFonts.getStdFontMap;
  44935. var getSerifFonts = coreStandardFonts.getSerifFonts;
  44936. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  44937. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  44938. var reverseIfRtl = coreUnicode.reverseIfRtl;
  44939. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  44940. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  44941. var PartialEvaluator = function PartialEvaluatorClosure() {
  44942. var DefaultPartialEvaluatorOptions = {
  44943. forceDataSchema: false,
  44944. maxImageSize: -1,
  44945. disableFontFace: false,
  44946. cMapOptions: {
  44947. url: null,
  44948. packed: false
  44949. }
  44950. };
  44951. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  44952. this.xref = xref;
  44953. this.resources = resources;
  44954. this.handler = handler;
  44955. this.forceDataSchema = forceDataSchema;
  44956. }
  44957. NativeImageDecoder.prototype = {
  44958. canDecode: function (image) {
  44959. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  44960. },
  44961. decode: function (image) {
  44962. var dict = image.dict;
  44963. var colorSpace = dict.get('ColorSpace', 'CS');
  44964. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  44965. var numComps = colorSpace.numComps;
  44966. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  44967. image.getIR(this.forceDataSchema),
  44968. numComps
  44969. ]);
  44970. return decodePromise.then(function (message) {
  44971. var data = message.data;
  44972. return new Stream(data, 0, data.length, image.dict);
  44973. });
  44974. }
  44975. };
  44976. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  44977. var dict = image.dict;
  44978. if (dict.has('DecodeParms') || dict.has('DP')) {
  44979. return false;
  44980. }
  44981. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  44982. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  44983. };
  44984. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  44985. var dict = image.dict;
  44986. if (dict.has('DecodeParms') || dict.has('DP')) {
  44987. return false;
  44988. }
  44989. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  44990. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  44991. };
  44992. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  44993. this.pdfManager = pdfManager;
  44994. this.xref = xref;
  44995. this.handler = handler;
  44996. this.pageIndex = pageIndex;
  44997. this.uniquePrefix = uniquePrefix;
  44998. this.idCounters = idCounters;
  44999. this.fontCache = fontCache;
  45000. this.options = options || DefaultPartialEvaluatorOptions;
  45001. }
  45002. var TIME_SLOT_DURATION_MS = 20;
  45003. var CHECK_TIME_EVERY = 100;
  45004. function TimeSlotManager() {
  45005. this.reset();
  45006. }
  45007. TimeSlotManager.prototype = {
  45008. check: function TimeSlotManager_check() {
  45009. if (++this.checked < CHECK_TIME_EVERY) {
  45010. return false;
  45011. }
  45012. this.checked = 0;
  45013. return this.endTime <= Date.now();
  45014. },
  45015. reset: function TimeSlotManager_reset() {
  45016. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  45017. this.checked = 0;
  45018. }
  45019. };
  45020. var deferred = Promise.resolve();
  45021. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  45022. PartialEvaluator.prototype = {
  45023. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  45024. if (!isDict(resources)) {
  45025. return false;
  45026. }
  45027. var processed = Object.create(null);
  45028. if (resources.objId) {
  45029. processed[resources.objId] = true;
  45030. }
  45031. var nodes = [resources], xref = this.xref;
  45032. while (nodes.length) {
  45033. var key, i, ii;
  45034. var node = nodes.shift();
  45035. var graphicStates = node.get('ExtGState');
  45036. if (isDict(graphicStates)) {
  45037. var graphicStatesKeys = graphicStates.getKeys();
  45038. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  45039. key = graphicStatesKeys[i];
  45040. var graphicState = graphicStates.get(key);
  45041. var bm = graphicState.get('BM');
  45042. if (isName(bm) && bm.name !== 'Normal') {
  45043. return true;
  45044. }
  45045. }
  45046. }
  45047. var xObjects = node.get('XObject');
  45048. if (!isDict(xObjects)) {
  45049. continue;
  45050. }
  45051. var xObjectsKeys = xObjects.getKeys();
  45052. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  45053. key = xObjectsKeys[i];
  45054. var xObject = xObjects.getRaw(key);
  45055. if (isRef(xObject)) {
  45056. if (processed[xObject.toString()]) {
  45057. continue;
  45058. }
  45059. xObject = xref.fetch(xObject);
  45060. }
  45061. if (!isStream(xObject)) {
  45062. continue;
  45063. }
  45064. if (xObject.dict.objId) {
  45065. if (processed[xObject.dict.objId]) {
  45066. continue;
  45067. }
  45068. processed[xObject.dict.objId] = true;
  45069. }
  45070. var xResources = xObject.dict.get('Resources');
  45071. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  45072. nodes.push(xResources);
  45073. if (xResources.objId) {
  45074. processed[xResources.objId] = true;
  45075. }
  45076. }
  45077. }
  45078. }
  45079. return false;
  45080. },
  45081. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  45082. var matrix = xobj.dict.getArray('Matrix');
  45083. var bbox = xobj.dict.getArray('BBox');
  45084. var group = xobj.dict.get('Group');
  45085. if (group) {
  45086. var groupOptions = {
  45087. matrix: matrix,
  45088. bbox: bbox,
  45089. smask: smask,
  45090. isolated: false,
  45091. knockout: false
  45092. };
  45093. var groupSubtype = group.get('S');
  45094. var colorSpace;
  45095. if (isName(groupSubtype, 'Transparency')) {
  45096. groupOptions.isolated = group.get('I') || false;
  45097. groupOptions.knockout = group.get('K') || false;
  45098. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  45099. }
  45100. if (smask && smask.backdrop) {
  45101. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  45102. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  45103. }
  45104. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  45105. }
  45106. operatorList.addOp(OPS.paintFormXObjectBegin, [
  45107. matrix,
  45108. bbox
  45109. ]);
  45110. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  45111. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  45112. if (group) {
  45113. operatorList.addOp(OPS.endGroup, [groupOptions]);
  45114. }
  45115. });
  45116. },
  45117. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  45118. var self = this;
  45119. var dict = image.dict;
  45120. var w = dict.get('Width', 'W');
  45121. var h = dict.get('Height', 'H');
  45122. if (!(w && isNum(w)) || !(h && isNum(h))) {
  45123. warn('Image dimensions are missing, or not numbers.');
  45124. return;
  45125. }
  45126. var maxImageSize = this.options.maxImageSize;
  45127. if (maxImageSize !== -1 && w * h > maxImageSize) {
  45128. warn('Image exceeded maximum allowed size and was removed.');
  45129. return;
  45130. }
  45131. var imageMask = dict.get('ImageMask', 'IM') || false;
  45132. var imgData, args;
  45133. if (imageMask) {
  45134. var width = dict.get('Width', 'W');
  45135. var height = dict.get('Height', 'H');
  45136. var bitStrideLength = width + 7 >> 3;
  45137. var imgArray = image.getBytes(bitStrideLength * height);
  45138. var decode = dict.getArray('Decode', 'D');
  45139. var inverseDecode = !!decode && decode[0] > 0;
  45140. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  45141. imgData.cached = true;
  45142. args = [imgData];
  45143. operatorList.addOp(OPS.paintImageMaskXObject, args);
  45144. if (cacheKey) {
  45145. imageCache[cacheKey] = {
  45146. fn: OPS.paintImageMaskXObject,
  45147. args: args
  45148. };
  45149. }
  45150. return;
  45151. }
  45152. var softMask = dict.get('SMask', 'SM') || false;
  45153. var mask = dict.get('Mask') || false;
  45154. var SMALL_IMAGE_DIMENSIONS = 200;
  45155. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  45156. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  45157. imgData = imageObj.createImageData(true);
  45158. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  45159. return;
  45160. }
  45161. var uniquePrefix = this.uniquePrefix || '';
  45162. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  45163. operatorList.addDependency(objId);
  45164. args = [
  45165. objId,
  45166. w,
  45167. h
  45168. ];
  45169. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  45170. operatorList.addOp(OPS.paintJpegXObject, args);
  45171. this.handler.send('obj', [
  45172. objId,
  45173. this.pageIndex,
  45174. 'JpegStream',
  45175. image.getIR(this.options.forceDataSchema)
  45176. ]);
  45177. return;
  45178. }
  45179. var nativeImageDecoder = null;
  45180. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  45181. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  45182. }
  45183. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  45184. var imgData = imageObj.createImageData(false);
  45185. self.handler.send('obj', [
  45186. objId,
  45187. self.pageIndex,
  45188. 'Image',
  45189. imgData
  45190. ], [imgData.data.buffer]);
  45191. }).then(undefined, function (reason) {
  45192. warn('Unable to decode image: ' + reason);
  45193. self.handler.send('obj', [
  45194. objId,
  45195. self.pageIndex,
  45196. 'Image',
  45197. null
  45198. ]);
  45199. });
  45200. operatorList.addOp(OPS.paintImageXObject, args);
  45201. if (cacheKey) {
  45202. imageCache[cacheKey] = {
  45203. fn: OPS.paintImageXObject,
  45204. args: args
  45205. };
  45206. }
  45207. },
  45208. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  45209. var smaskContent = smask.get('G');
  45210. var smaskOptions = {
  45211. subtype: smask.get('S').name,
  45212. backdrop: smask.get('BC')
  45213. };
  45214. var transferObj = smask.get('TR');
  45215. if (isPDFFunction(transferObj)) {
  45216. var transferFn = PDFFunction.parse(this.xref, transferObj);
  45217. var transferMap = new Uint8Array(256);
  45218. var tmp = new Float32Array(1);
  45219. for (var i = 0; i < 256; i++) {
  45220. tmp[0] = i / 255;
  45221. transferFn(tmp, 0, tmp, 0);
  45222. transferMap[i] = tmp[0] * 255 | 0;
  45223. }
  45224. smaskOptions.transferMap = transferMap;
  45225. }
  45226. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  45227. },
  45228. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  45229. var tilingOpList = new OperatorList();
  45230. var resourcesArray = [
  45231. patternDict.get('Resources'),
  45232. resources
  45233. ];
  45234. var patternResources = Dict.merge(this.xref, resourcesArray);
  45235. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  45236. operatorList.addDependencies(tilingOpList.dependencies);
  45237. operatorList.addOp(fn, getTilingPatternIR({
  45238. fnArray: tilingOpList.fnArray,
  45239. argsArray: tilingOpList.argsArray
  45240. }, patternDict, args));
  45241. });
  45242. },
  45243. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  45244. var fontName;
  45245. if (fontArgs) {
  45246. fontArgs = fontArgs.slice();
  45247. fontName = fontArgs[0].name;
  45248. }
  45249. var self = this;
  45250. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  45251. if (!translated.font.isType3Font) {
  45252. return translated;
  45253. }
  45254. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  45255. return translated;
  45256. }, function (reason) {
  45257. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45258. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  45259. });
  45260. }).then(function (translated) {
  45261. state.font = translated.font;
  45262. translated.send(self.handler);
  45263. return translated.loadedName;
  45264. });
  45265. },
  45266. handleText: function PartialEvaluator_handleText(chars, state) {
  45267. var font = state.font;
  45268. var glyphs = font.charsToGlyphs(chars);
  45269. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  45270. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  45271. var buildPath = function (fontChar) {
  45272. if (!font.renderer.hasBuiltPath(fontChar)) {
  45273. var path = font.renderer.getPathJs(fontChar);
  45274. this.handler.send('commonobj', [
  45275. font.loadedName + '_path_' + fontChar,
  45276. 'FontPath',
  45277. path
  45278. ]);
  45279. }
  45280. }.bind(this);
  45281. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  45282. var glyph = glyphs[i];
  45283. buildPath(glyph.fontChar);
  45284. var accent = glyph.accent;
  45285. if (accent && accent.fontChar) {
  45286. buildPath(accent.fontChar);
  45287. }
  45288. }
  45289. }
  45290. return glyphs;
  45291. },
  45292. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  45293. var gStateObj = [];
  45294. var gStateKeys = gState.getKeys();
  45295. var self = this;
  45296. var promise = Promise.resolve();
  45297. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  45298. var key = gStateKeys[i];
  45299. var value = gState.get(key);
  45300. switch (key) {
  45301. case 'Type':
  45302. break;
  45303. case 'LW':
  45304. case 'LC':
  45305. case 'LJ':
  45306. case 'ML':
  45307. case 'D':
  45308. case 'RI':
  45309. case 'FL':
  45310. case 'CA':
  45311. case 'ca':
  45312. gStateObj.push([
  45313. key,
  45314. value
  45315. ]);
  45316. break;
  45317. case 'Font':
  45318. promise = promise.then(function () {
  45319. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  45320. operatorList.addDependency(loadedName);
  45321. gStateObj.push([
  45322. key,
  45323. [
  45324. loadedName,
  45325. value[1]
  45326. ]
  45327. ]);
  45328. });
  45329. });
  45330. break;
  45331. case 'BM':
  45332. gStateObj.push([
  45333. key,
  45334. value
  45335. ]);
  45336. break;
  45337. case 'SMask':
  45338. if (isName(value, 'None')) {
  45339. gStateObj.push([
  45340. key,
  45341. false
  45342. ]);
  45343. break;
  45344. }
  45345. if (isDict(value)) {
  45346. promise = promise.then(function (dict) {
  45347. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  45348. }.bind(this, value));
  45349. gStateObj.push([
  45350. key,
  45351. true
  45352. ]);
  45353. } else {
  45354. warn('Unsupported SMask type');
  45355. }
  45356. break;
  45357. case 'OP':
  45358. case 'op':
  45359. case 'OPM':
  45360. case 'BG':
  45361. case 'BG2':
  45362. case 'UCR':
  45363. case 'UCR2':
  45364. case 'TR':
  45365. case 'TR2':
  45366. case 'HT':
  45367. case 'SM':
  45368. case 'SA':
  45369. case 'AIS':
  45370. case 'TK':
  45371. info('graphic state operator ' + key);
  45372. break;
  45373. default:
  45374. info('Unknown graphic state operator ' + key);
  45375. break;
  45376. }
  45377. }
  45378. return promise.then(function () {
  45379. if (gStateObj.length > 0) {
  45380. operatorList.addOp(OPS.setGState, [gStateObj]);
  45381. }
  45382. });
  45383. },
  45384. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  45385. function errorFont() {
  45386. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  45387. }
  45388. var fontRef;
  45389. if (font) {
  45390. assert(isRef(font));
  45391. fontRef = font;
  45392. } else {
  45393. var fontRes = resources.get('Font');
  45394. if (fontRes) {
  45395. fontRef = fontRes.getRaw(fontName);
  45396. } else {
  45397. warn('fontRes not available');
  45398. return errorFont();
  45399. }
  45400. }
  45401. if (!fontRef) {
  45402. warn('fontRef not available');
  45403. return errorFont();
  45404. }
  45405. if (this.fontCache.has(fontRef)) {
  45406. return this.fontCache.get(fontRef);
  45407. }
  45408. font = xref.fetchIfRef(fontRef);
  45409. if (!isDict(font)) {
  45410. return errorFont();
  45411. }
  45412. if (font.translated) {
  45413. return font.translated;
  45414. }
  45415. var fontCapability = createPromiseCapability();
  45416. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  45417. var descriptor = preEvaluatedFont.descriptor;
  45418. var fontRefIsRef = isRef(fontRef), fontID;
  45419. if (fontRefIsRef) {
  45420. fontID = fontRef.toString();
  45421. }
  45422. if (isDict(descriptor)) {
  45423. if (!descriptor.fontAliases) {
  45424. descriptor.fontAliases = Object.create(null);
  45425. }
  45426. var fontAliases = descriptor.fontAliases;
  45427. var hash = preEvaluatedFont.hash;
  45428. if (fontAliases[hash]) {
  45429. var aliasFontRef = fontAliases[hash].aliasRef;
  45430. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  45431. this.fontCache.putAlias(fontRef, aliasFontRef);
  45432. return this.fontCache.get(fontRef);
  45433. }
  45434. } else {
  45435. fontAliases[hash] = { fontID: Font.getFontID() };
  45436. }
  45437. if (fontRefIsRef) {
  45438. fontAliases[hash].aliasRef = fontRef;
  45439. }
  45440. fontID = fontAliases[hash].fontID;
  45441. }
  45442. if (fontRefIsRef) {
  45443. this.fontCache.put(fontRef, fontCapability.promise);
  45444. } else {
  45445. if (!fontID) {
  45446. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  45447. }
  45448. this.fontCache.put('id_' + fontID, fontCapability.promise);
  45449. }
  45450. assert(fontID, 'The "fontID" must be defined.');
  45451. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  45452. font.translated = fontCapability.promise;
  45453. var translatedPromise;
  45454. try {
  45455. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  45456. } catch (e) {
  45457. translatedPromise = Promise.reject(e);
  45458. }
  45459. var self = this;
  45460. translatedPromise.then(function (translatedFont) {
  45461. if (translatedFont.fontType !== undefined) {
  45462. var xrefFontStats = xref.stats.fontTypes;
  45463. xrefFontStats[translatedFont.fontType] = true;
  45464. }
  45465. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  45466. }, function (reason) {
  45467. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45468. try {
  45469. var descriptor = preEvaluatedFont.descriptor;
  45470. var fontFile3 = descriptor && descriptor.get('FontFile3');
  45471. var subtype = fontFile3 && fontFile3.get('Subtype');
  45472. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  45473. var xrefFontStats = xref.stats.fontTypes;
  45474. xrefFontStats[fontType] = true;
  45475. } catch (ex) {
  45476. }
  45477. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  45478. });
  45479. return fontCapability.promise;
  45480. },
  45481. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  45482. var lastIndex = operatorList.length - 1;
  45483. if (!args) {
  45484. args = [];
  45485. }
  45486. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  45487. operatorList.addOp(OPS.constructPath, [
  45488. [fn],
  45489. args
  45490. ]);
  45491. } else {
  45492. var opArgs = operatorList.argsArray[lastIndex];
  45493. opArgs[0].push(fn);
  45494. Array.prototype.push.apply(opArgs[1], args);
  45495. }
  45496. },
  45497. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  45498. var patternName = args[args.length - 1];
  45499. var pattern;
  45500. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  45501. var dict = isStream(pattern) ? pattern.dict : pattern;
  45502. var typeNum = dict.get('PatternType');
  45503. if (typeNum === TILING_PATTERN) {
  45504. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  45505. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  45506. } else if (typeNum === SHADING_PATTERN) {
  45507. var shading = dict.get('Shading');
  45508. var matrix = dict.getArray('Matrix');
  45509. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  45510. operatorList.addOp(fn, pattern.getIR());
  45511. return Promise.resolve();
  45512. } else {
  45513. return Promise.reject('Unknown PatternType: ' + typeNum);
  45514. }
  45515. }
  45516. operatorList.addOp(fn, args);
  45517. return Promise.resolve();
  45518. },
  45519. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  45520. var self = this;
  45521. var xref = this.xref;
  45522. var imageCache = Object.create(null);
  45523. assert(operatorList);
  45524. resources = resources || Dict.empty;
  45525. var xobjs = resources.get('XObject') || Dict.empty;
  45526. var patterns = resources.get('Pattern') || Dict.empty;
  45527. var stateManager = new StateManager(initialState || new EvalState());
  45528. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45529. var timeSlotManager = new TimeSlotManager();
  45530. return new Promise(function promiseBody(resolve, reject) {
  45531. var next = function (promise) {
  45532. promise.then(function () {
  45533. try {
  45534. promiseBody(resolve, reject);
  45535. } catch (ex) {
  45536. reject(ex);
  45537. }
  45538. }, reject);
  45539. };
  45540. task.ensureNotTerminated();
  45541. timeSlotManager.reset();
  45542. var stop, operation = {}, i, ii, cs;
  45543. while (!(stop = timeSlotManager.check())) {
  45544. operation.args = null;
  45545. if (!preprocessor.read(operation)) {
  45546. break;
  45547. }
  45548. var args = operation.args;
  45549. var fn = operation.fn;
  45550. switch (fn | 0) {
  45551. case OPS.paintXObject:
  45552. if (args[0].code) {
  45553. break;
  45554. }
  45555. var name = args[0].name;
  45556. if (!name) {
  45557. warn('XObject must be referred to by name.');
  45558. continue;
  45559. }
  45560. if (imageCache[name] !== undefined) {
  45561. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  45562. args = null;
  45563. continue;
  45564. }
  45565. var xobj = xobjs.get(name);
  45566. if (xobj) {
  45567. assert(isStream(xobj), 'XObject should be a stream');
  45568. var type = xobj.dict.get('Subtype');
  45569. assert(isName(type), 'XObject should have a Name subtype');
  45570. if (type.name === 'Form') {
  45571. stateManager.save();
  45572. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  45573. stateManager.restore();
  45574. }));
  45575. return;
  45576. } else if (type.name === 'Image') {
  45577. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  45578. args = null;
  45579. continue;
  45580. } else if (type.name === 'PS') {
  45581. info('Ignored XObject subtype PS');
  45582. continue;
  45583. } else {
  45584. error('Unhandled XObject subtype ' + type.name);
  45585. }
  45586. }
  45587. break;
  45588. case OPS.setFont:
  45589. var fontSize = args[1];
  45590. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  45591. operatorList.addDependency(loadedName);
  45592. operatorList.addOp(OPS.setFont, [
  45593. loadedName,
  45594. fontSize
  45595. ]);
  45596. }));
  45597. return;
  45598. case OPS.endInlineImage:
  45599. var cacheKey = args[0].cacheKey;
  45600. if (cacheKey) {
  45601. var cacheEntry = imageCache[cacheKey];
  45602. if (cacheEntry !== undefined) {
  45603. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  45604. args = null;
  45605. continue;
  45606. }
  45607. }
  45608. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  45609. args = null;
  45610. continue;
  45611. case OPS.showText:
  45612. args[0] = self.handleText(args[0], stateManager.state);
  45613. break;
  45614. case OPS.showSpacedText:
  45615. var arr = args[0];
  45616. var combinedGlyphs = [];
  45617. var arrLength = arr.length;
  45618. var state = stateManager.state;
  45619. for (i = 0; i < arrLength; ++i) {
  45620. var arrItem = arr[i];
  45621. if (isString(arrItem)) {
  45622. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  45623. } else if (isNum(arrItem)) {
  45624. combinedGlyphs.push(arrItem);
  45625. }
  45626. }
  45627. args[0] = combinedGlyphs;
  45628. fn = OPS.showText;
  45629. break;
  45630. case OPS.nextLineShowText:
  45631. operatorList.addOp(OPS.nextLine);
  45632. args[0] = self.handleText(args[0], stateManager.state);
  45633. fn = OPS.showText;
  45634. break;
  45635. case OPS.nextLineSetSpacingShowText:
  45636. operatorList.addOp(OPS.nextLine);
  45637. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  45638. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  45639. args[0] = self.handleText(args[0], stateManager.state);
  45640. fn = OPS.showText;
  45641. break;
  45642. case OPS.setTextRenderingMode:
  45643. stateManager.state.textRenderingMode = args[0];
  45644. break;
  45645. case OPS.setFillColorSpace:
  45646. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  45647. continue;
  45648. case OPS.setStrokeColorSpace:
  45649. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  45650. continue;
  45651. case OPS.setFillColor:
  45652. cs = stateManager.state.fillColorSpace;
  45653. args = cs.getRgb(args, 0);
  45654. fn = OPS.setFillRGBColor;
  45655. break;
  45656. case OPS.setStrokeColor:
  45657. cs = stateManager.state.strokeColorSpace;
  45658. args = cs.getRgb(args, 0);
  45659. fn = OPS.setStrokeRGBColor;
  45660. break;
  45661. case OPS.setFillGray:
  45662. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  45663. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45664. fn = OPS.setFillRGBColor;
  45665. break;
  45666. case OPS.setStrokeGray:
  45667. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  45668. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45669. fn = OPS.setStrokeRGBColor;
  45670. break;
  45671. case OPS.setFillCMYKColor:
  45672. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  45673. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45674. fn = OPS.setFillRGBColor;
  45675. break;
  45676. case OPS.setStrokeCMYKColor:
  45677. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  45678. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45679. fn = OPS.setStrokeRGBColor;
  45680. break;
  45681. case OPS.setFillRGBColor:
  45682. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  45683. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45684. break;
  45685. case OPS.setStrokeRGBColor:
  45686. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  45687. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45688. break;
  45689. case OPS.setFillColorN:
  45690. cs = stateManager.state.fillColorSpace;
  45691. if (cs.name === 'Pattern') {
  45692. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  45693. return;
  45694. }
  45695. args = cs.getRgb(args, 0);
  45696. fn = OPS.setFillRGBColor;
  45697. break;
  45698. case OPS.setStrokeColorN:
  45699. cs = stateManager.state.strokeColorSpace;
  45700. if (cs.name === 'Pattern') {
  45701. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  45702. return;
  45703. }
  45704. args = cs.getRgb(args, 0);
  45705. fn = OPS.setStrokeRGBColor;
  45706. break;
  45707. case OPS.shadingFill:
  45708. var shadingRes = resources.get('Shading');
  45709. if (!shadingRes) {
  45710. error('No shading resource found');
  45711. }
  45712. var shading = shadingRes.get(args[0].name);
  45713. if (!shading) {
  45714. error('No shading object found');
  45715. }
  45716. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  45717. var patternIR = shadingFill.getIR();
  45718. args = [patternIR];
  45719. fn = OPS.shadingFill;
  45720. break;
  45721. case OPS.setGState:
  45722. var dictName = args[0];
  45723. var extGState = resources.get('ExtGState');
  45724. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  45725. break;
  45726. }
  45727. var gState = extGState.get(dictName.name);
  45728. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  45729. return;
  45730. case OPS.moveTo:
  45731. case OPS.lineTo:
  45732. case OPS.curveTo:
  45733. case OPS.curveTo2:
  45734. case OPS.curveTo3:
  45735. case OPS.closePath:
  45736. self.buildPath(operatorList, fn, args);
  45737. continue;
  45738. case OPS.rectangle:
  45739. self.buildPath(operatorList, fn, args);
  45740. continue;
  45741. case OPS.markPoint:
  45742. case OPS.markPointProps:
  45743. case OPS.beginMarkedContent:
  45744. case OPS.beginMarkedContentProps:
  45745. case OPS.endMarkedContent:
  45746. case OPS.beginCompat:
  45747. case OPS.endCompat:
  45748. continue;
  45749. default:
  45750. if (args !== null) {
  45751. for (i = 0, ii = args.length; i < ii; i++) {
  45752. if (args[i] instanceof Dict) {
  45753. break;
  45754. }
  45755. }
  45756. if (i < ii) {
  45757. warn('getOperatorList - ignoring operator: ' + fn);
  45758. continue;
  45759. }
  45760. }
  45761. }
  45762. operatorList.addOp(fn, args);
  45763. }
  45764. if (stop) {
  45765. next(deferred);
  45766. return;
  45767. }
  45768. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  45769. operatorList.addOp(OPS.restore, []);
  45770. }
  45771. resolve();
  45772. });
  45773. },
  45774. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  45775. stateManager = stateManager || new StateManager(new TextState());
  45776. var WhitespaceRegexp = /\s/g;
  45777. var textContent = {
  45778. items: [],
  45779. styles: Object.create(null)
  45780. };
  45781. var textContentItem = {
  45782. initialized: false,
  45783. str: [],
  45784. width: 0,
  45785. height: 0,
  45786. vertical: false,
  45787. lastAdvanceWidth: 0,
  45788. lastAdvanceHeight: 0,
  45789. textAdvanceScale: 0,
  45790. spaceWidth: 0,
  45791. fakeSpaceMin: Infinity,
  45792. fakeMultiSpaceMin: Infinity,
  45793. fakeMultiSpaceMax: -0,
  45794. textRunBreakAllowed: false,
  45795. transform: null,
  45796. fontName: null
  45797. };
  45798. var SPACE_FACTOR = 0.3;
  45799. var MULTI_SPACE_FACTOR = 1.5;
  45800. var MULTI_SPACE_FACTOR_MAX = 4;
  45801. var self = this;
  45802. var xref = this.xref;
  45803. resources = xref.fetchIfRef(resources) || Dict.empty;
  45804. var xobjs = null;
  45805. var xobjsCache = Object.create(null);
  45806. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45807. var textState;
  45808. function ensureTextContentItem() {
  45809. if (textContentItem.initialized) {
  45810. return textContentItem;
  45811. }
  45812. var font = textState.font;
  45813. if (!(font.loadedName in textContent.styles)) {
  45814. textContent.styles[font.loadedName] = {
  45815. fontFamily: font.fallbackName,
  45816. ascent: font.ascent,
  45817. descent: font.descent,
  45818. vertical: font.vertical
  45819. };
  45820. }
  45821. textContentItem.fontName = font.loadedName;
  45822. var tsm = [
  45823. textState.fontSize * textState.textHScale,
  45824. 0,
  45825. 0,
  45826. textState.fontSize,
  45827. 0,
  45828. textState.textRise
  45829. ];
  45830. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  45831. var glyphHeight = font.bbox[3] - font.bbox[1];
  45832. if (glyphHeight > 0) {
  45833. glyphHeight = glyphHeight * textState.fontMatrix[3];
  45834. tsm[3] *= glyphHeight;
  45835. }
  45836. }
  45837. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  45838. textContentItem.transform = trm;
  45839. if (!font.vertical) {
  45840. textContentItem.width = 0;
  45841. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  45842. textContentItem.vertical = false;
  45843. } else {
  45844. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  45845. textContentItem.height = 0;
  45846. textContentItem.vertical = true;
  45847. }
  45848. var a = textState.textLineMatrix[0];
  45849. var b = textState.textLineMatrix[1];
  45850. var scaleLineX = Math.sqrt(a * a + b * b);
  45851. a = textState.ctm[0];
  45852. b = textState.ctm[1];
  45853. var scaleCtmX = Math.sqrt(a * a + b * b);
  45854. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  45855. textContentItem.lastAdvanceWidth = 0;
  45856. textContentItem.lastAdvanceHeight = 0;
  45857. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  45858. if (spaceWidth) {
  45859. textContentItem.spaceWidth = spaceWidth;
  45860. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  45861. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  45862. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  45863. textContentItem.textRunBreakAllowed = !font.isMonospace;
  45864. } else {
  45865. textContentItem.spaceWidth = 0;
  45866. textContentItem.fakeSpaceMin = Infinity;
  45867. textContentItem.fakeMultiSpaceMin = Infinity;
  45868. textContentItem.fakeMultiSpaceMax = 0;
  45869. textContentItem.textRunBreakAllowed = false;
  45870. }
  45871. textContentItem.initialized = true;
  45872. return textContentItem;
  45873. }
  45874. function replaceWhitespace(str) {
  45875. var i = 0, ii = str.length, code;
  45876. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  45877. i++;
  45878. }
  45879. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  45880. }
  45881. function runBidiTransform(textChunk) {
  45882. var str = textChunk.str.join('');
  45883. var bidiResult = bidi(str, -1, textChunk.vertical);
  45884. return {
  45885. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  45886. dir: bidiResult.dir,
  45887. width: textChunk.width,
  45888. height: textChunk.height,
  45889. transform: textChunk.transform,
  45890. fontName: textChunk.fontName
  45891. };
  45892. }
  45893. function handleSetFont(fontName, fontRef) {
  45894. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  45895. textState.font = translated.font;
  45896. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  45897. });
  45898. }
  45899. function buildTextContentItem(chars) {
  45900. var font = textState.font;
  45901. var textChunk = ensureTextContentItem();
  45902. var width = 0;
  45903. var height = 0;
  45904. var glyphs = font.charsToGlyphs(chars);
  45905. var defaultVMetrics = font.defaultVMetrics;
  45906. for (var i = 0; i < glyphs.length; i++) {
  45907. var glyph = glyphs[i];
  45908. var vMetricX = null;
  45909. var vMetricY = null;
  45910. var glyphWidth = null;
  45911. if (font.vertical) {
  45912. if (glyph.vmetric) {
  45913. glyphWidth = glyph.vmetric[0];
  45914. vMetricX = glyph.vmetric[1];
  45915. vMetricY = glyph.vmetric[2];
  45916. } else {
  45917. glyphWidth = glyph.width;
  45918. vMetricX = glyph.width * 0.5;
  45919. vMetricY = defaultVMetrics[2];
  45920. }
  45921. } else {
  45922. glyphWidth = glyph.width;
  45923. }
  45924. var glyphUnicode = glyph.unicode;
  45925. var NormalizedUnicodes = getNormalizedUnicodes();
  45926. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  45927. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  45928. }
  45929. glyphUnicode = reverseIfRtl(glyphUnicode);
  45930. var charSpacing = textState.charSpacing;
  45931. if (glyph.isSpace) {
  45932. var wordSpacing = textState.wordSpacing;
  45933. charSpacing += wordSpacing;
  45934. if (wordSpacing > 0) {
  45935. addFakeSpaces(wordSpacing, textChunk.str);
  45936. }
  45937. }
  45938. var tx = 0;
  45939. var ty = 0;
  45940. if (!font.vertical) {
  45941. var w0 = glyphWidth * textState.fontMatrix[0];
  45942. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  45943. width += tx;
  45944. } else {
  45945. var w1 = glyphWidth * textState.fontMatrix[0];
  45946. ty = w1 * textState.fontSize + charSpacing;
  45947. height += ty;
  45948. }
  45949. textState.translateTextMatrix(tx, ty);
  45950. textChunk.str.push(glyphUnicode);
  45951. }
  45952. if (!font.vertical) {
  45953. textChunk.lastAdvanceWidth = width;
  45954. textChunk.width += width * textChunk.textAdvanceScale;
  45955. } else {
  45956. textChunk.lastAdvanceHeight = height;
  45957. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  45958. }
  45959. return textChunk;
  45960. }
  45961. function addFakeSpaces(width, strBuf) {
  45962. if (width < textContentItem.fakeSpaceMin) {
  45963. return;
  45964. }
  45965. if (width < textContentItem.fakeMultiSpaceMin) {
  45966. strBuf.push(' ');
  45967. return;
  45968. }
  45969. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  45970. while (fakeSpaces-- > 0) {
  45971. strBuf.push(' ');
  45972. }
  45973. }
  45974. function flushTextContentItem() {
  45975. if (!textContentItem.initialized) {
  45976. return;
  45977. }
  45978. textContent.items.push(runBidiTransform(textContentItem));
  45979. textContentItem.initialized = false;
  45980. textContentItem.str.length = 0;
  45981. }
  45982. var timeSlotManager = new TimeSlotManager();
  45983. return new Promise(function promiseBody(resolve, reject) {
  45984. var next = function (promise) {
  45985. promise.then(function () {
  45986. try {
  45987. promiseBody(resolve, reject);
  45988. } catch (ex) {
  45989. reject(ex);
  45990. }
  45991. }, reject);
  45992. };
  45993. task.ensureNotTerminated();
  45994. timeSlotManager.reset();
  45995. var stop, operation = {}, args = [];
  45996. while (!(stop = timeSlotManager.check())) {
  45997. args.length = 0;
  45998. operation.args = args;
  45999. if (!preprocessor.read(operation)) {
  46000. break;
  46001. }
  46002. textState = stateManager.state;
  46003. var fn = operation.fn;
  46004. args = operation.args;
  46005. var advance, diff;
  46006. switch (fn | 0) {
  46007. case OPS.setFont:
  46008. var fontNameArg = args[0].name, fontSizeArg = args[1];
  46009. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  46010. break;
  46011. }
  46012. flushTextContentItem();
  46013. textState.fontName = fontNameArg;
  46014. textState.fontSize = fontSizeArg;
  46015. next(handleSetFont(fontNameArg, null));
  46016. return;
  46017. case OPS.setTextRise:
  46018. flushTextContentItem();
  46019. textState.textRise = args[0];
  46020. break;
  46021. case OPS.setHScale:
  46022. flushTextContentItem();
  46023. textState.textHScale = args[0] / 100;
  46024. break;
  46025. case OPS.setLeading:
  46026. flushTextContentItem();
  46027. textState.leading = args[0];
  46028. break;
  46029. case OPS.moveText:
  46030. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  46031. advance = args[0] - args[1];
  46032. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  46033. textState.translateTextLineMatrix(args[0], args[1]);
  46034. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  46035. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  46036. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  46037. addFakeSpaces(diff, textContentItem.str);
  46038. break;
  46039. }
  46040. flushTextContentItem();
  46041. textState.translateTextLineMatrix(args[0], args[1]);
  46042. textState.textMatrix = textState.textLineMatrix.slice();
  46043. break;
  46044. case OPS.setLeadingMoveText:
  46045. flushTextContentItem();
  46046. textState.leading = -args[1];
  46047. textState.translateTextLineMatrix(args[0], args[1]);
  46048. textState.textMatrix = textState.textLineMatrix.slice();
  46049. break;
  46050. case OPS.nextLine:
  46051. flushTextContentItem();
  46052. textState.carriageReturn();
  46053. break;
  46054. case OPS.setTextMatrix:
  46055. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  46056. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  46057. textState.translateTextLineMatrix(advance.width, advance.height);
  46058. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  46059. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  46060. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  46061. addFakeSpaces(diff, textContentItem.str);
  46062. break;
  46063. }
  46064. flushTextContentItem();
  46065. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46066. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46067. break;
  46068. case OPS.setCharSpacing:
  46069. textState.charSpacing = args[0];
  46070. break;
  46071. case OPS.setWordSpacing:
  46072. textState.wordSpacing = args[0];
  46073. break;
  46074. case OPS.beginText:
  46075. flushTextContentItem();
  46076. textState.textMatrix = IDENTITY_MATRIX.slice();
  46077. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  46078. break;
  46079. case OPS.showSpacedText:
  46080. var items = args[0];
  46081. var offset;
  46082. for (var j = 0, jj = items.length; j < jj; j++) {
  46083. if (typeof items[j] === 'string') {
  46084. buildTextContentItem(items[j]);
  46085. } else if (isNum(items[j])) {
  46086. ensureTextContentItem();
  46087. advance = items[j] * textState.fontSize / 1000;
  46088. var breakTextRun = false;
  46089. if (textState.font.vertical) {
  46090. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  46091. textState.translateTextMatrix(0, advance);
  46092. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46093. if (!breakTextRun) {
  46094. textContentItem.height += offset;
  46095. }
  46096. } else {
  46097. advance = -advance;
  46098. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  46099. textState.translateTextMatrix(advance, 0);
  46100. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46101. if (!breakTextRun) {
  46102. textContentItem.width += offset;
  46103. }
  46104. }
  46105. if (breakTextRun) {
  46106. flushTextContentItem();
  46107. } else if (advance > 0) {
  46108. addFakeSpaces(advance, textContentItem.str);
  46109. }
  46110. }
  46111. }
  46112. break;
  46113. case OPS.showText:
  46114. buildTextContentItem(args[0]);
  46115. break;
  46116. case OPS.nextLineShowText:
  46117. flushTextContentItem();
  46118. textState.carriageReturn();
  46119. buildTextContentItem(args[0]);
  46120. break;
  46121. case OPS.nextLineSetSpacingShowText:
  46122. flushTextContentItem();
  46123. textState.wordSpacing = args[0];
  46124. textState.charSpacing = args[1];
  46125. textState.carriageReturn();
  46126. buildTextContentItem(args[2]);
  46127. break;
  46128. case OPS.paintXObject:
  46129. flushTextContentItem();
  46130. if (args[0].code) {
  46131. break;
  46132. }
  46133. if (!xobjs) {
  46134. xobjs = resources.get('XObject') || Dict.empty;
  46135. }
  46136. var name = args[0].name;
  46137. if (xobjsCache.key === name) {
  46138. if (xobjsCache.texts) {
  46139. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  46140. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  46141. }
  46142. break;
  46143. }
  46144. var xobj = xobjs.get(name);
  46145. if (!xobj) {
  46146. break;
  46147. }
  46148. assert(isStream(xobj), 'XObject should be a stream');
  46149. var type = xobj.dict.get('Subtype');
  46150. assert(isName(type), 'XObject should have a Name subtype');
  46151. if ('Form' !== type.name) {
  46152. xobjsCache.key = name;
  46153. xobjsCache.texts = null;
  46154. break;
  46155. }
  46156. stateManager.save();
  46157. var matrix = xobj.dict.getArray('Matrix');
  46158. if (isArray(matrix) && matrix.length === 6) {
  46159. stateManager.transform(matrix);
  46160. }
  46161. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  46162. Util.appendToArray(textContent.items, formTextContent.items);
  46163. Util.extendObj(textContent.styles, formTextContent.styles);
  46164. stateManager.restore();
  46165. xobjsCache.key = name;
  46166. xobjsCache.texts = formTextContent;
  46167. }));
  46168. return;
  46169. case OPS.setGState:
  46170. flushTextContentItem();
  46171. var dictName = args[0];
  46172. var extGState = resources.get('ExtGState');
  46173. if (!isDict(extGState) || !isName(dictName)) {
  46174. break;
  46175. }
  46176. var gState = extGState.get(dictName.name);
  46177. if (!isDict(gState)) {
  46178. break;
  46179. }
  46180. var gStateFont = gState.get('Font');
  46181. if (gStateFont) {
  46182. textState.fontName = null;
  46183. textState.fontSize = gStateFont[1];
  46184. next(handleSetFont(null, gStateFont[0]));
  46185. return;
  46186. }
  46187. break;
  46188. }
  46189. }
  46190. if (stop) {
  46191. next(deferred);
  46192. return;
  46193. }
  46194. flushTextContentItem();
  46195. resolve(textContent);
  46196. });
  46197. },
  46198. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  46199. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46200. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  46201. if (properties.composite) {
  46202. var cidSystemInfo = dict.get('CIDSystemInfo');
  46203. if (isDict(cidSystemInfo)) {
  46204. properties.cidSystemInfo = {
  46205. registry: cidSystemInfo.get('Registry'),
  46206. ordering: cidSystemInfo.get('Ordering'),
  46207. supplement: cidSystemInfo.get('Supplement')
  46208. };
  46209. }
  46210. var cidToGidMap = dict.get('CIDToGIDMap');
  46211. if (isStream(cidToGidMap)) {
  46212. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  46213. }
  46214. }
  46215. var differences = [];
  46216. var baseEncodingName = null;
  46217. var encoding;
  46218. if (dict.has('Encoding')) {
  46219. encoding = dict.get('Encoding');
  46220. if (isDict(encoding)) {
  46221. baseEncodingName = encoding.get('BaseEncoding');
  46222. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  46223. if (encoding.has('Differences')) {
  46224. var diffEncoding = encoding.get('Differences');
  46225. var index = 0;
  46226. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  46227. var data = xref.fetchIfRef(diffEncoding[j]);
  46228. if (isNum(data)) {
  46229. index = data;
  46230. } else if (isName(data)) {
  46231. differences[index++] = data.name;
  46232. } else {
  46233. error('Invalid entry in \'Differences\' array: ' + data);
  46234. }
  46235. }
  46236. }
  46237. } else if (isName(encoding)) {
  46238. baseEncodingName = encoding.name;
  46239. } else {
  46240. error('Encoding is not a Name nor a Dict');
  46241. }
  46242. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  46243. baseEncodingName = null;
  46244. }
  46245. }
  46246. if (baseEncodingName) {
  46247. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  46248. } else {
  46249. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46250. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  46251. encoding = StandardEncoding;
  46252. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  46253. encoding = WinAnsiEncoding;
  46254. }
  46255. if (isSymbolicFont) {
  46256. encoding = MacRomanEncoding;
  46257. if (!properties.file) {
  46258. if (/Symbol/i.test(properties.name)) {
  46259. encoding = SymbolSetEncoding;
  46260. } else if (/Dingbats/i.test(properties.name)) {
  46261. encoding = ZapfDingbatsEncoding;
  46262. }
  46263. }
  46264. }
  46265. properties.defaultEncoding = encoding;
  46266. }
  46267. properties.differences = differences;
  46268. properties.baseEncodingName = baseEncodingName;
  46269. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  46270. properties.dict = dict;
  46271. return toUnicodePromise.then(function (toUnicode) {
  46272. properties.toUnicode = toUnicode;
  46273. return this.buildToUnicode(properties);
  46274. }.bind(this)).then(function (toUnicode) {
  46275. properties.toUnicode = toUnicode;
  46276. return properties;
  46277. });
  46278. },
  46279. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  46280. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  46281. if (properties.hasIncludedToUnicodeMap) {
  46282. return Promise.resolve(properties.toUnicode);
  46283. }
  46284. var toUnicode, charcode, glyphName;
  46285. if (!properties.composite)
  46286. {
  46287. toUnicode = [];
  46288. var encoding = properties.defaultEncoding.slice();
  46289. var baseEncodingName = properties.baseEncodingName;
  46290. var differences = properties.differences;
  46291. for (charcode in differences) {
  46292. glyphName = differences[charcode];
  46293. if (glyphName === '.notdef') {
  46294. continue;
  46295. }
  46296. encoding[charcode] = glyphName;
  46297. }
  46298. var glyphsUnicodeMap = getGlyphsUnicode();
  46299. for (charcode in encoding) {
  46300. glyphName = encoding[charcode];
  46301. if (glyphName === '') {
  46302. continue;
  46303. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  46304. var code = 0;
  46305. switch (glyphName[0]) {
  46306. case 'G':
  46307. if (glyphName.length === 3) {
  46308. code = parseInt(glyphName.substr(1), 16);
  46309. }
  46310. break;
  46311. case 'g':
  46312. if (glyphName.length === 5) {
  46313. code = parseInt(glyphName.substr(1), 16);
  46314. }
  46315. break;
  46316. case 'C':
  46317. case 'c':
  46318. if (glyphName.length >= 3) {
  46319. code = +glyphName.substr(1);
  46320. }
  46321. break;
  46322. default:
  46323. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  46324. if (unicode !== -1) {
  46325. code = unicode;
  46326. }
  46327. }
  46328. if (code) {
  46329. if (baseEncodingName && code === +charcode) {
  46330. var baseEncoding = getEncoding(baseEncodingName);
  46331. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  46332. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46333. continue;
  46334. }
  46335. }
  46336. toUnicode[charcode] = String.fromCharCode(code);
  46337. }
  46338. continue;
  46339. }
  46340. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46341. }
  46342. return Promise.resolve(new ToUnicodeMap(toUnicode));
  46343. }
  46344. 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'))) {
  46345. var registry = properties.cidSystemInfo.registry;
  46346. var ordering = properties.cidSystemInfo.ordering;
  46347. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  46348. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  46349. var cMap = properties.cMap;
  46350. toUnicode = [];
  46351. cMap.forEach(function (charcode, cid) {
  46352. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  46353. var ucs2 = ucs2CMap.lookup(cid);
  46354. if (ucs2) {
  46355. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  46356. }
  46357. });
  46358. return new ToUnicodeMap(toUnicode);
  46359. });
  46360. }
  46361. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  46362. },
  46363. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  46364. var cmapObj = toUnicode;
  46365. if (isName(cmapObj)) {
  46366. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46367. if (cmap instanceof IdentityCMap) {
  46368. return new IdentityToUnicodeMap(0, 0xFFFF);
  46369. }
  46370. return new ToUnicodeMap(cmap.getMap());
  46371. });
  46372. } else if (isStream(cmapObj)) {
  46373. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46374. if (cmap instanceof IdentityCMap) {
  46375. return new IdentityToUnicodeMap(0, 0xFFFF);
  46376. }
  46377. var map = new Array(cmap.length);
  46378. cmap.forEach(function (charCode, token) {
  46379. var str = [];
  46380. for (var k = 0; k < token.length; k += 2) {
  46381. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46382. if ((w1 & 0xF800) !== 0xD800) {
  46383. str.push(w1);
  46384. continue;
  46385. }
  46386. k += 2;
  46387. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46388. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  46389. }
  46390. map[charCode] = String.fromCharCode.apply(String, str);
  46391. });
  46392. return new ToUnicodeMap(map);
  46393. });
  46394. }
  46395. return Promise.resolve(null);
  46396. },
  46397. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  46398. var glyphsData = cidToGidStream.getBytes();
  46399. var result = [];
  46400. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  46401. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  46402. if (glyphID === 0) {
  46403. continue;
  46404. }
  46405. var code = j >> 1;
  46406. result[code] = glyphID;
  46407. }
  46408. return result;
  46409. },
  46410. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  46411. var glyphsWidths = [];
  46412. var defaultWidth = 0;
  46413. var glyphsVMetrics = [];
  46414. var defaultVMetrics;
  46415. var i, ii, j, jj, start, code, widths;
  46416. if (properties.composite) {
  46417. defaultWidth = dict.get('DW') || 1000;
  46418. widths = dict.get('W');
  46419. if (widths) {
  46420. for (i = 0, ii = widths.length; i < ii; i++) {
  46421. start = xref.fetchIfRef(widths[i++]);
  46422. code = xref.fetchIfRef(widths[i]);
  46423. if (isArray(code)) {
  46424. for (j = 0, jj = code.length; j < jj; j++) {
  46425. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  46426. }
  46427. } else {
  46428. var width = xref.fetchIfRef(widths[++i]);
  46429. for (j = start; j <= code; j++) {
  46430. glyphsWidths[j] = width;
  46431. }
  46432. }
  46433. }
  46434. }
  46435. if (properties.vertical) {
  46436. var vmetrics = dict.getArray('DW2') || [
  46437. 880,
  46438. -1000
  46439. ];
  46440. defaultVMetrics = [
  46441. vmetrics[1],
  46442. defaultWidth * 0.5,
  46443. vmetrics[0]
  46444. ];
  46445. vmetrics = dict.get('W2');
  46446. if (vmetrics) {
  46447. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  46448. start = xref.fetchIfRef(vmetrics[i++]);
  46449. code = xref.fetchIfRef(vmetrics[i]);
  46450. if (isArray(code)) {
  46451. for (j = 0, jj = code.length; j < jj; j++) {
  46452. glyphsVMetrics[start++] = [
  46453. xref.fetchIfRef(code[j++]),
  46454. xref.fetchIfRef(code[j++]),
  46455. xref.fetchIfRef(code[j])
  46456. ];
  46457. }
  46458. } else {
  46459. var vmetric = [
  46460. xref.fetchIfRef(vmetrics[++i]),
  46461. xref.fetchIfRef(vmetrics[++i]),
  46462. xref.fetchIfRef(vmetrics[++i])
  46463. ];
  46464. for (j = start; j <= code; j++) {
  46465. glyphsVMetrics[j] = vmetric;
  46466. }
  46467. }
  46468. }
  46469. }
  46470. }
  46471. } else {
  46472. var firstChar = properties.firstChar;
  46473. widths = dict.get('Widths');
  46474. if (widths) {
  46475. j = firstChar;
  46476. for (i = 0, ii = widths.length; i < ii; i++) {
  46477. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  46478. }
  46479. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  46480. } else {
  46481. var baseFontName = dict.get('BaseFont');
  46482. if (isName(baseFontName)) {
  46483. var metrics = this.getBaseFontMetrics(baseFontName.name);
  46484. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  46485. defaultWidth = metrics.defaultWidth;
  46486. }
  46487. }
  46488. }
  46489. var isMonospace = true;
  46490. var firstWidth = defaultWidth;
  46491. for (var glyph in glyphsWidths) {
  46492. var glyphWidth = glyphsWidths[glyph];
  46493. if (!glyphWidth) {
  46494. continue;
  46495. }
  46496. if (!firstWidth) {
  46497. firstWidth = glyphWidth;
  46498. continue;
  46499. }
  46500. if (firstWidth !== glyphWidth) {
  46501. isMonospace = false;
  46502. break;
  46503. }
  46504. }
  46505. if (isMonospace) {
  46506. properties.flags |= FontFlags.FixedPitch;
  46507. }
  46508. properties.defaultWidth = defaultWidth;
  46509. properties.widths = glyphsWidths;
  46510. properties.defaultVMetrics = defaultVMetrics;
  46511. properties.vmetrics = glyphsVMetrics;
  46512. },
  46513. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  46514. var fontNameWoStyle = baseFontName.split('-')[0];
  46515. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  46516. },
  46517. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  46518. var defaultWidth = 0;
  46519. var widths = [];
  46520. var monospace = false;
  46521. var stdFontMap = getStdFontMap();
  46522. var lookupName = stdFontMap[name] || name;
  46523. var Metrics = getMetrics();
  46524. if (!(lookupName in Metrics)) {
  46525. if (this.isSerifFont(name)) {
  46526. lookupName = 'Times-Roman';
  46527. } else {
  46528. lookupName = 'Helvetica';
  46529. }
  46530. }
  46531. var glyphWidths = Metrics[lookupName];
  46532. if (isNum(glyphWidths)) {
  46533. defaultWidth = glyphWidths;
  46534. monospace = true;
  46535. } else {
  46536. widths = glyphWidths();
  46537. }
  46538. return {
  46539. defaultWidth: defaultWidth,
  46540. monospace: monospace,
  46541. widths: widths
  46542. };
  46543. },
  46544. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  46545. var widths = Object.create(null);
  46546. var differences = properties.differences;
  46547. var encoding = properties.defaultEncoding;
  46548. for (var charCode = 0; charCode < 256; charCode++) {
  46549. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  46550. widths[charCode] = widthsByGlyphName[differences[charCode]];
  46551. continue;
  46552. }
  46553. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  46554. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  46555. continue;
  46556. }
  46557. }
  46558. return widths;
  46559. },
  46560. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  46561. var baseDict = dict;
  46562. var type = dict.get('Subtype');
  46563. assert(isName(type), 'invalid font Subtype');
  46564. var composite = false;
  46565. var uint8array;
  46566. if (type.name === 'Type0') {
  46567. var df = dict.get('DescendantFonts');
  46568. if (!df) {
  46569. error('Descendant fonts are not specified');
  46570. }
  46571. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  46572. type = dict.get('Subtype');
  46573. assert(isName(type), 'invalid font Subtype');
  46574. composite = true;
  46575. }
  46576. var descriptor = dict.get('FontDescriptor');
  46577. if (descriptor) {
  46578. var hash = new MurmurHash3_64();
  46579. var encoding = baseDict.getRaw('Encoding');
  46580. if (isName(encoding)) {
  46581. hash.update(encoding.name);
  46582. } else if (isRef(encoding)) {
  46583. hash.update(encoding.toString());
  46584. } else if (isDict(encoding)) {
  46585. var keys = encoding.getKeys();
  46586. for (var i = 0, ii = keys.length; i < ii; i++) {
  46587. var entry = encoding.getRaw(keys[i]);
  46588. if (isName(entry)) {
  46589. hash.update(entry.name);
  46590. } else if (isRef(entry)) {
  46591. hash.update(entry.toString());
  46592. } else if (isArray(entry)) {
  46593. hash.update(entry.length.toString());
  46594. }
  46595. }
  46596. }
  46597. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46598. if (isStream(toUnicode)) {
  46599. var stream = toUnicode.str || toUnicode;
  46600. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  46601. hash.update(uint8array);
  46602. } else if (isName(toUnicode)) {
  46603. hash.update(toUnicode.name);
  46604. }
  46605. var widths = dict.get('Widths') || baseDict.get('Widths');
  46606. if (widths) {
  46607. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  46608. hash.update(uint8array);
  46609. }
  46610. }
  46611. return {
  46612. descriptor: descriptor,
  46613. dict: dict,
  46614. baseDict: baseDict,
  46615. composite: composite,
  46616. type: type.name,
  46617. hash: hash ? hash.hexdigest() : ''
  46618. };
  46619. },
  46620. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  46621. var baseDict = preEvaluatedFont.baseDict;
  46622. var dict = preEvaluatedFont.dict;
  46623. var composite = preEvaluatedFont.composite;
  46624. var descriptor = preEvaluatedFont.descriptor;
  46625. var type = preEvaluatedFont.type;
  46626. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  46627. var cMapOptions = this.options.cMapOptions;
  46628. var properties;
  46629. if (!descriptor) {
  46630. if (type === 'Type3') {
  46631. descriptor = new Dict(null);
  46632. descriptor.set('FontName', Name.get(type));
  46633. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  46634. } else {
  46635. var baseFontName = dict.get('BaseFont');
  46636. if (!isName(baseFontName)) {
  46637. error('Base font is not specified');
  46638. }
  46639. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  46640. var metrics = this.getBaseFontMetrics(baseFontName);
  46641. var fontNameWoStyle = baseFontName.split('-')[0];
  46642. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  46643. properties = {
  46644. type: type,
  46645. name: baseFontName,
  46646. widths: metrics.widths,
  46647. defaultWidth: metrics.defaultWidth,
  46648. flags: flags,
  46649. firstChar: 0,
  46650. lastChar: maxCharIndex
  46651. };
  46652. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  46653. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  46654. return new Font(baseFontName, null, properties);
  46655. }.bind(this));
  46656. }
  46657. }
  46658. var firstChar = dict.get('FirstChar') || 0;
  46659. var lastChar = dict.get('LastChar') || maxCharIndex;
  46660. var fontName = descriptor.get('FontName');
  46661. var baseFont = dict.get('BaseFont');
  46662. if (isString(fontName)) {
  46663. fontName = Name.get(fontName);
  46664. }
  46665. if (isString(baseFont)) {
  46666. baseFont = Name.get(baseFont);
  46667. }
  46668. if (type !== 'Type3') {
  46669. var fontNameStr = fontName && fontName.name;
  46670. var baseFontStr = baseFont && baseFont.name;
  46671. if (fontNameStr !== baseFontStr) {
  46672. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  46673. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  46674. fontName = baseFont;
  46675. }
  46676. }
  46677. }
  46678. fontName = fontName || baseFont;
  46679. assert(isName(fontName), 'invalid font name');
  46680. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  46681. if (fontFile) {
  46682. if (fontFile.dict) {
  46683. var subtype = fontFile.dict.get('Subtype');
  46684. if (subtype) {
  46685. subtype = subtype.name;
  46686. }
  46687. var length1 = fontFile.dict.get('Length1');
  46688. var length2 = fontFile.dict.get('Length2');
  46689. var length3 = fontFile.dict.get('Length3');
  46690. }
  46691. }
  46692. properties = {
  46693. type: type,
  46694. name: fontName.name,
  46695. subtype: subtype,
  46696. file: fontFile,
  46697. length1: length1,
  46698. length2: length2,
  46699. length3: length3,
  46700. loadedName: baseDict.loadedName,
  46701. composite: composite,
  46702. wideChars: composite,
  46703. fixedPitch: false,
  46704. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  46705. firstChar: firstChar || 0,
  46706. lastChar: lastChar || maxCharIndex,
  46707. bbox: descriptor.getArray('FontBBox'),
  46708. ascent: descriptor.get('Ascent'),
  46709. descent: descriptor.get('Descent'),
  46710. xHeight: descriptor.get('XHeight'),
  46711. capHeight: descriptor.get('CapHeight'),
  46712. flags: descriptor.get('Flags'),
  46713. italicAngle: descriptor.get('ItalicAngle'),
  46714. coded: false
  46715. };
  46716. var cMapPromise;
  46717. if (composite) {
  46718. var cidEncoding = baseDict.get('Encoding');
  46719. if (isName(cidEncoding)) {
  46720. properties.cidEncoding = cidEncoding.name;
  46721. }
  46722. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  46723. properties.cMap = cMap;
  46724. properties.vertical = properties.cMap.vertical;
  46725. });
  46726. } else {
  46727. cMapPromise = Promise.resolve(undefined);
  46728. }
  46729. return cMapPromise.then(function () {
  46730. return this.extractDataStructures(dict, baseDict, xref, properties);
  46731. }.bind(this)).then(function (properties) {
  46732. this.extractWidths(dict, xref, descriptor, properties);
  46733. if (type === 'Type3') {
  46734. properties.isType3Font = true;
  46735. }
  46736. return new Font(fontName.name, fontFile, properties);
  46737. }.bind(this));
  46738. }
  46739. };
  46740. return PartialEvaluator;
  46741. }();
  46742. var TranslatedFont = function TranslatedFontClosure() {
  46743. function TranslatedFont(loadedName, font, dict) {
  46744. this.loadedName = loadedName;
  46745. this.font = font;
  46746. this.dict = dict;
  46747. this.type3Loaded = null;
  46748. this.sent = false;
  46749. }
  46750. TranslatedFont.prototype = {
  46751. send: function (handler) {
  46752. if (this.sent) {
  46753. return;
  46754. }
  46755. var fontData = this.font.exportData();
  46756. handler.send('commonobj', [
  46757. this.loadedName,
  46758. 'Font',
  46759. fontData
  46760. ]);
  46761. this.sent = true;
  46762. },
  46763. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  46764. assert(this.font.isType3Font);
  46765. if (this.type3Loaded) {
  46766. return this.type3Loaded;
  46767. }
  46768. var translatedFont = this.font;
  46769. var loadCharProcsPromise = Promise.resolve();
  46770. var charProcs = this.dict.get('CharProcs');
  46771. var fontResources = this.dict.get('Resources') || resources;
  46772. var charProcKeys = charProcs.getKeys();
  46773. var charProcOperatorList = Object.create(null);
  46774. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  46775. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  46776. var glyphStream = charProcs.get(key);
  46777. var operatorList = new OperatorList();
  46778. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  46779. charProcOperatorList[key] = operatorList.getIR();
  46780. parentOperatorList.addDependencies(operatorList.dependencies);
  46781. }, function (reason) {
  46782. warn('Type3 font resource \"' + key + '\" is not available');
  46783. var operatorList = new OperatorList();
  46784. charProcOperatorList[key] = operatorList.getIR();
  46785. });
  46786. }.bind(this, charProcKeys[i]));
  46787. }
  46788. this.type3Loaded = loadCharProcsPromise.then(function () {
  46789. translatedFont.charProcOperatorList = charProcOperatorList;
  46790. });
  46791. return this.type3Loaded;
  46792. }
  46793. };
  46794. return TranslatedFont;
  46795. }();
  46796. var OperatorList = function OperatorListClosure() {
  46797. var CHUNK_SIZE = 1000;
  46798. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  46799. function getTransfers(queue) {
  46800. var transfers = [];
  46801. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  46802. for (var i = 0, ii = queue.length; i < ii; i++) {
  46803. switch (fnArray[i]) {
  46804. case OPS.paintInlineImageXObject:
  46805. case OPS.paintInlineImageXObjectGroup:
  46806. case OPS.paintImageMaskXObject:
  46807. var arg = argsArray[i][0];
  46808. if (!arg.cached) {
  46809. transfers.push(arg.data.buffer);
  46810. }
  46811. break;
  46812. }
  46813. }
  46814. return transfers;
  46815. }
  46816. function OperatorList(intent, messageHandler, pageIndex) {
  46817. this.messageHandler = messageHandler;
  46818. this.fnArray = [];
  46819. this.argsArray = [];
  46820. this.dependencies = Object.create(null);
  46821. this._totalLength = 0;
  46822. this.pageIndex = pageIndex;
  46823. this.intent = intent;
  46824. }
  46825. OperatorList.prototype = {
  46826. get length() {
  46827. return this.argsArray.length;
  46828. },
  46829. get totalLength() {
  46830. return this._totalLength + this.length;
  46831. },
  46832. addOp: function (fn, args) {
  46833. this.fnArray.push(fn);
  46834. this.argsArray.push(args);
  46835. if (this.messageHandler) {
  46836. if (this.fnArray.length >= CHUNK_SIZE) {
  46837. this.flush();
  46838. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  46839. this.flush();
  46840. }
  46841. }
  46842. },
  46843. addDependency: function (dependency) {
  46844. if (dependency in this.dependencies) {
  46845. return;
  46846. }
  46847. this.dependencies[dependency] = true;
  46848. this.addOp(OPS.dependency, [dependency]);
  46849. },
  46850. addDependencies: function (dependencies) {
  46851. for (var key in dependencies) {
  46852. this.addDependency(key);
  46853. }
  46854. },
  46855. addOpList: function (opList) {
  46856. Util.extendObj(this.dependencies, opList.dependencies);
  46857. for (var i = 0, ii = opList.length; i < ii; i++) {
  46858. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  46859. }
  46860. },
  46861. getIR: function () {
  46862. return {
  46863. fnArray: this.fnArray,
  46864. argsArray: this.argsArray,
  46865. length: this.length
  46866. };
  46867. },
  46868. flush: function (lastChunk) {
  46869. if (this.intent !== 'oplist') {
  46870. new QueueOptimizer().optimize(this);
  46871. }
  46872. var transfers = getTransfers(this);
  46873. var length = this.length;
  46874. this._totalLength += length;
  46875. this.messageHandler.send('RenderPageChunk', {
  46876. operatorList: {
  46877. fnArray: this.fnArray,
  46878. argsArray: this.argsArray,
  46879. lastChunk: lastChunk,
  46880. length: length
  46881. },
  46882. pageIndex: this.pageIndex,
  46883. intent: this.intent
  46884. }, transfers);
  46885. this.dependencies = Object.create(null);
  46886. this.fnArray.length = 0;
  46887. this.argsArray.length = 0;
  46888. }
  46889. };
  46890. return OperatorList;
  46891. }();
  46892. var StateManager = function StateManagerClosure() {
  46893. function StateManager(initialState) {
  46894. this.state = initialState;
  46895. this.stateStack = [];
  46896. }
  46897. StateManager.prototype = {
  46898. save: function () {
  46899. var old = this.state;
  46900. this.stateStack.push(this.state);
  46901. this.state = old.clone();
  46902. },
  46903. restore: function () {
  46904. var prev = this.stateStack.pop();
  46905. if (prev) {
  46906. this.state = prev;
  46907. }
  46908. },
  46909. transform: function (args) {
  46910. this.state.ctm = Util.transform(this.state.ctm, args);
  46911. }
  46912. };
  46913. return StateManager;
  46914. }();
  46915. var TextState = function TextStateClosure() {
  46916. function TextState() {
  46917. this.ctm = new Float32Array(IDENTITY_MATRIX);
  46918. this.fontName = null;
  46919. this.fontSize = 0;
  46920. this.font = null;
  46921. this.fontMatrix = FONT_IDENTITY_MATRIX;
  46922. this.textMatrix = IDENTITY_MATRIX.slice();
  46923. this.textLineMatrix = IDENTITY_MATRIX.slice();
  46924. this.charSpacing = 0;
  46925. this.wordSpacing = 0;
  46926. this.leading = 0;
  46927. this.textHScale = 1;
  46928. this.textRise = 0;
  46929. }
  46930. TextState.prototype = {
  46931. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  46932. var m = this.textMatrix;
  46933. m[0] = a;
  46934. m[1] = b;
  46935. m[2] = c;
  46936. m[3] = d;
  46937. m[4] = e;
  46938. m[5] = f;
  46939. },
  46940. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  46941. var m = this.textLineMatrix;
  46942. m[0] = a;
  46943. m[1] = b;
  46944. m[2] = c;
  46945. m[3] = d;
  46946. m[4] = e;
  46947. m[5] = f;
  46948. },
  46949. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  46950. var m = this.textMatrix;
  46951. m[4] = m[0] * x + m[2] * y + m[4];
  46952. m[5] = m[1] * x + m[3] * y + m[5];
  46953. },
  46954. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  46955. var m = this.textLineMatrix;
  46956. m[4] = m[0] * x + m[2] * y + m[4];
  46957. m[5] = m[1] * x + m[3] * y + m[5];
  46958. },
  46959. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  46960. var font = this.font;
  46961. if (!font) {
  46962. return null;
  46963. }
  46964. var m = this.textLineMatrix;
  46965. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  46966. return null;
  46967. }
  46968. var txDiff = e - m[4], tyDiff = f - m[5];
  46969. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  46970. return null;
  46971. }
  46972. var tx, ty, denominator = a * d - b * c;
  46973. if (font.vertical) {
  46974. tx = -tyDiff * c / denominator;
  46975. ty = tyDiff * a / denominator;
  46976. } else {
  46977. tx = txDiff * d / denominator;
  46978. ty = -txDiff * b / denominator;
  46979. }
  46980. return {
  46981. width: tx,
  46982. height: ty,
  46983. value: font.vertical ? ty : tx
  46984. };
  46985. },
  46986. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  46987. var tsm = [
  46988. this.fontSize * this.textHScale,
  46989. 0,
  46990. 0,
  46991. this.fontSize,
  46992. 0,
  46993. this.textRise
  46994. ];
  46995. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  46996. },
  46997. carriageReturn: function TextState_carriageReturn() {
  46998. this.translateTextLineMatrix(0, -this.leading);
  46999. this.textMatrix = this.textLineMatrix.slice();
  47000. },
  47001. clone: function TextState_clone() {
  47002. var clone = Object.create(this);
  47003. clone.textMatrix = this.textMatrix.slice();
  47004. clone.textLineMatrix = this.textLineMatrix.slice();
  47005. clone.fontMatrix = this.fontMatrix.slice();
  47006. return clone;
  47007. }
  47008. };
  47009. return TextState;
  47010. }();
  47011. var EvalState = function EvalStateClosure() {
  47012. function EvalState() {
  47013. this.ctm = new Float32Array(IDENTITY_MATRIX);
  47014. this.font = null;
  47015. this.textRenderingMode = TextRenderingMode.FILL;
  47016. this.fillColorSpace = ColorSpace.singletons.gray;
  47017. this.strokeColorSpace = ColorSpace.singletons.gray;
  47018. }
  47019. EvalState.prototype = {
  47020. clone: function CanvasExtraState_clone() {
  47021. return Object.create(this);
  47022. }
  47023. };
  47024. return EvalState;
  47025. }();
  47026. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  47027. var getOPMap = getLookupTableFactory(function (t) {
  47028. t['w'] = {
  47029. id: OPS.setLineWidth,
  47030. numArgs: 1,
  47031. variableArgs: false
  47032. };
  47033. t['J'] = {
  47034. id: OPS.setLineCap,
  47035. numArgs: 1,
  47036. variableArgs: false
  47037. };
  47038. t['j'] = {
  47039. id: OPS.setLineJoin,
  47040. numArgs: 1,
  47041. variableArgs: false
  47042. };
  47043. t['M'] = {
  47044. id: OPS.setMiterLimit,
  47045. numArgs: 1,
  47046. variableArgs: false
  47047. };
  47048. t['d'] = {
  47049. id: OPS.setDash,
  47050. numArgs: 2,
  47051. variableArgs: false
  47052. };
  47053. t['ri'] = {
  47054. id: OPS.setRenderingIntent,
  47055. numArgs: 1,
  47056. variableArgs: false
  47057. };
  47058. t['i'] = {
  47059. id: OPS.setFlatness,
  47060. numArgs: 1,
  47061. variableArgs: false
  47062. };
  47063. t['gs'] = {
  47064. id: OPS.setGState,
  47065. numArgs: 1,
  47066. variableArgs: false
  47067. };
  47068. t['q'] = {
  47069. id: OPS.save,
  47070. numArgs: 0,
  47071. variableArgs: false
  47072. };
  47073. t['Q'] = {
  47074. id: OPS.restore,
  47075. numArgs: 0,
  47076. variableArgs: false
  47077. };
  47078. t['cm'] = {
  47079. id: OPS.transform,
  47080. numArgs: 6,
  47081. variableArgs: false
  47082. };
  47083. t['m'] = {
  47084. id: OPS.moveTo,
  47085. numArgs: 2,
  47086. variableArgs: false
  47087. };
  47088. t['l'] = {
  47089. id: OPS.lineTo,
  47090. numArgs: 2,
  47091. variableArgs: false
  47092. };
  47093. t['c'] = {
  47094. id: OPS.curveTo,
  47095. numArgs: 6,
  47096. variableArgs: false
  47097. };
  47098. t['v'] = {
  47099. id: OPS.curveTo2,
  47100. numArgs: 4,
  47101. variableArgs: false
  47102. };
  47103. t['y'] = {
  47104. id: OPS.curveTo3,
  47105. numArgs: 4,
  47106. variableArgs: false
  47107. };
  47108. t['h'] = {
  47109. id: OPS.closePath,
  47110. numArgs: 0,
  47111. variableArgs: false
  47112. };
  47113. t['re'] = {
  47114. id: OPS.rectangle,
  47115. numArgs: 4,
  47116. variableArgs: false
  47117. };
  47118. t['S'] = {
  47119. id: OPS.stroke,
  47120. numArgs: 0,
  47121. variableArgs: false
  47122. };
  47123. t['s'] = {
  47124. id: OPS.closeStroke,
  47125. numArgs: 0,
  47126. variableArgs: false
  47127. };
  47128. t['f'] = {
  47129. id: OPS.fill,
  47130. numArgs: 0,
  47131. variableArgs: false
  47132. };
  47133. t['F'] = {
  47134. id: OPS.fill,
  47135. numArgs: 0,
  47136. variableArgs: false
  47137. };
  47138. t['f*'] = {
  47139. id: OPS.eoFill,
  47140. numArgs: 0,
  47141. variableArgs: false
  47142. };
  47143. t['B'] = {
  47144. id: OPS.fillStroke,
  47145. numArgs: 0,
  47146. variableArgs: false
  47147. };
  47148. t['B*'] = {
  47149. id: OPS.eoFillStroke,
  47150. numArgs: 0,
  47151. variableArgs: false
  47152. };
  47153. t['b'] = {
  47154. id: OPS.closeFillStroke,
  47155. numArgs: 0,
  47156. variableArgs: false
  47157. };
  47158. t['b*'] = {
  47159. id: OPS.closeEOFillStroke,
  47160. numArgs: 0,
  47161. variableArgs: false
  47162. };
  47163. t['n'] = {
  47164. id: OPS.endPath,
  47165. numArgs: 0,
  47166. variableArgs: false
  47167. };
  47168. t['W'] = {
  47169. id: OPS.clip,
  47170. numArgs: 0,
  47171. variableArgs: false
  47172. };
  47173. t['W*'] = {
  47174. id: OPS.eoClip,
  47175. numArgs: 0,
  47176. variableArgs: false
  47177. };
  47178. t['BT'] = {
  47179. id: OPS.beginText,
  47180. numArgs: 0,
  47181. variableArgs: false
  47182. };
  47183. t['ET'] = {
  47184. id: OPS.endText,
  47185. numArgs: 0,
  47186. variableArgs: false
  47187. };
  47188. t['Tc'] = {
  47189. id: OPS.setCharSpacing,
  47190. numArgs: 1,
  47191. variableArgs: false
  47192. };
  47193. t['Tw'] = {
  47194. id: OPS.setWordSpacing,
  47195. numArgs: 1,
  47196. variableArgs: false
  47197. };
  47198. t['Tz'] = {
  47199. id: OPS.setHScale,
  47200. numArgs: 1,
  47201. variableArgs: false
  47202. };
  47203. t['TL'] = {
  47204. id: OPS.setLeading,
  47205. numArgs: 1,
  47206. variableArgs: false
  47207. };
  47208. t['Tf'] = {
  47209. id: OPS.setFont,
  47210. numArgs: 2,
  47211. variableArgs: false
  47212. };
  47213. t['Tr'] = {
  47214. id: OPS.setTextRenderingMode,
  47215. numArgs: 1,
  47216. variableArgs: false
  47217. };
  47218. t['Ts'] = {
  47219. id: OPS.setTextRise,
  47220. numArgs: 1,
  47221. variableArgs: false
  47222. };
  47223. t['Td'] = {
  47224. id: OPS.moveText,
  47225. numArgs: 2,
  47226. variableArgs: false
  47227. };
  47228. t['TD'] = {
  47229. id: OPS.setLeadingMoveText,
  47230. numArgs: 2,
  47231. variableArgs: false
  47232. };
  47233. t['Tm'] = {
  47234. id: OPS.setTextMatrix,
  47235. numArgs: 6,
  47236. variableArgs: false
  47237. };
  47238. t['T*'] = {
  47239. id: OPS.nextLine,
  47240. numArgs: 0,
  47241. variableArgs: false
  47242. };
  47243. t['Tj'] = {
  47244. id: OPS.showText,
  47245. numArgs: 1,
  47246. variableArgs: false
  47247. };
  47248. t['TJ'] = {
  47249. id: OPS.showSpacedText,
  47250. numArgs: 1,
  47251. variableArgs: false
  47252. };
  47253. t['\''] = {
  47254. id: OPS.nextLineShowText,
  47255. numArgs: 1,
  47256. variableArgs: false
  47257. };
  47258. t['"'] = {
  47259. id: OPS.nextLineSetSpacingShowText,
  47260. numArgs: 3,
  47261. variableArgs: false
  47262. };
  47263. t['d0'] = {
  47264. id: OPS.setCharWidth,
  47265. numArgs: 2,
  47266. variableArgs: false
  47267. };
  47268. t['d1'] = {
  47269. id: OPS.setCharWidthAndBounds,
  47270. numArgs: 6,
  47271. variableArgs: false
  47272. };
  47273. t['CS'] = {
  47274. id: OPS.setStrokeColorSpace,
  47275. numArgs: 1,
  47276. variableArgs: false
  47277. };
  47278. t['cs'] = {
  47279. id: OPS.setFillColorSpace,
  47280. numArgs: 1,
  47281. variableArgs: false
  47282. };
  47283. t['SC'] = {
  47284. id: OPS.setStrokeColor,
  47285. numArgs: 4,
  47286. variableArgs: true
  47287. };
  47288. t['SCN'] = {
  47289. id: OPS.setStrokeColorN,
  47290. numArgs: 33,
  47291. variableArgs: true
  47292. };
  47293. t['sc'] = {
  47294. id: OPS.setFillColor,
  47295. numArgs: 4,
  47296. variableArgs: true
  47297. };
  47298. t['scn'] = {
  47299. id: OPS.setFillColorN,
  47300. numArgs: 33,
  47301. variableArgs: true
  47302. };
  47303. t['G'] = {
  47304. id: OPS.setStrokeGray,
  47305. numArgs: 1,
  47306. variableArgs: false
  47307. };
  47308. t['g'] = {
  47309. id: OPS.setFillGray,
  47310. numArgs: 1,
  47311. variableArgs: false
  47312. };
  47313. t['RG'] = {
  47314. id: OPS.setStrokeRGBColor,
  47315. numArgs: 3,
  47316. variableArgs: false
  47317. };
  47318. t['rg'] = {
  47319. id: OPS.setFillRGBColor,
  47320. numArgs: 3,
  47321. variableArgs: false
  47322. };
  47323. t['K'] = {
  47324. id: OPS.setStrokeCMYKColor,
  47325. numArgs: 4,
  47326. variableArgs: false
  47327. };
  47328. t['k'] = {
  47329. id: OPS.setFillCMYKColor,
  47330. numArgs: 4,
  47331. variableArgs: false
  47332. };
  47333. t['sh'] = {
  47334. id: OPS.shadingFill,
  47335. numArgs: 1,
  47336. variableArgs: false
  47337. };
  47338. t['BI'] = {
  47339. id: OPS.beginInlineImage,
  47340. numArgs: 0,
  47341. variableArgs: false
  47342. };
  47343. t['ID'] = {
  47344. id: OPS.beginImageData,
  47345. numArgs: 0,
  47346. variableArgs: false
  47347. };
  47348. t['EI'] = {
  47349. id: OPS.endInlineImage,
  47350. numArgs: 1,
  47351. variableArgs: false
  47352. };
  47353. t['Do'] = {
  47354. id: OPS.paintXObject,
  47355. numArgs: 1,
  47356. variableArgs: false
  47357. };
  47358. t['MP'] = {
  47359. id: OPS.markPoint,
  47360. numArgs: 1,
  47361. variableArgs: false
  47362. };
  47363. t['DP'] = {
  47364. id: OPS.markPointProps,
  47365. numArgs: 2,
  47366. variableArgs: false
  47367. };
  47368. t['BMC'] = {
  47369. id: OPS.beginMarkedContent,
  47370. numArgs: 1,
  47371. variableArgs: false
  47372. };
  47373. t['BDC'] = {
  47374. id: OPS.beginMarkedContentProps,
  47375. numArgs: 2,
  47376. variableArgs: false
  47377. };
  47378. t['EMC'] = {
  47379. id: OPS.endMarkedContent,
  47380. numArgs: 0,
  47381. variableArgs: false
  47382. };
  47383. t['BX'] = {
  47384. id: OPS.beginCompat,
  47385. numArgs: 0,
  47386. variableArgs: false
  47387. };
  47388. t['EX'] = {
  47389. id: OPS.endCompat,
  47390. numArgs: 0,
  47391. variableArgs: false
  47392. };
  47393. t['BM'] = null;
  47394. t['BD'] = null;
  47395. t['true'] = null;
  47396. t['fa'] = null;
  47397. t['fal'] = null;
  47398. t['fals'] = null;
  47399. t['false'] = null;
  47400. t['nu'] = null;
  47401. t['nul'] = null;
  47402. t['null'] = null;
  47403. });
  47404. function EvaluatorPreprocessor(stream, xref, stateManager) {
  47405. this.opMap = getOPMap();
  47406. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  47407. this.stateManager = stateManager;
  47408. this.nonProcessedArgs = [];
  47409. }
  47410. EvaluatorPreprocessor.prototype = {
  47411. get savedStatesDepth() {
  47412. return this.stateManager.stateStack.length;
  47413. },
  47414. read: function EvaluatorPreprocessor_read(operation) {
  47415. var args = operation.args;
  47416. while (true) {
  47417. var obj = this.parser.getObj();
  47418. if (isCmd(obj)) {
  47419. var cmd = obj.cmd;
  47420. var opSpec = this.opMap[cmd];
  47421. if (!opSpec) {
  47422. warn('Unknown command "' + cmd + '"');
  47423. continue;
  47424. }
  47425. var fn = opSpec.id;
  47426. var numArgs = opSpec.numArgs;
  47427. var argsLength = args !== null ? args.length : 0;
  47428. if (!opSpec.variableArgs) {
  47429. if (argsLength !== numArgs) {
  47430. var nonProcessedArgs = this.nonProcessedArgs;
  47431. while (argsLength > numArgs) {
  47432. nonProcessedArgs.push(args.shift());
  47433. argsLength--;
  47434. }
  47435. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  47436. if (args === null) {
  47437. args = [];
  47438. }
  47439. args.unshift(nonProcessedArgs.pop());
  47440. argsLength++;
  47441. }
  47442. }
  47443. if (argsLength < numArgs) {
  47444. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  47445. if (args !== null) {
  47446. args.length = 0;
  47447. }
  47448. continue;
  47449. }
  47450. } else if (argsLength > numArgs) {
  47451. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  47452. }
  47453. this.preprocessCommand(fn, args);
  47454. operation.fn = fn;
  47455. operation.args = args;
  47456. return true;
  47457. } else {
  47458. if (isEOF(obj)) {
  47459. return false;
  47460. }
  47461. if (obj !== null) {
  47462. if (args === null) {
  47463. args = [];
  47464. }
  47465. args.push(obj);
  47466. assert(args.length <= 33, 'Too many arguments');
  47467. }
  47468. }
  47469. }
  47470. },
  47471. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  47472. switch (fn | 0) {
  47473. case OPS.save:
  47474. this.stateManager.save();
  47475. break;
  47476. case OPS.restore:
  47477. this.stateManager.restore();
  47478. break;
  47479. case OPS.transform:
  47480. this.stateManager.transform(args);
  47481. break;
  47482. }
  47483. }
  47484. };
  47485. return EvaluatorPreprocessor;
  47486. }();
  47487. var QueueOptimizer = function QueueOptimizerClosure() {
  47488. function addState(parentState, pattern, fn) {
  47489. var state = parentState;
  47490. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  47491. var item = pattern[i];
  47492. state = state[item] || (state[item] = []);
  47493. }
  47494. state[pattern[pattern.length - 1]] = fn;
  47495. }
  47496. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  47497. var iFirstPIMXO = iFirstSave + 2;
  47498. for (var i = 0; i < count; i++) {
  47499. var arg = argsArray[iFirstPIMXO + 4 * i];
  47500. var imageMask = arg.length === 1 && arg[0];
  47501. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  47502. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  47503. continue;
  47504. }
  47505. break;
  47506. }
  47507. return count - i;
  47508. }
  47509. var InitialState = [];
  47510. addState(InitialState, [
  47511. OPS.save,
  47512. OPS.transform,
  47513. OPS.paintInlineImageXObject,
  47514. OPS.restore
  47515. ], function foundInlineImageGroup(context) {
  47516. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  47517. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  47518. var MAX_WIDTH = 1000;
  47519. var IMAGE_PADDING = 1;
  47520. var fnArray = context.fnArray, argsArray = context.argsArray;
  47521. var curr = context.iCurr;
  47522. var iFirstSave = curr - 3;
  47523. var iFirstTransform = curr - 2;
  47524. var iFirstPIIXO = curr - 1;
  47525. var i = iFirstSave + 4;
  47526. var ii = fnArray.length;
  47527. while (i + 3 < ii) {
  47528. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  47529. break;
  47530. }
  47531. i += 4;
  47532. }
  47533. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  47534. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  47535. return i;
  47536. }
  47537. var maxX = 0;
  47538. var map = [], maxLineHeight = 0;
  47539. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  47540. var q;
  47541. for (q = 0; q < count; q++) {
  47542. var transform = argsArray[iFirstTransform + (q << 2)];
  47543. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  47544. if (currentX + img.width > MAX_WIDTH) {
  47545. maxX = Math.max(maxX, currentX);
  47546. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  47547. currentX = 0;
  47548. maxLineHeight = 0;
  47549. }
  47550. map.push({
  47551. transform: transform,
  47552. x: currentX,
  47553. y: currentY,
  47554. w: img.width,
  47555. h: img.height
  47556. });
  47557. currentX += img.width + 2 * IMAGE_PADDING;
  47558. maxLineHeight = Math.max(maxLineHeight, img.height);
  47559. }
  47560. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  47561. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  47562. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  47563. var imgRowSize = imgWidth << 2;
  47564. for (q = 0; q < count; q++) {
  47565. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  47566. var rowSize = map[q].w << 2;
  47567. var dataOffset = 0;
  47568. var offset = map[q].x + map[q].y * imgWidth << 2;
  47569. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  47570. for (var k = 0, kk = map[q].h; k < kk; k++) {
  47571. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  47572. dataOffset += rowSize;
  47573. offset += imgRowSize;
  47574. }
  47575. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  47576. while (offset >= 0) {
  47577. data[offset - 4] = data[offset];
  47578. data[offset - 3] = data[offset + 1];
  47579. data[offset - 2] = data[offset + 2];
  47580. data[offset - 1] = data[offset + 3];
  47581. data[offset + rowSize] = data[offset + rowSize - 4];
  47582. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  47583. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  47584. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  47585. offset -= imgRowSize;
  47586. }
  47587. }
  47588. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  47589. argsArray.splice(iFirstSave, count * 4, [
  47590. {
  47591. width: imgWidth,
  47592. height: imgHeight,
  47593. kind: ImageKind.RGBA_32BPP,
  47594. data: imgData
  47595. },
  47596. map
  47597. ]);
  47598. return iFirstSave + 1;
  47599. });
  47600. addState(InitialState, [
  47601. OPS.save,
  47602. OPS.transform,
  47603. OPS.paintImageMaskXObject,
  47604. OPS.restore
  47605. ], function foundImageMaskGroup(context) {
  47606. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  47607. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  47608. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  47609. var fnArray = context.fnArray, argsArray = context.argsArray;
  47610. var curr = context.iCurr;
  47611. var iFirstSave = curr - 3;
  47612. var iFirstTransform = curr - 2;
  47613. var iFirstPIMXO = curr - 1;
  47614. var i = iFirstSave + 4;
  47615. var ii = fnArray.length;
  47616. while (i + 3 < ii) {
  47617. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  47618. break;
  47619. }
  47620. i += 4;
  47621. }
  47622. var count = (i - iFirstSave) / 4;
  47623. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  47624. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  47625. return i;
  47626. }
  47627. var q;
  47628. var isSameImage = false;
  47629. var iTransform, transformArgs;
  47630. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  47631. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  47632. isSameImage = true;
  47633. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47634. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47635. iTransform = iFirstTransform + 4;
  47636. var iPIMXO = iFirstPIMXO + 4;
  47637. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  47638. transformArgs = argsArray[iTransform];
  47639. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  47640. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  47641. isSameImage = false;
  47642. } else {
  47643. count = q;
  47644. }
  47645. break;
  47646. }
  47647. }
  47648. }
  47649. if (isSameImage) {
  47650. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  47651. var positions = new Float32Array(count * 2);
  47652. iTransform = iFirstTransform;
  47653. for (q = 0; q < count; q++, iTransform += 4) {
  47654. transformArgs = argsArray[iTransform];
  47655. positions[q << 1] = transformArgs[4];
  47656. positions[(q << 1) + 1] = transformArgs[5];
  47657. }
  47658. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  47659. argsArray.splice(iFirstSave, count * 4, [
  47660. firstPIMXOArg0,
  47661. firstTransformArg0,
  47662. firstTransformArg3,
  47663. positions
  47664. ]);
  47665. } else {
  47666. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  47667. var images = [];
  47668. for (q = 0; q < count; q++) {
  47669. transformArgs = argsArray[iFirstTransform + (q << 2)];
  47670. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  47671. images.push({
  47672. data: maskParams.data,
  47673. width: maskParams.width,
  47674. height: maskParams.height,
  47675. transform: transformArgs
  47676. });
  47677. }
  47678. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  47679. argsArray.splice(iFirstSave, count * 4, [images]);
  47680. }
  47681. return iFirstSave + 1;
  47682. });
  47683. addState(InitialState, [
  47684. OPS.save,
  47685. OPS.transform,
  47686. OPS.paintImageXObject,
  47687. OPS.restore
  47688. ], function (context) {
  47689. var MIN_IMAGES_IN_BLOCK = 3;
  47690. var MAX_IMAGES_IN_BLOCK = 1000;
  47691. var fnArray = context.fnArray, argsArray = context.argsArray;
  47692. var curr = context.iCurr;
  47693. var iFirstSave = curr - 3;
  47694. var iFirstTransform = curr - 2;
  47695. var iFirstPIXO = curr - 1;
  47696. var iFirstRestore = curr;
  47697. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  47698. return iFirstRestore + 1;
  47699. }
  47700. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  47701. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47702. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47703. var i = iFirstSave + 4;
  47704. var ii = fnArray.length;
  47705. while (i + 3 < ii) {
  47706. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  47707. break;
  47708. }
  47709. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  47710. break;
  47711. }
  47712. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  47713. break;
  47714. }
  47715. i += 4;
  47716. }
  47717. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  47718. if (count < MIN_IMAGES_IN_BLOCK) {
  47719. return i;
  47720. }
  47721. var positions = new Float32Array(count * 2);
  47722. var iTransform = iFirstTransform;
  47723. for (var q = 0; q < count; q++, iTransform += 4) {
  47724. var transformArgs = argsArray[iTransform];
  47725. positions[q << 1] = transformArgs[4];
  47726. positions[(q << 1) + 1] = transformArgs[5];
  47727. }
  47728. var args = [
  47729. firstPIXOArg0,
  47730. firstTransformArg0,
  47731. firstTransformArg3,
  47732. positions
  47733. ];
  47734. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  47735. argsArray.splice(iFirstSave, count * 4, args);
  47736. return iFirstSave + 1;
  47737. });
  47738. addState(InitialState, [
  47739. OPS.beginText,
  47740. OPS.setFont,
  47741. OPS.setTextMatrix,
  47742. OPS.showText,
  47743. OPS.endText
  47744. ], function (context) {
  47745. var MIN_CHARS_IN_BLOCK = 3;
  47746. var MAX_CHARS_IN_BLOCK = 1000;
  47747. var fnArray = context.fnArray, argsArray = context.argsArray;
  47748. var curr = context.iCurr;
  47749. var iFirstBeginText = curr - 4;
  47750. var iFirstSetFont = curr - 3;
  47751. var iFirstSetTextMatrix = curr - 2;
  47752. var iFirstShowText = curr - 1;
  47753. var iFirstEndText = curr;
  47754. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  47755. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  47756. var i = iFirstBeginText + 5;
  47757. var ii = fnArray.length;
  47758. while (i + 4 < ii) {
  47759. 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) {
  47760. break;
  47761. }
  47762. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  47763. break;
  47764. }
  47765. i += 5;
  47766. }
  47767. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  47768. if (count < MIN_CHARS_IN_BLOCK) {
  47769. return i;
  47770. }
  47771. var iFirst = iFirstBeginText;
  47772. 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) {
  47773. count++;
  47774. iFirst -= 5;
  47775. }
  47776. var iEndText = iFirst + 4;
  47777. for (var q = 1; q < count; q++) {
  47778. fnArray.splice(iEndText, 3);
  47779. argsArray.splice(iEndText, 3);
  47780. iEndText += 2;
  47781. }
  47782. return iEndText + 1;
  47783. });
  47784. function QueueOptimizer() {
  47785. }
  47786. QueueOptimizer.prototype = {
  47787. optimize: function QueueOptimizer_optimize(queue) {
  47788. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  47789. var context = {
  47790. iCurr: 0,
  47791. fnArray: fnArray,
  47792. argsArray: argsArray
  47793. };
  47794. var state;
  47795. var i = 0, ii = fnArray.length;
  47796. while (i < ii) {
  47797. state = (state || InitialState)[fnArray[i]];
  47798. if (typeof state === 'function') {
  47799. context.iCurr = i;
  47800. i = state(context);
  47801. state = undefined;
  47802. ii = context.fnArray.length;
  47803. } else {
  47804. i++;
  47805. }
  47806. }
  47807. }
  47808. };
  47809. return QueueOptimizer;
  47810. }();
  47811. exports.OperatorList = OperatorList;
  47812. exports.PartialEvaluator = PartialEvaluator;
  47813. }));
  47814. (function (root, factory) {
  47815. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  47816. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  47817. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  47818. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  47819. var AnnotationFlag = sharedUtil.AnnotationFlag;
  47820. var AnnotationType = sharedUtil.AnnotationType;
  47821. var OPS = sharedUtil.OPS;
  47822. var Util = sharedUtil.Util;
  47823. var isString = sharedUtil.isString;
  47824. var isArray = sharedUtil.isArray;
  47825. var isInt = sharedUtil.isInt;
  47826. var stringToBytes = sharedUtil.stringToBytes;
  47827. var stringToPDFString = sharedUtil.stringToPDFString;
  47828. var warn = sharedUtil.warn;
  47829. var Dict = corePrimitives.Dict;
  47830. var isDict = corePrimitives.isDict;
  47831. var isName = corePrimitives.isName;
  47832. var isRef = corePrimitives.isRef;
  47833. var Stream = coreStream.Stream;
  47834. var ColorSpace = coreColorSpace.ColorSpace;
  47835. var Catalog = coreObj.Catalog;
  47836. var ObjectLoader = coreObj.ObjectLoader;
  47837. var FileSpec = coreObj.FileSpec;
  47838. var OperatorList = coreEvaluator.OperatorList;
  47839. function AnnotationFactory() {
  47840. }
  47841. AnnotationFactory.prototype = {
  47842. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  47843. var dict = xref.fetchIfRef(ref);
  47844. if (!isDict(dict)) {
  47845. return;
  47846. }
  47847. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  47848. var subtype = dict.get('Subtype');
  47849. subtype = isName(subtype) ? subtype.name : null;
  47850. var parameters = {
  47851. xref: xref,
  47852. dict: dict,
  47853. ref: isRef(ref) ? ref : null,
  47854. subtype: subtype,
  47855. id: id,
  47856. pdfManager: pdfManager
  47857. };
  47858. switch (subtype) {
  47859. case 'Link':
  47860. return new LinkAnnotation(parameters);
  47861. case 'Text':
  47862. return new TextAnnotation(parameters);
  47863. case 'Widget':
  47864. var fieldType = Util.getInheritableProperty(dict, 'FT');
  47865. fieldType = isName(fieldType) ? fieldType.name : null;
  47866. switch (fieldType) {
  47867. case 'Tx':
  47868. return new TextWidgetAnnotation(parameters);
  47869. case 'Ch':
  47870. return new ChoiceWidgetAnnotation(parameters);
  47871. }
  47872. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  47873. return new WidgetAnnotation(parameters);
  47874. case 'Popup':
  47875. return new PopupAnnotation(parameters);
  47876. case 'Highlight':
  47877. return new HighlightAnnotation(parameters);
  47878. case 'Underline':
  47879. return new UnderlineAnnotation(parameters);
  47880. case 'Squiggly':
  47881. return new SquigglyAnnotation(parameters);
  47882. case 'StrikeOut':
  47883. return new StrikeOutAnnotation(parameters);
  47884. case 'FileAttachment':
  47885. return new FileAttachmentAnnotation(parameters);
  47886. default:
  47887. if (!subtype) {
  47888. warn('Annotation is missing the required /Subtype.');
  47889. } else {
  47890. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  47891. }
  47892. return new Annotation(parameters);
  47893. }
  47894. }
  47895. };
  47896. var Annotation = function AnnotationClosure() {
  47897. function getTransformMatrix(rect, bbox, matrix) {
  47898. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  47899. var minX = bounds[0];
  47900. var minY = bounds[1];
  47901. var maxX = bounds[2];
  47902. var maxY = bounds[3];
  47903. if (minX === maxX || minY === maxY) {
  47904. return [
  47905. 1,
  47906. 0,
  47907. 0,
  47908. 1,
  47909. rect[0],
  47910. rect[1]
  47911. ];
  47912. }
  47913. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  47914. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  47915. return [
  47916. xRatio,
  47917. 0,
  47918. 0,
  47919. yRatio,
  47920. rect[0] - minX * xRatio,
  47921. rect[1] - minY * yRatio
  47922. ];
  47923. }
  47924. function getDefaultAppearance(dict) {
  47925. var appearanceState = dict.get('AP');
  47926. if (!isDict(appearanceState)) {
  47927. return;
  47928. }
  47929. var appearance;
  47930. var appearances = appearanceState.get('N');
  47931. if (isDict(appearances)) {
  47932. var as = dict.get('AS');
  47933. if (as && appearances.has(as.name)) {
  47934. appearance = appearances.get(as.name);
  47935. }
  47936. } else {
  47937. appearance = appearances;
  47938. }
  47939. return appearance;
  47940. }
  47941. function Annotation(params) {
  47942. var dict = params.dict;
  47943. this.setFlags(dict.get('F'));
  47944. this.setRectangle(dict.getArray('Rect'));
  47945. this.setColor(dict.getArray('C'));
  47946. this.setBorderStyle(dict);
  47947. this.appearance = getDefaultAppearance(dict);
  47948. this.data = {};
  47949. this.data.id = params.id;
  47950. this.data.subtype = params.subtype;
  47951. this.data.annotationFlags = this.flags;
  47952. this.data.rect = this.rectangle;
  47953. this.data.color = this.color;
  47954. this.data.borderStyle = this.borderStyle;
  47955. this.data.hasAppearance = !!this.appearance;
  47956. }
  47957. Annotation.prototype = {
  47958. _hasFlag: function Annotation_hasFlag(flags, flag) {
  47959. return !!(flags & flag);
  47960. },
  47961. _isViewable: function Annotation_isViewable(flags) {
  47962. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  47963. },
  47964. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  47965. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  47966. },
  47967. get viewable() {
  47968. if (this.flags === 0) {
  47969. return true;
  47970. }
  47971. return this._isViewable(this.flags);
  47972. },
  47973. get printable() {
  47974. if (this.flags === 0) {
  47975. return false;
  47976. }
  47977. return this._isPrintable(this.flags);
  47978. },
  47979. setFlags: function Annotation_setFlags(flags) {
  47980. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  47981. },
  47982. hasFlag: function Annotation_hasFlag(flag) {
  47983. return this._hasFlag(this.flags, flag);
  47984. },
  47985. setRectangle: function Annotation_setRectangle(rectangle) {
  47986. if (isArray(rectangle) && rectangle.length === 4) {
  47987. this.rectangle = Util.normalizeRect(rectangle);
  47988. } else {
  47989. this.rectangle = [
  47990. 0,
  47991. 0,
  47992. 0,
  47993. 0
  47994. ];
  47995. }
  47996. },
  47997. setColor: function Annotation_setColor(color) {
  47998. var rgbColor = new Uint8Array(3);
  47999. if (!isArray(color)) {
  48000. this.color = rgbColor;
  48001. return;
  48002. }
  48003. switch (color.length) {
  48004. case 0:
  48005. this.color = null;
  48006. break;
  48007. case 1:
  48008. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  48009. this.color = rgbColor;
  48010. break;
  48011. case 3:
  48012. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  48013. this.color = rgbColor;
  48014. break;
  48015. case 4:
  48016. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  48017. this.color = rgbColor;
  48018. break;
  48019. default:
  48020. this.color = rgbColor;
  48021. break;
  48022. }
  48023. },
  48024. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  48025. this.borderStyle = new AnnotationBorderStyle();
  48026. if (!isDict(borderStyle)) {
  48027. return;
  48028. }
  48029. if (borderStyle.has('BS')) {
  48030. var dict = borderStyle.get('BS');
  48031. var dictType = dict.get('Type');
  48032. if (!dictType || isName(dictType, 'Border')) {
  48033. this.borderStyle.setWidth(dict.get('W'));
  48034. this.borderStyle.setStyle(dict.get('S'));
  48035. this.borderStyle.setDashArray(dict.getArray('D'));
  48036. }
  48037. } else if (borderStyle.has('Border')) {
  48038. var array = borderStyle.getArray('Border');
  48039. if (isArray(array) && array.length >= 3) {
  48040. this.borderStyle.setHorizontalCornerRadius(array[0]);
  48041. this.borderStyle.setVerticalCornerRadius(array[1]);
  48042. this.borderStyle.setWidth(array[2]);
  48043. if (array.length === 4) {
  48044. this.borderStyle.setDashArray(array[3]);
  48045. }
  48046. }
  48047. } else {
  48048. this.borderStyle.setWidth(0);
  48049. }
  48050. },
  48051. _preparePopup: function Annotation_preparePopup(dict) {
  48052. if (!dict.has('C')) {
  48053. this.data.color = null;
  48054. }
  48055. this.data.hasPopup = dict.has('Popup');
  48056. this.data.title = stringToPDFString(dict.get('T') || '');
  48057. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  48058. },
  48059. loadResources: function Annotation_loadResources(keys) {
  48060. return new Promise(function (resolve, reject) {
  48061. this.appearance.dict.getAsync('Resources').then(function (resources) {
  48062. if (!resources) {
  48063. resolve();
  48064. return;
  48065. }
  48066. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  48067. objectLoader.load().then(function () {
  48068. resolve(resources);
  48069. }, reject);
  48070. }, reject);
  48071. }.bind(this));
  48072. },
  48073. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  48074. if (!this.appearance) {
  48075. return Promise.resolve(new OperatorList());
  48076. }
  48077. var data = this.data;
  48078. var appearanceDict = this.appearance.dict;
  48079. var resourcesPromise = this.loadResources([
  48080. 'ExtGState',
  48081. 'ColorSpace',
  48082. 'Pattern',
  48083. 'Shading',
  48084. 'XObject',
  48085. 'Font'
  48086. ]);
  48087. var bbox = appearanceDict.getArray('BBox') || [
  48088. 0,
  48089. 0,
  48090. 1,
  48091. 1
  48092. ];
  48093. var matrix = appearanceDict.getArray('Matrix') || [
  48094. 1,
  48095. 0,
  48096. 0,
  48097. 1,
  48098. 0,
  48099. 0
  48100. ];
  48101. var transform = getTransformMatrix(data.rect, bbox, matrix);
  48102. var self = this;
  48103. return resourcesPromise.then(function (resources) {
  48104. var opList = new OperatorList();
  48105. opList.addOp(OPS.beginAnnotation, [
  48106. data.rect,
  48107. transform,
  48108. matrix
  48109. ]);
  48110. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  48111. opList.addOp(OPS.endAnnotation, []);
  48112. self.appearance.reset();
  48113. return opList;
  48114. });
  48115. });
  48116. }
  48117. };
  48118. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  48119. var annotationPromises = [];
  48120. for (var i = 0, n = annotations.length; i < n; ++i) {
  48121. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  48122. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  48123. }
  48124. }
  48125. return Promise.all(annotationPromises).then(function (operatorLists) {
  48126. opList.addOp(OPS.beginAnnotations, []);
  48127. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  48128. opList.addOpList(operatorLists[i]);
  48129. }
  48130. opList.addOp(OPS.endAnnotations, []);
  48131. });
  48132. };
  48133. return Annotation;
  48134. }();
  48135. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  48136. function AnnotationBorderStyle() {
  48137. this.width = 1;
  48138. this.style = AnnotationBorderStyleType.SOLID;
  48139. this.dashArray = [3];
  48140. this.horizontalCornerRadius = 0;
  48141. this.verticalCornerRadius = 0;
  48142. }
  48143. AnnotationBorderStyle.prototype = {
  48144. setWidth: function AnnotationBorderStyle_setWidth(width) {
  48145. if (width === (width | 0)) {
  48146. this.width = width;
  48147. }
  48148. },
  48149. setStyle: function AnnotationBorderStyle_setStyle(style) {
  48150. if (!style) {
  48151. return;
  48152. }
  48153. switch (style.name) {
  48154. case 'S':
  48155. this.style = AnnotationBorderStyleType.SOLID;
  48156. break;
  48157. case 'D':
  48158. this.style = AnnotationBorderStyleType.DASHED;
  48159. break;
  48160. case 'B':
  48161. this.style = AnnotationBorderStyleType.BEVELED;
  48162. break;
  48163. case 'I':
  48164. this.style = AnnotationBorderStyleType.INSET;
  48165. break;
  48166. case 'U':
  48167. this.style = AnnotationBorderStyleType.UNDERLINE;
  48168. break;
  48169. default:
  48170. break;
  48171. }
  48172. },
  48173. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  48174. if (isArray(dashArray) && dashArray.length > 0) {
  48175. var isValid = true;
  48176. var allZeros = true;
  48177. for (var i = 0, len = dashArray.length; i < len; i++) {
  48178. var element = dashArray[i];
  48179. var validNumber = +element >= 0;
  48180. if (!validNumber) {
  48181. isValid = false;
  48182. break;
  48183. } else if (element > 0) {
  48184. allZeros = false;
  48185. }
  48186. }
  48187. if (isValid && !allZeros) {
  48188. this.dashArray = dashArray;
  48189. } else {
  48190. this.width = 0;
  48191. }
  48192. } else if (dashArray) {
  48193. this.width = 0;
  48194. }
  48195. },
  48196. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  48197. if (radius === (radius | 0)) {
  48198. this.horizontalCornerRadius = radius;
  48199. }
  48200. },
  48201. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  48202. if (radius === (radius | 0)) {
  48203. this.verticalCornerRadius = radius;
  48204. }
  48205. }
  48206. };
  48207. return AnnotationBorderStyle;
  48208. }();
  48209. var WidgetAnnotation = function WidgetAnnotationClosure() {
  48210. function WidgetAnnotation(params) {
  48211. Annotation.call(this, params);
  48212. var dict = params.dict;
  48213. var data = this.data;
  48214. data.annotationType = AnnotationType.WIDGET;
  48215. data.fieldName = this._constructFieldName(dict);
  48216. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  48217. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  48218. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  48219. var fieldType = Util.getInheritableProperty(dict, 'FT');
  48220. data.fieldType = isName(fieldType) ? fieldType.name : null;
  48221. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  48222. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  48223. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  48224. data.fieldFlags = 0;
  48225. }
  48226. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  48227. if (data.fieldType === 'Sig') {
  48228. this.setFlags(AnnotationFlag.HIDDEN);
  48229. }
  48230. }
  48231. Util.inherit(WidgetAnnotation, Annotation, {
  48232. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  48233. if (!dict.has('T') && !dict.has('Parent')) {
  48234. warn('Unknown field name, falling back to empty field name.');
  48235. return '';
  48236. }
  48237. if (!dict.has('Parent')) {
  48238. return stringToPDFString(dict.get('T'));
  48239. }
  48240. var fieldName = [];
  48241. if (dict.has('T')) {
  48242. fieldName.unshift(stringToPDFString(dict.get('T')));
  48243. }
  48244. var loopDict = dict;
  48245. while (loopDict.has('Parent')) {
  48246. loopDict = loopDict.get('Parent');
  48247. if (loopDict.has('T')) {
  48248. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  48249. }
  48250. }
  48251. return fieldName.join('.');
  48252. },
  48253. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  48254. return !!(this.data.fieldFlags & flag);
  48255. }
  48256. });
  48257. return WidgetAnnotation;
  48258. }();
  48259. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  48260. function TextWidgetAnnotation(params) {
  48261. WidgetAnnotation.call(this, params);
  48262. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  48263. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  48264. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  48265. alignment = null;
  48266. }
  48267. this.data.textAlignment = alignment;
  48268. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  48269. if (!isInt(maximumLength) || maximumLength < 0) {
  48270. maximumLength = null;
  48271. }
  48272. this.data.maxLen = maximumLength;
  48273. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  48274. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  48275. }
  48276. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  48277. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48278. var operatorList = new OperatorList();
  48279. if (renderForms) {
  48280. return Promise.resolve(operatorList);
  48281. }
  48282. if (this.appearance) {
  48283. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48284. }
  48285. if (!this.data.defaultAppearance) {
  48286. return Promise.resolve(operatorList);
  48287. }
  48288. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  48289. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  48290. return operatorList;
  48291. });
  48292. }
  48293. });
  48294. return TextWidgetAnnotation;
  48295. }();
  48296. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  48297. function ChoiceWidgetAnnotation(params) {
  48298. WidgetAnnotation.call(this, params);
  48299. this.data.options = [];
  48300. var options = params.dict.getArray('Opt');
  48301. if (isArray(options)) {
  48302. for (var i = 0, ii = options.length; i < ii; i++) {
  48303. var option = options[i];
  48304. this.data.options[i] = {
  48305. exportValue: isArray(option) ? option[0] : option,
  48306. displayValue: isArray(option) ? option[1] : option
  48307. };
  48308. }
  48309. }
  48310. if (!isArray(this.data.fieldValue)) {
  48311. this.data.fieldValue = [this.data.fieldValue];
  48312. }
  48313. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  48314. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  48315. }
  48316. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  48317. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48318. var operatorList = new OperatorList();
  48319. if (renderForms) {
  48320. return Promise.resolve(operatorList);
  48321. }
  48322. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48323. }
  48324. });
  48325. return ChoiceWidgetAnnotation;
  48326. }();
  48327. var TextAnnotation = function TextAnnotationClosure() {
  48328. var DEFAULT_ICON_SIZE = 22;
  48329. function TextAnnotation(parameters) {
  48330. Annotation.call(this, parameters);
  48331. this.data.annotationType = AnnotationType.TEXT;
  48332. if (this.data.hasAppearance) {
  48333. this.data.name = 'NoIcon';
  48334. } else {
  48335. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  48336. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  48337. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  48338. }
  48339. this._preparePopup(parameters.dict);
  48340. }
  48341. Util.inherit(TextAnnotation, Annotation, {});
  48342. return TextAnnotation;
  48343. }();
  48344. var LinkAnnotation = function LinkAnnotationClosure() {
  48345. function LinkAnnotation(params) {
  48346. Annotation.call(this, params);
  48347. var data = this.data;
  48348. data.annotationType = AnnotationType.LINK;
  48349. Catalog.parseDestDictionary({
  48350. destDict: params.dict,
  48351. resultObj: data,
  48352. docBaseUrl: params.pdfManager.docBaseUrl
  48353. });
  48354. }
  48355. Util.inherit(LinkAnnotation, Annotation, {});
  48356. return LinkAnnotation;
  48357. }();
  48358. var PopupAnnotation = function PopupAnnotationClosure() {
  48359. function PopupAnnotation(parameters) {
  48360. Annotation.call(this, parameters);
  48361. this.data.annotationType = AnnotationType.POPUP;
  48362. var dict = parameters.dict;
  48363. var parentItem = dict.get('Parent');
  48364. if (!parentItem) {
  48365. warn('Popup annotation has a missing or invalid parent annotation.');
  48366. return;
  48367. }
  48368. this.data.parentId = dict.getRaw('Parent').toString();
  48369. this.data.title = stringToPDFString(parentItem.get('T') || '');
  48370. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  48371. if (!parentItem.has('C')) {
  48372. this.data.color = null;
  48373. } else {
  48374. this.setColor(parentItem.getArray('C'));
  48375. this.data.color = this.color;
  48376. }
  48377. if (!this.viewable) {
  48378. var parentFlags = parentItem.get('F');
  48379. if (this._isViewable(parentFlags)) {
  48380. this.setFlags(parentFlags);
  48381. }
  48382. }
  48383. }
  48384. Util.inherit(PopupAnnotation, Annotation, {});
  48385. return PopupAnnotation;
  48386. }();
  48387. var HighlightAnnotation = function HighlightAnnotationClosure() {
  48388. function HighlightAnnotation(parameters) {
  48389. Annotation.call(this, parameters);
  48390. this.data.annotationType = AnnotationType.HIGHLIGHT;
  48391. this._preparePopup(parameters.dict);
  48392. this.data.borderStyle.setWidth(0);
  48393. }
  48394. Util.inherit(HighlightAnnotation, Annotation, {});
  48395. return HighlightAnnotation;
  48396. }();
  48397. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  48398. function UnderlineAnnotation(parameters) {
  48399. Annotation.call(this, parameters);
  48400. this.data.annotationType = AnnotationType.UNDERLINE;
  48401. this._preparePopup(parameters.dict);
  48402. this.data.borderStyle.setWidth(0);
  48403. }
  48404. Util.inherit(UnderlineAnnotation, Annotation, {});
  48405. return UnderlineAnnotation;
  48406. }();
  48407. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  48408. function SquigglyAnnotation(parameters) {
  48409. Annotation.call(this, parameters);
  48410. this.data.annotationType = AnnotationType.SQUIGGLY;
  48411. this._preparePopup(parameters.dict);
  48412. this.data.borderStyle.setWidth(0);
  48413. }
  48414. Util.inherit(SquigglyAnnotation, Annotation, {});
  48415. return SquigglyAnnotation;
  48416. }();
  48417. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  48418. function StrikeOutAnnotation(parameters) {
  48419. Annotation.call(this, parameters);
  48420. this.data.annotationType = AnnotationType.STRIKEOUT;
  48421. this._preparePopup(parameters.dict);
  48422. this.data.borderStyle.setWidth(0);
  48423. }
  48424. Util.inherit(StrikeOutAnnotation, Annotation, {});
  48425. return StrikeOutAnnotation;
  48426. }();
  48427. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  48428. function FileAttachmentAnnotation(parameters) {
  48429. Annotation.call(this, parameters);
  48430. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  48431. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  48432. this.data.file = file.serializable;
  48433. this._preparePopup(parameters.dict);
  48434. }
  48435. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  48436. return FileAttachmentAnnotation;
  48437. }();
  48438. exports.Annotation = Annotation;
  48439. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  48440. exports.AnnotationFactory = AnnotationFactory;
  48441. }));
  48442. (function (root, factory) {
  48443. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  48444. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  48445. var MissingDataException = sharedUtil.MissingDataException;
  48446. var Util = sharedUtil.Util;
  48447. var assert = sharedUtil.assert;
  48448. var error = sharedUtil.error;
  48449. var info = sharedUtil.info;
  48450. var isArray = sharedUtil.isArray;
  48451. var isArrayBuffer = sharedUtil.isArrayBuffer;
  48452. var isNum = sharedUtil.isNum;
  48453. var isString = sharedUtil.isString;
  48454. var shadow = sharedUtil.shadow;
  48455. var stringToBytes = sharedUtil.stringToBytes;
  48456. var stringToPDFString = sharedUtil.stringToPDFString;
  48457. var warn = sharedUtil.warn;
  48458. var isSpace = sharedUtil.isSpace;
  48459. var Dict = corePrimitives.Dict;
  48460. var isDict = corePrimitives.isDict;
  48461. var isName = corePrimitives.isName;
  48462. var isStream = corePrimitives.isStream;
  48463. var NullStream = coreStream.NullStream;
  48464. var Stream = coreStream.Stream;
  48465. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  48466. var Catalog = coreObj.Catalog;
  48467. var ObjectLoader = coreObj.ObjectLoader;
  48468. var XRef = coreObj.XRef;
  48469. var Linearization = coreParser.Linearization;
  48470. var calculateMD5 = coreCrypto.calculateMD5;
  48471. var OperatorList = coreEvaluator.OperatorList;
  48472. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  48473. var Annotation = coreAnnotation.Annotation;
  48474. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  48475. var Page = function PageClosure() {
  48476. var DEFAULT_USER_UNIT = 1.0;
  48477. var LETTER_SIZE_MEDIABOX = [
  48478. 0,
  48479. 0,
  48480. 612,
  48481. 792
  48482. ];
  48483. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  48484. this.pdfManager = pdfManager;
  48485. this.pageIndex = pageIndex;
  48486. this.pageDict = pageDict;
  48487. this.xref = xref;
  48488. this.ref = ref;
  48489. this.fontCache = fontCache;
  48490. this.uniquePrefix = 'p' + this.pageIndex + '_';
  48491. this.idCounters = { obj: 0 };
  48492. this.evaluatorOptions = pdfManager.evaluatorOptions;
  48493. this.resourcesPromise = null;
  48494. }
  48495. Page.prototype = {
  48496. getPageProp: function Page_getPageProp(key) {
  48497. return this.pageDict.get(key);
  48498. },
  48499. getInheritedPageProp: function Page_getInheritedPageProp(key) {
  48500. var dict = this.pageDict, valueArray = null, loopCount = 0;
  48501. var MAX_LOOP_COUNT = 100;
  48502. while (dict) {
  48503. var value = dict.get(key);
  48504. if (value) {
  48505. if (!valueArray) {
  48506. valueArray = [];
  48507. }
  48508. valueArray.push(value);
  48509. }
  48510. if (++loopCount > MAX_LOOP_COUNT) {
  48511. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  48512. break;
  48513. }
  48514. dict = dict.get('Parent');
  48515. }
  48516. if (!valueArray) {
  48517. return Dict.empty;
  48518. }
  48519. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  48520. return valueArray[0];
  48521. }
  48522. return Dict.merge(this.xref, valueArray);
  48523. },
  48524. get content() {
  48525. return this.getPageProp('Contents');
  48526. },
  48527. get resources() {
  48528. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  48529. },
  48530. get mediaBox() {
  48531. var obj = this.getInheritedPageProp('MediaBox');
  48532. if (!isArray(obj) || obj.length !== 4) {
  48533. obj = LETTER_SIZE_MEDIABOX;
  48534. }
  48535. return shadow(this, 'mediaBox', obj);
  48536. },
  48537. get userUnit() {
  48538. var obj = this.getPageProp('UserUnit');
  48539. if (!isNum(obj) || obj <= 0) {
  48540. obj = DEFAULT_USER_UNIT;
  48541. }
  48542. return shadow(this, 'userUnit', obj);
  48543. },
  48544. get view() {
  48545. var mediaBox = this.mediaBox;
  48546. var cropBox = this.getInheritedPageProp('CropBox');
  48547. if (!isArray(cropBox) || cropBox.length !== 4) {
  48548. return shadow(this, 'view', mediaBox);
  48549. }
  48550. cropBox = Util.intersect(cropBox, mediaBox);
  48551. if (!cropBox) {
  48552. return shadow(this, 'view', mediaBox);
  48553. }
  48554. return shadow(this, 'view', cropBox);
  48555. },
  48556. get rotate() {
  48557. var rotate = this.getInheritedPageProp('Rotate') || 0;
  48558. if (rotate % 90 !== 0) {
  48559. rotate = 0;
  48560. } else if (rotate >= 360) {
  48561. rotate = rotate % 360;
  48562. } else if (rotate < 0) {
  48563. rotate = (rotate % 360 + 360) % 360;
  48564. }
  48565. return shadow(this, 'rotate', rotate);
  48566. },
  48567. getContentStream: function Page_getContentStream() {
  48568. var content = this.content;
  48569. var stream;
  48570. if (isArray(content)) {
  48571. var xref = this.xref;
  48572. var i, n = content.length;
  48573. var streams = [];
  48574. for (i = 0; i < n; ++i) {
  48575. streams.push(xref.fetchIfRef(content[i]));
  48576. }
  48577. stream = new StreamsSequenceStream(streams);
  48578. } else if (isStream(content)) {
  48579. stream = content;
  48580. } else {
  48581. stream = new NullStream();
  48582. }
  48583. return stream;
  48584. },
  48585. loadResources: function Page_loadResources(keys) {
  48586. if (!this.resourcesPromise) {
  48587. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  48588. }
  48589. return this.resourcesPromise.then(function resourceSuccess() {
  48590. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  48591. return objectLoader.load();
  48592. }.bind(this));
  48593. },
  48594. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  48595. var self = this;
  48596. var pdfManager = this.pdfManager;
  48597. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48598. var resourcesPromise = this.loadResources([
  48599. 'ExtGState',
  48600. 'ColorSpace',
  48601. 'Pattern',
  48602. 'Shading',
  48603. 'XObject',
  48604. 'Font'
  48605. ]);
  48606. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  48607. var dataPromises = Promise.all([
  48608. contentStreamPromise,
  48609. resourcesPromise
  48610. ]);
  48611. var pageListPromise = dataPromises.then(function (data) {
  48612. var contentStream = data[0];
  48613. var opList = new OperatorList(intent, handler, self.pageIndex);
  48614. handler.send('StartRenderPage', {
  48615. transparency: partialEvaluator.hasBlendModes(self.resources),
  48616. pageIndex: self.pageIndex,
  48617. intent: intent
  48618. });
  48619. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  48620. return opList;
  48621. });
  48622. });
  48623. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  48624. return Promise.all([
  48625. pageListPromise,
  48626. annotationsPromise
  48627. ]).then(function (datas) {
  48628. var pageOpList = datas[0];
  48629. var annotations = datas[1];
  48630. if (annotations.length === 0) {
  48631. pageOpList.flush(true);
  48632. return pageOpList;
  48633. }
  48634. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  48635. return annotationsReadyPromise.then(function () {
  48636. pageOpList.flush(true);
  48637. return pageOpList;
  48638. });
  48639. });
  48640. },
  48641. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  48642. var handler = {
  48643. on: function nullHandlerOn() {
  48644. },
  48645. send: function nullHandlerSend() {
  48646. }
  48647. };
  48648. var self = this;
  48649. var pdfManager = this.pdfManager;
  48650. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48651. var resourcesPromise = this.loadResources([
  48652. 'ExtGState',
  48653. 'XObject',
  48654. 'Font'
  48655. ]);
  48656. var dataPromises = Promise.all([
  48657. contentStreamPromise,
  48658. resourcesPromise
  48659. ]);
  48660. return dataPromises.then(function (data) {
  48661. var contentStream = data[0];
  48662. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  48663. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  48664. });
  48665. },
  48666. getAnnotationsData: function Page_getAnnotationsData(intent) {
  48667. var annotations = this.annotations;
  48668. var annotationsData = [];
  48669. for (var i = 0, n = annotations.length; i < n; ++i) {
  48670. if (intent) {
  48671. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  48672. continue;
  48673. }
  48674. }
  48675. annotationsData.push(annotations[i].data);
  48676. }
  48677. return annotationsData;
  48678. },
  48679. get annotations() {
  48680. var annotations = [];
  48681. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  48682. var annotationFactory = new AnnotationFactory();
  48683. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  48684. var annotationRef = annotationRefs[i];
  48685. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  48686. if (annotation) {
  48687. annotations.push(annotation);
  48688. }
  48689. }
  48690. return shadow(this, 'annotations', annotations);
  48691. }
  48692. };
  48693. return Page;
  48694. }();
  48695. var PDFDocument = function PDFDocumentClosure() {
  48696. var FINGERPRINT_FIRST_BYTES = 1024;
  48697. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  48698. function PDFDocument(pdfManager, arg, password) {
  48699. if (isStream(arg)) {
  48700. init.call(this, pdfManager, arg, password);
  48701. } else if (isArrayBuffer(arg)) {
  48702. init.call(this, pdfManager, new Stream(arg), password);
  48703. } else {
  48704. error('PDFDocument: Unknown argument type');
  48705. }
  48706. }
  48707. function init(pdfManager, stream, password) {
  48708. assert(stream.length > 0, 'stream must have data');
  48709. this.pdfManager = pdfManager;
  48710. this.stream = stream;
  48711. var xref = new XRef(this.stream, password, pdfManager);
  48712. this.xref = xref;
  48713. }
  48714. function find(stream, needle, limit, backwards) {
  48715. var pos = stream.pos;
  48716. var end = stream.end;
  48717. var strBuf = [];
  48718. if (pos + limit > end) {
  48719. limit = end - pos;
  48720. }
  48721. for (var n = 0; n < limit; ++n) {
  48722. strBuf.push(String.fromCharCode(stream.getByte()));
  48723. }
  48724. var str = strBuf.join('');
  48725. stream.pos = pos;
  48726. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  48727. if (index === -1) {
  48728. return false;
  48729. }
  48730. stream.pos += index;
  48731. return true;
  48732. }
  48733. var DocumentInfoValidators = {
  48734. get entries() {
  48735. return shadow(this, 'entries', {
  48736. Title: isString,
  48737. Author: isString,
  48738. Subject: isString,
  48739. Keywords: isString,
  48740. Creator: isString,
  48741. Producer: isString,
  48742. CreationDate: isString,
  48743. ModDate: isString,
  48744. Trapped: isName
  48745. });
  48746. }
  48747. };
  48748. PDFDocument.prototype = {
  48749. parse: function PDFDocument_parse(recoveryMode) {
  48750. this.setup(recoveryMode);
  48751. var version = this.catalog.catDict.get('Version');
  48752. if (isName(version)) {
  48753. this.pdfFormatVersion = version.name;
  48754. }
  48755. try {
  48756. this.acroForm = this.catalog.catDict.get('AcroForm');
  48757. if (this.acroForm) {
  48758. this.xfa = this.acroForm.get('XFA');
  48759. var fields = this.acroForm.get('Fields');
  48760. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  48761. this.acroForm = null;
  48762. }
  48763. }
  48764. } catch (ex) {
  48765. info('Something wrong with AcroForm entry');
  48766. this.acroForm = null;
  48767. }
  48768. },
  48769. get linearization() {
  48770. var linearization = null;
  48771. if (this.stream.length) {
  48772. try {
  48773. linearization = Linearization.create(this.stream);
  48774. } catch (err) {
  48775. if (err instanceof MissingDataException) {
  48776. throw err;
  48777. }
  48778. info(err);
  48779. }
  48780. }
  48781. return shadow(this, 'linearization', linearization);
  48782. },
  48783. get startXRef() {
  48784. var stream = this.stream;
  48785. var startXRef = 0;
  48786. var linearization = this.linearization;
  48787. if (linearization) {
  48788. stream.reset();
  48789. if (find(stream, 'endobj', 1024)) {
  48790. startXRef = stream.pos + 6;
  48791. }
  48792. } else {
  48793. var step = 1024;
  48794. var found = false, pos = stream.end;
  48795. while (!found && pos > 0) {
  48796. pos -= step - 'startxref'.length;
  48797. if (pos < 0) {
  48798. pos = 0;
  48799. }
  48800. stream.pos = pos;
  48801. found = find(stream, 'startxref', step, true);
  48802. }
  48803. if (found) {
  48804. stream.skip(9);
  48805. var ch;
  48806. do {
  48807. ch = stream.getByte();
  48808. } while (isSpace(ch));
  48809. var str = '';
  48810. while (ch >= 0x20 && ch <= 0x39) {
  48811. str += String.fromCharCode(ch);
  48812. ch = stream.getByte();
  48813. }
  48814. startXRef = parseInt(str, 10);
  48815. if (isNaN(startXRef)) {
  48816. startXRef = 0;
  48817. }
  48818. }
  48819. }
  48820. return shadow(this, 'startXRef', startXRef);
  48821. },
  48822. get mainXRefEntriesOffset() {
  48823. var mainXRefEntriesOffset = 0;
  48824. var linearization = this.linearization;
  48825. if (linearization) {
  48826. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  48827. }
  48828. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  48829. },
  48830. checkHeader: function PDFDocument_checkHeader() {
  48831. var stream = this.stream;
  48832. stream.reset();
  48833. if (find(stream, '%PDF-', 1024)) {
  48834. stream.moveStart();
  48835. var MAX_VERSION_LENGTH = 12;
  48836. var version = '', ch;
  48837. while ((ch = stream.getByte()) > 0x20) {
  48838. if (version.length >= MAX_VERSION_LENGTH) {
  48839. break;
  48840. }
  48841. version += String.fromCharCode(ch);
  48842. }
  48843. if (!this.pdfFormatVersion) {
  48844. this.pdfFormatVersion = version.substring(5);
  48845. }
  48846. return;
  48847. }
  48848. },
  48849. parseStartXRef: function PDFDocument_parseStartXRef() {
  48850. var startXRef = this.startXRef;
  48851. this.xref.setStartXRef(startXRef);
  48852. },
  48853. setup: function PDFDocument_setup(recoveryMode) {
  48854. this.xref.parse(recoveryMode);
  48855. var self = this;
  48856. var pageFactory = {
  48857. createPage: function (pageIndex, dict, ref, fontCache) {
  48858. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  48859. }
  48860. };
  48861. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  48862. },
  48863. get numPages() {
  48864. var linearization = this.linearization;
  48865. var num = linearization ? linearization.numPages : this.catalog.numPages;
  48866. return shadow(this, 'numPages', num);
  48867. },
  48868. get documentInfo() {
  48869. var docInfo = {
  48870. PDFFormatVersion: this.pdfFormatVersion,
  48871. IsAcroFormPresent: !!this.acroForm,
  48872. IsXFAPresent: !!this.xfa
  48873. };
  48874. var infoDict;
  48875. try {
  48876. infoDict = this.xref.trailer.get('Info');
  48877. } catch (err) {
  48878. info('The document information dictionary is invalid.');
  48879. }
  48880. if (infoDict) {
  48881. var validEntries = DocumentInfoValidators.entries;
  48882. for (var key in validEntries) {
  48883. if (infoDict.has(key)) {
  48884. var value = infoDict.get(key);
  48885. if (validEntries[key](value)) {
  48886. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  48887. } else {
  48888. info('Bad value in document info for "' + key + '"');
  48889. }
  48890. }
  48891. }
  48892. }
  48893. return shadow(this, 'documentInfo', docInfo);
  48894. },
  48895. get fingerprint() {
  48896. var xref = this.xref, hash, fileID = '';
  48897. var idArray = xref.trailer.get('ID');
  48898. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  48899. hash = stringToBytes(idArray[0]);
  48900. } else {
  48901. if (this.stream.ensureRange) {
  48902. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  48903. }
  48904. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  48905. }
  48906. for (var i = 0, n = hash.length; i < n; i++) {
  48907. var hex = hash[i].toString(16);
  48908. fileID += hex.length === 1 ? '0' + hex : hex;
  48909. }
  48910. return shadow(this, 'fingerprint', fileID);
  48911. },
  48912. getPage: function PDFDocument_getPage(pageIndex) {
  48913. return this.catalog.getPage(pageIndex);
  48914. },
  48915. cleanup: function PDFDocument_cleanup() {
  48916. return this.catalog.cleanup();
  48917. }
  48918. };
  48919. return PDFDocument;
  48920. }();
  48921. exports.Page = Page;
  48922. exports.PDFDocument = PDFDocument;
  48923. }));
  48924. (function (root, factory) {
  48925. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  48926. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  48927. var warn = sharedUtil.warn;
  48928. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  48929. var shadow = sharedUtil.shadow;
  48930. var NotImplementedException = sharedUtil.NotImplementedException;
  48931. var MissingDataException = sharedUtil.MissingDataException;
  48932. var createPromiseCapability = sharedUtil.createPromiseCapability;
  48933. var Util = sharedUtil.Util;
  48934. var Stream = coreStream.Stream;
  48935. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  48936. var PDFDocument = coreDocument.PDFDocument;
  48937. var BasePdfManager = function BasePdfManagerClosure() {
  48938. function BasePdfManager() {
  48939. throw new Error('Cannot initialize BaseManagerManager');
  48940. }
  48941. BasePdfManager.prototype = {
  48942. get docId() {
  48943. return this._docId;
  48944. },
  48945. get docBaseUrl() {
  48946. var docBaseUrl = null;
  48947. if (this._docBaseUrl) {
  48948. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  48949. if (absoluteUrl) {
  48950. docBaseUrl = absoluteUrl.href;
  48951. } else {
  48952. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  48953. }
  48954. }
  48955. return shadow(this, 'docBaseUrl', docBaseUrl);
  48956. },
  48957. onLoadedStream: function BasePdfManager_onLoadedStream() {
  48958. throw new NotImplementedException();
  48959. },
  48960. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  48961. return this.ensure(this.pdfDocument, prop, args);
  48962. },
  48963. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  48964. return this.ensure(this.pdfDocument.xref, prop, args);
  48965. },
  48966. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  48967. return this.ensure(this.pdfDocument.catalog, prop, args);
  48968. },
  48969. getPage: function BasePdfManager_getPage(pageIndex) {
  48970. return this.pdfDocument.getPage(pageIndex);
  48971. },
  48972. cleanup: function BasePdfManager_cleanup() {
  48973. return this.pdfDocument.cleanup();
  48974. },
  48975. ensure: function BasePdfManager_ensure(obj, prop, args) {
  48976. return new NotImplementedException();
  48977. },
  48978. requestRange: function BasePdfManager_requestRange(begin, end) {
  48979. return new NotImplementedException();
  48980. },
  48981. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  48982. return new NotImplementedException();
  48983. },
  48984. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  48985. return new NotImplementedException();
  48986. },
  48987. updatePassword: function BasePdfManager_updatePassword(password) {
  48988. this.pdfDocument.xref.password = this.password = password;
  48989. if (this._passwordChangedCapability) {
  48990. this._passwordChangedCapability.resolve();
  48991. }
  48992. },
  48993. passwordChanged: function BasePdfManager_passwordChanged() {
  48994. this._passwordChangedCapability = createPromiseCapability();
  48995. return this._passwordChangedCapability.promise;
  48996. },
  48997. terminate: function BasePdfManager_terminate() {
  48998. return new NotImplementedException();
  48999. }
  49000. };
  49001. return BasePdfManager;
  49002. }();
  49003. var LocalPdfManager = function LocalPdfManagerClosure() {
  49004. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  49005. this._docId = docId;
  49006. this._docBaseUrl = docBaseUrl;
  49007. this.evaluatorOptions = evaluatorOptions;
  49008. var stream = new Stream(data);
  49009. this.pdfDocument = new PDFDocument(this, stream, password);
  49010. this._loadedStreamCapability = createPromiseCapability();
  49011. this._loadedStreamCapability.resolve(stream);
  49012. }
  49013. Util.inherit(LocalPdfManager, BasePdfManager, {
  49014. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  49015. return new Promise(function (resolve, reject) {
  49016. try {
  49017. var value = obj[prop];
  49018. var result;
  49019. if (typeof value === 'function') {
  49020. result = value.apply(obj, args);
  49021. } else {
  49022. result = value;
  49023. }
  49024. resolve(result);
  49025. } catch (e) {
  49026. reject(e);
  49027. }
  49028. });
  49029. },
  49030. requestRange: function LocalPdfManager_requestRange(begin, end) {
  49031. return Promise.resolve();
  49032. },
  49033. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  49034. return;
  49035. },
  49036. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  49037. return this._loadedStreamCapability.promise;
  49038. },
  49039. terminate: function LocalPdfManager_terminate() {
  49040. return;
  49041. }
  49042. });
  49043. return LocalPdfManager;
  49044. }();
  49045. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  49046. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  49047. this._docId = docId;
  49048. this._docBaseUrl = docBaseUrl;
  49049. this.msgHandler = args.msgHandler;
  49050. this.evaluatorOptions = evaluatorOptions;
  49051. var params = {
  49052. msgHandler: args.msgHandler,
  49053. url: args.url,
  49054. length: args.length,
  49055. disableAutoFetch: args.disableAutoFetch,
  49056. rangeChunkSize: args.rangeChunkSize
  49057. };
  49058. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  49059. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  49060. }
  49061. Util.inherit(NetworkPdfManager, BasePdfManager, {
  49062. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  49063. var pdfManager = this;
  49064. return new Promise(function (resolve, reject) {
  49065. function ensureHelper() {
  49066. try {
  49067. var result;
  49068. var value = obj[prop];
  49069. if (typeof value === 'function') {
  49070. result = value.apply(obj, args);
  49071. } else {
  49072. result = value;
  49073. }
  49074. resolve(result);
  49075. } catch (e) {
  49076. if (!(e instanceof MissingDataException)) {
  49077. reject(e);
  49078. return;
  49079. }
  49080. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  49081. }
  49082. }
  49083. ensureHelper();
  49084. });
  49085. },
  49086. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  49087. return this.streamManager.requestRange(begin, end);
  49088. },
  49089. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  49090. this.streamManager.requestAllChunks();
  49091. },
  49092. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  49093. this.streamManager.onReceiveData({ chunk: chunk });
  49094. },
  49095. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  49096. return this.streamManager.onLoadedStream();
  49097. },
  49098. terminate: function NetworkPdfManager_terminate() {
  49099. this.streamManager.abort();
  49100. }
  49101. });
  49102. return NetworkPdfManager;
  49103. }();
  49104. exports.LocalPdfManager = LocalPdfManager;
  49105. exports.NetworkPdfManager = NetworkPdfManager;
  49106. }));
  49107. (function (root, factory) {
  49108. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  49109. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  49110. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  49111. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49112. var MessageHandler = sharedUtil.MessageHandler;
  49113. var MissingPDFException = sharedUtil.MissingPDFException;
  49114. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  49115. var PasswordException = sharedUtil.PasswordException;
  49116. var PasswordResponses = sharedUtil.PasswordResponses;
  49117. var UnknownErrorException = sharedUtil.UnknownErrorException;
  49118. var XRefParseException = sharedUtil.XRefParseException;
  49119. var arrayByteLength = sharedUtil.arrayByteLength;
  49120. var arraysToBytes = sharedUtil.arraysToBytes;
  49121. var assert = sharedUtil.assert;
  49122. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49123. var error = sharedUtil.error;
  49124. var info = sharedUtil.info;
  49125. var warn = sharedUtil.warn;
  49126. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  49127. var Ref = corePrimitives.Ref;
  49128. var LocalPdfManager = corePdfManager.LocalPdfManager;
  49129. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  49130. var globalScope = sharedUtil.globalScope;
  49131. var WorkerTask = function WorkerTaskClosure() {
  49132. function WorkerTask(name) {
  49133. this.name = name;
  49134. this.terminated = false;
  49135. this._capability = createPromiseCapability();
  49136. }
  49137. WorkerTask.prototype = {
  49138. get finished() {
  49139. return this._capability.promise;
  49140. },
  49141. finish: function () {
  49142. this._capability.resolve();
  49143. },
  49144. terminate: function () {
  49145. this.terminated = true;
  49146. },
  49147. ensureNotTerminated: function () {
  49148. if (this.terminated) {
  49149. throw new Error('Worker task was terminated');
  49150. }
  49151. }
  49152. };
  49153. return WorkerTask;
  49154. }();
  49155. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  49156. function PDFWorkerStream(params, msgHandler) {
  49157. this._queuedChunks = [];
  49158. var initialData = params.initialData;
  49159. if (initialData && initialData.length > 0) {
  49160. this._queuedChunks.push(initialData);
  49161. }
  49162. this._msgHandler = msgHandler;
  49163. this._isRangeSupported = !params.disableRange;
  49164. this._isStreamingSupported = !params.disableStream;
  49165. this._contentLength = params.length;
  49166. this._fullRequestReader = null;
  49167. this._rangeReaders = [];
  49168. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  49169. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  49170. }
  49171. PDFWorkerStream.prototype = {
  49172. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  49173. if (args.begin === undefined) {
  49174. if (this._fullRequestReader) {
  49175. this._fullRequestReader._enqueue(args.chunk);
  49176. } else {
  49177. this._queuedChunks.push(args.chunk);
  49178. }
  49179. } else {
  49180. var found = this._rangeReaders.some(function (rangeReader) {
  49181. if (rangeReader._begin !== args.begin) {
  49182. return false;
  49183. }
  49184. rangeReader._enqueue(args.chunk);
  49185. return true;
  49186. });
  49187. assert(found);
  49188. }
  49189. },
  49190. _onProgress: function PDFWorkerStream_onProgress(evt) {
  49191. if (this._rangeReaders.length > 0) {
  49192. var firstReader = this._rangeReaders[0];
  49193. if (firstReader.onProgress) {
  49194. firstReader.onProgress({ loaded: evt.loaded });
  49195. }
  49196. }
  49197. },
  49198. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  49199. var i = this._rangeReaders.indexOf(reader);
  49200. if (i >= 0) {
  49201. this._rangeReaders.splice(i, 1);
  49202. }
  49203. },
  49204. getFullReader: function PDFWorkerStream_getFullReader() {
  49205. assert(!this._fullRequestReader);
  49206. var queuedChunks = this._queuedChunks;
  49207. this._queuedChunks = null;
  49208. return new PDFWorkerStreamReader(this, queuedChunks);
  49209. },
  49210. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  49211. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  49212. this._msgHandler.send('RequestDataRange', {
  49213. begin: begin,
  49214. end: end
  49215. });
  49216. this._rangeReaders.push(reader);
  49217. return reader;
  49218. },
  49219. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  49220. if (this._fullRequestReader) {
  49221. this._fullRequestReader.cancel(reason);
  49222. }
  49223. var readers = this._rangeReaders.slice(0);
  49224. readers.forEach(function (rangeReader) {
  49225. rangeReader.cancel(reason);
  49226. });
  49227. }
  49228. };
  49229. function PDFWorkerStreamReader(stream, queuedChunks) {
  49230. this._stream = stream;
  49231. this._done = false;
  49232. this._queuedChunks = queuedChunks || [];
  49233. this._requests = [];
  49234. this._headersReady = Promise.resolve();
  49235. stream._fullRequestReader = this;
  49236. this.onProgress = null;
  49237. }
  49238. PDFWorkerStreamReader.prototype = {
  49239. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  49240. if (this._done) {
  49241. return;
  49242. }
  49243. if (this._requests.length > 0) {
  49244. var requestCapability = this._requests.shift();
  49245. requestCapability.resolve({
  49246. value: chunk,
  49247. done: false
  49248. });
  49249. return;
  49250. }
  49251. this._queuedChunks.push(chunk);
  49252. },
  49253. get headersReady() {
  49254. return this._headersReady;
  49255. },
  49256. get isRangeSupported() {
  49257. return this._stream._isRangeSupported;
  49258. },
  49259. get isStreamingSupported() {
  49260. return this._stream._isStreamingSupported;
  49261. },
  49262. get contentLength() {
  49263. return this._stream._contentLength;
  49264. },
  49265. read: function PDFWorkerStreamReader_read() {
  49266. if (this._queuedChunks.length > 0) {
  49267. var chunk = this._queuedChunks.shift();
  49268. return Promise.resolve({
  49269. value: chunk,
  49270. done: false
  49271. });
  49272. }
  49273. if (this._done) {
  49274. return Promise.resolve({
  49275. value: undefined,
  49276. done: true
  49277. });
  49278. }
  49279. var requestCapability = createPromiseCapability();
  49280. this._requests.push(requestCapability);
  49281. return requestCapability.promise;
  49282. },
  49283. cancel: function PDFWorkerStreamReader_cancel(reason) {
  49284. this._done = true;
  49285. this._requests.forEach(function (requestCapability) {
  49286. requestCapability.resolve({
  49287. value: undefined,
  49288. done: true
  49289. });
  49290. });
  49291. this._requests = [];
  49292. }
  49293. };
  49294. function PDFWorkerStreamRangeReader(stream, begin, end) {
  49295. this._stream = stream;
  49296. this._begin = begin;
  49297. this._end = end;
  49298. this._queuedChunk = null;
  49299. this._requests = [];
  49300. this._done = false;
  49301. this.onProgress = null;
  49302. }
  49303. PDFWorkerStreamRangeReader.prototype = {
  49304. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  49305. if (this._done) {
  49306. return;
  49307. }
  49308. if (this._requests.length === 0) {
  49309. this._queuedChunk = chunk;
  49310. } else {
  49311. var requestsCapability = this._requests.shift();
  49312. requestsCapability.resolve({
  49313. value: chunk,
  49314. done: false
  49315. });
  49316. this._requests.forEach(function (requestCapability) {
  49317. requestCapability.resolve({
  49318. value: undefined,
  49319. done: true
  49320. });
  49321. });
  49322. this._requests = [];
  49323. }
  49324. this._done = true;
  49325. this._stream._removeRangeReader(this);
  49326. },
  49327. get isStreamingSupported() {
  49328. return false;
  49329. },
  49330. read: function PDFWorkerStreamRangeReader_read() {
  49331. if (this._queuedChunk) {
  49332. return Promise.resolve({
  49333. value: this._queuedChunk,
  49334. done: false
  49335. });
  49336. }
  49337. if (this._done) {
  49338. return Promise.resolve({
  49339. value: undefined,
  49340. done: true
  49341. });
  49342. }
  49343. var requestCapability = createPromiseCapability();
  49344. this._requests.push(requestCapability);
  49345. return requestCapability.promise;
  49346. },
  49347. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  49348. this._done = true;
  49349. this._requests.forEach(function (requestCapability) {
  49350. requestCapability.resolve({
  49351. value: undefined,
  49352. done: true
  49353. });
  49354. });
  49355. this._requests = [];
  49356. this._stream._removeRangeReader(this);
  49357. }
  49358. };
  49359. return PDFWorkerStream;
  49360. }();
  49361. var PDFNetworkStream;
  49362. function setPDFNetworkStreamClass(cls) {
  49363. PDFNetworkStream = cls;
  49364. }
  49365. var WorkerMessageHandler = {
  49366. setup: function wphSetup(handler, port) {
  49367. var testMessageProcessed = false;
  49368. handler.on('test', function wphSetupTest(data) {
  49369. if (testMessageProcessed) {
  49370. return;
  49371. }
  49372. testMessageProcessed = true;
  49373. if (!(data instanceof Uint8Array)) {
  49374. handler.send('test', 'main', false);
  49375. return;
  49376. }
  49377. var supportTransfers = data[0] === 255;
  49378. handler.postMessageTransfers = supportTransfers;
  49379. var xhr = new XMLHttpRequest();
  49380. var responseExists = 'response' in xhr;
  49381. try {
  49382. var dummy = xhr.responseType;
  49383. } catch (e) {
  49384. responseExists = false;
  49385. }
  49386. if (!responseExists) {
  49387. handler.send('test', false);
  49388. return;
  49389. }
  49390. handler.send('test', {
  49391. supportTypedArray: true,
  49392. supportTransfers: supportTransfers
  49393. });
  49394. });
  49395. handler.on('configure', function wphConfigure(data) {
  49396. setVerbosityLevel(data.verbosity);
  49397. });
  49398. handler.on('GetDocRequest', function wphSetupDoc(data) {
  49399. return WorkerMessageHandler.createDocumentHandler(data, port);
  49400. });
  49401. },
  49402. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  49403. var pdfManager;
  49404. var terminated = false;
  49405. var cancelXHRs = null;
  49406. var WorkerTasks = [];
  49407. var docId = docParams.docId;
  49408. var docBaseUrl = docParams.docBaseUrl;
  49409. var workerHandlerName = docParams.docId + '_worker';
  49410. var handler = new MessageHandler(workerHandlerName, docId, port);
  49411. handler.postMessageTransfers = docParams.postMessageTransfers;
  49412. function ensureNotTerminated() {
  49413. if (terminated) {
  49414. throw new Error('Worker was terminated');
  49415. }
  49416. }
  49417. function startWorkerTask(task) {
  49418. WorkerTasks.push(task);
  49419. }
  49420. function finishWorkerTask(task) {
  49421. task.finish();
  49422. var i = WorkerTasks.indexOf(task);
  49423. WorkerTasks.splice(i, 1);
  49424. }
  49425. function loadDocument(recoveryMode) {
  49426. var loadDocumentCapability = createPromiseCapability();
  49427. var parseSuccess = function parseSuccess() {
  49428. var numPagesPromise = pdfManager.ensureDoc('numPages');
  49429. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  49430. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  49431. Promise.all([
  49432. numPagesPromise,
  49433. fingerprintPromise,
  49434. encryptedPromise
  49435. ]).then(function onDocReady(results) {
  49436. var doc = {
  49437. numPages: results[0],
  49438. fingerprint: results[1],
  49439. encrypted: !!results[2]
  49440. };
  49441. loadDocumentCapability.resolve(doc);
  49442. }, parseFailure);
  49443. };
  49444. var parseFailure = function parseFailure(e) {
  49445. loadDocumentCapability.reject(e);
  49446. };
  49447. pdfManager.ensureDoc('checkHeader', []).then(function () {
  49448. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  49449. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  49450. }, parseFailure);
  49451. }, parseFailure);
  49452. return loadDocumentCapability.promise;
  49453. }
  49454. function getPdfManager(data, evaluatorOptions) {
  49455. var pdfManagerCapability = createPromiseCapability();
  49456. var pdfManager;
  49457. var source = data.source;
  49458. if (source.data) {
  49459. try {
  49460. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  49461. pdfManagerCapability.resolve(pdfManager);
  49462. } catch (ex) {
  49463. pdfManagerCapability.reject(ex);
  49464. }
  49465. return pdfManagerCapability.promise;
  49466. }
  49467. var pdfStream;
  49468. try {
  49469. if (source.chunkedViewerLoading) {
  49470. pdfStream = new PDFWorkerStream(source, handler);
  49471. } else {
  49472. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  49473. pdfStream = new PDFNetworkStream(data);
  49474. }
  49475. } catch (ex) {
  49476. pdfManagerCapability.reject(ex);
  49477. return pdfManagerCapability.promise;
  49478. }
  49479. var fullRequest = pdfStream.getFullReader();
  49480. fullRequest.headersReady.then(function () {
  49481. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  49482. fullRequest.onProgress = function (evt) {
  49483. handler.send('DocProgress', {
  49484. loaded: evt.loaded,
  49485. total: evt.total
  49486. });
  49487. };
  49488. }
  49489. if (!fullRequest.isRangeSupported) {
  49490. return;
  49491. }
  49492. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  49493. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  49494. msgHandler: handler,
  49495. url: source.url,
  49496. password: source.password,
  49497. length: fullRequest.contentLength,
  49498. disableAutoFetch: disableAutoFetch,
  49499. rangeChunkSize: source.rangeChunkSize
  49500. }, evaluatorOptions, docBaseUrl);
  49501. pdfManagerCapability.resolve(pdfManager);
  49502. cancelXHRs = null;
  49503. }).catch(function (reason) {
  49504. pdfManagerCapability.reject(reason);
  49505. cancelXHRs = null;
  49506. });
  49507. var cachedChunks = [], loaded = 0;
  49508. var flushChunks = function () {
  49509. var pdfFile = arraysToBytes(cachedChunks);
  49510. if (source.length && pdfFile.length !== source.length) {
  49511. warn('reported HTTP length is different from actual');
  49512. }
  49513. try {
  49514. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  49515. pdfManagerCapability.resolve(pdfManager);
  49516. } catch (ex) {
  49517. pdfManagerCapability.reject(ex);
  49518. }
  49519. cachedChunks = [];
  49520. };
  49521. var readPromise = new Promise(function (resolve, reject) {
  49522. var readChunk = function (chunk) {
  49523. try {
  49524. ensureNotTerminated();
  49525. if (chunk.done) {
  49526. if (!pdfManager) {
  49527. flushChunks();
  49528. }
  49529. cancelXHRs = null;
  49530. return;
  49531. }
  49532. var data = chunk.value;
  49533. loaded += arrayByteLength(data);
  49534. if (!fullRequest.isStreamingSupported) {
  49535. handler.send('DocProgress', {
  49536. loaded: loaded,
  49537. total: Math.max(loaded, fullRequest.contentLength || 0)
  49538. });
  49539. }
  49540. if (pdfManager) {
  49541. pdfManager.sendProgressiveData(data);
  49542. } else {
  49543. cachedChunks.push(data);
  49544. }
  49545. fullRequest.read().then(readChunk, reject);
  49546. } catch (e) {
  49547. reject(e);
  49548. }
  49549. };
  49550. fullRequest.read().then(readChunk, reject);
  49551. });
  49552. readPromise.catch(function (e) {
  49553. pdfManagerCapability.reject(e);
  49554. cancelXHRs = null;
  49555. });
  49556. cancelXHRs = function () {
  49557. pdfStream.cancelAllRequests('abort');
  49558. };
  49559. return pdfManagerCapability.promise;
  49560. }
  49561. var setupDoc = function (data) {
  49562. var onSuccess = function (doc) {
  49563. ensureNotTerminated();
  49564. handler.send('GetDoc', { pdfInfo: doc });
  49565. };
  49566. var onFailure = function (e) {
  49567. if (e instanceof PasswordException) {
  49568. if (e.code === PasswordResponses.NEED_PASSWORD) {
  49569. handler.send('NeedPassword', e);
  49570. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  49571. handler.send('IncorrectPassword', e);
  49572. }
  49573. } else if (e instanceof InvalidPDFException) {
  49574. handler.send('InvalidPDF', e);
  49575. } else if (e instanceof MissingPDFException) {
  49576. handler.send('MissingPDF', e);
  49577. } else if (e instanceof UnexpectedResponseException) {
  49578. handler.send('UnexpectedResponse', e);
  49579. } else {
  49580. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  49581. }
  49582. };
  49583. ensureNotTerminated();
  49584. var cMapOptions = {
  49585. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  49586. packed: data.cMapPacked === true
  49587. };
  49588. var evaluatorOptions = {
  49589. forceDataSchema: data.disableCreateObjectURL,
  49590. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  49591. disableFontFace: data.disableFontFace,
  49592. cMapOptions: cMapOptions
  49593. };
  49594. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  49595. if (terminated) {
  49596. newPdfManager.terminate();
  49597. throw new Error('Worker was terminated');
  49598. }
  49599. pdfManager = newPdfManager;
  49600. handler.send('PDFManagerReady', null);
  49601. pdfManager.onLoadedStream().then(function (stream) {
  49602. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  49603. });
  49604. }).then(function pdfManagerReady() {
  49605. ensureNotTerminated();
  49606. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  49607. ensureNotTerminated();
  49608. if (!(ex instanceof XRefParseException)) {
  49609. if (ex instanceof PasswordException) {
  49610. pdfManager.passwordChanged().then(pdfManagerReady);
  49611. }
  49612. onFailure(ex);
  49613. return;
  49614. }
  49615. pdfManager.requestLoadedStream();
  49616. pdfManager.onLoadedStream().then(function () {
  49617. ensureNotTerminated();
  49618. loadDocument(true).then(onSuccess, onFailure);
  49619. });
  49620. }, onFailure);
  49621. }, onFailure);
  49622. };
  49623. handler.on('GetPage', function wphSetupGetPage(data) {
  49624. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49625. var rotatePromise = pdfManager.ensure(page, 'rotate');
  49626. var refPromise = pdfManager.ensure(page, 'ref');
  49627. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  49628. var viewPromise = pdfManager.ensure(page, 'view');
  49629. return Promise.all([
  49630. rotatePromise,
  49631. refPromise,
  49632. userUnitPromise,
  49633. viewPromise
  49634. ]).then(function (results) {
  49635. return {
  49636. rotate: results[0],
  49637. ref: results[1],
  49638. userUnit: results[2],
  49639. view: results[3]
  49640. };
  49641. });
  49642. });
  49643. });
  49644. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  49645. var ref = new Ref(data.ref.num, data.ref.gen);
  49646. var catalog = pdfManager.pdfDocument.catalog;
  49647. return catalog.getPageIndex(ref);
  49648. });
  49649. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  49650. return pdfManager.ensureCatalog('destinations');
  49651. });
  49652. handler.on('GetDestination', function wphSetupGetDestination(data) {
  49653. return pdfManager.ensureCatalog('getDestination', [data.id]);
  49654. });
  49655. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  49656. return pdfManager.ensureCatalog('pageLabels');
  49657. });
  49658. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  49659. return pdfManager.ensureCatalog('attachments');
  49660. });
  49661. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  49662. return pdfManager.ensureCatalog('javaScript');
  49663. });
  49664. handler.on('GetOutline', function wphSetupGetOutline(data) {
  49665. return pdfManager.ensureCatalog('documentOutline');
  49666. });
  49667. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  49668. return Promise.all([
  49669. pdfManager.ensureDoc('documentInfo'),
  49670. pdfManager.ensureCatalog('metadata')
  49671. ]);
  49672. });
  49673. handler.on('GetData', function wphSetupGetData(data) {
  49674. pdfManager.requestLoadedStream();
  49675. return pdfManager.onLoadedStream().then(function (stream) {
  49676. return stream.bytes;
  49677. });
  49678. });
  49679. handler.on('GetStats', function wphSetupGetStats(data) {
  49680. return pdfManager.pdfDocument.xref.stats;
  49681. });
  49682. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  49683. pdfManager.updatePassword(data);
  49684. });
  49685. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  49686. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49687. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  49688. });
  49689. });
  49690. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  49691. var pageIndex = data.pageIndex;
  49692. pdfManager.getPage(pageIndex).then(function (page) {
  49693. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  49694. startWorkerTask(task);
  49695. var pageNum = pageIndex + 1;
  49696. var start = Date.now();
  49697. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  49698. finishWorkerTask(task);
  49699. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  49700. }, function (e) {
  49701. finishWorkerTask(task);
  49702. if (task.terminated) {
  49703. return;
  49704. }
  49705. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  49706. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  49707. var wrappedException;
  49708. if (typeof e === 'string') {
  49709. wrappedException = {
  49710. message: e,
  49711. stack: minimumStackMessage
  49712. };
  49713. } else if (typeof e === 'object') {
  49714. wrappedException = {
  49715. message: e.message || e.toString(),
  49716. stack: e.stack || minimumStackMessage
  49717. };
  49718. } else {
  49719. wrappedException = {
  49720. message: 'Unknown exception type: ' + typeof e,
  49721. stack: minimumStackMessage
  49722. };
  49723. }
  49724. handler.send('PageError', {
  49725. pageNum: pageNum,
  49726. error: wrappedException,
  49727. intent: data.intent
  49728. });
  49729. });
  49730. });
  49731. }, this);
  49732. handler.on('GetTextContent', function wphExtractText(data) {
  49733. var pageIndex = data.pageIndex;
  49734. var normalizeWhitespace = data.normalizeWhitespace;
  49735. var combineTextItems = data.combineTextItems;
  49736. return pdfManager.getPage(pageIndex).then(function (page) {
  49737. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  49738. startWorkerTask(task);
  49739. var pageNum = pageIndex + 1;
  49740. var start = Date.now();
  49741. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  49742. finishWorkerTask(task);
  49743. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  49744. return textContent;
  49745. }, function (reason) {
  49746. finishWorkerTask(task);
  49747. if (task.terminated) {
  49748. return;
  49749. }
  49750. throw reason;
  49751. });
  49752. });
  49753. });
  49754. handler.on('Cleanup', function wphCleanup(data) {
  49755. return pdfManager.cleanup();
  49756. });
  49757. handler.on('Terminate', function wphTerminate(data) {
  49758. terminated = true;
  49759. if (pdfManager) {
  49760. pdfManager.terminate();
  49761. pdfManager = null;
  49762. }
  49763. if (cancelXHRs) {
  49764. cancelXHRs();
  49765. }
  49766. var waitOn = [];
  49767. WorkerTasks.forEach(function (task) {
  49768. waitOn.push(task.finished);
  49769. task.terminate();
  49770. });
  49771. return Promise.all(waitOn).then(function () {
  49772. handler.destroy();
  49773. handler = null;
  49774. });
  49775. });
  49776. handler.on('Ready', function wphReady(data) {
  49777. setupDoc(docParams);
  49778. docParams = null;
  49779. });
  49780. return workerHandlerName;
  49781. }
  49782. };
  49783. function initializeWorker() {
  49784. if (!('console' in globalScope)) {
  49785. var consoleTimer = {};
  49786. var workerConsole = {
  49787. log: function log() {
  49788. var args = Array.prototype.slice.call(arguments);
  49789. globalScope.postMessage({
  49790. targetName: 'main',
  49791. action: 'console_log',
  49792. data: args
  49793. });
  49794. },
  49795. error: function error() {
  49796. var args = Array.prototype.slice.call(arguments);
  49797. globalScope.postMessage({
  49798. targetName: 'main',
  49799. action: 'console_error',
  49800. data: args
  49801. });
  49802. throw 'pdf.js execution error';
  49803. },
  49804. time: function time(name) {
  49805. consoleTimer[name] = Date.now();
  49806. },
  49807. timeEnd: function timeEnd(name) {
  49808. var time = consoleTimer[name];
  49809. if (!time) {
  49810. error('Unknown timer name ' + name);
  49811. }
  49812. this.log('Timer:', name, Date.now() - time);
  49813. }
  49814. };
  49815. globalScope.console = workerConsole;
  49816. }
  49817. var handler = new MessageHandler('worker', 'main', self);
  49818. WorkerMessageHandler.setup(handler, self);
  49819. handler.send('ready', null);
  49820. }
  49821. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  49822. initializeWorker();
  49823. }
  49824. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  49825. exports.WorkerTask = WorkerTask;
  49826. exports.WorkerMessageHandler = WorkerMessageHandler;
  49827. }));
  49828. (function (root, factory) {
  49829. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  49830. }(this, function (exports, sharedUtil, coreWorker) {
  49831. var OK_RESPONSE = 200;
  49832. var PARTIAL_CONTENT_RESPONSE = 206;
  49833. function NetworkManager(url, args) {
  49834. this.url = url;
  49835. args = args || {};
  49836. this.isHttp = /^https?:/i.test(url);
  49837. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  49838. this.withCredentials = args.withCredentials || false;
  49839. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  49840. return new XMLHttpRequest();
  49841. };
  49842. this.currXhrId = 0;
  49843. this.pendingRequests = Object.create(null);
  49844. this.loadedRequests = Object.create(null);
  49845. }
  49846. function getArrayBuffer(xhr) {
  49847. var data = xhr.response;
  49848. if (typeof data !== 'string') {
  49849. return data;
  49850. }
  49851. var length = data.length;
  49852. var array = new Uint8Array(length);
  49853. for (var i = 0; i < length; i++) {
  49854. array[i] = data.charCodeAt(i) & 0xFF;
  49855. }
  49856. return array.buffer;
  49857. }
  49858. var supportsMozChunked = function supportsMozChunkedClosure() {
  49859. try {
  49860. var x = new XMLHttpRequest();
  49861. x.open('GET', 'https://example.com');
  49862. x.responseType = 'moz-chunked-arraybuffer';
  49863. return x.responseType === 'moz-chunked-arraybuffer';
  49864. } catch (e) {
  49865. return false;
  49866. }
  49867. }();
  49868. NetworkManager.prototype = {
  49869. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  49870. var args = {
  49871. begin: begin,
  49872. end: end
  49873. };
  49874. for (var prop in listeners) {
  49875. args[prop] = listeners[prop];
  49876. }
  49877. return this.request(args);
  49878. },
  49879. requestFull: function NetworkManager_requestFull(listeners) {
  49880. return this.request(listeners);
  49881. },
  49882. request: function NetworkManager_request(args) {
  49883. var xhr = this.getXhr();
  49884. var xhrId = this.currXhrId++;
  49885. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  49886. xhr.open('GET', this.url);
  49887. xhr.withCredentials = this.withCredentials;
  49888. for (var property in this.httpHeaders) {
  49889. var value = this.httpHeaders[property];
  49890. if (typeof value === 'undefined') {
  49891. continue;
  49892. }
  49893. xhr.setRequestHeader(property, value);
  49894. }
  49895. if (this.isHttp && 'begin' in args && 'end' in args) {
  49896. var rangeStr = args.begin + '-' + (args.end - 1);
  49897. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  49898. pendingRequest.expectedStatus = 206;
  49899. } else {
  49900. pendingRequest.expectedStatus = 200;
  49901. }
  49902. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  49903. if (useMozChunkedLoading) {
  49904. xhr.responseType = 'moz-chunked-arraybuffer';
  49905. pendingRequest.onProgressiveData = args.onProgressiveData;
  49906. pendingRequest.mozChunked = true;
  49907. } else {
  49908. xhr.responseType = 'arraybuffer';
  49909. }
  49910. if (args.onError) {
  49911. xhr.onerror = function (evt) {
  49912. args.onError(xhr.status);
  49913. };
  49914. }
  49915. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  49916. xhr.onprogress = this.onProgress.bind(this, xhrId);
  49917. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  49918. pendingRequest.onDone = args.onDone;
  49919. pendingRequest.onError = args.onError;
  49920. pendingRequest.onProgress = args.onProgress;
  49921. xhr.send(null);
  49922. return xhrId;
  49923. },
  49924. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  49925. var pendingRequest = this.pendingRequests[xhrId];
  49926. if (!pendingRequest) {
  49927. return;
  49928. }
  49929. if (pendingRequest.mozChunked) {
  49930. var chunk = getArrayBuffer(pendingRequest.xhr);
  49931. pendingRequest.onProgressiveData(chunk);
  49932. }
  49933. var onProgress = pendingRequest.onProgress;
  49934. if (onProgress) {
  49935. onProgress(evt);
  49936. }
  49937. },
  49938. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  49939. var pendingRequest = this.pendingRequests[xhrId];
  49940. if (!pendingRequest) {
  49941. return;
  49942. }
  49943. var xhr = pendingRequest.xhr;
  49944. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  49945. pendingRequest.onHeadersReceived();
  49946. delete pendingRequest.onHeadersReceived;
  49947. }
  49948. if (xhr.readyState !== 4) {
  49949. return;
  49950. }
  49951. if (!(xhrId in this.pendingRequests)) {
  49952. return;
  49953. }
  49954. delete this.pendingRequests[xhrId];
  49955. if (xhr.status === 0 && this.isHttp) {
  49956. if (pendingRequest.onError) {
  49957. pendingRequest.onError(xhr.status);
  49958. }
  49959. return;
  49960. }
  49961. var xhrStatus = xhr.status || OK_RESPONSE;
  49962. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  49963. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  49964. if (pendingRequest.onError) {
  49965. pendingRequest.onError(xhr.status);
  49966. }
  49967. return;
  49968. }
  49969. this.loadedRequests[xhrId] = true;
  49970. var chunk = getArrayBuffer(xhr);
  49971. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  49972. var rangeHeader = xhr.getResponseHeader('Content-Range');
  49973. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  49974. var begin = parseInt(matches[1], 10);
  49975. pendingRequest.onDone({
  49976. begin: begin,
  49977. chunk: chunk
  49978. });
  49979. } else if (pendingRequest.onProgressiveData) {
  49980. pendingRequest.onDone(null);
  49981. } else if (chunk) {
  49982. pendingRequest.onDone({
  49983. begin: 0,
  49984. chunk: chunk
  49985. });
  49986. } else if (pendingRequest.onError) {
  49987. pendingRequest.onError(xhr.status);
  49988. }
  49989. },
  49990. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  49991. for (var xhrId in this.pendingRequests) {
  49992. return true;
  49993. }
  49994. return false;
  49995. },
  49996. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  49997. return this.pendingRequests[xhrId].xhr;
  49998. },
  49999. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  50000. return !!this.pendingRequests[xhrId].onProgressiveData;
  50001. },
  50002. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  50003. return xhrId in this.pendingRequests;
  50004. },
  50005. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  50006. return xhrId in this.loadedRequests;
  50007. },
  50008. abortAllRequests: function NetworkManager_abortAllRequests() {
  50009. for (var xhrId in this.pendingRequests) {
  50010. this.abortRequest(xhrId | 0);
  50011. }
  50012. },
  50013. abortRequest: function NetworkManager_abortRequest(xhrId) {
  50014. var xhr = this.pendingRequests[xhrId].xhr;
  50015. delete this.pendingRequests[xhrId];
  50016. xhr.abort();
  50017. }
  50018. };
  50019. var assert = sharedUtil.assert;
  50020. var createPromiseCapability = sharedUtil.createPromiseCapability;
  50021. var isInt = sharedUtil.isInt;
  50022. var MissingPDFException = sharedUtil.MissingPDFException;
  50023. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  50024. function PDFNetworkStream(options) {
  50025. this._options = options;
  50026. var source = options.source;
  50027. this._manager = new NetworkManager(source.url, {
  50028. httpHeaders: source.httpHeaders,
  50029. withCredentials: source.withCredentials
  50030. });
  50031. this._rangeChunkSize = source.rangeChunkSize;
  50032. this._fullRequestReader = null;
  50033. this._rangeRequestReaders = [];
  50034. }
  50035. PDFNetworkStream.prototype = {
  50036. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  50037. var i = this._rangeRequestReaders.indexOf(reader);
  50038. if (i >= 0) {
  50039. this._rangeRequestReaders.splice(i, 1);
  50040. }
  50041. },
  50042. getFullReader: function PDFNetworkStream_getFullReader() {
  50043. assert(!this._fullRequestReader);
  50044. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  50045. return this._fullRequestReader;
  50046. },
  50047. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  50048. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  50049. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  50050. this._rangeRequestReaders.push(reader);
  50051. return reader;
  50052. },
  50053. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  50054. if (this._fullRequestReader) {
  50055. this._fullRequestReader.cancel(reason);
  50056. }
  50057. var readers = this._rangeRequestReaders.slice(0);
  50058. readers.forEach(function (reader) {
  50059. reader.cancel(reason);
  50060. });
  50061. }
  50062. };
  50063. function PDFNetworkStreamFullRequestReader(manager, options) {
  50064. this._manager = manager;
  50065. var source = options.source;
  50066. var args = {
  50067. onHeadersReceived: this._onHeadersReceived.bind(this),
  50068. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  50069. onDone: this._onDone.bind(this),
  50070. onError: this._onError.bind(this),
  50071. onProgress: this._onProgress.bind(this)
  50072. };
  50073. this._url = source.url;
  50074. this._fullRequestId = manager.requestFull(args);
  50075. this._headersReceivedCapability = createPromiseCapability();
  50076. this._disableRange = options.disableRange || false;
  50077. this._contentLength = source.length;
  50078. this._rangeChunkSize = source.rangeChunkSize;
  50079. if (!this._rangeChunkSize && !this._disableRange) {
  50080. this._disableRange = true;
  50081. }
  50082. this._isStreamingSupported = false;
  50083. this._isRangeSupported = false;
  50084. this._cachedChunks = [];
  50085. this._requests = [];
  50086. this._done = false;
  50087. this._storedError = undefined;
  50088. this.onProgress = null;
  50089. }
  50090. PDFNetworkStreamFullRequestReader.prototype = {
  50091. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  50092. if (this._disableRange) {
  50093. return false;
  50094. }
  50095. var networkManager = this._manager;
  50096. if (!networkManager.isHttp) {
  50097. return false;
  50098. }
  50099. var fullRequestXhrId = this._fullRequestId;
  50100. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  50101. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  50102. return false;
  50103. }
  50104. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  50105. if (contentEncoding !== 'identity') {
  50106. return false;
  50107. }
  50108. var length = fullRequestXhr.getResponseHeader('Content-Length');
  50109. length = parseInt(length, 10);
  50110. if (!isInt(length)) {
  50111. return false;
  50112. }
  50113. this._contentLength = length;
  50114. if (length <= 2 * this._rangeChunkSize) {
  50115. return false;
  50116. }
  50117. return true;
  50118. },
  50119. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  50120. if (this._validateRangeRequestCapabilities()) {
  50121. this._isRangeSupported = true;
  50122. }
  50123. var networkManager = this._manager;
  50124. var fullRequestXhrId = this._fullRequestId;
  50125. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  50126. this._isStreamingSupported = true;
  50127. } else if (this._isRangeSupported) {
  50128. networkManager.abortRequest(fullRequestXhrId);
  50129. }
  50130. this._headersReceivedCapability.resolve();
  50131. },
  50132. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  50133. if (this._requests.length > 0) {
  50134. var requestCapability = this._requests.shift();
  50135. requestCapability.resolve({
  50136. value: chunk,
  50137. done: false
  50138. });
  50139. } else {
  50140. this._cachedChunks.push(chunk);
  50141. }
  50142. },
  50143. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  50144. if (args) {
  50145. this._onProgressiveData(args.chunk);
  50146. }
  50147. this._done = true;
  50148. if (this._cachedChunks.length > 0) {
  50149. return;
  50150. }
  50151. this._requests.forEach(function (requestCapability) {
  50152. requestCapability.resolve({
  50153. value: undefined,
  50154. done: true
  50155. });
  50156. });
  50157. this._requests = [];
  50158. },
  50159. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  50160. var url = this._url;
  50161. var exception;
  50162. if (status === 404 || status === 0 && /^file:/.test(url)) {
  50163. exception = new MissingPDFException('Missing PDF "' + url + '".');
  50164. } else {
  50165. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  50166. }
  50167. this._storedError = exception;
  50168. this._headersReceivedCapability.reject(exception);
  50169. this._requests.forEach(function (requestCapability) {
  50170. requestCapability.reject(exception);
  50171. });
  50172. this._requests = [];
  50173. this._cachedChunks = [];
  50174. },
  50175. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  50176. if (this.onProgress) {
  50177. this.onProgress({
  50178. loaded: data.loaded,
  50179. total: data.lengthComputable ? data.total : this._contentLength
  50180. });
  50181. }
  50182. },
  50183. get isRangeSupported() {
  50184. return this._isRangeSupported;
  50185. },
  50186. get isStreamingSupported() {
  50187. return this._isStreamingSupported;
  50188. },
  50189. get contentLength() {
  50190. return this._contentLength;
  50191. },
  50192. get headersReady() {
  50193. return this._headersReceivedCapability.promise;
  50194. },
  50195. read: function PDFNetworkStreamFullRequestReader_read() {
  50196. if (this._storedError) {
  50197. return Promise.reject(this._storedError);
  50198. }
  50199. if (this._cachedChunks.length > 0) {
  50200. var chunk = this._cachedChunks.shift();
  50201. return Promise.resolve(chunk);
  50202. }
  50203. if (this._done) {
  50204. return Promise.resolve({
  50205. value: undefined,
  50206. done: true
  50207. });
  50208. }
  50209. var requestCapability = createPromiseCapability();
  50210. this._requests.push(requestCapability);
  50211. return requestCapability.promise;
  50212. },
  50213. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  50214. this._done = true;
  50215. this._headersReceivedCapability.reject(reason);
  50216. this._requests.forEach(function (requestCapability) {
  50217. requestCapability.resolve({
  50218. value: undefined,
  50219. done: true
  50220. });
  50221. });
  50222. this._requests = [];
  50223. if (this._manager.isPendingRequest(this._fullRequestId)) {
  50224. this._manager.abortRequest(this._fullRequestId);
  50225. }
  50226. this._fullRequestReader = null;
  50227. }
  50228. };
  50229. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  50230. this._manager = manager;
  50231. var args = {
  50232. onDone: this._onDone.bind(this),
  50233. onProgress: this._onProgress.bind(this)
  50234. };
  50235. this._requestId = manager.requestRange(begin, end, args);
  50236. this._requests = [];
  50237. this._queuedChunk = null;
  50238. this._done = false;
  50239. this.onProgress = null;
  50240. this.onClosed = null;
  50241. }
  50242. PDFNetworkStreamRangeRequestReader.prototype = {
  50243. _close: function PDFNetworkStreamRangeRequestReader_close() {
  50244. if (this.onClosed) {
  50245. this.onClosed(this);
  50246. }
  50247. },
  50248. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  50249. var chunk = data.chunk;
  50250. if (this._requests.length > 0) {
  50251. var requestCapability = this._requests.shift();
  50252. requestCapability.resolve({
  50253. value: chunk,
  50254. done: false
  50255. });
  50256. } else {
  50257. this._queuedChunk = chunk;
  50258. }
  50259. this._done = true;
  50260. this._requests.forEach(function (requestCapability) {
  50261. requestCapability.resolve({
  50262. value: undefined,
  50263. done: true
  50264. });
  50265. });
  50266. this._requests = [];
  50267. this._close();
  50268. },
  50269. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  50270. if (!this.isStreamingSupported && this.onProgress) {
  50271. this.onProgress({ loaded: evt.loaded });
  50272. }
  50273. },
  50274. get isStreamingSupported() {
  50275. return false;
  50276. },
  50277. read: function PDFNetworkStreamRangeRequestReader_read() {
  50278. if (this._queuedChunk !== null) {
  50279. var chunk = this._queuedChunk;
  50280. this._queuedChunk = null;
  50281. return Promise.resolve({
  50282. value: chunk,
  50283. done: false
  50284. });
  50285. }
  50286. if (this._done) {
  50287. return Promise.resolve({
  50288. value: undefined,
  50289. done: true
  50290. });
  50291. }
  50292. var requestCapability = createPromiseCapability();
  50293. this._requests.push(requestCapability);
  50294. return requestCapability.promise;
  50295. },
  50296. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  50297. this._done = true;
  50298. this._requests.forEach(function (requestCapability) {
  50299. requestCapability.resolve({
  50300. value: undefined,
  50301. done: true
  50302. });
  50303. });
  50304. this._requests = [];
  50305. if (this._manager.isPendingRequest(this._requestId)) {
  50306. this._manager.abortRequest(this._requestId);
  50307. }
  50308. this._close();
  50309. }
  50310. };
  50311. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  50312. exports.PDFNetworkStream = PDFNetworkStream;
  50313. exports.NetworkManager = NetworkManager;
  50314. }));
  50315. }.call(pdfjsLibs));
  50316. exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  50317. }));