pdf.worker.js 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346
  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.365';
  27. var pdfjsBuild = 'fa6b9b7';
  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. var mode;
  41284. if (isName(cs)) {
  41285. mode = cs.name;
  41286. this.mode = mode;
  41287. switch (mode) {
  41288. case 'DeviceGray':
  41289. case 'G':
  41290. return 'DeviceGrayCS';
  41291. case 'DeviceRGB':
  41292. case 'RGB':
  41293. return 'DeviceRgbCS';
  41294. case 'DeviceCMYK':
  41295. case 'CMYK':
  41296. return 'DeviceCmykCS';
  41297. case 'Pattern':
  41298. return [
  41299. 'PatternCS',
  41300. null
  41301. ];
  41302. default:
  41303. error('unrecognized colorspace ' + mode);
  41304. }
  41305. } else if (isArray(cs)) {
  41306. mode = xref.fetchIfRef(cs[0]).name;
  41307. this.mode = mode;
  41308. var numComps, params, alt, whitePoint, blackPoint, gamma;
  41309. switch (mode) {
  41310. case 'DeviceGray':
  41311. case 'G':
  41312. return 'DeviceGrayCS';
  41313. case 'DeviceRGB':
  41314. case 'RGB':
  41315. return 'DeviceRgbCS';
  41316. case 'DeviceCMYK':
  41317. case 'CMYK':
  41318. return 'DeviceCmykCS';
  41319. case 'CalGray':
  41320. params = xref.fetchIfRef(cs[1]);
  41321. whitePoint = params.getArray('WhitePoint');
  41322. blackPoint = params.getArray('BlackPoint');
  41323. gamma = params.get('Gamma');
  41324. return [
  41325. 'CalGrayCS',
  41326. whitePoint,
  41327. blackPoint,
  41328. gamma
  41329. ];
  41330. case 'CalRGB':
  41331. params = xref.fetchIfRef(cs[1]);
  41332. whitePoint = params.getArray('WhitePoint');
  41333. blackPoint = params.getArray('BlackPoint');
  41334. gamma = params.getArray('Gamma');
  41335. var matrix = params.getArray('Matrix');
  41336. return [
  41337. 'CalRGBCS',
  41338. whitePoint,
  41339. blackPoint,
  41340. gamma,
  41341. matrix
  41342. ];
  41343. case 'ICCBased':
  41344. var stream = xref.fetchIfRef(cs[1]);
  41345. var dict = stream.dict;
  41346. numComps = dict.get('N');
  41347. alt = dict.get('Alternate');
  41348. if (alt) {
  41349. var altIR = ColorSpace.parseToIR(alt, xref, res);
  41350. var altCS = ColorSpace.fromIR(altIR);
  41351. if (altCS.numComps === numComps) {
  41352. return altIR;
  41353. }
  41354. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  41355. }
  41356. if (numComps === 1) {
  41357. return 'DeviceGrayCS';
  41358. } else if (numComps === 3) {
  41359. return 'DeviceRgbCS';
  41360. } else if (numComps === 4) {
  41361. return 'DeviceCmykCS';
  41362. }
  41363. break;
  41364. case 'Pattern':
  41365. var basePatternCS = cs[1] || null;
  41366. if (basePatternCS) {
  41367. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  41368. }
  41369. return [
  41370. 'PatternCS',
  41371. basePatternCS
  41372. ];
  41373. case 'Indexed':
  41374. case 'I':
  41375. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  41376. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  41377. var lookup = xref.fetchIfRef(cs[3]);
  41378. if (isStream(lookup)) {
  41379. lookup = lookup.getBytes();
  41380. }
  41381. return [
  41382. 'IndexedCS',
  41383. baseIndexedCS,
  41384. hiVal,
  41385. lookup
  41386. ];
  41387. case 'Separation':
  41388. case 'DeviceN':
  41389. var name = xref.fetchIfRef(cs[1]);
  41390. numComps = 1;
  41391. if (isName(name)) {
  41392. numComps = 1;
  41393. } else if (isArray(name)) {
  41394. numComps = name.length;
  41395. }
  41396. alt = ColorSpace.parseToIR(cs[2], xref, res);
  41397. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  41398. return [
  41399. 'AlternateCS',
  41400. numComps,
  41401. alt,
  41402. tintFnIR
  41403. ];
  41404. case 'Lab':
  41405. params = xref.fetchIfRef(cs[1]);
  41406. whitePoint = params.getArray('WhitePoint');
  41407. blackPoint = params.getArray('BlackPoint');
  41408. var range = params.getArray('Range');
  41409. return [
  41410. 'LabCS',
  41411. whitePoint,
  41412. blackPoint,
  41413. range
  41414. ];
  41415. default:
  41416. error('unimplemented color space object "' + mode + '"');
  41417. }
  41418. } else {
  41419. error('unrecognized color space object: "' + cs + '"');
  41420. }
  41421. return null;
  41422. };
  41423. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  41424. if (!isArray(decode)) {
  41425. return true;
  41426. }
  41427. if (n * 2 !== decode.length) {
  41428. warn('The decode map is not the correct length');
  41429. return true;
  41430. }
  41431. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  41432. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  41433. return false;
  41434. }
  41435. }
  41436. return true;
  41437. };
  41438. ColorSpace.singletons = {
  41439. get gray() {
  41440. return shadow(this, 'gray', new DeviceGrayCS());
  41441. },
  41442. get rgb() {
  41443. return shadow(this, 'rgb', new DeviceRgbCS());
  41444. },
  41445. get cmyk() {
  41446. return shadow(this, 'cmyk', new DeviceCmykCS());
  41447. }
  41448. };
  41449. return ColorSpace;
  41450. }();
  41451. var AlternateCS = function AlternateCSClosure() {
  41452. function AlternateCS(numComps, base, tintFn) {
  41453. this.name = 'Alternate';
  41454. this.numComps = numComps;
  41455. this.defaultColor = new Float32Array(numComps);
  41456. for (var i = 0; i < numComps; ++i) {
  41457. this.defaultColor[i] = 1;
  41458. }
  41459. this.base = base;
  41460. this.tintFn = tintFn;
  41461. this.tmpBuf = new Float32Array(base.numComps);
  41462. }
  41463. AlternateCS.prototype = {
  41464. getRgb: ColorSpace.prototype.getRgb,
  41465. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41466. var tmpBuf = this.tmpBuf;
  41467. this.tintFn(src, srcOffset, tmpBuf, 0);
  41468. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  41469. },
  41470. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41471. var tintFn = this.tintFn;
  41472. var base = this.base;
  41473. var scale = 1 / ((1 << bits) - 1);
  41474. var baseNumComps = base.numComps;
  41475. var usesZeroToOneRange = base.usesZeroToOneRange;
  41476. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  41477. var pos = isPassthrough ? destOffset : 0;
  41478. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  41479. var numComps = this.numComps;
  41480. var scaled = new Float32Array(numComps);
  41481. var tinted = new Float32Array(baseNumComps);
  41482. var i, j;
  41483. if (usesZeroToOneRange) {
  41484. for (i = 0; i < count; i++) {
  41485. for (j = 0; j < numComps; j++) {
  41486. scaled[j] = src[srcOffset++] * scale;
  41487. }
  41488. tintFn(scaled, 0, tinted, 0);
  41489. for (j = 0; j < baseNumComps; j++) {
  41490. baseBuf[pos++] = tinted[j] * 255;
  41491. }
  41492. }
  41493. } else {
  41494. for (i = 0; i < count; i++) {
  41495. for (j = 0; j < numComps; j++) {
  41496. scaled[j] = src[srcOffset++] * scale;
  41497. }
  41498. tintFn(scaled, 0, tinted, 0);
  41499. base.getRgbItem(tinted, 0, baseBuf, pos);
  41500. pos += baseNumComps;
  41501. }
  41502. }
  41503. if (!isPassthrough) {
  41504. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  41505. }
  41506. },
  41507. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  41508. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  41509. },
  41510. isPassthrough: ColorSpace.prototype.isPassthrough,
  41511. fillRgb: ColorSpace.prototype.fillRgb,
  41512. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  41513. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41514. },
  41515. usesZeroToOneRange: true
  41516. };
  41517. return AlternateCS;
  41518. }();
  41519. var PatternCS = function PatternCSClosure() {
  41520. function PatternCS(baseCS) {
  41521. this.name = 'Pattern';
  41522. this.base = baseCS;
  41523. }
  41524. PatternCS.prototype = {};
  41525. return PatternCS;
  41526. }();
  41527. var IndexedCS = function IndexedCSClosure() {
  41528. function IndexedCS(base, highVal, lookup) {
  41529. this.name = 'Indexed';
  41530. this.numComps = 1;
  41531. this.defaultColor = new Uint8Array([0]);
  41532. this.base = base;
  41533. this.highVal = highVal;
  41534. var baseNumComps = base.numComps;
  41535. var length = baseNumComps * highVal;
  41536. var lookupArray;
  41537. if (isStream(lookup)) {
  41538. lookupArray = new Uint8Array(length);
  41539. var bytes = lookup.getBytes(length);
  41540. lookupArray.set(bytes);
  41541. } else if (isString(lookup)) {
  41542. lookupArray = new Uint8Array(length);
  41543. for (var i = 0; i < length; ++i) {
  41544. lookupArray[i] = lookup.charCodeAt(i);
  41545. }
  41546. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  41547. lookupArray = lookup;
  41548. } else {
  41549. error('Unrecognized lookup table: ' + lookup);
  41550. }
  41551. this.lookup = lookupArray;
  41552. }
  41553. IndexedCS.prototype = {
  41554. getRgb: ColorSpace.prototype.getRgb,
  41555. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41556. var numComps = this.base.numComps;
  41557. var start = src[srcOffset] * numComps;
  41558. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  41559. },
  41560. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41561. var base = this.base;
  41562. var numComps = base.numComps;
  41563. var outputDelta = base.getOutputLength(numComps, alpha01);
  41564. var lookup = this.lookup;
  41565. for (var i = 0; i < count; ++i) {
  41566. var lookupPos = src[srcOffset++] * numComps;
  41567. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  41568. destOffset += outputDelta;
  41569. }
  41570. },
  41571. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  41572. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  41573. },
  41574. isPassthrough: ColorSpace.prototype.isPassthrough,
  41575. fillRgb: ColorSpace.prototype.fillRgb,
  41576. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  41577. return true;
  41578. },
  41579. usesZeroToOneRange: true
  41580. };
  41581. return IndexedCS;
  41582. }();
  41583. var DeviceGrayCS = function DeviceGrayCSClosure() {
  41584. function DeviceGrayCS() {
  41585. this.name = 'DeviceGray';
  41586. this.numComps = 1;
  41587. this.defaultColor = new Float32Array([0]);
  41588. }
  41589. DeviceGrayCS.prototype = {
  41590. getRgb: ColorSpace.prototype.getRgb,
  41591. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41592. var c = src[srcOffset] * 255 | 0;
  41593. c = c < 0 ? 0 : c > 255 ? 255 : c;
  41594. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  41595. },
  41596. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41597. var scale = 255 / ((1 << bits) - 1);
  41598. var j = srcOffset, q = destOffset;
  41599. for (var i = 0; i < count; ++i) {
  41600. var c = scale * src[j++] | 0;
  41601. dest[q++] = c;
  41602. dest[q++] = c;
  41603. dest[q++] = c;
  41604. q += alpha01;
  41605. }
  41606. },
  41607. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  41608. return inputLength * (3 + alpha01);
  41609. },
  41610. isPassthrough: ColorSpace.prototype.isPassthrough,
  41611. fillRgb: ColorSpace.prototype.fillRgb,
  41612. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  41613. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41614. },
  41615. usesZeroToOneRange: true
  41616. };
  41617. return DeviceGrayCS;
  41618. }();
  41619. var DeviceRgbCS = function DeviceRgbCSClosure() {
  41620. function DeviceRgbCS() {
  41621. this.name = 'DeviceRGB';
  41622. this.numComps = 3;
  41623. this.defaultColor = new Float32Array([
  41624. 0,
  41625. 0,
  41626. 0
  41627. ]);
  41628. }
  41629. DeviceRgbCS.prototype = {
  41630. getRgb: ColorSpace.prototype.getRgb,
  41631. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41632. var r = src[srcOffset] * 255 | 0;
  41633. var g = src[srcOffset + 1] * 255 | 0;
  41634. var b = src[srcOffset + 2] * 255 | 0;
  41635. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  41636. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  41637. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  41638. },
  41639. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41640. if (bits === 8 && alpha01 === 0) {
  41641. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  41642. return;
  41643. }
  41644. var scale = 255 / ((1 << bits) - 1);
  41645. var j = srcOffset, q = destOffset;
  41646. for (var i = 0; i < count; ++i) {
  41647. dest[q++] = scale * src[j++] | 0;
  41648. dest[q++] = scale * src[j++] | 0;
  41649. dest[q++] = scale * src[j++] | 0;
  41650. q += alpha01;
  41651. }
  41652. },
  41653. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  41654. return inputLength * (3 + alpha01) / 3 | 0;
  41655. },
  41656. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  41657. return bits === 8;
  41658. },
  41659. fillRgb: ColorSpace.prototype.fillRgb,
  41660. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  41661. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41662. },
  41663. usesZeroToOneRange: true
  41664. };
  41665. return DeviceRgbCS;
  41666. }();
  41667. var DeviceCmykCS = function DeviceCmykCSClosure() {
  41668. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  41669. var c = src[srcOffset + 0] * srcScale;
  41670. var m = src[srcOffset + 1] * srcScale;
  41671. var y = src[srcOffset + 2] * srcScale;
  41672. var k = src[srcOffset + 3] * srcScale;
  41673. 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;
  41674. 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;
  41675. 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;
  41676. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  41677. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  41678. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  41679. }
  41680. function DeviceCmykCS() {
  41681. this.name = 'DeviceCMYK';
  41682. this.numComps = 4;
  41683. this.defaultColor = new Float32Array([
  41684. 0,
  41685. 0,
  41686. 0,
  41687. 1
  41688. ]);
  41689. }
  41690. DeviceCmykCS.prototype = {
  41691. getRgb: ColorSpace.prototype.getRgb,
  41692. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41693. convertToRgb(src, srcOffset, 1, dest, destOffset);
  41694. },
  41695. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41696. var scale = 1 / ((1 << bits) - 1);
  41697. for (var i = 0; i < count; i++) {
  41698. convertToRgb(src, srcOffset, scale, dest, destOffset);
  41699. srcOffset += 4;
  41700. destOffset += 3 + alpha01;
  41701. }
  41702. },
  41703. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  41704. return inputLength / 4 * (3 + alpha01) | 0;
  41705. },
  41706. isPassthrough: ColorSpace.prototype.isPassthrough,
  41707. fillRgb: ColorSpace.prototype.fillRgb,
  41708. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  41709. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41710. },
  41711. usesZeroToOneRange: true
  41712. };
  41713. return DeviceCmykCS;
  41714. }();
  41715. var CalGrayCS = function CalGrayCSClosure() {
  41716. function CalGrayCS(whitePoint, blackPoint, gamma) {
  41717. this.name = 'CalGray';
  41718. this.numComps = 1;
  41719. this.defaultColor = new Float32Array([0]);
  41720. if (!whitePoint) {
  41721. error('WhitePoint missing - required for color space CalGray');
  41722. }
  41723. blackPoint = blackPoint || [
  41724. 0,
  41725. 0,
  41726. 0
  41727. ];
  41728. gamma = gamma || 1;
  41729. this.XW = whitePoint[0];
  41730. this.YW = whitePoint[1];
  41731. this.ZW = whitePoint[2];
  41732. this.XB = blackPoint[0];
  41733. this.YB = blackPoint[1];
  41734. this.ZB = blackPoint[2];
  41735. this.G = gamma;
  41736. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  41737. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41738. }
  41739. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  41740. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  41741. this.XB = this.YB = this.ZB = 0;
  41742. }
  41743. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  41744. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  41745. }
  41746. if (this.G < 1) {
  41747. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  41748. this.G = 1;
  41749. }
  41750. }
  41751. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  41752. var A = src[srcOffset] * scale;
  41753. var AG = Math.pow(A, cs.G);
  41754. var L = cs.YW * AG;
  41755. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  41756. dest[destOffset] = val;
  41757. dest[destOffset + 1] = val;
  41758. dest[destOffset + 2] = val;
  41759. }
  41760. CalGrayCS.prototype = {
  41761. getRgb: ColorSpace.prototype.getRgb,
  41762. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41763. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  41764. },
  41765. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41766. var scale = 1 / ((1 << bits) - 1);
  41767. for (var i = 0; i < count; ++i) {
  41768. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  41769. srcOffset += 1;
  41770. destOffset += 3 + alpha01;
  41771. }
  41772. },
  41773. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  41774. return inputLength * (3 + alpha01);
  41775. },
  41776. isPassthrough: ColorSpace.prototype.isPassthrough,
  41777. fillRgb: ColorSpace.prototype.fillRgb,
  41778. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  41779. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41780. },
  41781. usesZeroToOneRange: true
  41782. };
  41783. return CalGrayCS;
  41784. }();
  41785. var CalRGBCS = function CalRGBCSClosure() {
  41786. var BRADFORD_SCALE_MATRIX = new Float32Array([
  41787. 0.8951,
  41788. 0.2664,
  41789. -0.1614,
  41790. -0.7502,
  41791. 1.7135,
  41792. 0.0367,
  41793. 0.0389,
  41794. -0.0685,
  41795. 1.0296
  41796. ]);
  41797. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  41798. 0.9869929,
  41799. -0.1470543,
  41800. 0.1599627,
  41801. 0.4323053,
  41802. 0.5183603,
  41803. 0.0492912,
  41804. -0.0085287,
  41805. 0.0400428,
  41806. 0.9684867
  41807. ]);
  41808. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  41809. 3.2404542,
  41810. -1.5371385,
  41811. -0.4985314,
  41812. -0.9692660,
  41813. 1.8760108,
  41814. 0.0415560,
  41815. 0.0556434,
  41816. -0.2040259,
  41817. 1.0572252
  41818. ]);
  41819. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  41820. 1,
  41821. 1,
  41822. 1
  41823. ]);
  41824. var tempNormalizeMatrix = new Float32Array(3);
  41825. var tempConvertMatrix1 = new Float32Array(3);
  41826. var tempConvertMatrix2 = new Float32Array(3);
  41827. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  41828. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  41829. this.name = 'CalRGB';
  41830. this.numComps = 3;
  41831. this.defaultColor = new Float32Array(3);
  41832. if (!whitePoint) {
  41833. error('WhitePoint missing - required for color space CalRGB');
  41834. }
  41835. blackPoint = blackPoint || new Float32Array(3);
  41836. gamma = gamma || new Float32Array([
  41837. 1,
  41838. 1,
  41839. 1
  41840. ]);
  41841. matrix = matrix || new Float32Array([
  41842. 1,
  41843. 0,
  41844. 0,
  41845. 0,
  41846. 1,
  41847. 0,
  41848. 0,
  41849. 0,
  41850. 1
  41851. ]);
  41852. var XW = whitePoint[0];
  41853. var YW = whitePoint[1];
  41854. var ZW = whitePoint[2];
  41855. this.whitePoint = whitePoint;
  41856. var XB = blackPoint[0];
  41857. var YB = blackPoint[1];
  41858. var ZB = blackPoint[2];
  41859. this.blackPoint = blackPoint;
  41860. this.GR = gamma[0];
  41861. this.GG = gamma[1];
  41862. this.GB = gamma[2];
  41863. this.MXA = matrix[0];
  41864. this.MYA = matrix[1];
  41865. this.MZA = matrix[2];
  41866. this.MXB = matrix[3];
  41867. this.MYB = matrix[4];
  41868. this.MZB = matrix[5];
  41869. this.MXC = matrix[6];
  41870. this.MYC = matrix[7];
  41871. this.MZC = matrix[8];
  41872. if (XW < 0 || ZW < 0 || YW !== 1) {
  41873. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41874. }
  41875. if (XB < 0 || YB < 0 || ZB < 0) {
  41876. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  41877. this.blackPoint = new Float32Array(3);
  41878. }
  41879. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  41880. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  41881. this.GR = this.GG = this.GB = 1;
  41882. }
  41883. 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) {
  41884. 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');
  41885. this.MXA = this.MYB = this.MZC = 1;
  41886. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  41887. }
  41888. }
  41889. function matrixProduct(a, b, result) {
  41890. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  41891. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  41892. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  41893. }
  41894. function convertToFlat(sourceWhitePoint, LMS, result) {
  41895. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  41896. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  41897. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  41898. }
  41899. function convertToD65(sourceWhitePoint, LMS, result) {
  41900. var D65X = 0.95047;
  41901. var D65Y = 1;
  41902. var D65Z = 1.08883;
  41903. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  41904. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  41905. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  41906. }
  41907. function sRGBTransferFunction(color) {
  41908. if (color <= 0.0031308) {
  41909. return adjustToRange(0, 1, 12.92 * color);
  41910. }
  41911. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  41912. }
  41913. function adjustToRange(min, max, value) {
  41914. return Math.max(min, Math.min(max, value));
  41915. }
  41916. function decodeL(L) {
  41917. if (L < 0) {
  41918. return -decodeL(-L);
  41919. }
  41920. if (L > 8.0) {
  41921. return Math.pow((L + 16) / 116, 3);
  41922. }
  41923. return L * DECODE_L_CONSTANT;
  41924. }
  41925. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  41926. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  41927. result[0] = XYZ_Flat[0];
  41928. result[1] = XYZ_Flat[1];
  41929. result[2] = XYZ_Flat[2];
  41930. return;
  41931. }
  41932. var zeroDecodeL = decodeL(0);
  41933. var X_DST = zeroDecodeL;
  41934. var X_SRC = decodeL(sourceBlackPoint[0]);
  41935. var Y_DST = zeroDecodeL;
  41936. var Y_SRC = decodeL(sourceBlackPoint[1]);
  41937. var Z_DST = zeroDecodeL;
  41938. var Z_SRC = decodeL(sourceBlackPoint[2]);
  41939. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  41940. var X_Offset = 1 - X_Scale;
  41941. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  41942. var Y_Offset = 1 - Y_Scale;
  41943. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  41944. var Z_Offset = 1 - Z_Scale;
  41945. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  41946. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  41947. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  41948. }
  41949. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  41950. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  41951. result[0] = XYZ_In[0];
  41952. result[1] = XYZ_In[1];
  41953. result[2] = XYZ_In[2];
  41954. return;
  41955. }
  41956. var LMS = result;
  41957. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  41958. var LMS_Flat = tempNormalizeMatrix;
  41959. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  41960. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  41961. }
  41962. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  41963. var LMS = result;
  41964. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  41965. var LMS_D65 = tempNormalizeMatrix;
  41966. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  41967. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  41968. }
  41969. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  41970. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  41971. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  41972. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  41973. var AGR = Math.pow(A, cs.GR);
  41974. var BGG = Math.pow(B, cs.GG);
  41975. var CGB = Math.pow(C, cs.GB);
  41976. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  41977. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  41978. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  41979. var XYZ = tempConvertMatrix1;
  41980. XYZ[0] = X;
  41981. XYZ[1] = Y;
  41982. XYZ[2] = Z;
  41983. var XYZ_Flat = tempConvertMatrix2;
  41984. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  41985. var XYZ_Black = tempConvertMatrix1;
  41986. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  41987. var XYZ_D65 = tempConvertMatrix2;
  41988. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  41989. var SRGB = tempConvertMatrix1;
  41990. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  41991. var sR = sRGBTransferFunction(SRGB[0]);
  41992. var sG = sRGBTransferFunction(SRGB[1]);
  41993. var sB = sRGBTransferFunction(SRGB[2]);
  41994. dest[destOffset] = Math.round(sR * 255);
  41995. dest[destOffset + 1] = Math.round(sG * 255);
  41996. dest[destOffset + 2] = Math.round(sB * 255);
  41997. }
  41998. CalRGBCS.prototype = {
  41999. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  42000. var rgb = new Uint8Array(3);
  42001. this.getRgbItem(src, srcOffset, rgb, 0);
  42002. return rgb;
  42003. },
  42004. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42005. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  42006. },
  42007. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42008. var scale = 1 / ((1 << bits) - 1);
  42009. for (var i = 0; i < count; ++i) {
  42010. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  42011. srcOffset += 3;
  42012. destOffset += 3 + alpha01;
  42013. }
  42014. },
  42015. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  42016. return inputLength * (3 + alpha01) / 3 | 0;
  42017. },
  42018. isPassthrough: ColorSpace.prototype.isPassthrough,
  42019. fillRgb: ColorSpace.prototype.fillRgb,
  42020. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  42021. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  42022. },
  42023. usesZeroToOneRange: true
  42024. };
  42025. return CalRGBCS;
  42026. }();
  42027. var LabCS = function LabCSClosure() {
  42028. function LabCS(whitePoint, blackPoint, range) {
  42029. this.name = 'Lab';
  42030. this.numComps = 3;
  42031. this.defaultColor = new Float32Array([
  42032. 0,
  42033. 0,
  42034. 0
  42035. ]);
  42036. if (!whitePoint) {
  42037. error('WhitePoint missing - required for color space Lab');
  42038. }
  42039. blackPoint = blackPoint || [
  42040. 0,
  42041. 0,
  42042. 0
  42043. ];
  42044. range = range || [
  42045. -100,
  42046. 100,
  42047. -100,
  42048. 100
  42049. ];
  42050. this.XW = whitePoint[0];
  42051. this.YW = whitePoint[1];
  42052. this.ZW = whitePoint[2];
  42053. this.amin = range[0];
  42054. this.amax = range[1];
  42055. this.bmin = range[2];
  42056. this.bmax = range[3];
  42057. this.XB = blackPoint[0];
  42058. this.YB = blackPoint[1];
  42059. this.ZB = blackPoint[2];
  42060. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  42061. error('Invalid WhitePoint components, no fallback available');
  42062. }
  42063. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  42064. info('Invalid BlackPoint, falling back to default');
  42065. this.XB = this.YB = this.ZB = 0;
  42066. }
  42067. if (this.amin > this.amax || this.bmin > this.bmax) {
  42068. info('Invalid Range, falling back to defaults');
  42069. this.amin = -100;
  42070. this.amax = 100;
  42071. this.bmin = -100;
  42072. this.bmax = 100;
  42073. }
  42074. }
  42075. function fn_g(x) {
  42076. if (x >= 6 / 29) {
  42077. return x * x * x;
  42078. } else {
  42079. return 108 / 841 * (x - 4 / 29);
  42080. }
  42081. }
  42082. function decode(value, high1, low2, high2) {
  42083. return low2 + value * (high2 - low2) / high1;
  42084. }
  42085. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  42086. var Ls = src[srcOffset];
  42087. var as = src[srcOffset + 1];
  42088. var bs = src[srcOffset + 2];
  42089. if (maxVal !== false) {
  42090. Ls = decode(Ls, maxVal, 0, 100);
  42091. as = decode(as, maxVal, cs.amin, cs.amax);
  42092. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  42093. }
  42094. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  42095. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  42096. var M = (Ls + 16) / 116;
  42097. var L = M + as / 500;
  42098. var N = M - bs / 200;
  42099. var X = cs.XW * fn_g(L);
  42100. var Y = cs.YW * fn_g(M);
  42101. var Z = cs.ZW * fn_g(N);
  42102. var r, g, b;
  42103. if (cs.ZW < 1) {
  42104. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  42105. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  42106. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  42107. } else {
  42108. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  42109. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  42110. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  42111. }
  42112. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  42113. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  42114. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  42115. }
  42116. LabCS.prototype = {
  42117. getRgb: ColorSpace.prototype.getRgb,
  42118. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42119. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  42120. },
  42121. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42122. var maxVal = (1 << bits) - 1;
  42123. for (var i = 0; i < count; i++) {
  42124. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  42125. srcOffset += 3;
  42126. destOffset += 3 + alpha01;
  42127. }
  42128. },
  42129. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  42130. return inputLength * (3 + alpha01) / 3 | 0;
  42131. },
  42132. isPassthrough: ColorSpace.prototype.isPassthrough,
  42133. fillRgb: ColorSpace.prototype.fillRgb,
  42134. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  42135. return true;
  42136. },
  42137. usesZeroToOneRange: false
  42138. };
  42139. return LabCS;
  42140. }();
  42141. exports.ColorSpace = ColorSpace;
  42142. }));
  42143. (function (root, factory) {
  42144. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  42145. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  42146. var ImageKind = sharedUtil.ImageKind;
  42147. var assert = sharedUtil.assert;
  42148. var error = sharedUtil.error;
  42149. var info = sharedUtil.info;
  42150. var isArray = sharedUtil.isArray;
  42151. var warn = sharedUtil.warn;
  42152. var Name = corePrimitives.Name;
  42153. var isStream = corePrimitives.isStream;
  42154. var ColorSpace = coreColorSpace.ColorSpace;
  42155. var DecodeStream = coreStream.DecodeStream;
  42156. var JpegStream = coreStream.JpegStream;
  42157. var JpxImage = coreJpx.JpxImage;
  42158. var PDFImage = function PDFImageClosure() {
  42159. function handleImageData(image, nativeDecoder) {
  42160. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  42161. return nativeDecoder.decode(image);
  42162. } else {
  42163. return Promise.resolve(image);
  42164. }
  42165. }
  42166. function decodeAndClamp(value, addend, coefficient, max) {
  42167. value = addend + value * coefficient;
  42168. return value < 0 ? 0 : value > max ? max : value;
  42169. }
  42170. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  42171. var length = w2 * h2;
  42172. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42173. var xRatio = w1 / w2;
  42174. var yRatio = h1 / h2;
  42175. var i, j, py, newIndex = 0, oldIndex;
  42176. var xScaled = new Uint16Array(w2);
  42177. var w1Scanline = w1;
  42178. for (i = 0; i < w2; i++) {
  42179. xScaled[i] = Math.floor(i * xRatio);
  42180. }
  42181. for (i = 0; i < h2; i++) {
  42182. py = Math.floor(i * yRatio) * w1Scanline;
  42183. for (j = 0; j < w2; j++) {
  42184. oldIndex = py + xScaled[j];
  42185. dest[newIndex++] = src[oldIndex];
  42186. }
  42187. }
  42188. return dest;
  42189. }
  42190. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  42191. this.image = image;
  42192. var dict = image.dict;
  42193. if (dict.has('Filter')) {
  42194. var filter = dict.get('Filter').name;
  42195. if (filter === 'JPXDecode') {
  42196. var jpxImage = new JpxImage();
  42197. jpxImage.parseImageProperties(image.stream);
  42198. image.stream.reset();
  42199. image.bitsPerComponent = jpxImage.bitsPerComponent;
  42200. image.numComps = jpxImage.componentsCount;
  42201. } else if (filter === 'JBIG2Decode') {
  42202. image.bitsPerComponent = 1;
  42203. image.numComps = 1;
  42204. }
  42205. }
  42206. this.width = dict.get('Width', 'W');
  42207. this.height = dict.get('Height', 'H');
  42208. if (this.width < 1 || this.height < 1) {
  42209. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  42210. }
  42211. this.interpolate = dict.get('Interpolate', 'I') || false;
  42212. this.imageMask = dict.get('ImageMask', 'IM') || false;
  42213. this.matte = dict.get('Matte') || false;
  42214. var bitsPerComponent = image.bitsPerComponent;
  42215. if (!bitsPerComponent) {
  42216. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  42217. if (!bitsPerComponent) {
  42218. if (this.imageMask) {
  42219. bitsPerComponent = 1;
  42220. } else {
  42221. error('Bits per component missing in image: ' + this.imageMask);
  42222. }
  42223. }
  42224. }
  42225. this.bpc = bitsPerComponent;
  42226. if (!this.imageMask) {
  42227. var colorSpace = dict.get('ColorSpace', 'CS');
  42228. if (!colorSpace) {
  42229. info('JPX images (which do not require color spaces)');
  42230. switch (image.numComps) {
  42231. case 1:
  42232. colorSpace = Name.get('DeviceGray');
  42233. break;
  42234. case 3:
  42235. colorSpace = Name.get('DeviceRGB');
  42236. break;
  42237. case 4:
  42238. colorSpace = Name.get('DeviceCMYK');
  42239. break;
  42240. default:
  42241. error('JPX images with ' + this.numComps + ' color components not supported.');
  42242. }
  42243. }
  42244. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  42245. this.numComps = this.colorSpace.numComps;
  42246. }
  42247. this.decode = dict.getArray('Decode', 'D');
  42248. this.needsDecode = false;
  42249. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  42250. this.needsDecode = true;
  42251. var max = (1 << bitsPerComponent) - 1;
  42252. this.decodeCoefficients = [];
  42253. this.decodeAddends = [];
  42254. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  42255. var dmin = this.decode[i];
  42256. var dmax = this.decode[i + 1];
  42257. this.decodeCoefficients[j] = dmax - dmin;
  42258. this.decodeAddends[j] = max * dmin;
  42259. }
  42260. }
  42261. if (smask) {
  42262. this.smask = new PDFImage(xref, res, smask, false);
  42263. } else if (mask) {
  42264. if (isStream(mask)) {
  42265. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  42266. if (!imageMask) {
  42267. warn('Ignoring /Mask in image without /ImageMask.');
  42268. } else {
  42269. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  42270. }
  42271. } else {
  42272. this.mask = mask;
  42273. }
  42274. }
  42275. }
  42276. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  42277. var imagePromise = handleImageData(image, nativeDecoder);
  42278. var smaskPromise;
  42279. var maskPromise;
  42280. var smask = image.dict.get('SMask');
  42281. var mask = image.dict.get('Mask');
  42282. if (smask) {
  42283. smaskPromise = handleImageData(smask, nativeDecoder);
  42284. maskPromise = Promise.resolve(null);
  42285. } else {
  42286. smaskPromise = Promise.resolve(null);
  42287. if (mask) {
  42288. if (isStream(mask)) {
  42289. maskPromise = handleImageData(mask, nativeDecoder);
  42290. } else if (isArray(mask)) {
  42291. maskPromise = Promise.resolve(mask);
  42292. } else {
  42293. warn('Unsupported mask format.');
  42294. maskPromise = Promise.resolve(null);
  42295. }
  42296. } else {
  42297. maskPromise = Promise.resolve(null);
  42298. }
  42299. }
  42300. return Promise.all([
  42301. imagePromise,
  42302. smaskPromise,
  42303. maskPromise
  42304. ]).then(function (results) {
  42305. var imageData = results[0];
  42306. var smaskData = results[1];
  42307. var maskData = results[2];
  42308. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  42309. });
  42310. };
  42311. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  42312. var computedLength = (width + 7 >> 3) * height;
  42313. var actualLength = imgArray.byteLength;
  42314. var haveFullData = computedLength === actualLength;
  42315. var data, i;
  42316. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  42317. data = imgArray;
  42318. } else if (!inverseDecode) {
  42319. data = new Uint8Array(actualLength);
  42320. data.set(imgArray);
  42321. } else {
  42322. data = new Uint8Array(computedLength);
  42323. data.set(imgArray);
  42324. for (i = actualLength; i < computedLength; i++) {
  42325. data[i] = 0xff;
  42326. }
  42327. }
  42328. if (inverseDecode) {
  42329. for (i = 0; i < actualLength; i++) {
  42330. data[i] = ~data[i];
  42331. }
  42332. }
  42333. return {
  42334. data: data,
  42335. width: width,
  42336. height: height
  42337. };
  42338. };
  42339. PDFImage.prototype = {
  42340. get drawWidth() {
  42341. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  42342. },
  42343. get drawHeight() {
  42344. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  42345. },
  42346. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  42347. var bpc = this.bpc;
  42348. var numComps = this.numComps;
  42349. var decodeAddends = this.decodeAddends;
  42350. var decodeCoefficients = this.decodeCoefficients;
  42351. var max = (1 << bpc) - 1;
  42352. var i, ii;
  42353. if (bpc === 1) {
  42354. for (i = 0, ii = buffer.length; i < ii; i++) {
  42355. buffer[i] = +!buffer[i];
  42356. }
  42357. return;
  42358. }
  42359. var index = 0;
  42360. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  42361. for (var j = 0; j < numComps; j++) {
  42362. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  42363. index++;
  42364. }
  42365. }
  42366. },
  42367. getComponents: function PDFImage_getComponents(buffer) {
  42368. var bpc = this.bpc;
  42369. if (bpc === 8) {
  42370. return buffer;
  42371. }
  42372. var width = this.width;
  42373. var height = this.height;
  42374. var numComps = this.numComps;
  42375. var length = width * height * numComps;
  42376. var bufferPos = 0;
  42377. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42378. var rowComps = width * numComps;
  42379. var max = (1 << bpc) - 1;
  42380. var i = 0, ii, buf;
  42381. if (bpc === 1) {
  42382. var mask, loop1End, loop2End;
  42383. for (var j = 0; j < height; j++) {
  42384. loop1End = i + (rowComps & ~7);
  42385. loop2End = i + rowComps;
  42386. while (i < loop1End) {
  42387. buf = buffer[bufferPos++];
  42388. output[i] = buf >> 7 & 1;
  42389. output[i + 1] = buf >> 6 & 1;
  42390. output[i + 2] = buf >> 5 & 1;
  42391. output[i + 3] = buf >> 4 & 1;
  42392. output[i + 4] = buf >> 3 & 1;
  42393. output[i + 5] = buf >> 2 & 1;
  42394. output[i + 6] = buf >> 1 & 1;
  42395. output[i + 7] = buf & 1;
  42396. i += 8;
  42397. }
  42398. if (i < loop2End) {
  42399. buf = buffer[bufferPos++];
  42400. mask = 128;
  42401. while (i < loop2End) {
  42402. output[i++] = +!!(buf & mask);
  42403. mask >>= 1;
  42404. }
  42405. }
  42406. }
  42407. } else {
  42408. var bits = 0;
  42409. buf = 0;
  42410. for (i = 0, ii = length; i < ii; ++i) {
  42411. if (i % rowComps === 0) {
  42412. buf = 0;
  42413. bits = 0;
  42414. }
  42415. while (bits < bpc) {
  42416. buf = buf << 8 | buffer[bufferPos++];
  42417. bits += 8;
  42418. }
  42419. var remainingBits = bits - bpc;
  42420. var value = buf >> remainingBits;
  42421. output[i] = value < 0 ? 0 : value > max ? max : value;
  42422. buf = buf & (1 << remainingBits) - 1;
  42423. bits = remainingBits;
  42424. }
  42425. }
  42426. return output;
  42427. },
  42428. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  42429. var smask = this.smask;
  42430. var mask = this.mask;
  42431. var alphaBuf, sw, sh, i, ii, j;
  42432. if (smask) {
  42433. sw = smask.width;
  42434. sh = smask.height;
  42435. alphaBuf = new Uint8Array(sw * sh);
  42436. smask.fillGrayBuffer(alphaBuf);
  42437. if (sw !== width || sh !== height) {
  42438. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  42439. }
  42440. } else if (mask) {
  42441. if (mask instanceof PDFImage) {
  42442. sw = mask.width;
  42443. sh = mask.height;
  42444. alphaBuf = new Uint8Array(sw * sh);
  42445. mask.numComps = 1;
  42446. mask.fillGrayBuffer(alphaBuf);
  42447. for (i = 0, ii = sw * sh; i < ii; ++i) {
  42448. alphaBuf[i] = 255 - alphaBuf[i];
  42449. }
  42450. if (sw !== width || sh !== height) {
  42451. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  42452. }
  42453. } else if (isArray(mask)) {
  42454. alphaBuf = new Uint8Array(width * height);
  42455. var numComps = this.numComps;
  42456. for (i = 0, ii = width * height; i < ii; ++i) {
  42457. var opacity = 0;
  42458. var imageOffset = i * numComps;
  42459. for (j = 0; j < numComps; ++j) {
  42460. var color = image[imageOffset + j];
  42461. var maskOffset = j * 2;
  42462. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  42463. opacity = 255;
  42464. break;
  42465. }
  42466. }
  42467. alphaBuf[i] = opacity;
  42468. }
  42469. } else {
  42470. error('Unknown mask format.');
  42471. }
  42472. }
  42473. if (alphaBuf) {
  42474. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42475. rgbaBuf[j] = alphaBuf[i];
  42476. }
  42477. } else {
  42478. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42479. rgbaBuf[j] = 255;
  42480. }
  42481. }
  42482. },
  42483. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  42484. var matte = this.smask && this.smask.matte;
  42485. if (!matte) {
  42486. return;
  42487. }
  42488. var matteRgb = this.colorSpace.getRgb(matte, 0);
  42489. var matteR = matteRgb[0];
  42490. var matteG = matteRgb[1];
  42491. var matteB = matteRgb[2];
  42492. var length = width * height * 4;
  42493. var r, g, b;
  42494. for (var i = 0; i < length; i += 4) {
  42495. var alpha = buffer[i + 3];
  42496. if (alpha === 0) {
  42497. buffer[i] = 255;
  42498. buffer[i + 1] = 255;
  42499. buffer[i + 2] = 255;
  42500. continue;
  42501. }
  42502. var k = 255 / alpha;
  42503. r = (buffer[i] - matteR) * k + matteR;
  42504. g = (buffer[i + 1] - matteG) * k + matteG;
  42505. b = (buffer[i + 2] - matteB) * k + matteB;
  42506. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  42507. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  42508. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  42509. }
  42510. },
  42511. createImageData: function PDFImage_createImageData(forceRGBA) {
  42512. var drawWidth = this.drawWidth;
  42513. var drawHeight = this.drawHeight;
  42514. var imgData = {
  42515. width: drawWidth,
  42516. height: drawHeight
  42517. };
  42518. var numComps = this.numComps;
  42519. var originalWidth = this.width;
  42520. var originalHeight = this.height;
  42521. var bpc = this.bpc;
  42522. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  42523. var imgArray;
  42524. if (!forceRGBA) {
  42525. var kind;
  42526. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  42527. kind = ImageKind.GRAYSCALE_1BPP;
  42528. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  42529. kind = ImageKind.RGB_24BPP;
  42530. }
  42531. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  42532. imgData.kind = kind;
  42533. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42534. if (this.image instanceof DecodeStream) {
  42535. imgData.data = imgArray;
  42536. } else {
  42537. var newArray = new Uint8Array(imgArray.length);
  42538. newArray.set(imgArray);
  42539. imgData.data = newArray;
  42540. }
  42541. if (this.needsDecode) {
  42542. assert(kind === ImageKind.GRAYSCALE_1BPP);
  42543. var buffer = imgData.data;
  42544. for (var i = 0, ii = buffer.length; i < ii; i++) {
  42545. buffer[i] ^= 0xff;
  42546. }
  42547. }
  42548. return imgData;
  42549. }
  42550. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  42551. imgData.kind = ImageKind.RGB_24BPP;
  42552. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  42553. return imgData;
  42554. }
  42555. }
  42556. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42557. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  42558. var comps = this.getComponents(imgArray);
  42559. var alpha01, maybeUndoPreblend;
  42560. if (!forceRGBA && !this.smask && !this.mask) {
  42561. imgData.kind = ImageKind.RGB_24BPP;
  42562. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  42563. alpha01 = 0;
  42564. maybeUndoPreblend = false;
  42565. } else {
  42566. imgData.kind = ImageKind.RGBA_32BPP;
  42567. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  42568. alpha01 = 1;
  42569. maybeUndoPreblend = true;
  42570. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  42571. }
  42572. if (this.needsDecode) {
  42573. this.decodeBuffer(comps);
  42574. }
  42575. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  42576. if (maybeUndoPreblend) {
  42577. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  42578. }
  42579. return imgData;
  42580. },
  42581. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  42582. var numComps = this.numComps;
  42583. if (numComps !== 1) {
  42584. error('Reading gray scale from a color image: ' + numComps);
  42585. }
  42586. var width = this.width;
  42587. var height = this.height;
  42588. var bpc = this.bpc;
  42589. var rowBytes = width * numComps * bpc + 7 >> 3;
  42590. var imgArray = this.getImageBytes(height * rowBytes);
  42591. var comps = this.getComponents(imgArray);
  42592. var i, length;
  42593. if (bpc === 1) {
  42594. length = width * height;
  42595. if (this.needsDecode) {
  42596. for (i = 0; i < length; ++i) {
  42597. buffer[i] = comps[i] - 1 & 255;
  42598. }
  42599. } else {
  42600. for (i = 0; i < length; ++i) {
  42601. buffer[i] = -comps[i] & 255;
  42602. }
  42603. }
  42604. return;
  42605. }
  42606. if (this.needsDecode) {
  42607. this.decodeBuffer(comps);
  42608. }
  42609. length = width * height;
  42610. var scale = 255 / ((1 << bpc) - 1);
  42611. for (i = 0; i < length; ++i) {
  42612. buffer[i] = scale * comps[i] | 0;
  42613. }
  42614. },
  42615. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  42616. this.image.reset();
  42617. this.image.drawWidth = drawWidth || this.width;
  42618. this.image.drawHeight = drawHeight || this.height;
  42619. this.image.forceRGB = !!forceRGB;
  42620. return this.image.getBytes(length);
  42621. }
  42622. };
  42623. return PDFImage;
  42624. }();
  42625. exports.PDFImage = PDFImage;
  42626. }));
  42627. (function (root, factory) {
  42628. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  42629. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  42630. var InvalidPDFException = sharedUtil.InvalidPDFException;
  42631. var MissingDataException = sharedUtil.MissingDataException;
  42632. var XRefParseException = sharedUtil.XRefParseException;
  42633. var assert = sharedUtil.assert;
  42634. var bytesToString = sharedUtil.bytesToString;
  42635. var createPromiseCapability = sharedUtil.createPromiseCapability;
  42636. var error = sharedUtil.error;
  42637. var info = sharedUtil.info;
  42638. var isArray = sharedUtil.isArray;
  42639. var isBool = sharedUtil.isBool;
  42640. var isInt = sharedUtil.isInt;
  42641. var isString = sharedUtil.isString;
  42642. var shadow = sharedUtil.shadow;
  42643. var stringToPDFString = sharedUtil.stringToPDFString;
  42644. var stringToUTF8String = sharedUtil.stringToUTF8String;
  42645. var warn = sharedUtil.warn;
  42646. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  42647. var Util = sharedUtil.Util;
  42648. var Ref = corePrimitives.Ref;
  42649. var RefSet = corePrimitives.RefSet;
  42650. var RefSetCache = corePrimitives.RefSetCache;
  42651. var isName = corePrimitives.isName;
  42652. var isCmd = corePrimitives.isCmd;
  42653. var isDict = corePrimitives.isDict;
  42654. var isRef = corePrimitives.isRef;
  42655. var isRefsEqual = corePrimitives.isRefsEqual;
  42656. var isStream = corePrimitives.isStream;
  42657. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  42658. var Lexer = coreParser.Lexer;
  42659. var Parser = coreParser.Parser;
  42660. var ChunkedStream = coreChunkedStream.ChunkedStream;
  42661. var ColorSpace = coreColorSpace.ColorSpace;
  42662. var Catalog = function CatalogClosure() {
  42663. function Catalog(pdfManager, xref, pageFactory) {
  42664. this.pdfManager = pdfManager;
  42665. this.xref = xref;
  42666. this.catDict = xref.getCatalogObj();
  42667. this.fontCache = new RefSetCache();
  42668. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  42669. this.pageFactory = pageFactory;
  42670. this.pagePromises = [];
  42671. }
  42672. Catalog.prototype = {
  42673. get metadata() {
  42674. var streamRef = this.catDict.getRaw('Metadata');
  42675. if (!isRef(streamRef)) {
  42676. return shadow(this, 'metadata', null);
  42677. }
  42678. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  42679. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  42680. var metadata;
  42681. if (stream && isDict(stream.dict)) {
  42682. var type = stream.dict.get('Type');
  42683. var subtype = stream.dict.get('Subtype');
  42684. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  42685. try {
  42686. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  42687. } catch (e) {
  42688. info('Skipping invalid metadata.');
  42689. }
  42690. }
  42691. }
  42692. return shadow(this, 'metadata', metadata);
  42693. },
  42694. get toplevelPagesDict() {
  42695. var pagesObj = this.catDict.get('Pages');
  42696. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  42697. return shadow(this, 'toplevelPagesDict', pagesObj);
  42698. },
  42699. get documentOutline() {
  42700. var obj = null;
  42701. try {
  42702. obj = this.readDocumentOutline();
  42703. } catch (ex) {
  42704. if (ex instanceof MissingDataException) {
  42705. throw ex;
  42706. }
  42707. warn('Unable to read document outline');
  42708. }
  42709. return shadow(this, 'documentOutline', obj);
  42710. },
  42711. readDocumentOutline: function Catalog_readDocumentOutline() {
  42712. var obj = this.catDict.get('Outlines');
  42713. if (!isDict(obj)) {
  42714. return null;
  42715. }
  42716. obj = obj.getRaw('First');
  42717. if (!isRef(obj)) {
  42718. return null;
  42719. }
  42720. var root = { items: [] };
  42721. var queue = [{
  42722. obj: obj,
  42723. parent: root
  42724. }];
  42725. var processed = new RefSet();
  42726. processed.put(obj);
  42727. var xref = this.xref, blackColor = new Uint8Array(3);
  42728. while (queue.length > 0) {
  42729. var i = queue.shift();
  42730. var outlineDict = xref.fetchIfRef(i.obj);
  42731. if (outlineDict === null) {
  42732. continue;
  42733. }
  42734. assert(outlineDict.has('Title'), 'Invalid outline item');
  42735. var data = {
  42736. url: null,
  42737. dest: null
  42738. };
  42739. Catalog.parseDestDictionary({
  42740. destDict: outlineDict,
  42741. resultObj: data,
  42742. docBaseUrl: this.pdfManager.docBaseUrl
  42743. });
  42744. var title = outlineDict.get('Title');
  42745. var flags = outlineDict.get('F') || 0;
  42746. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  42747. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  42748. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  42749. }
  42750. var outlineItem = {
  42751. dest: data.dest,
  42752. url: data.url,
  42753. unsafeUrl: data.unsafeUrl,
  42754. newWindow: data.newWindow,
  42755. title: stringToPDFString(title),
  42756. color: rgbColor,
  42757. count: outlineDict.get('Count'),
  42758. bold: !!(flags & 2),
  42759. italic: !!(flags & 1),
  42760. items: []
  42761. };
  42762. i.parent.items.push(outlineItem);
  42763. obj = outlineDict.getRaw('First');
  42764. if (isRef(obj) && !processed.has(obj)) {
  42765. queue.push({
  42766. obj: obj,
  42767. parent: outlineItem
  42768. });
  42769. processed.put(obj);
  42770. }
  42771. obj = outlineDict.getRaw('Next');
  42772. if (isRef(obj) && !processed.has(obj)) {
  42773. queue.push({
  42774. obj: obj,
  42775. parent: i.parent
  42776. });
  42777. processed.put(obj);
  42778. }
  42779. }
  42780. return root.items.length > 0 ? root.items : null;
  42781. },
  42782. get numPages() {
  42783. var obj = this.toplevelPagesDict.get('Count');
  42784. assert(isInt(obj), 'page count in top level pages object is not an integer');
  42785. return shadow(this, 'num', obj);
  42786. },
  42787. get destinations() {
  42788. function fetchDestination(dest) {
  42789. return isDict(dest) ? dest.get('D') : dest;
  42790. }
  42791. var xref = this.xref;
  42792. var dests = {}, nameTreeRef, nameDictionaryRef;
  42793. var obj = this.catDict.get('Names');
  42794. if (obj && obj.has('Dests')) {
  42795. nameTreeRef = obj.getRaw('Dests');
  42796. } else if (this.catDict.has('Dests')) {
  42797. nameDictionaryRef = this.catDict.get('Dests');
  42798. }
  42799. if (nameDictionaryRef) {
  42800. obj = nameDictionaryRef;
  42801. obj.forEach(function catalogForEach(key, value) {
  42802. if (!value) {
  42803. return;
  42804. }
  42805. dests[key] = fetchDestination(value);
  42806. });
  42807. }
  42808. if (nameTreeRef) {
  42809. var nameTree = new NameTree(nameTreeRef, xref);
  42810. var names = nameTree.getAll();
  42811. for (var name in names) {
  42812. dests[name] = fetchDestination(names[name]);
  42813. }
  42814. }
  42815. return shadow(this, 'destinations', dests);
  42816. },
  42817. getDestination: function Catalog_getDestination(destinationId) {
  42818. function fetchDestination(dest) {
  42819. return isDict(dest) ? dest.get('D') : dest;
  42820. }
  42821. var xref = this.xref;
  42822. var dest = null, nameTreeRef, nameDictionaryRef;
  42823. var obj = this.catDict.get('Names');
  42824. if (obj && obj.has('Dests')) {
  42825. nameTreeRef = obj.getRaw('Dests');
  42826. } else if (this.catDict.has('Dests')) {
  42827. nameDictionaryRef = this.catDict.get('Dests');
  42828. }
  42829. if (nameDictionaryRef) {
  42830. var value = nameDictionaryRef.get(destinationId);
  42831. if (value) {
  42832. dest = fetchDestination(value);
  42833. }
  42834. }
  42835. if (nameTreeRef) {
  42836. var nameTree = new NameTree(nameTreeRef, xref);
  42837. dest = fetchDestination(nameTree.get(destinationId));
  42838. }
  42839. return dest;
  42840. },
  42841. get pageLabels() {
  42842. var obj = null;
  42843. try {
  42844. obj = this.readPageLabels();
  42845. } catch (ex) {
  42846. if (ex instanceof MissingDataException) {
  42847. throw ex;
  42848. }
  42849. warn('Unable to read page labels.');
  42850. }
  42851. return shadow(this, 'pageLabels', obj);
  42852. },
  42853. readPageLabels: function Catalog_readPageLabels() {
  42854. var obj = this.catDict.getRaw('PageLabels');
  42855. if (!obj) {
  42856. return null;
  42857. }
  42858. var pageLabels = new Array(this.numPages);
  42859. var style = null;
  42860. var prefix = '';
  42861. var numberTree = new NumberTree(obj, this.xref);
  42862. var nums = numberTree.getAll();
  42863. var currentLabel = '', currentIndex = 1;
  42864. for (var i = 0, ii = this.numPages; i < ii; i++) {
  42865. if (i in nums) {
  42866. var labelDict = nums[i];
  42867. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  42868. var type = labelDict.get('Type');
  42869. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  42870. var s = labelDict.get('S');
  42871. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  42872. style = s ? s.name : null;
  42873. var p = labelDict.get('P');
  42874. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  42875. prefix = p ? stringToPDFString(p) : '';
  42876. var st = labelDict.get('St');
  42877. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  42878. currentIndex = st || 1;
  42879. }
  42880. switch (style) {
  42881. case 'D':
  42882. currentLabel = currentIndex;
  42883. break;
  42884. case 'R':
  42885. case 'r':
  42886. currentLabel = Util.toRoman(currentIndex, style === 'r');
  42887. break;
  42888. case 'A':
  42889. case 'a':
  42890. var LIMIT = 26;
  42891. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  42892. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  42893. var letterIndex = currentIndex - 1;
  42894. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  42895. var charBuf = [];
  42896. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  42897. charBuf.push(character);
  42898. }
  42899. currentLabel = charBuf.join('');
  42900. break;
  42901. default:
  42902. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  42903. }
  42904. pageLabels[i] = prefix + currentLabel;
  42905. currentLabel = '';
  42906. currentIndex++;
  42907. }
  42908. return pageLabels;
  42909. },
  42910. get attachments() {
  42911. var xref = this.xref;
  42912. var attachments = null, nameTreeRef;
  42913. var obj = this.catDict.get('Names');
  42914. if (obj) {
  42915. nameTreeRef = obj.getRaw('EmbeddedFiles');
  42916. }
  42917. if (nameTreeRef) {
  42918. var nameTree = new NameTree(nameTreeRef, xref);
  42919. var names = nameTree.getAll();
  42920. for (var name in names) {
  42921. var fs = new FileSpec(names[name], xref);
  42922. if (!attachments) {
  42923. attachments = Object.create(null);
  42924. }
  42925. attachments[stringToPDFString(name)] = fs.serializable;
  42926. }
  42927. }
  42928. return shadow(this, 'attachments', attachments);
  42929. },
  42930. get javaScript() {
  42931. var xref = this.xref;
  42932. var obj = this.catDict.get('Names');
  42933. var javaScript = [];
  42934. function appendIfJavaScriptDict(jsDict) {
  42935. var type = jsDict.get('S');
  42936. if (!isName(type, 'JavaScript')) {
  42937. return;
  42938. }
  42939. var js = jsDict.get('JS');
  42940. if (isStream(js)) {
  42941. js = bytesToString(js.getBytes());
  42942. } else if (!isString(js)) {
  42943. return;
  42944. }
  42945. javaScript.push(stringToPDFString(js));
  42946. }
  42947. if (obj && obj.has('JavaScript')) {
  42948. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  42949. var names = nameTree.getAll();
  42950. for (var name in names) {
  42951. var jsDict = names[name];
  42952. if (isDict(jsDict)) {
  42953. appendIfJavaScriptDict(jsDict);
  42954. }
  42955. }
  42956. }
  42957. var openactionDict = this.catDict.get('OpenAction');
  42958. if (isDict(openactionDict, 'Action')) {
  42959. var actionType = openactionDict.get('S');
  42960. if (isName(actionType, 'Named')) {
  42961. var action = openactionDict.get('N');
  42962. if (isName(action, 'Print')) {
  42963. javaScript.push('print({});');
  42964. }
  42965. } else {
  42966. appendIfJavaScriptDict(openactionDict);
  42967. }
  42968. }
  42969. return shadow(this, 'javaScript', javaScript);
  42970. },
  42971. cleanup: function Catalog_cleanup() {
  42972. var promises = [];
  42973. this.fontCache.forEach(function (promise) {
  42974. promises.push(promise);
  42975. });
  42976. return Promise.all(promises).then(function (translatedFonts) {
  42977. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  42978. var font = translatedFonts[i].dict;
  42979. delete font.translated;
  42980. }
  42981. this.fontCache.clear();
  42982. }.bind(this));
  42983. },
  42984. getPage: function Catalog_getPage(pageIndex) {
  42985. if (!(pageIndex in this.pagePromises)) {
  42986. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  42987. var dict = a[0];
  42988. var ref = a[1];
  42989. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  42990. }.bind(this));
  42991. }
  42992. return this.pagePromises[pageIndex];
  42993. },
  42994. getPageDict: function Catalog_getPageDict(pageIndex) {
  42995. var capability = createPromiseCapability();
  42996. var nodesToVisit = [this.catDict.getRaw('Pages')];
  42997. var currentPageIndex = 0;
  42998. var xref = this.xref;
  42999. var checkAllKids = false;
  43000. function next() {
  43001. while (nodesToVisit.length) {
  43002. var currentNode = nodesToVisit.pop();
  43003. if (isRef(currentNode)) {
  43004. xref.fetchAsync(currentNode).then(function (obj) {
  43005. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  43006. if (pageIndex === currentPageIndex) {
  43007. capability.resolve([
  43008. obj,
  43009. currentNode
  43010. ]);
  43011. } else {
  43012. currentPageIndex++;
  43013. next();
  43014. }
  43015. return;
  43016. }
  43017. nodesToVisit.push(obj);
  43018. next();
  43019. }, capability.reject);
  43020. return;
  43021. }
  43022. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  43023. var count = currentNode.get('Count');
  43024. if (count === 0) {
  43025. checkAllKids = true;
  43026. }
  43027. if (currentPageIndex + count <= pageIndex) {
  43028. currentPageIndex += count;
  43029. continue;
  43030. }
  43031. var kids = currentNode.get('Kids');
  43032. assert(isArray(kids), 'page dictionary kids object is not an array');
  43033. if (!checkAllKids && count === kids.length) {
  43034. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  43035. currentPageIndex = pageIndex;
  43036. continue;
  43037. } else {
  43038. for (var last = kids.length - 1; last >= 0; last--) {
  43039. nodesToVisit.push(kids[last]);
  43040. }
  43041. }
  43042. }
  43043. capability.reject('Page index ' + pageIndex + ' not found.');
  43044. }
  43045. next();
  43046. return capability.promise;
  43047. },
  43048. getPageIndex: function Catalog_getPageIndex(pageRef) {
  43049. var xref = this.xref;
  43050. function pagesBeforeRef(kidRef) {
  43051. var total = 0;
  43052. var parentRef;
  43053. return xref.fetchAsync(kidRef).then(function (node) {
  43054. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  43055. throw new Error('The reference does not point to a /Page Dict.');
  43056. }
  43057. if (!node) {
  43058. return null;
  43059. }
  43060. assert(isDict(node), 'node must be a Dict.');
  43061. parentRef = node.getRaw('Parent');
  43062. return node.getAsync('Parent');
  43063. }).then(function (parent) {
  43064. if (!parent) {
  43065. return null;
  43066. }
  43067. assert(isDict(parent), 'parent must be a Dict.');
  43068. return parent.getAsync('Kids');
  43069. }).then(function (kids) {
  43070. if (!kids) {
  43071. return null;
  43072. }
  43073. var kidPromises = [];
  43074. var found = false;
  43075. for (var i = 0; i < kids.length; i++) {
  43076. var kid = kids[i];
  43077. assert(isRef(kid), 'kid must be a Ref.');
  43078. if (kid.num === kidRef.num) {
  43079. found = true;
  43080. break;
  43081. }
  43082. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  43083. if (kid.has('Count')) {
  43084. var count = kid.get('Count');
  43085. total += count;
  43086. } else {
  43087. total++;
  43088. }
  43089. }));
  43090. }
  43091. if (!found) {
  43092. error('kid ref not found in parents kids');
  43093. }
  43094. return Promise.all(kidPromises).then(function () {
  43095. return [
  43096. total,
  43097. parentRef
  43098. ];
  43099. });
  43100. });
  43101. }
  43102. var total = 0;
  43103. function next(ref) {
  43104. return pagesBeforeRef(ref).then(function (args) {
  43105. if (!args) {
  43106. return total;
  43107. }
  43108. var count = args[0];
  43109. var parentRef = args[1];
  43110. total += count;
  43111. return next(parentRef);
  43112. });
  43113. }
  43114. return next(pageRef);
  43115. }
  43116. };
  43117. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  43118. function addDefaultProtocolToUrl(url) {
  43119. if (url.indexOf('www.') === 0) {
  43120. return 'http://' + url;
  43121. }
  43122. return url;
  43123. }
  43124. function tryConvertUrlEncoding(url) {
  43125. try {
  43126. return stringToUTF8String(url);
  43127. } catch (e) {
  43128. return url;
  43129. }
  43130. }
  43131. var destDict = params.destDict;
  43132. if (!isDict(destDict)) {
  43133. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  43134. return;
  43135. }
  43136. var resultObj = params.resultObj;
  43137. if (typeof resultObj !== 'object') {
  43138. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  43139. return;
  43140. }
  43141. var docBaseUrl = params.docBaseUrl || null;
  43142. var action = destDict.get('A'), url, dest;
  43143. if (isDict(action)) {
  43144. var linkType = action.get('S').name;
  43145. switch (linkType) {
  43146. case 'URI':
  43147. url = action.get('URI');
  43148. if (isName(url)) {
  43149. url = '/' + url.name;
  43150. } else if (isString(url)) {
  43151. url = addDefaultProtocolToUrl(url);
  43152. }
  43153. break;
  43154. case 'GoTo':
  43155. dest = action.get('D');
  43156. break;
  43157. case 'Launch':
  43158. case 'GoToR':
  43159. var urlDict = action.get('F');
  43160. if (isDict(urlDict)) {
  43161. url = urlDict.get('F') || null;
  43162. } else if (isString(urlDict)) {
  43163. url = urlDict;
  43164. }
  43165. var remoteDest = action.get('D');
  43166. if (remoteDest) {
  43167. if (isName(remoteDest)) {
  43168. remoteDest = remoteDest.name;
  43169. }
  43170. if (isString(url)) {
  43171. var baseUrl = url.split('#')[0];
  43172. if (isString(remoteDest)) {
  43173. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  43174. } else if (isArray(remoteDest)) {
  43175. url = baseUrl + '#' + JSON.stringify(remoteDest);
  43176. }
  43177. }
  43178. }
  43179. var newWindow = action.get('NewWindow');
  43180. if (isBool(newWindow)) {
  43181. resultObj.newWindow = newWindow;
  43182. }
  43183. break;
  43184. case 'Named':
  43185. var namedAction = action.get('N');
  43186. if (isName(namedAction)) {
  43187. resultObj.action = namedAction.name;
  43188. }
  43189. break;
  43190. case 'JavaScript':
  43191. var jsAction = action.get('JS'), js;
  43192. if (isStream(jsAction)) {
  43193. js = bytesToString(jsAction.getBytes());
  43194. } else if (isString(jsAction)) {
  43195. js = jsAction;
  43196. }
  43197. if (js) {
  43198. var URL_OPEN_METHODS = [
  43199. 'app.launchURL',
  43200. 'window.open'
  43201. ];
  43202. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  43203. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  43204. if (jsUrl && jsUrl[1]) {
  43205. url = jsUrl[1];
  43206. break;
  43207. }
  43208. }
  43209. default:
  43210. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  43211. break;
  43212. }
  43213. } else if (destDict.has('Dest')) {
  43214. dest = destDict.get('Dest');
  43215. }
  43216. if (isString(url)) {
  43217. url = tryConvertUrlEncoding(url);
  43218. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  43219. if (absoluteUrl) {
  43220. resultObj.url = absoluteUrl.href;
  43221. }
  43222. resultObj.unsafeUrl = url;
  43223. }
  43224. if (dest) {
  43225. if (isName(dest)) {
  43226. dest = dest.name;
  43227. }
  43228. if (isString(dest) || isArray(dest)) {
  43229. resultObj.dest = dest;
  43230. }
  43231. }
  43232. };
  43233. return Catalog;
  43234. }();
  43235. var XRef = function XRefClosure() {
  43236. function XRef(stream, password) {
  43237. this.stream = stream;
  43238. this.entries = [];
  43239. this.xrefstms = Object.create(null);
  43240. this.cache = [];
  43241. this.password = password;
  43242. this.stats = {
  43243. streamTypes: [],
  43244. fontTypes: []
  43245. };
  43246. }
  43247. XRef.prototype = {
  43248. setStartXRef: function XRef_setStartXRef(startXRef) {
  43249. this.startXRefQueue = [startXRef];
  43250. },
  43251. parse: function XRef_parse(recoveryMode) {
  43252. var trailerDict;
  43253. if (!recoveryMode) {
  43254. trailerDict = this.readXRef();
  43255. } else {
  43256. warn('Indexing all PDF objects');
  43257. trailerDict = this.indexObjects();
  43258. }
  43259. trailerDict.assignXref(this);
  43260. this.trailer = trailerDict;
  43261. var encrypt = trailerDict.get('Encrypt');
  43262. if (encrypt) {
  43263. var ids = trailerDict.get('ID');
  43264. var fileId = ids && ids.length ? ids[0] : '';
  43265. encrypt.suppressEncryption = true;
  43266. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  43267. }
  43268. if (!(this.root = trailerDict.get('Root'))) {
  43269. error('Invalid root reference');
  43270. }
  43271. },
  43272. processXRefTable: function XRef_processXRefTable(parser) {
  43273. if (!('tableState' in this)) {
  43274. this.tableState = {
  43275. entryNum: 0,
  43276. streamPos: parser.lexer.stream.pos,
  43277. parserBuf1: parser.buf1,
  43278. parserBuf2: parser.buf2
  43279. };
  43280. }
  43281. var obj = this.readXRefTable(parser);
  43282. if (!isCmd(obj, 'trailer')) {
  43283. error('Invalid XRef table: could not find trailer dictionary');
  43284. }
  43285. var dict = parser.getObj();
  43286. if (!isDict(dict) && dict.dict) {
  43287. dict = dict.dict;
  43288. }
  43289. if (!isDict(dict)) {
  43290. error('Invalid XRef table: could not parse trailer dictionary');
  43291. }
  43292. delete this.tableState;
  43293. return dict;
  43294. },
  43295. readXRefTable: function XRef_readXRefTable(parser) {
  43296. var stream = parser.lexer.stream;
  43297. var tableState = this.tableState;
  43298. stream.pos = tableState.streamPos;
  43299. parser.buf1 = tableState.parserBuf1;
  43300. parser.buf2 = tableState.parserBuf2;
  43301. var obj;
  43302. while (true) {
  43303. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  43304. if (isCmd(obj = parser.getObj(), 'trailer')) {
  43305. break;
  43306. }
  43307. tableState.firstEntryNum = obj;
  43308. tableState.entryCount = parser.getObj();
  43309. }
  43310. var first = tableState.firstEntryNum;
  43311. var count = tableState.entryCount;
  43312. if (!isInt(first) || !isInt(count)) {
  43313. error('Invalid XRef table: wrong types in subsection header');
  43314. }
  43315. for (var i = tableState.entryNum; i < count; i++) {
  43316. tableState.streamPos = stream.pos;
  43317. tableState.entryNum = i;
  43318. tableState.parserBuf1 = parser.buf1;
  43319. tableState.parserBuf2 = parser.buf2;
  43320. var entry = {};
  43321. entry.offset = parser.getObj();
  43322. entry.gen = parser.getObj();
  43323. var type = parser.getObj();
  43324. if (isCmd(type, 'f')) {
  43325. entry.free = true;
  43326. } else if (isCmd(type, 'n')) {
  43327. entry.uncompressed = true;
  43328. }
  43329. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  43330. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  43331. }
  43332. if (i === 0 && entry.free && first === 1) {
  43333. first = 0;
  43334. }
  43335. if (!this.entries[i + first]) {
  43336. this.entries[i + first] = entry;
  43337. }
  43338. }
  43339. tableState.entryNum = 0;
  43340. tableState.streamPos = stream.pos;
  43341. tableState.parserBuf1 = parser.buf1;
  43342. tableState.parserBuf2 = parser.buf2;
  43343. delete tableState.firstEntryNum;
  43344. delete tableState.entryCount;
  43345. }
  43346. if (this.entries[0] && !this.entries[0].free) {
  43347. error('Invalid XRef table: unexpected first object');
  43348. }
  43349. return obj;
  43350. },
  43351. processXRefStream: function XRef_processXRefStream(stream) {
  43352. if (!('streamState' in this)) {
  43353. var streamParameters = stream.dict;
  43354. var byteWidths = streamParameters.get('W');
  43355. var range = streamParameters.get('Index');
  43356. if (!range) {
  43357. range = [
  43358. 0,
  43359. streamParameters.get('Size')
  43360. ];
  43361. }
  43362. this.streamState = {
  43363. entryRanges: range,
  43364. byteWidths: byteWidths,
  43365. entryNum: 0,
  43366. streamPos: stream.pos
  43367. };
  43368. }
  43369. this.readXRefStream(stream);
  43370. delete this.streamState;
  43371. return stream.dict;
  43372. },
  43373. readXRefStream: function XRef_readXRefStream(stream) {
  43374. var i, j;
  43375. var streamState = this.streamState;
  43376. stream.pos = streamState.streamPos;
  43377. var byteWidths = streamState.byteWidths;
  43378. var typeFieldWidth = byteWidths[0];
  43379. var offsetFieldWidth = byteWidths[1];
  43380. var generationFieldWidth = byteWidths[2];
  43381. var entryRanges = streamState.entryRanges;
  43382. while (entryRanges.length > 0) {
  43383. var first = entryRanges[0];
  43384. var n = entryRanges[1];
  43385. if (!isInt(first) || !isInt(n)) {
  43386. error('Invalid XRef range fields: ' + first + ', ' + n);
  43387. }
  43388. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  43389. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  43390. }
  43391. for (i = streamState.entryNum; i < n; ++i) {
  43392. streamState.entryNum = i;
  43393. streamState.streamPos = stream.pos;
  43394. var type = 0, offset = 0, generation = 0;
  43395. for (j = 0; j < typeFieldWidth; ++j) {
  43396. type = type << 8 | stream.getByte();
  43397. }
  43398. if (typeFieldWidth === 0) {
  43399. type = 1;
  43400. }
  43401. for (j = 0; j < offsetFieldWidth; ++j) {
  43402. offset = offset << 8 | stream.getByte();
  43403. }
  43404. for (j = 0; j < generationFieldWidth; ++j) {
  43405. generation = generation << 8 | stream.getByte();
  43406. }
  43407. var entry = {};
  43408. entry.offset = offset;
  43409. entry.gen = generation;
  43410. switch (type) {
  43411. case 0:
  43412. entry.free = true;
  43413. break;
  43414. case 1:
  43415. entry.uncompressed = true;
  43416. break;
  43417. case 2:
  43418. break;
  43419. default:
  43420. error('Invalid XRef entry type: ' + type);
  43421. }
  43422. if (!this.entries[first + i]) {
  43423. this.entries[first + i] = entry;
  43424. }
  43425. }
  43426. streamState.entryNum = 0;
  43427. streamState.streamPos = stream.pos;
  43428. entryRanges.splice(0, 2);
  43429. }
  43430. },
  43431. indexObjects: function XRef_indexObjects() {
  43432. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  43433. var PERCENT = 0x25, LT = 0x3C;
  43434. function readToken(data, offset) {
  43435. var token = '', ch = data[offset];
  43436. while (ch !== LF && ch !== CR && ch !== LT) {
  43437. if (++offset >= data.length) {
  43438. break;
  43439. }
  43440. token += String.fromCharCode(ch);
  43441. ch = data[offset];
  43442. }
  43443. return token;
  43444. }
  43445. function skipUntil(data, offset, what) {
  43446. var length = what.length, dataLength = data.length;
  43447. var skipped = 0;
  43448. while (offset < dataLength) {
  43449. var i = 0;
  43450. while (i < length && data[offset + i] === what[i]) {
  43451. ++i;
  43452. }
  43453. if (i >= length) {
  43454. break;
  43455. }
  43456. offset++;
  43457. skipped++;
  43458. }
  43459. return skipped;
  43460. }
  43461. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  43462. var trailerBytes = new Uint8Array([
  43463. 116,
  43464. 114,
  43465. 97,
  43466. 105,
  43467. 108,
  43468. 101,
  43469. 114
  43470. ]);
  43471. var startxrefBytes = new Uint8Array([
  43472. 115,
  43473. 116,
  43474. 97,
  43475. 114,
  43476. 116,
  43477. 120,
  43478. 114,
  43479. 101,
  43480. 102
  43481. ]);
  43482. var endobjBytes = new Uint8Array([
  43483. 101,
  43484. 110,
  43485. 100,
  43486. 111,
  43487. 98,
  43488. 106
  43489. ]);
  43490. var xrefBytes = new Uint8Array([
  43491. 47,
  43492. 88,
  43493. 82,
  43494. 101,
  43495. 102
  43496. ]);
  43497. this.entries.length = 0;
  43498. var stream = this.stream;
  43499. stream.pos = 0;
  43500. var buffer = stream.getBytes();
  43501. var position = stream.start, length = buffer.length;
  43502. var trailers = [], xrefStms = [];
  43503. while (position < length) {
  43504. var ch = buffer[position];
  43505. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  43506. ++position;
  43507. continue;
  43508. }
  43509. if (ch === PERCENT) {
  43510. do {
  43511. ++position;
  43512. if (position >= length) {
  43513. break;
  43514. }
  43515. ch = buffer[position];
  43516. } while (ch !== LF && ch !== CR);
  43517. continue;
  43518. }
  43519. var token = readToken(buffer, position);
  43520. var m;
  43521. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  43522. position += skipUntil(buffer, position, trailerBytes);
  43523. trailers.push(position);
  43524. position += skipUntil(buffer, position, startxrefBytes);
  43525. } else if (m = objRegExp.exec(token)) {
  43526. if (typeof this.entries[m[1]] === 'undefined') {
  43527. this.entries[m[1]] = {
  43528. offset: position - stream.start,
  43529. gen: m[2] | 0,
  43530. uncompressed: true
  43531. };
  43532. }
  43533. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  43534. var content = buffer.subarray(position, position + contentLength);
  43535. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  43536. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  43537. xrefStms.push(position - stream.start);
  43538. this.xrefstms[position - stream.start] = 1;
  43539. }
  43540. position += contentLength;
  43541. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  43542. trailers.push(position);
  43543. position += skipUntil(buffer, position, startxrefBytes);
  43544. } else {
  43545. position += token.length + 1;
  43546. }
  43547. }
  43548. var i, ii;
  43549. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  43550. this.startXRefQueue.push(xrefStms[i]);
  43551. this.readXRef(true);
  43552. }
  43553. var dict;
  43554. for (i = 0, ii = trailers.length; i < ii; ++i) {
  43555. stream.pos = trailers[i];
  43556. var parser = new Parser(new Lexer(stream), true, this, true);
  43557. var obj = parser.getObj();
  43558. if (!isCmd(obj, 'trailer')) {
  43559. continue;
  43560. }
  43561. dict = parser.getObj();
  43562. if (!isDict(dict)) {
  43563. continue;
  43564. }
  43565. if (dict.has('ID')) {
  43566. return dict;
  43567. }
  43568. }
  43569. if (dict) {
  43570. return dict;
  43571. }
  43572. throw new InvalidPDFException('Invalid PDF structure');
  43573. },
  43574. readXRef: function XRef_readXRef(recoveryMode) {
  43575. var stream = this.stream;
  43576. try {
  43577. while (this.startXRefQueue.length) {
  43578. var startXRef = this.startXRefQueue[0];
  43579. stream.pos = startXRef + stream.start;
  43580. var parser = new Parser(new Lexer(stream), true, this);
  43581. var obj = parser.getObj();
  43582. var dict;
  43583. if (isCmd(obj, 'xref')) {
  43584. dict = this.processXRefTable(parser);
  43585. if (!this.topDict) {
  43586. this.topDict = dict;
  43587. }
  43588. obj = dict.get('XRefStm');
  43589. if (isInt(obj)) {
  43590. var pos = obj;
  43591. if (!(pos in this.xrefstms)) {
  43592. this.xrefstms[pos] = 1;
  43593. this.startXRefQueue.push(pos);
  43594. }
  43595. }
  43596. } else if (isInt(obj)) {
  43597. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  43598. error('Invalid XRef stream');
  43599. }
  43600. dict = this.processXRefStream(obj);
  43601. if (!this.topDict) {
  43602. this.topDict = dict;
  43603. }
  43604. if (!dict) {
  43605. error('Failed to read XRef stream');
  43606. }
  43607. } else {
  43608. error('Invalid XRef stream header');
  43609. }
  43610. obj = dict.get('Prev');
  43611. if (isInt(obj)) {
  43612. this.startXRefQueue.push(obj);
  43613. } else if (isRef(obj)) {
  43614. this.startXRefQueue.push(obj.num);
  43615. }
  43616. this.startXRefQueue.shift();
  43617. }
  43618. return this.topDict;
  43619. } catch (e) {
  43620. if (e instanceof MissingDataException) {
  43621. throw e;
  43622. }
  43623. info('(while reading XRef): ' + e);
  43624. }
  43625. if (recoveryMode) {
  43626. return;
  43627. }
  43628. throw new XRefParseException();
  43629. },
  43630. getEntry: function XRef_getEntry(i) {
  43631. var xrefEntry = this.entries[i];
  43632. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  43633. return xrefEntry;
  43634. }
  43635. return null;
  43636. },
  43637. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  43638. if (!isRef(obj)) {
  43639. return obj;
  43640. }
  43641. return this.fetch(obj, suppressEncryption);
  43642. },
  43643. fetch: function XRef_fetch(ref, suppressEncryption) {
  43644. assert(isRef(ref), 'ref object is not a reference');
  43645. var num = ref.num;
  43646. if (num in this.cache) {
  43647. var cacheEntry = this.cache[num];
  43648. return cacheEntry;
  43649. }
  43650. var xrefEntry = this.getEntry(num);
  43651. if (xrefEntry === null) {
  43652. return this.cache[num] = null;
  43653. }
  43654. if (xrefEntry.uncompressed) {
  43655. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  43656. } else {
  43657. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  43658. }
  43659. if (isDict(xrefEntry)) {
  43660. xrefEntry.objId = ref.toString();
  43661. } else if (isStream(xrefEntry)) {
  43662. xrefEntry.dict.objId = ref.toString();
  43663. }
  43664. return xrefEntry;
  43665. },
  43666. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  43667. var gen = ref.gen;
  43668. var num = ref.num;
  43669. if (xrefEntry.gen !== gen) {
  43670. error('inconsistent generation in XRef');
  43671. }
  43672. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  43673. var parser = new Parser(new Lexer(stream), true, this);
  43674. var obj1 = parser.getObj();
  43675. var obj2 = parser.getObj();
  43676. var obj3 = parser.getObj();
  43677. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  43678. error('bad XRef entry');
  43679. }
  43680. if (!isCmd(obj3, 'obj')) {
  43681. if (obj3.cmd.indexOf('obj') === 0) {
  43682. num = parseInt(obj3.cmd.substring(3), 10);
  43683. if (!isNaN(num)) {
  43684. return num;
  43685. }
  43686. }
  43687. error('bad XRef entry');
  43688. }
  43689. if (this.encrypt && !suppressEncryption) {
  43690. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  43691. } else {
  43692. xrefEntry = parser.getObj();
  43693. }
  43694. if (!isStream(xrefEntry)) {
  43695. this.cache[num] = xrefEntry;
  43696. }
  43697. return xrefEntry;
  43698. },
  43699. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  43700. var tableOffset = xrefEntry.offset;
  43701. var stream = this.fetch(new Ref(tableOffset, 0));
  43702. if (!isStream(stream)) {
  43703. error('bad ObjStm stream');
  43704. }
  43705. var first = stream.dict.get('First');
  43706. var n = stream.dict.get('N');
  43707. if (!isInt(first) || !isInt(n)) {
  43708. error('invalid first and n parameters for ObjStm stream');
  43709. }
  43710. var parser = new Parser(new Lexer(stream), false, this);
  43711. parser.allowStreams = true;
  43712. var i, entries = [], num, nums = [];
  43713. for (i = 0; i < n; ++i) {
  43714. num = parser.getObj();
  43715. if (!isInt(num)) {
  43716. error('invalid object number in the ObjStm stream: ' + num);
  43717. }
  43718. nums.push(num);
  43719. var offset = parser.getObj();
  43720. if (!isInt(offset)) {
  43721. error('invalid object offset in the ObjStm stream: ' + offset);
  43722. }
  43723. }
  43724. for (i = 0; i < n; ++i) {
  43725. entries.push(parser.getObj());
  43726. if (isCmd(parser.buf1, 'endobj')) {
  43727. parser.shift();
  43728. }
  43729. num = nums[i];
  43730. var entry = this.entries[num];
  43731. if (entry && entry.offset === tableOffset && entry.gen === i) {
  43732. this.cache[num] = entries[i];
  43733. }
  43734. }
  43735. xrefEntry = entries[xrefEntry.gen];
  43736. if (xrefEntry === undefined) {
  43737. error('bad XRef entry for compressed object');
  43738. }
  43739. return xrefEntry;
  43740. },
  43741. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  43742. if (!isRef(obj)) {
  43743. return Promise.resolve(obj);
  43744. }
  43745. return this.fetchAsync(obj, suppressEncryption);
  43746. },
  43747. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  43748. var streamManager = this.stream.manager;
  43749. var xref = this;
  43750. return new Promise(function tryFetch(resolve, reject) {
  43751. try {
  43752. resolve(xref.fetch(ref, suppressEncryption));
  43753. } catch (e) {
  43754. if (e instanceof MissingDataException) {
  43755. streamManager.requestRange(e.begin, e.end).then(function () {
  43756. tryFetch(resolve, reject);
  43757. }, reject);
  43758. return;
  43759. }
  43760. reject(e);
  43761. }
  43762. });
  43763. },
  43764. getCatalogObj: function XRef_getCatalogObj() {
  43765. return this.root;
  43766. }
  43767. };
  43768. return XRef;
  43769. }();
  43770. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  43771. function NameOrNumberTree(root, xref) {
  43772. throw new Error('Cannot initialize NameOrNumberTree.');
  43773. }
  43774. NameOrNumberTree.prototype = {
  43775. getAll: function NameOrNumberTree_getAll() {
  43776. var dict = Object.create(null);
  43777. if (!this.root) {
  43778. return dict;
  43779. }
  43780. var xref = this.xref;
  43781. var processed = new RefSet();
  43782. processed.put(this.root);
  43783. var queue = [this.root];
  43784. while (queue.length > 0) {
  43785. var i, n;
  43786. var obj = xref.fetchIfRef(queue.shift());
  43787. if (!isDict(obj)) {
  43788. continue;
  43789. }
  43790. if (obj.has('Kids')) {
  43791. var kids = obj.get('Kids');
  43792. for (i = 0, n = kids.length; i < n; i++) {
  43793. var kid = kids[i];
  43794. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  43795. queue.push(kid);
  43796. processed.put(kid);
  43797. }
  43798. continue;
  43799. }
  43800. var entries = obj.get(this._type);
  43801. if (isArray(entries)) {
  43802. for (i = 0, n = entries.length; i < n; i += 2) {
  43803. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  43804. }
  43805. }
  43806. }
  43807. return dict;
  43808. },
  43809. get: function NameOrNumberTree_get(key) {
  43810. if (!this.root) {
  43811. return null;
  43812. }
  43813. var xref = this.xref;
  43814. var kidsOrEntries = xref.fetchIfRef(this.root);
  43815. var loopCount = 0;
  43816. var MAX_LEVELS = 10;
  43817. var l, r, m;
  43818. while (kidsOrEntries.has('Kids')) {
  43819. if (++loopCount > MAX_LEVELS) {
  43820. warn('Search depth limit reached for "' + this._type + '" tree.');
  43821. return null;
  43822. }
  43823. var kids = kidsOrEntries.get('Kids');
  43824. if (!isArray(kids)) {
  43825. return null;
  43826. }
  43827. l = 0;
  43828. r = kids.length - 1;
  43829. while (l <= r) {
  43830. m = l + r >> 1;
  43831. var kid = xref.fetchIfRef(kids[m]);
  43832. var limits = kid.get('Limits');
  43833. if (key < xref.fetchIfRef(limits[0])) {
  43834. r = m - 1;
  43835. } else if (key > xref.fetchIfRef(limits[1])) {
  43836. l = m + 1;
  43837. } else {
  43838. kidsOrEntries = xref.fetchIfRef(kids[m]);
  43839. break;
  43840. }
  43841. }
  43842. if (l > r) {
  43843. return null;
  43844. }
  43845. }
  43846. var entries = kidsOrEntries.get(this._type);
  43847. if (isArray(entries)) {
  43848. l = 0;
  43849. r = entries.length - 2;
  43850. while (l <= r) {
  43851. m = l + r & ~1;
  43852. var currentKey = xref.fetchIfRef(entries[m]);
  43853. if (key < currentKey) {
  43854. r = m - 2;
  43855. } else if (key > currentKey) {
  43856. l = m + 2;
  43857. } else {
  43858. return xref.fetchIfRef(entries[m + 1]);
  43859. }
  43860. }
  43861. }
  43862. return null;
  43863. }
  43864. };
  43865. return NameOrNumberTree;
  43866. }();
  43867. var NameTree = function NameTreeClosure() {
  43868. function NameTree(root, xref) {
  43869. this.root = root;
  43870. this.xref = xref;
  43871. this._type = 'Names';
  43872. }
  43873. Util.inherit(NameTree, NameOrNumberTree, {});
  43874. return NameTree;
  43875. }();
  43876. var NumberTree = function NumberTreeClosure() {
  43877. function NumberTree(root, xref) {
  43878. this.root = root;
  43879. this.xref = xref;
  43880. this._type = 'Nums';
  43881. }
  43882. Util.inherit(NumberTree, NameOrNumberTree, {});
  43883. return NumberTree;
  43884. }();
  43885. var FileSpec = function FileSpecClosure() {
  43886. function FileSpec(root, xref) {
  43887. if (!root || !isDict(root)) {
  43888. return;
  43889. }
  43890. this.xref = xref;
  43891. this.root = root;
  43892. if (root.has('FS')) {
  43893. this.fs = root.get('FS');
  43894. }
  43895. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  43896. if (root.has('RF')) {
  43897. warn('Related file specifications are not supported');
  43898. }
  43899. this.contentAvailable = true;
  43900. if (!root.has('EF')) {
  43901. this.contentAvailable = false;
  43902. warn('Non-embedded file specifications are not supported');
  43903. }
  43904. }
  43905. function pickPlatformItem(dict) {
  43906. if (dict.has('UF')) {
  43907. return dict.get('UF');
  43908. } else if (dict.has('F')) {
  43909. return dict.get('F');
  43910. } else if (dict.has('Unix')) {
  43911. return dict.get('Unix');
  43912. } else if (dict.has('Mac')) {
  43913. return dict.get('Mac');
  43914. } else if (dict.has('DOS')) {
  43915. return dict.get('DOS');
  43916. } else {
  43917. return null;
  43918. }
  43919. }
  43920. FileSpec.prototype = {
  43921. get filename() {
  43922. if (!this._filename && this.root) {
  43923. var filename = pickPlatformItem(this.root) || 'unnamed';
  43924. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  43925. }
  43926. return this._filename;
  43927. },
  43928. get content() {
  43929. if (!this.contentAvailable) {
  43930. return null;
  43931. }
  43932. if (!this.contentRef && this.root) {
  43933. this.contentRef = pickPlatformItem(this.root.get('EF'));
  43934. }
  43935. var content = null;
  43936. if (this.contentRef) {
  43937. var xref = this.xref;
  43938. var fileObj = xref.fetchIfRef(this.contentRef);
  43939. if (fileObj && isStream(fileObj)) {
  43940. content = fileObj.getBytes();
  43941. } else {
  43942. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  43943. }
  43944. } else {
  43945. warn('Embedded file specification does not have a content');
  43946. }
  43947. return content;
  43948. },
  43949. get serializable() {
  43950. return {
  43951. filename: this.filename,
  43952. content: this.content
  43953. };
  43954. }
  43955. };
  43956. return FileSpec;
  43957. }();
  43958. var ObjectLoader = function () {
  43959. function mayHaveChildren(value) {
  43960. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  43961. }
  43962. function addChildren(node, nodesToVisit) {
  43963. var value;
  43964. if (isDict(node) || isStream(node)) {
  43965. var map;
  43966. if (isDict(node)) {
  43967. map = node.map;
  43968. } else {
  43969. map = node.dict.map;
  43970. }
  43971. for (var key in map) {
  43972. value = map[key];
  43973. if (mayHaveChildren(value)) {
  43974. nodesToVisit.push(value);
  43975. }
  43976. }
  43977. } else if (isArray(node)) {
  43978. for (var i = 0, ii = node.length; i < ii; i++) {
  43979. value = node[i];
  43980. if (mayHaveChildren(value)) {
  43981. nodesToVisit.push(value);
  43982. }
  43983. }
  43984. }
  43985. }
  43986. function ObjectLoader(obj, keys, xref) {
  43987. this.obj = obj;
  43988. this.keys = keys;
  43989. this.xref = xref;
  43990. this.refSet = null;
  43991. this.capability = null;
  43992. }
  43993. ObjectLoader.prototype = {
  43994. load: function ObjectLoader_load() {
  43995. var keys = this.keys;
  43996. this.capability = createPromiseCapability();
  43997. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  43998. this.capability.resolve();
  43999. return this.capability.promise;
  44000. }
  44001. this.refSet = new RefSet();
  44002. var nodesToVisit = [];
  44003. for (var i = 0; i < keys.length; i++) {
  44004. nodesToVisit.push(this.obj[keys[i]]);
  44005. }
  44006. this._walk(nodesToVisit);
  44007. return this.capability.promise;
  44008. },
  44009. _walk: function ObjectLoader_walk(nodesToVisit) {
  44010. var nodesToRevisit = [];
  44011. var pendingRequests = [];
  44012. while (nodesToVisit.length) {
  44013. var currentNode = nodesToVisit.pop();
  44014. if (isRef(currentNode)) {
  44015. if (this.refSet.has(currentNode)) {
  44016. continue;
  44017. }
  44018. try {
  44019. var ref = currentNode;
  44020. this.refSet.put(ref);
  44021. currentNode = this.xref.fetch(currentNode);
  44022. } catch (e) {
  44023. if (!(e instanceof MissingDataException)) {
  44024. throw e;
  44025. }
  44026. nodesToRevisit.push(currentNode);
  44027. pendingRequests.push({
  44028. begin: e.begin,
  44029. end: e.end
  44030. });
  44031. }
  44032. }
  44033. if (currentNode && currentNode.getBaseStreams) {
  44034. var baseStreams = currentNode.getBaseStreams();
  44035. var foundMissingData = false;
  44036. for (var i = 0; i < baseStreams.length; i++) {
  44037. var stream = baseStreams[i];
  44038. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  44039. foundMissingData = true;
  44040. pendingRequests.push({
  44041. begin: stream.start,
  44042. end: stream.end
  44043. });
  44044. }
  44045. }
  44046. if (foundMissingData) {
  44047. nodesToRevisit.push(currentNode);
  44048. }
  44049. }
  44050. addChildren(currentNode, nodesToVisit);
  44051. }
  44052. if (pendingRequests.length) {
  44053. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  44054. nodesToVisit = nodesToRevisit;
  44055. for (var i = 0; i < nodesToRevisit.length; i++) {
  44056. var node = nodesToRevisit[i];
  44057. if (isRef(node)) {
  44058. this.refSet.remove(node);
  44059. }
  44060. }
  44061. this._walk(nodesToVisit);
  44062. }.bind(this), this.capability.reject);
  44063. return;
  44064. }
  44065. this.refSet = null;
  44066. this.capability.resolve();
  44067. }
  44068. };
  44069. return ObjectLoader;
  44070. }();
  44071. exports.Catalog = Catalog;
  44072. exports.ObjectLoader = ObjectLoader;
  44073. exports.XRef = XRef;
  44074. exports.FileSpec = FileSpec;
  44075. }));
  44076. (function (root, factory) {
  44077. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  44078. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  44079. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  44080. var MissingDataException = sharedUtil.MissingDataException;
  44081. var Util = sharedUtil.Util;
  44082. var assert = sharedUtil.assert;
  44083. var error = sharedUtil.error;
  44084. var info = sharedUtil.info;
  44085. var warn = sharedUtil.warn;
  44086. var isStream = corePrimitives.isStream;
  44087. var PDFFunction = coreFunction.PDFFunction;
  44088. var ColorSpace = coreColorSpace.ColorSpace;
  44089. var ShadingType = {
  44090. FUNCTION_BASED: 1,
  44091. AXIAL: 2,
  44092. RADIAL: 3,
  44093. FREE_FORM_MESH: 4,
  44094. LATTICE_FORM_MESH: 5,
  44095. COONS_PATCH_MESH: 6,
  44096. TENSOR_PATCH_MESH: 7
  44097. };
  44098. var Pattern = function PatternClosure() {
  44099. function Pattern() {
  44100. error('should not call Pattern constructor');
  44101. }
  44102. Pattern.prototype = {
  44103. getPattern: function Pattern_getPattern(ctx) {
  44104. error('Should not call Pattern.getStyle: ' + ctx);
  44105. }
  44106. };
  44107. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  44108. var dict = isStream(shading) ? shading.dict : shading;
  44109. var type = dict.get('ShadingType');
  44110. try {
  44111. switch (type) {
  44112. case ShadingType.AXIAL:
  44113. case ShadingType.RADIAL:
  44114. return new Shadings.RadialAxial(dict, matrix, xref, res);
  44115. case ShadingType.FREE_FORM_MESH:
  44116. case ShadingType.LATTICE_FORM_MESH:
  44117. case ShadingType.COONS_PATCH_MESH:
  44118. case ShadingType.TENSOR_PATCH_MESH:
  44119. return new Shadings.Mesh(shading, matrix, xref, res);
  44120. default:
  44121. throw new Error('Unsupported ShadingType: ' + type);
  44122. }
  44123. } catch (ex) {
  44124. if (ex instanceof MissingDataException) {
  44125. throw ex;
  44126. }
  44127. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  44128. warn(ex);
  44129. return new Shadings.Dummy();
  44130. }
  44131. };
  44132. return Pattern;
  44133. }();
  44134. var Shadings = {};
  44135. Shadings.SMALL_NUMBER = 1e-6;
  44136. Shadings.RadialAxial = function RadialAxialClosure() {
  44137. function RadialAxial(dict, matrix, xref, res) {
  44138. this.matrix = matrix;
  44139. this.coordsArr = dict.getArray('Coords');
  44140. this.shadingType = dict.get('ShadingType');
  44141. this.type = 'Pattern';
  44142. var cs = dict.get('ColorSpace', 'CS');
  44143. cs = ColorSpace.parse(cs, xref, res);
  44144. this.cs = cs;
  44145. var t0 = 0.0, t1 = 1.0;
  44146. if (dict.has('Domain')) {
  44147. var domainArr = dict.getArray('Domain');
  44148. t0 = domainArr[0];
  44149. t1 = domainArr[1];
  44150. }
  44151. var extendStart = false, extendEnd = false;
  44152. if (dict.has('Extend')) {
  44153. var extendArr = dict.getArray('Extend');
  44154. extendStart = extendArr[0];
  44155. extendEnd = extendArr[1];
  44156. }
  44157. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  44158. var x1 = this.coordsArr[0];
  44159. var y1 = this.coordsArr[1];
  44160. var r1 = this.coordsArr[2];
  44161. var x2 = this.coordsArr[3];
  44162. var y2 = this.coordsArr[4];
  44163. var r2 = this.coordsArr[5];
  44164. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  44165. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  44166. warn('Unsupported radial gradient.');
  44167. }
  44168. }
  44169. this.extendStart = extendStart;
  44170. this.extendEnd = extendEnd;
  44171. var fnObj = dict.get('Function');
  44172. var fn = PDFFunction.parseArray(xref, fnObj);
  44173. var diff = t1 - t0;
  44174. var step = diff / 10;
  44175. var colorStops = this.colorStops = [];
  44176. if (t0 >= t1 || step <= 0) {
  44177. info('Bad shading domain.');
  44178. return;
  44179. }
  44180. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  44181. var rgbColor;
  44182. for (var i = t0; i <= t1; i += step) {
  44183. ratio[0] = i;
  44184. fn(ratio, 0, color, 0);
  44185. rgbColor = cs.getRgb(color, 0);
  44186. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44187. colorStops.push([
  44188. (i - t0) / diff,
  44189. cssColor
  44190. ]);
  44191. }
  44192. var background = 'transparent';
  44193. if (dict.has('Background')) {
  44194. rgbColor = cs.getRgb(dict.get('Background'), 0);
  44195. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44196. }
  44197. if (!extendStart) {
  44198. colorStops.unshift([
  44199. 0,
  44200. background
  44201. ]);
  44202. colorStops[1][0] += Shadings.SMALL_NUMBER;
  44203. }
  44204. if (!extendEnd) {
  44205. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  44206. colorStops.push([
  44207. 1,
  44208. background
  44209. ]);
  44210. }
  44211. this.colorStops = colorStops;
  44212. }
  44213. RadialAxial.prototype = {
  44214. getIR: function RadialAxial_getIR() {
  44215. var coordsArr = this.coordsArr;
  44216. var shadingType = this.shadingType;
  44217. var type, p0, p1, r0, r1;
  44218. if (shadingType === ShadingType.AXIAL) {
  44219. p0 = [
  44220. coordsArr[0],
  44221. coordsArr[1]
  44222. ];
  44223. p1 = [
  44224. coordsArr[2],
  44225. coordsArr[3]
  44226. ];
  44227. r0 = null;
  44228. r1 = null;
  44229. type = 'axial';
  44230. } else if (shadingType === ShadingType.RADIAL) {
  44231. p0 = [
  44232. coordsArr[0],
  44233. coordsArr[1]
  44234. ];
  44235. p1 = [
  44236. coordsArr[3],
  44237. coordsArr[4]
  44238. ];
  44239. r0 = coordsArr[2];
  44240. r1 = coordsArr[5];
  44241. type = 'radial';
  44242. } else {
  44243. error('getPattern type unknown: ' + shadingType);
  44244. }
  44245. var matrix = this.matrix;
  44246. if (matrix) {
  44247. p0 = Util.applyTransform(p0, matrix);
  44248. p1 = Util.applyTransform(p1, matrix);
  44249. if (shadingType === ShadingType.RADIAL) {
  44250. var scale = Util.singularValueDecompose2dScale(matrix);
  44251. r0 *= scale[0];
  44252. r1 *= scale[1];
  44253. }
  44254. }
  44255. return [
  44256. 'RadialAxial',
  44257. type,
  44258. this.colorStops,
  44259. p0,
  44260. p1,
  44261. r0,
  44262. r1
  44263. ];
  44264. }
  44265. };
  44266. return RadialAxial;
  44267. }();
  44268. Shadings.Mesh = function MeshClosure() {
  44269. function MeshStreamReader(stream, context) {
  44270. this.stream = stream;
  44271. this.context = context;
  44272. this.buffer = 0;
  44273. this.bufferLength = 0;
  44274. var numComps = context.numComps;
  44275. this.tmpCompsBuf = new Float32Array(numComps);
  44276. var csNumComps = context.colorSpace.numComps;
  44277. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  44278. }
  44279. MeshStreamReader.prototype = {
  44280. get hasData() {
  44281. if (this.stream.end) {
  44282. return this.stream.pos < this.stream.end;
  44283. }
  44284. if (this.bufferLength > 0) {
  44285. return true;
  44286. }
  44287. var nextByte = this.stream.getByte();
  44288. if (nextByte < 0) {
  44289. return false;
  44290. }
  44291. this.buffer = nextByte;
  44292. this.bufferLength = 8;
  44293. return true;
  44294. },
  44295. readBits: function MeshStreamReader_readBits(n) {
  44296. var buffer = this.buffer;
  44297. var bufferLength = this.bufferLength;
  44298. if (n === 32) {
  44299. if (bufferLength === 0) {
  44300. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  44301. }
  44302. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  44303. var nextByte = this.stream.getByte();
  44304. this.buffer = nextByte & (1 << bufferLength) - 1;
  44305. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  44306. }
  44307. if (n === 8 && bufferLength === 0) {
  44308. return this.stream.getByte();
  44309. }
  44310. while (bufferLength < n) {
  44311. buffer = buffer << 8 | this.stream.getByte();
  44312. bufferLength += 8;
  44313. }
  44314. bufferLength -= n;
  44315. this.bufferLength = bufferLength;
  44316. this.buffer = buffer & (1 << bufferLength) - 1;
  44317. return buffer >> bufferLength;
  44318. },
  44319. align: function MeshStreamReader_align() {
  44320. this.buffer = 0;
  44321. this.bufferLength = 0;
  44322. },
  44323. readFlag: function MeshStreamReader_readFlag() {
  44324. return this.readBits(this.context.bitsPerFlag);
  44325. },
  44326. readCoordinate: function MeshStreamReader_readCoordinate() {
  44327. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  44328. var xi = this.readBits(bitsPerCoordinate);
  44329. var yi = this.readBits(bitsPerCoordinate);
  44330. var decode = this.context.decode;
  44331. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  44332. return [
  44333. xi * scale * (decode[1] - decode[0]) + decode[0],
  44334. yi * scale * (decode[3] - decode[2]) + decode[2]
  44335. ];
  44336. },
  44337. readComponents: function MeshStreamReader_readComponents() {
  44338. var numComps = this.context.numComps;
  44339. var bitsPerComponent = this.context.bitsPerComponent;
  44340. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  44341. var decode = this.context.decode;
  44342. var components = this.tmpCompsBuf;
  44343. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  44344. var ci = this.readBits(bitsPerComponent);
  44345. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  44346. }
  44347. var color = this.tmpCsCompsBuf;
  44348. if (this.context.colorFn) {
  44349. this.context.colorFn(components, 0, color, 0);
  44350. }
  44351. return this.context.colorSpace.getRgb(color, 0);
  44352. }
  44353. };
  44354. function decodeType4Shading(mesh, reader) {
  44355. var coords = mesh.coords;
  44356. var colors = mesh.colors;
  44357. var operators = [];
  44358. var ps = [];
  44359. var verticesLeft = 0;
  44360. while (reader.hasData) {
  44361. var f = reader.readFlag();
  44362. var coord = reader.readCoordinate();
  44363. var color = reader.readComponents();
  44364. if (verticesLeft === 0) {
  44365. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  44366. switch (f) {
  44367. case 0:
  44368. verticesLeft = 3;
  44369. break;
  44370. case 1:
  44371. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  44372. verticesLeft = 1;
  44373. break;
  44374. case 2:
  44375. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  44376. verticesLeft = 1;
  44377. break;
  44378. }
  44379. operators.push(f);
  44380. }
  44381. ps.push(coords.length);
  44382. coords.push(coord);
  44383. colors.push(color);
  44384. verticesLeft--;
  44385. reader.align();
  44386. }
  44387. mesh.figures.push({
  44388. type: 'triangles',
  44389. coords: new Int32Array(ps),
  44390. colors: new Int32Array(ps)
  44391. });
  44392. }
  44393. function decodeType5Shading(mesh, reader, verticesPerRow) {
  44394. var coords = mesh.coords;
  44395. var colors = mesh.colors;
  44396. var ps = [];
  44397. while (reader.hasData) {
  44398. var coord = reader.readCoordinate();
  44399. var color = reader.readComponents();
  44400. ps.push(coords.length);
  44401. coords.push(coord);
  44402. colors.push(color);
  44403. }
  44404. mesh.figures.push({
  44405. type: 'lattice',
  44406. coords: new Int32Array(ps),
  44407. colors: new Int32Array(ps),
  44408. verticesPerRow: verticesPerRow
  44409. });
  44410. }
  44411. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  44412. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  44413. var TRIANGLE_DENSITY = 20;
  44414. var getB = function getBClosure() {
  44415. function buildB(count) {
  44416. var lut = [];
  44417. for (var i = 0; i <= count; i++) {
  44418. var t = i / count, t_ = 1 - t;
  44419. lut.push(new Float32Array([
  44420. t_ * t_ * t_,
  44421. 3 * t * t_ * t_,
  44422. 3 * t * t * t_,
  44423. t * t * t
  44424. ]));
  44425. }
  44426. return lut;
  44427. }
  44428. var cache = [];
  44429. return function getB(count) {
  44430. if (!cache[count]) {
  44431. cache[count] = buildB(count);
  44432. }
  44433. return cache[count];
  44434. };
  44435. }();
  44436. function buildFigureFromPatch(mesh, index) {
  44437. var figure = mesh.figures[index];
  44438. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  44439. var coords = mesh.coords, colors = mesh.colors;
  44440. var pi = figure.coords;
  44441. var ci = figure.colors;
  44442. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44443. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44444. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44445. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44446. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  44447. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  44448. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  44449. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  44450. var verticesPerRow = splitXBy + 1;
  44451. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  44452. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  44453. var k = 0;
  44454. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  44455. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  44456. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  44457. for (var row = 0; row <= splitYBy; row++) {
  44458. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  44459. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  44460. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  44461. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  44462. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  44463. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  44464. for (var col = 0; col <= splitXBy; col++, k++) {
  44465. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  44466. continue;
  44467. }
  44468. var x = 0, y = 0;
  44469. var q = 0;
  44470. for (var i = 0; i <= 3; i++) {
  44471. for (var j = 0; j <= 3; j++, q++) {
  44472. var m = bRow[row][i] * bCol[col][j];
  44473. x += coords[pi[q]][0] * m;
  44474. y += coords[pi[q]][1] * m;
  44475. }
  44476. }
  44477. figureCoords[k] = coords.length;
  44478. coords.push([
  44479. x,
  44480. y
  44481. ]);
  44482. figureColors[k] = colors.length;
  44483. var newColor = new Uint8Array(3);
  44484. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  44485. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  44486. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  44487. colors.push(newColor);
  44488. }
  44489. }
  44490. figureCoords[0] = pi[0];
  44491. figureColors[0] = ci[0];
  44492. figureCoords[splitXBy] = pi[3];
  44493. figureColors[splitXBy] = ci[1];
  44494. figureCoords[verticesPerRow * splitYBy] = pi[12];
  44495. figureColors[verticesPerRow * splitYBy] = ci[2];
  44496. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  44497. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  44498. mesh.figures[index] = {
  44499. type: 'lattice',
  44500. coords: figureCoords,
  44501. colors: figureColors,
  44502. verticesPerRow: verticesPerRow
  44503. };
  44504. }
  44505. function decodeType6Shading(mesh, reader) {
  44506. var coords = mesh.coords;
  44507. var colors = mesh.colors;
  44508. var ps = new Int32Array(16);
  44509. var cs = new Int32Array(4);
  44510. while (reader.hasData) {
  44511. var f = reader.readFlag();
  44512. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  44513. var i, ii;
  44514. var pi = coords.length;
  44515. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  44516. coords.push(reader.readCoordinate());
  44517. }
  44518. var ci = colors.length;
  44519. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44520. colors.push(reader.readComponents());
  44521. }
  44522. var tmp1, tmp2, tmp3, tmp4;
  44523. switch (f) {
  44524. case 0:
  44525. ps[12] = pi + 3;
  44526. ps[13] = pi + 4;
  44527. ps[14] = pi + 5;
  44528. ps[15] = pi + 6;
  44529. ps[8] = pi + 2;
  44530. ps[11] = pi + 7;
  44531. ps[4] = pi + 1;
  44532. ps[7] = pi + 8;
  44533. ps[0] = pi;
  44534. ps[1] = pi + 11;
  44535. ps[2] = pi + 10;
  44536. ps[3] = pi + 9;
  44537. cs[2] = ci + 1;
  44538. cs[3] = ci + 2;
  44539. cs[0] = ci;
  44540. cs[1] = ci + 3;
  44541. break;
  44542. case 1:
  44543. tmp1 = ps[12];
  44544. tmp2 = ps[13];
  44545. tmp3 = ps[14];
  44546. tmp4 = ps[15];
  44547. ps[12] = tmp4;
  44548. ps[13] = pi + 0;
  44549. ps[14] = pi + 1;
  44550. ps[15] = pi + 2;
  44551. ps[8] = tmp3;
  44552. ps[11] = pi + 3;
  44553. ps[4] = tmp2;
  44554. ps[7] = pi + 4;
  44555. ps[0] = tmp1;
  44556. ps[1] = pi + 7;
  44557. ps[2] = pi + 6;
  44558. ps[3] = pi + 5;
  44559. tmp1 = cs[2];
  44560. tmp2 = cs[3];
  44561. cs[2] = tmp2;
  44562. cs[3] = ci;
  44563. cs[0] = tmp1;
  44564. cs[1] = ci + 1;
  44565. break;
  44566. case 2:
  44567. tmp1 = ps[15];
  44568. tmp2 = ps[11];
  44569. ps[12] = ps[3];
  44570. ps[13] = pi + 0;
  44571. ps[14] = pi + 1;
  44572. ps[15] = pi + 2;
  44573. ps[8] = ps[7];
  44574. ps[11] = pi + 3;
  44575. ps[4] = tmp2;
  44576. ps[7] = pi + 4;
  44577. ps[0] = tmp1;
  44578. ps[1] = pi + 7;
  44579. ps[2] = pi + 6;
  44580. ps[3] = pi + 5;
  44581. tmp1 = cs[3];
  44582. cs[2] = cs[1];
  44583. cs[3] = ci;
  44584. cs[0] = tmp1;
  44585. cs[1] = ci + 1;
  44586. break;
  44587. case 3:
  44588. ps[12] = ps[0];
  44589. ps[13] = pi + 0;
  44590. ps[14] = pi + 1;
  44591. ps[15] = pi + 2;
  44592. ps[8] = ps[1];
  44593. ps[11] = pi + 3;
  44594. ps[4] = ps[2];
  44595. ps[7] = pi + 4;
  44596. ps[0] = ps[3];
  44597. ps[1] = pi + 7;
  44598. ps[2] = pi + 6;
  44599. ps[3] = pi + 5;
  44600. cs[2] = cs[0];
  44601. cs[3] = ci;
  44602. cs[0] = cs[1];
  44603. cs[1] = ci + 1;
  44604. break;
  44605. }
  44606. ps[5] = coords.length;
  44607. coords.push([
  44608. (-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,
  44609. (-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
  44610. ]);
  44611. ps[6] = coords.length;
  44612. coords.push([
  44613. (-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,
  44614. (-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
  44615. ]);
  44616. ps[9] = coords.length;
  44617. coords.push([
  44618. (-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,
  44619. (-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
  44620. ]);
  44621. ps[10] = coords.length;
  44622. coords.push([
  44623. (-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,
  44624. (-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
  44625. ]);
  44626. mesh.figures.push({
  44627. type: 'patch',
  44628. coords: new Int32Array(ps),
  44629. colors: new Int32Array(cs)
  44630. });
  44631. }
  44632. }
  44633. function decodeType7Shading(mesh, reader) {
  44634. var coords = mesh.coords;
  44635. var colors = mesh.colors;
  44636. var ps = new Int32Array(16);
  44637. var cs = new Int32Array(4);
  44638. while (reader.hasData) {
  44639. var f = reader.readFlag();
  44640. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  44641. var i, ii;
  44642. var pi = coords.length;
  44643. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  44644. coords.push(reader.readCoordinate());
  44645. }
  44646. var ci = colors.length;
  44647. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44648. colors.push(reader.readComponents());
  44649. }
  44650. var tmp1, tmp2, tmp3, tmp4;
  44651. switch (f) {
  44652. case 0:
  44653. ps[12] = pi + 3;
  44654. ps[13] = pi + 4;
  44655. ps[14] = pi + 5;
  44656. ps[15] = pi + 6;
  44657. ps[8] = pi + 2;
  44658. ps[9] = pi + 13;
  44659. ps[10] = pi + 14;
  44660. ps[11] = pi + 7;
  44661. ps[4] = pi + 1;
  44662. ps[5] = pi + 12;
  44663. ps[6] = pi + 15;
  44664. ps[7] = pi + 8;
  44665. ps[0] = pi;
  44666. ps[1] = pi + 11;
  44667. ps[2] = pi + 10;
  44668. ps[3] = pi + 9;
  44669. cs[2] = ci + 1;
  44670. cs[3] = ci + 2;
  44671. cs[0] = ci;
  44672. cs[1] = ci + 3;
  44673. break;
  44674. case 1:
  44675. tmp1 = ps[12];
  44676. tmp2 = ps[13];
  44677. tmp3 = ps[14];
  44678. tmp4 = ps[15];
  44679. ps[12] = tmp4;
  44680. ps[13] = pi + 0;
  44681. ps[14] = pi + 1;
  44682. ps[15] = pi + 2;
  44683. ps[8] = tmp3;
  44684. ps[9] = pi + 9;
  44685. ps[10] = pi + 10;
  44686. ps[11] = pi + 3;
  44687. ps[4] = tmp2;
  44688. ps[5] = pi + 8;
  44689. ps[6] = pi + 11;
  44690. ps[7] = pi + 4;
  44691. ps[0] = tmp1;
  44692. ps[1] = pi + 7;
  44693. ps[2] = pi + 6;
  44694. ps[3] = pi + 5;
  44695. tmp1 = cs[2];
  44696. tmp2 = cs[3];
  44697. cs[2] = tmp2;
  44698. cs[3] = ci;
  44699. cs[0] = tmp1;
  44700. cs[1] = ci + 1;
  44701. break;
  44702. case 2:
  44703. tmp1 = ps[15];
  44704. tmp2 = ps[11];
  44705. ps[12] = ps[3];
  44706. ps[13] = pi + 0;
  44707. ps[14] = pi + 1;
  44708. ps[15] = pi + 2;
  44709. ps[8] = ps[7];
  44710. ps[9] = pi + 9;
  44711. ps[10] = pi + 10;
  44712. ps[11] = pi + 3;
  44713. ps[4] = tmp2;
  44714. ps[5] = pi + 8;
  44715. ps[6] = pi + 11;
  44716. ps[7] = pi + 4;
  44717. ps[0] = tmp1;
  44718. ps[1] = pi + 7;
  44719. ps[2] = pi + 6;
  44720. ps[3] = pi + 5;
  44721. tmp1 = cs[3];
  44722. cs[2] = cs[1];
  44723. cs[3] = ci;
  44724. cs[0] = tmp1;
  44725. cs[1] = ci + 1;
  44726. break;
  44727. case 3:
  44728. ps[12] = ps[0];
  44729. ps[13] = pi + 0;
  44730. ps[14] = pi + 1;
  44731. ps[15] = pi + 2;
  44732. ps[8] = ps[1];
  44733. ps[9] = pi + 9;
  44734. ps[10] = pi + 10;
  44735. ps[11] = pi + 3;
  44736. ps[4] = ps[2];
  44737. ps[5] = pi + 8;
  44738. ps[6] = pi + 11;
  44739. ps[7] = pi + 4;
  44740. ps[0] = ps[3];
  44741. ps[1] = pi + 7;
  44742. ps[2] = pi + 6;
  44743. ps[3] = pi + 5;
  44744. cs[2] = cs[0];
  44745. cs[3] = ci;
  44746. cs[0] = cs[1];
  44747. cs[1] = ci + 1;
  44748. break;
  44749. }
  44750. mesh.figures.push({
  44751. type: 'patch',
  44752. coords: new Int32Array(ps),
  44753. colors: new Int32Array(cs)
  44754. });
  44755. }
  44756. }
  44757. function updateBounds(mesh) {
  44758. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  44759. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  44760. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  44761. minX = minX > x ? x : minX;
  44762. minY = minY > y ? y : minY;
  44763. maxX = maxX < x ? x : maxX;
  44764. maxY = maxY < y ? y : maxY;
  44765. }
  44766. mesh.bounds = [
  44767. minX,
  44768. minY,
  44769. maxX,
  44770. maxY
  44771. ];
  44772. }
  44773. function packData(mesh) {
  44774. var i, ii, j, jj;
  44775. var coords = mesh.coords;
  44776. var coordsPacked = new Float32Array(coords.length * 2);
  44777. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  44778. var xy = coords[i];
  44779. coordsPacked[j++] = xy[0];
  44780. coordsPacked[j++] = xy[1];
  44781. }
  44782. mesh.coords = coordsPacked;
  44783. var colors = mesh.colors;
  44784. var colorsPacked = new Uint8Array(colors.length * 3);
  44785. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  44786. var c = colors[i];
  44787. colorsPacked[j++] = c[0];
  44788. colorsPacked[j++] = c[1];
  44789. colorsPacked[j++] = c[2];
  44790. }
  44791. mesh.colors = colorsPacked;
  44792. var figures = mesh.figures;
  44793. for (i = 0, ii = figures.length; i < ii; i++) {
  44794. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  44795. for (j = 0, jj = ps.length; j < jj; j++) {
  44796. ps[j] *= 2;
  44797. cs[j] *= 3;
  44798. }
  44799. }
  44800. }
  44801. function Mesh(stream, matrix, xref, res) {
  44802. assert(isStream(stream), 'Mesh data is not a stream');
  44803. var dict = stream.dict;
  44804. this.matrix = matrix;
  44805. this.shadingType = dict.get('ShadingType');
  44806. this.type = 'Pattern';
  44807. this.bbox = dict.getArray('BBox');
  44808. var cs = dict.get('ColorSpace', 'CS');
  44809. cs = ColorSpace.parse(cs, xref, res);
  44810. this.cs = cs;
  44811. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  44812. var fnObj = dict.get('Function');
  44813. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  44814. this.coords = [];
  44815. this.colors = [];
  44816. this.figures = [];
  44817. var decodeContext = {
  44818. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  44819. bitsPerComponent: dict.get('BitsPerComponent'),
  44820. bitsPerFlag: dict.get('BitsPerFlag'),
  44821. decode: dict.getArray('Decode'),
  44822. colorFn: fn,
  44823. colorSpace: cs,
  44824. numComps: fn ? 1 : cs.numComps
  44825. };
  44826. var reader = new MeshStreamReader(stream, decodeContext);
  44827. var patchMesh = false;
  44828. switch (this.shadingType) {
  44829. case ShadingType.FREE_FORM_MESH:
  44830. decodeType4Shading(this, reader);
  44831. break;
  44832. case ShadingType.LATTICE_FORM_MESH:
  44833. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  44834. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  44835. decodeType5Shading(this, reader, verticesPerRow);
  44836. break;
  44837. case ShadingType.COONS_PATCH_MESH:
  44838. decodeType6Shading(this, reader);
  44839. patchMesh = true;
  44840. break;
  44841. case ShadingType.TENSOR_PATCH_MESH:
  44842. decodeType7Shading(this, reader);
  44843. patchMesh = true;
  44844. break;
  44845. default:
  44846. error('Unsupported mesh type.');
  44847. break;
  44848. }
  44849. if (patchMesh) {
  44850. updateBounds(this);
  44851. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  44852. buildFigureFromPatch(this, i);
  44853. }
  44854. }
  44855. updateBounds(this);
  44856. packData(this);
  44857. }
  44858. Mesh.prototype = {
  44859. getIR: function Mesh_getIR() {
  44860. return [
  44861. 'Mesh',
  44862. this.shadingType,
  44863. this.coords,
  44864. this.colors,
  44865. this.figures,
  44866. this.bounds,
  44867. this.matrix,
  44868. this.bbox,
  44869. this.background
  44870. ];
  44871. }
  44872. };
  44873. return Mesh;
  44874. }();
  44875. Shadings.Dummy = function DummyClosure() {
  44876. function Dummy() {
  44877. this.type = 'Pattern';
  44878. }
  44879. Dummy.prototype = {
  44880. getIR: function Dummy_getIR() {
  44881. return ['Dummy'];
  44882. }
  44883. };
  44884. return Dummy;
  44885. }();
  44886. function getTilingPatternIR(operatorList, dict, args) {
  44887. var matrix = dict.getArray('Matrix');
  44888. var bbox = dict.getArray('BBox');
  44889. var xstep = dict.get('XStep');
  44890. var ystep = dict.get('YStep');
  44891. var paintType = dict.get('PaintType');
  44892. var tilingType = dict.get('TilingType');
  44893. return [
  44894. 'TilingPattern',
  44895. args,
  44896. operatorList,
  44897. matrix,
  44898. bbox,
  44899. xstep,
  44900. ystep,
  44901. paintType,
  44902. tilingType
  44903. ];
  44904. }
  44905. exports.Pattern = Pattern;
  44906. exports.getTilingPatternIR = getTilingPatternIR;
  44907. }));
  44908. (function (root, factory) {
  44909. 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);
  44910. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  44911. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  44912. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  44913. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  44914. var ImageKind = sharedUtil.ImageKind;
  44915. var OPS = sharedUtil.OPS;
  44916. var TextRenderingMode = sharedUtil.TextRenderingMode;
  44917. var Util = sharedUtil.Util;
  44918. var assert = sharedUtil.assert;
  44919. var createPromiseCapability = sharedUtil.createPromiseCapability;
  44920. var error = sharedUtil.error;
  44921. var info = sharedUtil.info;
  44922. var isArray = sharedUtil.isArray;
  44923. var isNum = sharedUtil.isNum;
  44924. var isString = sharedUtil.isString;
  44925. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  44926. var warn = sharedUtil.warn;
  44927. var Dict = corePrimitives.Dict;
  44928. var Name = corePrimitives.Name;
  44929. var isCmd = corePrimitives.isCmd;
  44930. var isDict = corePrimitives.isDict;
  44931. var isName = corePrimitives.isName;
  44932. var isRef = corePrimitives.isRef;
  44933. var isStream = corePrimitives.isStream;
  44934. var DecodeStream = coreStream.DecodeStream;
  44935. var JpegStream = coreStream.JpegStream;
  44936. var Stream = coreStream.Stream;
  44937. var Lexer = coreParser.Lexer;
  44938. var Parser = coreParser.Parser;
  44939. var isEOF = coreParser.isEOF;
  44940. var PDFImage = coreImage.PDFImage;
  44941. var ColorSpace = coreColorSpace.ColorSpace;
  44942. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  44943. var ErrorFont = coreFonts.ErrorFont;
  44944. var FontFlags = coreFonts.FontFlags;
  44945. var Font = coreFonts.Font;
  44946. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  44947. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  44948. var getFontType = coreFonts.getFontType;
  44949. var isPDFFunction = coreFunction.isPDFFunction;
  44950. var PDFFunction = coreFunction.PDFFunction;
  44951. var Pattern = corePattern.Pattern;
  44952. var getTilingPatternIR = corePattern.getTilingPatternIR;
  44953. var CMapFactory = coreCMap.CMapFactory;
  44954. var IdentityCMap = coreCMap.IdentityCMap;
  44955. var getMetrics = coreMetrics.getMetrics;
  44956. var bidi = coreBidi.bidi;
  44957. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  44958. var StandardEncoding = coreEncodings.StandardEncoding;
  44959. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  44960. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  44961. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  44962. var getEncoding = coreEncodings.getEncoding;
  44963. var getStdFontMap = coreStandardFonts.getStdFontMap;
  44964. var getSerifFonts = coreStandardFonts.getSerifFonts;
  44965. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  44966. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  44967. var reverseIfRtl = coreUnicode.reverseIfRtl;
  44968. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  44969. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  44970. var PartialEvaluator = function PartialEvaluatorClosure() {
  44971. var DefaultPartialEvaluatorOptions = {
  44972. forceDataSchema: false,
  44973. maxImageSize: -1,
  44974. disableFontFace: false,
  44975. cMapOptions: {
  44976. url: null,
  44977. packed: false
  44978. }
  44979. };
  44980. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  44981. this.xref = xref;
  44982. this.resources = resources;
  44983. this.handler = handler;
  44984. this.forceDataSchema = forceDataSchema;
  44985. }
  44986. NativeImageDecoder.prototype = {
  44987. canDecode: function (image) {
  44988. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  44989. },
  44990. decode: function (image) {
  44991. var dict = image.dict;
  44992. var colorSpace = dict.get('ColorSpace', 'CS');
  44993. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  44994. var numComps = colorSpace.numComps;
  44995. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  44996. image.getIR(this.forceDataSchema),
  44997. numComps
  44998. ]);
  44999. return decodePromise.then(function (message) {
  45000. var data = message.data;
  45001. return new Stream(data, 0, data.length, image.dict);
  45002. });
  45003. }
  45004. };
  45005. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  45006. var dict = image.dict;
  45007. if (dict.has('DecodeParms') || dict.has('DP')) {
  45008. return false;
  45009. }
  45010. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  45011. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  45012. };
  45013. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  45014. var dict = image.dict;
  45015. if (dict.has('DecodeParms') || dict.has('DP')) {
  45016. return false;
  45017. }
  45018. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  45019. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  45020. };
  45021. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  45022. this.pdfManager = pdfManager;
  45023. this.xref = xref;
  45024. this.handler = handler;
  45025. this.pageIndex = pageIndex;
  45026. this.uniquePrefix = uniquePrefix;
  45027. this.idCounters = idCounters;
  45028. this.fontCache = fontCache;
  45029. this.options = options || DefaultPartialEvaluatorOptions;
  45030. }
  45031. var TIME_SLOT_DURATION_MS = 20;
  45032. var CHECK_TIME_EVERY = 100;
  45033. function TimeSlotManager() {
  45034. this.reset();
  45035. }
  45036. TimeSlotManager.prototype = {
  45037. check: function TimeSlotManager_check() {
  45038. if (++this.checked < CHECK_TIME_EVERY) {
  45039. return false;
  45040. }
  45041. this.checked = 0;
  45042. return this.endTime <= Date.now();
  45043. },
  45044. reset: function TimeSlotManager_reset() {
  45045. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  45046. this.checked = 0;
  45047. }
  45048. };
  45049. var deferred = Promise.resolve();
  45050. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  45051. PartialEvaluator.prototype = {
  45052. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  45053. if (!isDict(resources)) {
  45054. return false;
  45055. }
  45056. var processed = Object.create(null);
  45057. if (resources.objId) {
  45058. processed[resources.objId] = true;
  45059. }
  45060. var nodes = [resources], xref = this.xref;
  45061. while (nodes.length) {
  45062. var key, i, ii;
  45063. var node = nodes.shift();
  45064. var graphicStates = node.get('ExtGState');
  45065. if (isDict(graphicStates)) {
  45066. var graphicStatesKeys = graphicStates.getKeys();
  45067. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  45068. key = graphicStatesKeys[i];
  45069. var graphicState = graphicStates.get(key);
  45070. var bm = graphicState.get('BM');
  45071. if (isName(bm) && bm.name !== 'Normal') {
  45072. return true;
  45073. }
  45074. }
  45075. }
  45076. var xObjects = node.get('XObject');
  45077. if (!isDict(xObjects)) {
  45078. continue;
  45079. }
  45080. var xObjectsKeys = xObjects.getKeys();
  45081. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  45082. key = xObjectsKeys[i];
  45083. var xObject = xObjects.getRaw(key);
  45084. if (isRef(xObject)) {
  45085. if (processed[xObject.toString()]) {
  45086. continue;
  45087. }
  45088. xObject = xref.fetch(xObject);
  45089. }
  45090. if (!isStream(xObject)) {
  45091. continue;
  45092. }
  45093. if (xObject.dict.objId) {
  45094. if (processed[xObject.dict.objId]) {
  45095. continue;
  45096. }
  45097. processed[xObject.dict.objId] = true;
  45098. }
  45099. var xResources = xObject.dict.get('Resources');
  45100. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  45101. nodes.push(xResources);
  45102. if (xResources.objId) {
  45103. processed[xResources.objId] = true;
  45104. }
  45105. }
  45106. }
  45107. }
  45108. return false;
  45109. },
  45110. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  45111. var matrix = xobj.dict.getArray('Matrix');
  45112. var bbox = xobj.dict.getArray('BBox');
  45113. var group = xobj.dict.get('Group');
  45114. if (group) {
  45115. var groupOptions = {
  45116. matrix: matrix,
  45117. bbox: bbox,
  45118. smask: smask,
  45119. isolated: false,
  45120. knockout: false
  45121. };
  45122. var groupSubtype = group.get('S');
  45123. var colorSpace;
  45124. if (isName(groupSubtype, 'Transparency')) {
  45125. groupOptions.isolated = group.get('I') || false;
  45126. groupOptions.knockout = group.get('K') || false;
  45127. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  45128. }
  45129. if (smask && smask.backdrop) {
  45130. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  45131. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  45132. }
  45133. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  45134. }
  45135. operatorList.addOp(OPS.paintFormXObjectBegin, [
  45136. matrix,
  45137. bbox
  45138. ]);
  45139. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  45140. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  45141. if (group) {
  45142. operatorList.addOp(OPS.endGroup, [groupOptions]);
  45143. }
  45144. });
  45145. },
  45146. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  45147. var self = this;
  45148. var dict = image.dict;
  45149. var w = dict.get('Width', 'W');
  45150. var h = dict.get('Height', 'H');
  45151. if (!(w && isNum(w)) || !(h && isNum(h))) {
  45152. warn('Image dimensions are missing, or not numbers.');
  45153. return;
  45154. }
  45155. var maxImageSize = this.options.maxImageSize;
  45156. if (maxImageSize !== -1 && w * h > maxImageSize) {
  45157. warn('Image exceeded maximum allowed size and was removed.');
  45158. return;
  45159. }
  45160. var imageMask = dict.get('ImageMask', 'IM') || false;
  45161. var imgData, args;
  45162. if (imageMask) {
  45163. var width = dict.get('Width', 'W');
  45164. var height = dict.get('Height', 'H');
  45165. var bitStrideLength = width + 7 >> 3;
  45166. var imgArray = image.getBytes(bitStrideLength * height);
  45167. var decode = dict.getArray('Decode', 'D');
  45168. var inverseDecode = !!decode && decode[0] > 0;
  45169. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  45170. imgData.cached = true;
  45171. args = [imgData];
  45172. operatorList.addOp(OPS.paintImageMaskXObject, args);
  45173. if (cacheKey) {
  45174. imageCache[cacheKey] = {
  45175. fn: OPS.paintImageMaskXObject,
  45176. args: args
  45177. };
  45178. }
  45179. return;
  45180. }
  45181. var softMask = dict.get('SMask', 'SM') || false;
  45182. var mask = dict.get('Mask') || false;
  45183. var SMALL_IMAGE_DIMENSIONS = 200;
  45184. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  45185. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  45186. imgData = imageObj.createImageData(true);
  45187. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  45188. return;
  45189. }
  45190. var uniquePrefix = this.uniquePrefix || '';
  45191. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  45192. operatorList.addDependency(objId);
  45193. args = [
  45194. objId,
  45195. w,
  45196. h
  45197. ];
  45198. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  45199. operatorList.addOp(OPS.paintJpegXObject, args);
  45200. this.handler.send('obj', [
  45201. objId,
  45202. this.pageIndex,
  45203. 'JpegStream',
  45204. image.getIR(this.options.forceDataSchema)
  45205. ]);
  45206. return;
  45207. }
  45208. var nativeImageDecoder = null;
  45209. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  45210. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  45211. }
  45212. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  45213. var imgData = imageObj.createImageData(false);
  45214. self.handler.send('obj', [
  45215. objId,
  45216. self.pageIndex,
  45217. 'Image',
  45218. imgData
  45219. ], [imgData.data.buffer]);
  45220. }).then(undefined, function (reason) {
  45221. warn('Unable to decode image: ' + reason);
  45222. self.handler.send('obj', [
  45223. objId,
  45224. self.pageIndex,
  45225. 'Image',
  45226. null
  45227. ]);
  45228. });
  45229. operatorList.addOp(OPS.paintImageXObject, args);
  45230. if (cacheKey) {
  45231. imageCache[cacheKey] = {
  45232. fn: OPS.paintImageXObject,
  45233. args: args
  45234. };
  45235. }
  45236. },
  45237. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  45238. var smaskContent = smask.get('G');
  45239. var smaskOptions = {
  45240. subtype: smask.get('S').name,
  45241. backdrop: smask.get('BC')
  45242. };
  45243. var transferObj = smask.get('TR');
  45244. if (isPDFFunction(transferObj)) {
  45245. var transferFn = PDFFunction.parse(this.xref, transferObj);
  45246. var transferMap = new Uint8Array(256);
  45247. var tmp = new Float32Array(1);
  45248. for (var i = 0; i < 256; i++) {
  45249. tmp[0] = i / 255;
  45250. transferFn(tmp, 0, tmp, 0);
  45251. transferMap[i] = tmp[0] * 255 | 0;
  45252. }
  45253. smaskOptions.transferMap = transferMap;
  45254. }
  45255. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  45256. },
  45257. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  45258. var tilingOpList = new OperatorList();
  45259. var resourcesArray = [
  45260. patternDict.get('Resources'),
  45261. resources
  45262. ];
  45263. var patternResources = Dict.merge(this.xref, resourcesArray);
  45264. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  45265. operatorList.addDependencies(tilingOpList.dependencies);
  45266. operatorList.addOp(fn, getTilingPatternIR({
  45267. fnArray: tilingOpList.fnArray,
  45268. argsArray: tilingOpList.argsArray
  45269. }, patternDict, args));
  45270. });
  45271. },
  45272. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  45273. var fontName;
  45274. if (fontArgs) {
  45275. fontArgs = fontArgs.slice();
  45276. fontName = fontArgs[0].name;
  45277. }
  45278. var self = this;
  45279. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  45280. if (!translated.font.isType3Font) {
  45281. return translated;
  45282. }
  45283. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  45284. return translated;
  45285. }, function (reason) {
  45286. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45287. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  45288. });
  45289. }).then(function (translated) {
  45290. state.font = translated.font;
  45291. translated.send(self.handler);
  45292. return translated.loadedName;
  45293. });
  45294. },
  45295. handleText: function PartialEvaluator_handleText(chars, state) {
  45296. var font = state.font;
  45297. var glyphs = font.charsToGlyphs(chars);
  45298. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  45299. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  45300. var buildPath = function (fontChar) {
  45301. if (!font.renderer.hasBuiltPath(fontChar)) {
  45302. var path = font.renderer.getPathJs(fontChar);
  45303. this.handler.send('commonobj', [
  45304. font.loadedName + '_path_' + fontChar,
  45305. 'FontPath',
  45306. path
  45307. ]);
  45308. }
  45309. }.bind(this);
  45310. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  45311. var glyph = glyphs[i];
  45312. buildPath(glyph.fontChar);
  45313. var accent = glyph.accent;
  45314. if (accent && accent.fontChar) {
  45315. buildPath(accent.fontChar);
  45316. }
  45317. }
  45318. }
  45319. return glyphs;
  45320. },
  45321. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  45322. var gStateObj = [];
  45323. var gStateKeys = gState.getKeys();
  45324. var self = this;
  45325. var promise = Promise.resolve();
  45326. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  45327. var key = gStateKeys[i];
  45328. var value = gState.get(key);
  45329. switch (key) {
  45330. case 'Type':
  45331. break;
  45332. case 'LW':
  45333. case 'LC':
  45334. case 'LJ':
  45335. case 'ML':
  45336. case 'D':
  45337. case 'RI':
  45338. case 'FL':
  45339. case 'CA':
  45340. case 'ca':
  45341. gStateObj.push([
  45342. key,
  45343. value
  45344. ]);
  45345. break;
  45346. case 'Font':
  45347. promise = promise.then(function () {
  45348. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  45349. operatorList.addDependency(loadedName);
  45350. gStateObj.push([
  45351. key,
  45352. [
  45353. loadedName,
  45354. value[1]
  45355. ]
  45356. ]);
  45357. });
  45358. });
  45359. break;
  45360. case 'BM':
  45361. gStateObj.push([
  45362. key,
  45363. value
  45364. ]);
  45365. break;
  45366. case 'SMask':
  45367. if (isName(value, 'None')) {
  45368. gStateObj.push([
  45369. key,
  45370. false
  45371. ]);
  45372. break;
  45373. }
  45374. if (isDict(value)) {
  45375. promise = promise.then(function (dict) {
  45376. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  45377. }.bind(this, value));
  45378. gStateObj.push([
  45379. key,
  45380. true
  45381. ]);
  45382. } else {
  45383. warn('Unsupported SMask type');
  45384. }
  45385. break;
  45386. case 'OP':
  45387. case 'op':
  45388. case 'OPM':
  45389. case 'BG':
  45390. case 'BG2':
  45391. case 'UCR':
  45392. case 'UCR2':
  45393. case 'TR':
  45394. case 'TR2':
  45395. case 'HT':
  45396. case 'SM':
  45397. case 'SA':
  45398. case 'AIS':
  45399. case 'TK':
  45400. info('graphic state operator ' + key);
  45401. break;
  45402. default:
  45403. info('Unknown graphic state operator ' + key);
  45404. break;
  45405. }
  45406. }
  45407. return promise.then(function () {
  45408. if (gStateObj.length > 0) {
  45409. operatorList.addOp(OPS.setGState, [gStateObj]);
  45410. }
  45411. });
  45412. },
  45413. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  45414. function errorFont() {
  45415. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  45416. }
  45417. var fontRef;
  45418. if (font) {
  45419. assert(isRef(font));
  45420. fontRef = font;
  45421. } else {
  45422. var fontRes = resources.get('Font');
  45423. if (fontRes) {
  45424. fontRef = fontRes.getRaw(fontName);
  45425. } else {
  45426. warn('fontRes not available');
  45427. return errorFont();
  45428. }
  45429. }
  45430. if (!fontRef) {
  45431. warn('fontRef not available');
  45432. return errorFont();
  45433. }
  45434. if (this.fontCache.has(fontRef)) {
  45435. return this.fontCache.get(fontRef);
  45436. }
  45437. font = xref.fetchIfRef(fontRef);
  45438. if (!isDict(font)) {
  45439. return errorFont();
  45440. }
  45441. if (font.translated) {
  45442. return font.translated;
  45443. }
  45444. var fontCapability = createPromiseCapability();
  45445. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  45446. var descriptor = preEvaluatedFont.descriptor;
  45447. var fontRefIsRef = isRef(fontRef), fontID;
  45448. if (fontRefIsRef) {
  45449. fontID = fontRef.toString();
  45450. }
  45451. if (isDict(descriptor)) {
  45452. if (!descriptor.fontAliases) {
  45453. descriptor.fontAliases = Object.create(null);
  45454. }
  45455. var fontAliases = descriptor.fontAliases;
  45456. var hash = preEvaluatedFont.hash;
  45457. if (fontAliases[hash]) {
  45458. var aliasFontRef = fontAliases[hash].aliasRef;
  45459. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  45460. this.fontCache.putAlias(fontRef, aliasFontRef);
  45461. return this.fontCache.get(fontRef);
  45462. }
  45463. } else {
  45464. fontAliases[hash] = { fontID: Font.getFontID() };
  45465. }
  45466. if (fontRefIsRef) {
  45467. fontAliases[hash].aliasRef = fontRef;
  45468. }
  45469. fontID = fontAliases[hash].fontID;
  45470. }
  45471. if (fontRefIsRef) {
  45472. this.fontCache.put(fontRef, fontCapability.promise);
  45473. } else {
  45474. if (!fontID) {
  45475. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  45476. }
  45477. this.fontCache.put('id_' + fontID, fontCapability.promise);
  45478. }
  45479. assert(fontID, 'The "fontID" must be defined.');
  45480. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  45481. font.translated = fontCapability.promise;
  45482. var translatedPromise;
  45483. try {
  45484. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  45485. } catch (e) {
  45486. translatedPromise = Promise.reject(e);
  45487. }
  45488. var self = this;
  45489. translatedPromise.then(function (translatedFont) {
  45490. if (translatedFont.fontType !== undefined) {
  45491. var xrefFontStats = xref.stats.fontTypes;
  45492. xrefFontStats[translatedFont.fontType] = true;
  45493. }
  45494. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  45495. }, function (reason) {
  45496. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45497. try {
  45498. var descriptor = preEvaluatedFont.descriptor;
  45499. var fontFile3 = descriptor && descriptor.get('FontFile3');
  45500. var subtype = fontFile3 && fontFile3.get('Subtype');
  45501. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  45502. var xrefFontStats = xref.stats.fontTypes;
  45503. xrefFontStats[fontType] = true;
  45504. } catch (ex) {
  45505. }
  45506. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  45507. });
  45508. return fontCapability.promise;
  45509. },
  45510. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  45511. var lastIndex = operatorList.length - 1;
  45512. if (!args) {
  45513. args = [];
  45514. }
  45515. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  45516. operatorList.addOp(OPS.constructPath, [
  45517. [fn],
  45518. args
  45519. ]);
  45520. } else {
  45521. var opArgs = operatorList.argsArray[lastIndex];
  45522. opArgs[0].push(fn);
  45523. Array.prototype.push.apply(opArgs[1], args);
  45524. }
  45525. },
  45526. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  45527. var patternName = args[args.length - 1];
  45528. var pattern;
  45529. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  45530. var dict = isStream(pattern) ? pattern.dict : pattern;
  45531. var typeNum = dict.get('PatternType');
  45532. if (typeNum === TILING_PATTERN) {
  45533. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  45534. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  45535. } else if (typeNum === SHADING_PATTERN) {
  45536. var shading = dict.get('Shading');
  45537. var matrix = dict.getArray('Matrix');
  45538. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  45539. operatorList.addOp(fn, pattern.getIR());
  45540. return Promise.resolve();
  45541. } else {
  45542. return Promise.reject('Unknown PatternType: ' + typeNum);
  45543. }
  45544. }
  45545. operatorList.addOp(fn, args);
  45546. return Promise.resolve();
  45547. },
  45548. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  45549. var self = this;
  45550. var xref = this.xref;
  45551. var imageCache = Object.create(null);
  45552. assert(operatorList);
  45553. resources = resources || Dict.empty;
  45554. var xobjs = resources.get('XObject') || Dict.empty;
  45555. var patterns = resources.get('Pattern') || Dict.empty;
  45556. var stateManager = new StateManager(initialState || new EvalState());
  45557. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45558. var timeSlotManager = new TimeSlotManager();
  45559. return new Promise(function promiseBody(resolve, reject) {
  45560. var next = function (promise) {
  45561. promise.then(function () {
  45562. try {
  45563. promiseBody(resolve, reject);
  45564. } catch (ex) {
  45565. reject(ex);
  45566. }
  45567. }, reject);
  45568. };
  45569. task.ensureNotTerminated();
  45570. timeSlotManager.reset();
  45571. var stop, operation = {}, i, ii, cs;
  45572. while (!(stop = timeSlotManager.check())) {
  45573. operation.args = null;
  45574. if (!preprocessor.read(operation)) {
  45575. break;
  45576. }
  45577. var args = operation.args;
  45578. var fn = operation.fn;
  45579. switch (fn | 0) {
  45580. case OPS.paintXObject:
  45581. if (args[0].code) {
  45582. break;
  45583. }
  45584. var name = args[0].name;
  45585. if (!name) {
  45586. warn('XObject must be referred to by name.');
  45587. continue;
  45588. }
  45589. if (imageCache[name] !== undefined) {
  45590. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  45591. args = null;
  45592. continue;
  45593. }
  45594. var xobj = xobjs.get(name);
  45595. if (xobj) {
  45596. assert(isStream(xobj), 'XObject should be a stream');
  45597. var type = xobj.dict.get('Subtype');
  45598. assert(isName(type), 'XObject should have a Name subtype');
  45599. if (type.name === 'Form') {
  45600. stateManager.save();
  45601. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  45602. stateManager.restore();
  45603. }));
  45604. return;
  45605. } else if (type.name === 'Image') {
  45606. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  45607. args = null;
  45608. continue;
  45609. } else if (type.name === 'PS') {
  45610. info('Ignored XObject subtype PS');
  45611. continue;
  45612. } else {
  45613. error('Unhandled XObject subtype ' + type.name);
  45614. }
  45615. }
  45616. break;
  45617. case OPS.setFont:
  45618. var fontSize = args[1];
  45619. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  45620. operatorList.addDependency(loadedName);
  45621. operatorList.addOp(OPS.setFont, [
  45622. loadedName,
  45623. fontSize
  45624. ]);
  45625. }));
  45626. return;
  45627. case OPS.endInlineImage:
  45628. var cacheKey = args[0].cacheKey;
  45629. if (cacheKey) {
  45630. var cacheEntry = imageCache[cacheKey];
  45631. if (cacheEntry !== undefined) {
  45632. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  45633. args = null;
  45634. continue;
  45635. }
  45636. }
  45637. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  45638. args = null;
  45639. continue;
  45640. case OPS.showText:
  45641. args[0] = self.handleText(args[0], stateManager.state);
  45642. break;
  45643. case OPS.showSpacedText:
  45644. var arr = args[0];
  45645. var combinedGlyphs = [];
  45646. var arrLength = arr.length;
  45647. var state = stateManager.state;
  45648. for (i = 0; i < arrLength; ++i) {
  45649. var arrItem = arr[i];
  45650. if (isString(arrItem)) {
  45651. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  45652. } else if (isNum(arrItem)) {
  45653. combinedGlyphs.push(arrItem);
  45654. }
  45655. }
  45656. args[0] = combinedGlyphs;
  45657. fn = OPS.showText;
  45658. break;
  45659. case OPS.nextLineShowText:
  45660. operatorList.addOp(OPS.nextLine);
  45661. args[0] = self.handleText(args[0], stateManager.state);
  45662. fn = OPS.showText;
  45663. break;
  45664. case OPS.nextLineSetSpacingShowText:
  45665. operatorList.addOp(OPS.nextLine);
  45666. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  45667. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  45668. args[0] = self.handleText(args[0], stateManager.state);
  45669. fn = OPS.showText;
  45670. break;
  45671. case OPS.setTextRenderingMode:
  45672. stateManager.state.textRenderingMode = args[0];
  45673. break;
  45674. case OPS.setFillColorSpace:
  45675. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  45676. continue;
  45677. case OPS.setStrokeColorSpace:
  45678. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  45679. continue;
  45680. case OPS.setFillColor:
  45681. cs = stateManager.state.fillColorSpace;
  45682. args = cs.getRgb(args, 0);
  45683. fn = OPS.setFillRGBColor;
  45684. break;
  45685. case OPS.setStrokeColor:
  45686. cs = stateManager.state.strokeColorSpace;
  45687. args = cs.getRgb(args, 0);
  45688. fn = OPS.setStrokeRGBColor;
  45689. break;
  45690. case OPS.setFillGray:
  45691. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  45692. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45693. fn = OPS.setFillRGBColor;
  45694. break;
  45695. case OPS.setStrokeGray:
  45696. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  45697. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45698. fn = OPS.setStrokeRGBColor;
  45699. break;
  45700. case OPS.setFillCMYKColor:
  45701. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  45702. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45703. fn = OPS.setFillRGBColor;
  45704. break;
  45705. case OPS.setStrokeCMYKColor:
  45706. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  45707. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45708. fn = OPS.setStrokeRGBColor;
  45709. break;
  45710. case OPS.setFillRGBColor:
  45711. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  45712. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45713. break;
  45714. case OPS.setStrokeRGBColor:
  45715. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  45716. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45717. break;
  45718. case OPS.setFillColorN:
  45719. cs = stateManager.state.fillColorSpace;
  45720. if (cs.name === 'Pattern') {
  45721. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  45722. return;
  45723. }
  45724. args = cs.getRgb(args, 0);
  45725. fn = OPS.setFillRGBColor;
  45726. break;
  45727. case OPS.setStrokeColorN:
  45728. cs = stateManager.state.strokeColorSpace;
  45729. if (cs.name === 'Pattern') {
  45730. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  45731. return;
  45732. }
  45733. args = cs.getRgb(args, 0);
  45734. fn = OPS.setStrokeRGBColor;
  45735. break;
  45736. case OPS.shadingFill:
  45737. var shadingRes = resources.get('Shading');
  45738. if (!shadingRes) {
  45739. error('No shading resource found');
  45740. }
  45741. var shading = shadingRes.get(args[0].name);
  45742. if (!shading) {
  45743. error('No shading object found');
  45744. }
  45745. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  45746. var patternIR = shadingFill.getIR();
  45747. args = [patternIR];
  45748. fn = OPS.shadingFill;
  45749. break;
  45750. case OPS.setGState:
  45751. var dictName = args[0];
  45752. var extGState = resources.get('ExtGState');
  45753. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  45754. break;
  45755. }
  45756. var gState = extGState.get(dictName.name);
  45757. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  45758. return;
  45759. case OPS.moveTo:
  45760. case OPS.lineTo:
  45761. case OPS.curveTo:
  45762. case OPS.curveTo2:
  45763. case OPS.curveTo3:
  45764. case OPS.closePath:
  45765. self.buildPath(operatorList, fn, args);
  45766. continue;
  45767. case OPS.rectangle:
  45768. self.buildPath(operatorList, fn, args);
  45769. continue;
  45770. case OPS.markPoint:
  45771. case OPS.markPointProps:
  45772. case OPS.beginMarkedContent:
  45773. case OPS.beginMarkedContentProps:
  45774. case OPS.endMarkedContent:
  45775. case OPS.beginCompat:
  45776. case OPS.endCompat:
  45777. continue;
  45778. default:
  45779. if (args !== null) {
  45780. for (i = 0, ii = args.length; i < ii; i++) {
  45781. if (args[i] instanceof Dict) {
  45782. break;
  45783. }
  45784. }
  45785. if (i < ii) {
  45786. warn('getOperatorList - ignoring operator: ' + fn);
  45787. continue;
  45788. }
  45789. }
  45790. }
  45791. operatorList.addOp(fn, args);
  45792. }
  45793. if (stop) {
  45794. next(deferred);
  45795. return;
  45796. }
  45797. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  45798. operatorList.addOp(OPS.restore, []);
  45799. }
  45800. resolve();
  45801. });
  45802. },
  45803. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  45804. stateManager = stateManager || new StateManager(new TextState());
  45805. var WhitespaceRegexp = /\s/g;
  45806. var textContent = {
  45807. items: [],
  45808. styles: Object.create(null)
  45809. };
  45810. var textContentItem = {
  45811. initialized: false,
  45812. str: [],
  45813. width: 0,
  45814. height: 0,
  45815. vertical: false,
  45816. lastAdvanceWidth: 0,
  45817. lastAdvanceHeight: 0,
  45818. textAdvanceScale: 0,
  45819. spaceWidth: 0,
  45820. fakeSpaceMin: Infinity,
  45821. fakeMultiSpaceMin: Infinity,
  45822. fakeMultiSpaceMax: -0,
  45823. textRunBreakAllowed: false,
  45824. transform: null,
  45825. fontName: null
  45826. };
  45827. var SPACE_FACTOR = 0.3;
  45828. var MULTI_SPACE_FACTOR = 1.5;
  45829. var MULTI_SPACE_FACTOR_MAX = 4;
  45830. var self = this;
  45831. var xref = this.xref;
  45832. resources = xref.fetchIfRef(resources) || Dict.empty;
  45833. var xobjs = null;
  45834. var xobjsCache = Object.create(null);
  45835. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45836. var textState;
  45837. function ensureTextContentItem() {
  45838. if (textContentItem.initialized) {
  45839. return textContentItem;
  45840. }
  45841. var font = textState.font;
  45842. if (!(font.loadedName in textContent.styles)) {
  45843. textContent.styles[font.loadedName] = {
  45844. fontFamily: font.fallbackName,
  45845. ascent: font.ascent,
  45846. descent: font.descent,
  45847. vertical: font.vertical
  45848. };
  45849. }
  45850. textContentItem.fontName = font.loadedName;
  45851. var tsm = [
  45852. textState.fontSize * textState.textHScale,
  45853. 0,
  45854. 0,
  45855. textState.fontSize,
  45856. 0,
  45857. textState.textRise
  45858. ];
  45859. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  45860. var glyphHeight = font.bbox[3] - font.bbox[1];
  45861. if (glyphHeight > 0) {
  45862. glyphHeight = glyphHeight * textState.fontMatrix[3];
  45863. tsm[3] *= glyphHeight;
  45864. }
  45865. }
  45866. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  45867. textContentItem.transform = trm;
  45868. if (!font.vertical) {
  45869. textContentItem.width = 0;
  45870. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  45871. textContentItem.vertical = false;
  45872. } else {
  45873. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  45874. textContentItem.height = 0;
  45875. textContentItem.vertical = true;
  45876. }
  45877. var a = textState.textLineMatrix[0];
  45878. var b = textState.textLineMatrix[1];
  45879. var scaleLineX = Math.sqrt(a * a + b * b);
  45880. a = textState.ctm[0];
  45881. b = textState.ctm[1];
  45882. var scaleCtmX = Math.sqrt(a * a + b * b);
  45883. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  45884. textContentItem.lastAdvanceWidth = 0;
  45885. textContentItem.lastAdvanceHeight = 0;
  45886. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  45887. if (spaceWidth) {
  45888. textContentItem.spaceWidth = spaceWidth;
  45889. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  45890. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  45891. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  45892. textContentItem.textRunBreakAllowed = !font.isMonospace;
  45893. } else {
  45894. textContentItem.spaceWidth = 0;
  45895. textContentItem.fakeSpaceMin = Infinity;
  45896. textContentItem.fakeMultiSpaceMin = Infinity;
  45897. textContentItem.fakeMultiSpaceMax = 0;
  45898. textContentItem.textRunBreakAllowed = false;
  45899. }
  45900. textContentItem.initialized = true;
  45901. return textContentItem;
  45902. }
  45903. function replaceWhitespace(str) {
  45904. var i = 0, ii = str.length, code;
  45905. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  45906. i++;
  45907. }
  45908. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  45909. }
  45910. function runBidiTransform(textChunk) {
  45911. var str = textChunk.str.join('');
  45912. var bidiResult = bidi(str, -1, textChunk.vertical);
  45913. return {
  45914. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  45915. dir: bidiResult.dir,
  45916. width: textChunk.width,
  45917. height: textChunk.height,
  45918. transform: textChunk.transform,
  45919. fontName: textChunk.fontName
  45920. };
  45921. }
  45922. function handleSetFont(fontName, fontRef) {
  45923. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  45924. textState.font = translated.font;
  45925. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  45926. });
  45927. }
  45928. function buildTextContentItem(chars) {
  45929. var font = textState.font;
  45930. var textChunk = ensureTextContentItem();
  45931. var width = 0;
  45932. var height = 0;
  45933. var glyphs = font.charsToGlyphs(chars);
  45934. var defaultVMetrics = font.defaultVMetrics;
  45935. for (var i = 0; i < glyphs.length; i++) {
  45936. var glyph = glyphs[i];
  45937. var vMetricX = null;
  45938. var vMetricY = null;
  45939. var glyphWidth = null;
  45940. if (font.vertical) {
  45941. if (glyph.vmetric) {
  45942. glyphWidth = glyph.vmetric[0];
  45943. vMetricX = glyph.vmetric[1];
  45944. vMetricY = glyph.vmetric[2];
  45945. } else {
  45946. glyphWidth = glyph.width;
  45947. vMetricX = glyph.width * 0.5;
  45948. vMetricY = defaultVMetrics[2];
  45949. }
  45950. } else {
  45951. glyphWidth = glyph.width;
  45952. }
  45953. var glyphUnicode = glyph.unicode;
  45954. var NormalizedUnicodes = getNormalizedUnicodes();
  45955. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  45956. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  45957. }
  45958. glyphUnicode = reverseIfRtl(glyphUnicode);
  45959. var charSpacing = textState.charSpacing;
  45960. if (glyph.isSpace) {
  45961. var wordSpacing = textState.wordSpacing;
  45962. charSpacing += wordSpacing;
  45963. if (wordSpacing > 0) {
  45964. addFakeSpaces(wordSpacing, textChunk.str);
  45965. }
  45966. }
  45967. var tx = 0;
  45968. var ty = 0;
  45969. if (!font.vertical) {
  45970. var w0 = glyphWidth * textState.fontMatrix[0];
  45971. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  45972. width += tx;
  45973. } else {
  45974. var w1 = glyphWidth * textState.fontMatrix[0];
  45975. ty = w1 * textState.fontSize + charSpacing;
  45976. height += ty;
  45977. }
  45978. textState.translateTextMatrix(tx, ty);
  45979. textChunk.str.push(glyphUnicode);
  45980. }
  45981. if (!font.vertical) {
  45982. textChunk.lastAdvanceWidth = width;
  45983. textChunk.width += width * textChunk.textAdvanceScale;
  45984. } else {
  45985. textChunk.lastAdvanceHeight = height;
  45986. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  45987. }
  45988. return textChunk;
  45989. }
  45990. function addFakeSpaces(width, strBuf) {
  45991. if (width < textContentItem.fakeSpaceMin) {
  45992. return;
  45993. }
  45994. if (width < textContentItem.fakeMultiSpaceMin) {
  45995. strBuf.push(' ');
  45996. return;
  45997. }
  45998. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  45999. while (fakeSpaces-- > 0) {
  46000. strBuf.push(' ');
  46001. }
  46002. }
  46003. function flushTextContentItem() {
  46004. if (!textContentItem.initialized) {
  46005. return;
  46006. }
  46007. textContent.items.push(runBidiTransform(textContentItem));
  46008. textContentItem.initialized = false;
  46009. textContentItem.str.length = 0;
  46010. }
  46011. var timeSlotManager = new TimeSlotManager();
  46012. return new Promise(function promiseBody(resolve, reject) {
  46013. var next = function (promise) {
  46014. promise.then(function () {
  46015. try {
  46016. promiseBody(resolve, reject);
  46017. } catch (ex) {
  46018. reject(ex);
  46019. }
  46020. }, reject);
  46021. };
  46022. task.ensureNotTerminated();
  46023. timeSlotManager.reset();
  46024. var stop, operation = {}, args = [];
  46025. while (!(stop = timeSlotManager.check())) {
  46026. args.length = 0;
  46027. operation.args = args;
  46028. if (!preprocessor.read(operation)) {
  46029. break;
  46030. }
  46031. textState = stateManager.state;
  46032. var fn = operation.fn;
  46033. args = operation.args;
  46034. var advance, diff;
  46035. switch (fn | 0) {
  46036. case OPS.setFont:
  46037. var fontNameArg = args[0].name, fontSizeArg = args[1];
  46038. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  46039. break;
  46040. }
  46041. flushTextContentItem();
  46042. textState.fontName = fontNameArg;
  46043. textState.fontSize = fontSizeArg;
  46044. next(handleSetFont(fontNameArg, null));
  46045. return;
  46046. case OPS.setTextRise:
  46047. flushTextContentItem();
  46048. textState.textRise = args[0];
  46049. break;
  46050. case OPS.setHScale:
  46051. flushTextContentItem();
  46052. textState.textHScale = args[0] / 100;
  46053. break;
  46054. case OPS.setLeading:
  46055. flushTextContentItem();
  46056. textState.leading = args[0];
  46057. break;
  46058. case OPS.moveText:
  46059. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  46060. advance = args[0] - args[1];
  46061. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  46062. textState.translateTextLineMatrix(args[0], args[1]);
  46063. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  46064. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  46065. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  46066. addFakeSpaces(diff, textContentItem.str);
  46067. break;
  46068. }
  46069. flushTextContentItem();
  46070. textState.translateTextLineMatrix(args[0], args[1]);
  46071. textState.textMatrix = textState.textLineMatrix.slice();
  46072. break;
  46073. case OPS.setLeadingMoveText:
  46074. flushTextContentItem();
  46075. textState.leading = -args[1];
  46076. textState.translateTextLineMatrix(args[0], args[1]);
  46077. textState.textMatrix = textState.textLineMatrix.slice();
  46078. break;
  46079. case OPS.nextLine:
  46080. flushTextContentItem();
  46081. textState.carriageReturn();
  46082. break;
  46083. case OPS.setTextMatrix:
  46084. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  46085. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  46086. textState.translateTextLineMatrix(advance.width, advance.height);
  46087. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  46088. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  46089. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  46090. addFakeSpaces(diff, textContentItem.str);
  46091. break;
  46092. }
  46093. flushTextContentItem();
  46094. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46095. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46096. break;
  46097. case OPS.setCharSpacing:
  46098. textState.charSpacing = args[0];
  46099. break;
  46100. case OPS.setWordSpacing:
  46101. textState.wordSpacing = args[0];
  46102. break;
  46103. case OPS.beginText:
  46104. flushTextContentItem();
  46105. textState.textMatrix = IDENTITY_MATRIX.slice();
  46106. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  46107. break;
  46108. case OPS.showSpacedText:
  46109. var items = args[0];
  46110. var offset;
  46111. for (var j = 0, jj = items.length; j < jj; j++) {
  46112. if (typeof items[j] === 'string') {
  46113. buildTextContentItem(items[j]);
  46114. } else if (isNum(items[j])) {
  46115. ensureTextContentItem();
  46116. advance = items[j] * textState.fontSize / 1000;
  46117. var breakTextRun = false;
  46118. if (textState.font.vertical) {
  46119. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  46120. textState.translateTextMatrix(0, advance);
  46121. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46122. if (!breakTextRun) {
  46123. textContentItem.height += offset;
  46124. }
  46125. } else {
  46126. advance = -advance;
  46127. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  46128. textState.translateTextMatrix(advance, 0);
  46129. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46130. if (!breakTextRun) {
  46131. textContentItem.width += offset;
  46132. }
  46133. }
  46134. if (breakTextRun) {
  46135. flushTextContentItem();
  46136. } else if (advance > 0) {
  46137. addFakeSpaces(advance, textContentItem.str);
  46138. }
  46139. }
  46140. }
  46141. break;
  46142. case OPS.showText:
  46143. buildTextContentItem(args[0]);
  46144. break;
  46145. case OPS.nextLineShowText:
  46146. flushTextContentItem();
  46147. textState.carriageReturn();
  46148. buildTextContentItem(args[0]);
  46149. break;
  46150. case OPS.nextLineSetSpacingShowText:
  46151. flushTextContentItem();
  46152. textState.wordSpacing = args[0];
  46153. textState.charSpacing = args[1];
  46154. textState.carriageReturn();
  46155. buildTextContentItem(args[2]);
  46156. break;
  46157. case OPS.paintXObject:
  46158. flushTextContentItem();
  46159. if (args[0].code) {
  46160. break;
  46161. }
  46162. if (!xobjs) {
  46163. xobjs = resources.get('XObject') || Dict.empty;
  46164. }
  46165. var name = args[0].name;
  46166. if (xobjsCache.key === name) {
  46167. if (xobjsCache.texts) {
  46168. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  46169. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  46170. }
  46171. break;
  46172. }
  46173. var xobj = xobjs.get(name);
  46174. if (!xobj) {
  46175. break;
  46176. }
  46177. assert(isStream(xobj), 'XObject should be a stream');
  46178. var type = xobj.dict.get('Subtype');
  46179. assert(isName(type), 'XObject should have a Name subtype');
  46180. if ('Form' !== type.name) {
  46181. xobjsCache.key = name;
  46182. xobjsCache.texts = null;
  46183. break;
  46184. }
  46185. stateManager.save();
  46186. var matrix = xobj.dict.getArray('Matrix');
  46187. if (isArray(matrix) && matrix.length === 6) {
  46188. stateManager.transform(matrix);
  46189. }
  46190. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  46191. Util.appendToArray(textContent.items, formTextContent.items);
  46192. Util.extendObj(textContent.styles, formTextContent.styles);
  46193. stateManager.restore();
  46194. xobjsCache.key = name;
  46195. xobjsCache.texts = formTextContent;
  46196. }));
  46197. return;
  46198. case OPS.setGState:
  46199. flushTextContentItem();
  46200. var dictName = args[0];
  46201. var extGState = resources.get('ExtGState');
  46202. if (!isDict(extGState) || !isName(dictName)) {
  46203. break;
  46204. }
  46205. var gState = extGState.get(dictName.name);
  46206. if (!isDict(gState)) {
  46207. break;
  46208. }
  46209. var gStateFont = gState.get('Font');
  46210. if (gStateFont) {
  46211. textState.fontName = null;
  46212. textState.fontSize = gStateFont[1];
  46213. next(handleSetFont(null, gStateFont[0]));
  46214. return;
  46215. }
  46216. break;
  46217. }
  46218. }
  46219. if (stop) {
  46220. next(deferred);
  46221. return;
  46222. }
  46223. flushTextContentItem();
  46224. resolve(textContent);
  46225. });
  46226. },
  46227. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  46228. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46229. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  46230. if (properties.composite) {
  46231. var cidSystemInfo = dict.get('CIDSystemInfo');
  46232. if (isDict(cidSystemInfo)) {
  46233. properties.cidSystemInfo = {
  46234. registry: cidSystemInfo.get('Registry'),
  46235. ordering: cidSystemInfo.get('Ordering'),
  46236. supplement: cidSystemInfo.get('Supplement')
  46237. };
  46238. }
  46239. var cidToGidMap = dict.get('CIDToGIDMap');
  46240. if (isStream(cidToGidMap)) {
  46241. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  46242. }
  46243. }
  46244. var differences = [];
  46245. var baseEncodingName = null;
  46246. var encoding;
  46247. if (dict.has('Encoding')) {
  46248. encoding = dict.get('Encoding');
  46249. if (isDict(encoding)) {
  46250. baseEncodingName = encoding.get('BaseEncoding');
  46251. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  46252. if (encoding.has('Differences')) {
  46253. var diffEncoding = encoding.get('Differences');
  46254. var index = 0;
  46255. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  46256. var data = xref.fetchIfRef(diffEncoding[j]);
  46257. if (isNum(data)) {
  46258. index = data;
  46259. } else if (isName(data)) {
  46260. differences[index++] = data.name;
  46261. } else {
  46262. error('Invalid entry in \'Differences\' array: ' + data);
  46263. }
  46264. }
  46265. }
  46266. } else if (isName(encoding)) {
  46267. baseEncodingName = encoding.name;
  46268. } else {
  46269. error('Encoding is not a Name nor a Dict');
  46270. }
  46271. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  46272. baseEncodingName = null;
  46273. }
  46274. }
  46275. if (baseEncodingName) {
  46276. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  46277. } else {
  46278. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46279. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  46280. encoding = StandardEncoding;
  46281. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  46282. encoding = WinAnsiEncoding;
  46283. }
  46284. if (isSymbolicFont) {
  46285. encoding = MacRomanEncoding;
  46286. if (!properties.file) {
  46287. if (/Symbol/i.test(properties.name)) {
  46288. encoding = SymbolSetEncoding;
  46289. } else if (/Dingbats/i.test(properties.name)) {
  46290. encoding = ZapfDingbatsEncoding;
  46291. }
  46292. }
  46293. }
  46294. properties.defaultEncoding = encoding;
  46295. }
  46296. properties.differences = differences;
  46297. properties.baseEncodingName = baseEncodingName;
  46298. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  46299. properties.dict = dict;
  46300. return toUnicodePromise.then(function (toUnicode) {
  46301. properties.toUnicode = toUnicode;
  46302. return this.buildToUnicode(properties);
  46303. }.bind(this)).then(function (toUnicode) {
  46304. properties.toUnicode = toUnicode;
  46305. return properties;
  46306. });
  46307. },
  46308. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  46309. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  46310. if (properties.hasIncludedToUnicodeMap) {
  46311. return Promise.resolve(properties.toUnicode);
  46312. }
  46313. var toUnicode, charcode, glyphName;
  46314. if (!properties.composite)
  46315. {
  46316. toUnicode = [];
  46317. var encoding = properties.defaultEncoding.slice();
  46318. var baseEncodingName = properties.baseEncodingName;
  46319. var differences = properties.differences;
  46320. for (charcode in differences) {
  46321. glyphName = differences[charcode];
  46322. if (glyphName === '.notdef') {
  46323. continue;
  46324. }
  46325. encoding[charcode] = glyphName;
  46326. }
  46327. var glyphsUnicodeMap = getGlyphsUnicode();
  46328. for (charcode in encoding) {
  46329. glyphName = encoding[charcode];
  46330. if (glyphName === '') {
  46331. continue;
  46332. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  46333. var code = 0;
  46334. switch (glyphName[0]) {
  46335. case 'G':
  46336. if (glyphName.length === 3) {
  46337. code = parseInt(glyphName.substr(1), 16);
  46338. }
  46339. break;
  46340. case 'g':
  46341. if (glyphName.length === 5) {
  46342. code = parseInt(glyphName.substr(1), 16);
  46343. }
  46344. break;
  46345. case 'C':
  46346. case 'c':
  46347. if (glyphName.length >= 3) {
  46348. code = +glyphName.substr(1);
  46349. }
  46350. break;
  46351. default:
  46352. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  46353. if (unicode !== -1) {
  46354. code = unicode;
  46355. }
  46356. }
  46357. if (code) {
  46358. if (baseEncodingName && code === +charcode) {
  46359. var baseEncoding = getEncoding(baseEncodingName);
  46360. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  46361. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46362. continue;
  46363. }
  46364. }
  46365. toUnicode[charcode] = String.fromCharCode(code);
  46366. }
  46367. continue;
  46368. }
  46369. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46370. }
  46371. return Promise.resolve(new ToUnicodeMap(toUnicode));
  46372. }
  46373. 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'))) {
  46374. var registry = properties.cidSystemInfo.registry;
  46375. var ordering = properties.cidSystemInfo.ordering;
  46376. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  46377. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  46378. var cMap = properties.cMap;
  46379. toUnicode = [];
  46380. cMap.forEach(function (charcode, cid) {
  46381. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  46382. var ucs2 = ucs2CMap.lookup(cid);
  46383. if (ucs2) {
  46384. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  46385. }
  46386. });
  46387. return new ToUnicodeMap(toUnicode);
  46388. });
  46389. }
  46390. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  46391. },
  46392. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  46393. var cmapObj = toUnicode;
  46394. if (isName(cmapObj)) {
  46395. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46396. if (cmap instanceof IdentityCMap) {
  46397. return new IdentityToUnicodeMap(0, 0xFFFF);
  46398. }
  46399. return new ToUnicodeMap(cmap.getMap());
  46400. });
  46401. } else if (isStream(cmapObj)) {
  46402. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46403. if (cmap instanceof IdentityCMap) {
  46404. return new IdentityToUnicodeMap(0, 0xFFFF);
  46405. }
  46406. var map = new Array(cmap.length);
  46407. cmap.forEach(function (charCode, token) {
  46408. var str = [];
  46409. for (var k = 0; k < token.length; k += 2) {
  46410. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46411. if ((w1 & 0xF800) !== 0xD800) {
  46412. str.push(w1);
  46413. continue;
  46414. }
  46415. k += 2;
  46416. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46417. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  46418. }
  46419. map[charCode] = String.fromCharCode.apply(String, str);
  46420. });
  46421. return new ToUnicodeMap(map);
  46422. });
  46423. }
  46424. return Promise.resolve(null);
  46425. },
  46426. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  46427. var glyphsData = cidToGidStream.getBytes();
  46428. var result = [];
  46429. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  46430. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  46431. if (glyphID === 0) {
  46432. continue;
  46433. }
  46434. var code = j >> 1;
  46435. result[code] = glyphID;
  46436. }
  46437. return result;
  46438. },
  46439. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  46440. var glyphsWidths = [];
  46441. var defaultWidth = 0;
  46442. var glyphsVMetrics = [];
  46443. var defaultVMetrics;
  46444. var i, ii, j, jj, start, code, widths;
  46445. if (properties.composite) {
  46446. defaultWidth = dict.get('DW') || 1000;
  46447. widths = dict.get('W');
  46448. if (widths) {
  46449. for (i = 0, ii = widths.length; i < ii; i++) {
  46450. start = xref.fetchIfRef(widths[i++]);
  46451. code = xref.fetchIfRef(widths[i]);
  46452. if (isArray(code)) {
  46453. for (j = 0, jj = code.length; j < jj; j++) {
  46454. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  46455. }
  46456. } else {
  46457. var width = xref.fetchIfRef(widths[++i]);
  46458. for (j = start; j <= code; j++) {
  46459. glyphsWidths[j] = width;
  46460. }
  46461. }
  46462. }
  46463. }
  46464. if (properties.vertical) {
  46465. var vmetrics = dict.getArray('DW2') || [
  46466. 880,
  46467. -1000
  46468. ];
  46469. defaultVMetrics = [
  46470. vmetrics[1],
  46471. defaultWidth * 0.5,
  46472. vmetrics[0]
  46473. ];
  46474. vmetrics = dict.get('W2');
  46475. if (vmetrics) {
  46476. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  46477. start = xref.fetchIfRef(vmetrics[i++]);
  46478. code = xref.fetchIfRef(vmetrics[i]);
  46479. if (isArray(code)) {
  46480. for (j = 0, jj = code.length; j < jj; j++) {
  46481. glyphsVMetrics[start++] = [
  46482. xref.fetchIfRef(code[j++]),
  46483. xref.fetchIfRef(code[j++]),
  46484. xref.fetchIfRef(code[j])
  46485. ];
  46486. }
  46487. } else {
  46488. var vmetric = [
  46489. xref.fetchIfRef(vmetrics[++i]),
  46490. xref.fetchIfRef(vmetrics[++i]),
  46491. xref.fetchIfRef(vmetrics[++i])
  46492. ];
  46493. for (j = start; j <= code; j++) {
  46494. glyphsVMetrics[j] = vmetric;
  46495. }
  46496. }
  46497. }
  46498. }
  46499. }
  46500. } else {
  46501. var firstChar = properties.firstChar;
  46502. widths = dict.get('Widths');
  46503. if (widths) {
  46504. j = firstChar;
  46505. for (i = 0, ii = widths.length; i < ii; i++) {
  46506. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  46507. }
  46508. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  46509. } else {
  46510. var baseFontName = dict.get('BaseFont');
  46511. if (isName(baseFontName)) {
  46512. var metrics = this.getBaseFontMetrics(baseFontName.name);
  46513. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  46514. defaultWidth = metrics.defaultWidth;
  46515. }
  46516. }
  46517. }
  46518. var isMonospace = true;
  46519. var firstWidth = defaultWidth;
  46520. for (var glyph in glyphsWidths) {
  46521. var glyphWidth = glyphsWidths[glyph];
  46522. if (!glyphWidth) {
  46523. continue;
  46524. }
  46525. if (!firstWidth) {
  46526. firstWidth = glyphWidth;
  46527. continue;
  46528. }
  46529. if (firstWidth !== glyphWidth) {
  46530. isMonospace = false;
  46531. break;
  46532. }
  46533. }
  46534. if (isMonospace) {
  46535. properties.flags |= FontFlags.FixedPitch;
  46536. }
  46537. properties.defaultWidth = defaultWidth;
  46538. properties.widths = glyphsWidths;
  46539. properties.defaultVMetrics = defaultVMetrics;
  46540. properties.vmetrics = glyphsVMetrics;
  46541. },
  46542. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  46543. var fontNameWoStyle = baseFontName.split('-')[0];
  46544. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  46545. },
  46546. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  46547. var defaultWidth = 0;
  46548. var widths = [];
  46549. var monospace = false;
  46550. var stdFontMap = getStdFontMap();
  46551. var lookupName = stdFontMap[name] || name;
  46552. var Metrics = getMetrics();
  46553. if (!(lookupName in Metrics)) {
  46554. if (this.isSerifFont(name)) {
  46555. lookupName = 'Times-Roman';
  46556. } else {
  46557. lookupName = 'Helvetica';
  46558. }
  46559. }
  46560. var glyphWidths = Metrics[lookupName];
  46561. if (isNum(glyphWidths)) {
  46562. defaultWidth = glyphWidths;
  46563. monospace = true;
  46564. } else {
  46565. widths = glyphWidths();
  46566. }
  46567. return {
  46568. defaultWidth: defaultWidth,
  46569. monospace: monospace,
  46570. widths: widths
  46571. };
  46572. },
  46573. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  46574. var widths = Object.create(null);
  46575. var differences = properties.differences;
  46576. var encoding = properties.defaultEncoding;
  46577. for (var charCode = 0; charCode < 256; charCode++) {
  46578. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  46579. widths[charCode] = widthsByGlyphName[differences[charCode]];
  46580. continue;
  46581. }
  46582. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  46583. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  46584. continue;
  46585. }
  46586. }
  46587. return widths;
  46588. },
  46589. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  46590. var baseDict = dict;
  46591. var type = dict.get('Subtype');
  46592. assert(isName(type), 'invalid font Subtype');
  46593. var composite = false;
  46594. var uint8array;
  46595. if (type.name === 'Type0') {
  46596. var df = dict.get('DescendantFonts');
  46597. if (!df) {
  46598. error('Descendant fonts are not specified');
  46599. }
  46600. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  46601. type = dict.get('Subtype');
  46602. assert(isName(type), 'invalid font Subtype');
  46603. composite = true;
  46604. }
  46605. var descriptor = dict.get('FontDescriptor');
  46606. if (descriptor) {
  46607. var hash = new MurmurHash3_64();
  46608. var encoding = baseDict.getRaw('Encoding');
  46609. if (isName(encoding)) {
  46610. hash.update(encoding.name);
  46611. } else if (isRef(encoding)) {
  46612. hash.update(encoding.toString());
  46613. } else if (isDict(encoding)) {
  46614. var keys = encoding.getKeys();
  46615. for (var i = 0, ii = keys.length; i < ii; i++) {
  46616. var entry = encoding.getRaw(keys[i]);
  46617. if (isName(entry)) {
  46618. hash.update(entry.name);
  46619. } else if (isRef(entry)) {
  46620. hash.update(entry.toString());
  46621. } else if (isArray(entry)) {
  46622. hash.update(entry.length.toString());
  46623. }
  46624. }
  46625. }
  46626. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46627. if (isStream(toUnicode)) {
  46628. var stream = toUnicode.str || toUnicode;
  46629. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  46630. hash.update(uint8array);
  46631. } else if (isName(toUnicode)) {
  46632. hash.update(toUnicode.name);
  46633. }
  46634. var widths = dict.get('Widths') || baseDict.get('Widths');
  46635. if (widths) {
  46636. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  46637. hash.update(uint8array);
  46638. }
  46639. }
  46640. return {
  46641. descriptor: descriptor,
  46642. dict: dict,
  46643. baseDict: baseDict,
  46644. composite: composite,
  46645. type: type.name,
  46646. hash: hash ? hash.hexdigest() : ''
  46647. };
  46648. },
  46649. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  46650. var baseDict = preEvaluatedFont.baseDict;
  46651. var dict = preEvaluatedFont.dict;
  46652. var composite = preEvaluatedFont.composite;
  46653. var descriptor = preEvaluatedFont.descriptor;
  46654. var type = preEvaluatedFont.type;
  46655. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  46656. var cMapOptions = this.options.cMapOptions;
  46657. var properties;
  46658. if (!descriptor) {
  46659. if (type === 'Type3') {
  46660. descriptor = new Dict(null);
  46661. descriptor.set('FontName', Name.get(type));
  46662. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  46663. } else {
  46664. var baseFontName = dict.get('BaseFont');
  46665. if (!isName(baseFontName)) {
  46666. error('Base font is not specified');
  46667. }
  46668. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  46669. var metrics = this.getBaseFontMetrics(baseFontName);
  46670. var fontNameWoStyle = baseFontName.split('-')[0];
  46671. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  46672. properties = {
  46673. type: type,
  46674. name: baseFontName,
  46675. widths: metrics.widths,
  46676. defaultWidth: metrics.defaultWidth,
  46677. flags: flags,
  46678. firstChar: 0,
  46679. lastChar: maxCharIndex
  46680. };
  46681. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  46682. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  46683. return new Font(baseFontName, null, properties);
  46684. }.bind(this));
  46685. }
  46686. }
  46687. var firstChar = dict.get('FirstChar') || 0;
  46688. var lastChar = dict.get('LastChar') || maxCharIndex;
  46689. var fontName = descriptor.get('FontName');
  46690. var baseFont = dict.get('BaseFont');
  46691. if (isString(fontName)) {
  46692. fontName = Name.get(fontName);
  46693. }
  46694. if (isString(baseFont)) {
  46695. baseFont = Name.get(baseFont);
  46696. }
  46697. if (type !== 'Type3') {
  46698. var fontNameStr = fontName && fontName.name;
  46699. var baseFontStr = baseFont && baseFont.name;
  46700. if (fontNameStr !== baseFontStr) {
  46701. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  46702. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  46703. fontName = baseFont;
  46704. }
  46705. }
  46706. }
  46707. fontName = fontName || baseFont;
  46708. assert(isName(fontName), 'invalid font name');
  46709. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  46710. if (fontFile) {
  46711. if (fontFile.dict) {
  46712. var subtype = fontFile.dict.get('Subtype');
  46713. if (subtype) {
  46714. subtype = subtype.name;
  46715. }
  46716. var length1 = fontFile.dict.get('Length1');
  46717. var length2 = fontFile.dict.get('Length2');
  46718. var length3 = fontFile.dict.get('Length3');
  46719. }
  46720. }
  46721. properties = {
  46722. type: type,
  46723. name: fontName.name,
  46724. subtype: subtype,
  46725. file: fontFile,
  46726. length1: length1,
  46727. length2: length2,
  46728. length3: length3,
  46729. loadedName: baseDict.loadedName,
  46730. composite: composite,
  46731. wideChars: composite,
  46732. fixedPitch: false,
  46733. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  46734. firstChar: firstChar || 0,
  46735. lastChar: lastChar || maxCharIndex,
  46736. bbox: descriptor.getArray('FontBBox'),
  46737. ascent: descriptor.get('Ascent'),
  46738. descent: descriptor.get('Descent'),
  46739. xHeight: descriptor.get('XHeight'),
  46740. capHeight: descriptor.get('CapHeight'),
  46741. flags: descriptor.get('Flags'),
  46742. italicAngle: descriptor.get('ItalicAngle'),
  46743. coded: false
  46744. };
  46745. var cMapPromise;
  46746. if (composite) {
  46747. var cidEncoding = baseDict.get('Encoding');
  46748. if (isName(cidEncoding)) {
  46749. properties.cidEncoding = cidEncoding.name;
  46750. }
  46751. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  46752. properties.cMap = cMap;
  46753. properties.vertical = properties.cMap.vertical;
  46754. });
  46755. } else {
  46756. cMapPromise = Promise.resolve(undefined);
  46757. }
  46758. return cMapPromise.then(function () {
  46759. return this.extractDataStructures(dict, baseDict, xref, properties);
  46760. }.bind(this)).then(function (properties) {
  46761. this.extractWidths(dict, xref, descriptor, properties);
  46762. if (type === 'Type3') {
  46763. properties.isType3Font = true;
  46764. }
  46765. return new Font(fontName.name, fontFile, properties);
  46766. }.bind(this));
  46767. }
  46768. };
  46769. return PartialEvaluator;
  46770. }();
  46771. var TranslatedFont = function TranslatedFontClosure() {
  46772. function TranslatedFont(loadedName, font, dict) {
  46773. this.loadedName = loadedName;
  46774. this.font = font;
  46775. this.dict = dict;
  46776. this.type3Loaded = null;
  46777. this.sent = false;
  46778. }
  46779. TranslatedFont.prototype = {
  46780. send: function (handler) {
  46781. if (this.sent) {
  46782. return;
  46783. }
  46784. var fontData = this.font.exportData();
  46785. handler.send('commonobj', [
  46786. this.loadedName,
  46787. 'Font',
  46788. fontData
  46789. ]);
  46790. this.sent = true;
  46791. },
  46792. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  46793. assert(this.font.isType3Font);
  46794. if (this.type3Loaded) {
  46795. return this.type3Loaded;
  46796. }
  46797. var translatedFont = this.font;
  46798. var loadCharProcsPromise = Promise.resolve();
  46799. var charProcs = this.dict.get('CharProcs');
  46800. var fontResources = this.dict.get('Resources') || resources;
  46801. var charProcKeys = charProcs.getKeys();
  46802. var charProcOperatorList = Object.create(null);
  46803. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  46804. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  46805. var glyphStream = charProcs.get(key);
  46806. var operatorList = new OperatorList();
  46807. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  46808. charProcOperatorList[key] = operatorList.getIR();
  46809. parentOperatorList.addDependencies(operatorList.dependencies);
  46810. }, function (reason) {
  46811. warn('Type3 font resource \"' + key + '\" is not available');
  46812. var operatorList = new OperatorList();
  46813. charProcOperatorList[key] = operatorList.getIR();
  46814. });
  46815. }.bind(this, charProcKeys[i]));
  46816. }
  46817. this.type3Loaded = loadCharProcsPromise.then(function () {
  46818. translatedFont.charProcOperatorList = charProcOperatorList;
  46819. });
  46820. return this.type3Loaded;
  46821. }
  46822. };
  46823. return TranslatedFont;
  46824. }();
  46825. var OperatorList = function OperatorListClosure() {
  46826. var CHUNK_SIZE = 1000;
  46827. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  46828. function getTransfers(queue) {
  46829. var transfers = [];
  46830. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  46831. for (var i = 0, ii = queue.length; i < ii; i++) {
  46832. switch (fnArray[i]) {
  46833. case OPS.paintInlineImageXObject:
  46834. case OPS.paintInlineImageXObjectGroup:
  46835. case OPS.paintImageMaskXObject:
  46836. var arg = argsArray[i][0];
  46837. if (!arg.cached) {
  46838. transfers.push(arg.data.buffer);
  46839. }
  46840. break;
  46841. }
  46842. }
  46843. return transfers;
  46844. }
  46845. function OperatorList(intent, messageHandler, pageIndex) {
  46846. this.messageHandler = messageHandler;
  46847. this.fnArray = [];
  46848. this.argsArray = [];
  46849. this.dependencies = Object.create(null);
  46850. this._totalLength = 0;
  46851. this.pageIndex = pageIndex;
  46852. this.intent = intent;
  46853. }
  46854. OperatorList.prototype = {
  46855. get length() {
  46856. return this.argsArray.length;
  46857. },
  46858. get totalLength() {
  46859. return this._totalLength + this.length;
  46860. },
  46861. addOp: function (fn, args) {
  46862. this.fnArray.push(fn);
  46863. this.argsArray.push(args);
  46864. if (this.messageHandler) {
  46865. if (this.fnArray.length >= CHUNK_SIZE) {
  46866. this.flush();
  46867. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  46868. this.flush();
  46869. }
  46870. }
  46871. },
  46872. addDependency: function (dependency) {
  46873. if (dependency in this.dependencies) {
  46874. return;
  46875. }
  46876. this.dependencies[dependency] = true;
  46877. this.addOp(OPS.dependency, [dependency]);
  46878. },
  46879. addDependencies: function (dependencies) {
  46880. for (var key in dependencies) {
  46881. this.addDependency(key);
  46882. }
  46883. },
  46884. addOpList: function (opList) {
  46885. Util.extendObj(this.dependencies, opList.dependencies);
  46886. for (var i = 0, ii = opList.length; i < ii; i++) {
  46887. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  46888. }
  46889. },
  46890. getIR: function () {
  46891. return {
  46892. fnArray: this.fnArray,
  46893. argsArray: this.argsArray,
  46894. length: this.length
  46895. };
  46896. },
  46897. flush: function (lastChunk) {
  46898. if (this.intent !== 'oplist') {
  46899. new QueueOptimizer().optimize(this);
  46900. }
  46901. var transfers = getTransfers(this);
  46902. var length = this.length;
  46903. this._totalLength += length;
  46904. this.messageHandler.send('RenderPageChunk', {
  46905. operatorList: {
  46906. fnArray: this.fnArray,
  46907. argsArray: this.argsArray,
  46908. lastChunk: lastChunk,
  46909. length: length
  46910. },
  46911. pageIndex: this.pageIndex,
  46912. intent: this.intent
  46913. }, transfers);
  46914. this.dependencies = Object.create(null);
  46915. this.fnArray.length = 0;
  46916. this.argsArray.length = 0;
  46917. }
  46918. };
  46919. return OperatorList;
  46920. }();
  46921. var StateManager = function StateManagerClosure() {
  46922. function StateManager(initialState) {
  46923. this.state = initialState;
  46924. this.stateStack = [];
  46925. }
  46926. StateManager.prototype = {
  46927. save: function () {
  46928. var old = this.state;
  46929. this.stateStack.push(this.state);
  46930. this.state = old.clone();
  46931. },
  46932. restore: function () {
  46933. var prev = this.stateStack.pop();
  46934. if (prev) {
  46935. this.state = prev;
  46936. }
  46937. },
  46938. transform: function (args) {
  46939. this.state.ctm = Util.transform(this.state.ctm, args);
  46940. }
  46941. };
  46942. return StateManager;
  46943. }();
  46944. var TextState = function TextStateClosure() {
  46945. function TextState() {
  46946. this.ctm = new Float32Array(IDENTITY_MATRIX);
  46947. this.fontName = null;
  46948. this.fontSize = 0;
  46949. this.font = null;
  46950. this.fontMatrix = FONT_IDENTITY_MATRIX;
  46951. this.textMatrix = IDENTITY_MATRIX.slice();
  46952. this.textLineMatrix = IDENTITY_MATRIX.slice();
  46953. this.charSpacing = 0;
  46954. this.wordSpacing = 0;
  46955. this.leading = 0;
  46956. this.textHScale = 1;
  46957. this.textRise = 0;
  46958. }
  46959. TextState.prototype = {
  46960. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  46961. var m = this.textMatrix;
  46962. m[0] = a;
  46963. m[1] = b;
  46964. m[2] = c;
  46965. m[3] = d;
  46966. m[4] = e;
  46967. m[5] = f;
  46968. },
  46969. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  46970. var m = this.textLineMatrix;
  46971. m[0] = a;
  46972. m[1] = b;
  46973. m[2] = c;
  46974. m[3] = d;
  46975. m[4] = e;
  46976. m[5] = f;
  46977. },
  46978. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  46979. var m = this.textMatrix;
  46980. m[4] = m[0] * x + m[2] * y + m[4];
  46981. m[5] = m[1] * x + m[3] * y + m[5];
  46982. },
  46983. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  46984. var m = this.textLineMatrix;
  46985. m[4] = m[0] * x + m[2] * y + m[4];
  46986. m[5] = m[1] * x + m[3] * y + m[5];
  46987. },
  46988. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  46989. var font = this.font;
  46990. if (!font) {
  46991. return null;
  46992. }
  46993. var m = this.textLineMatrix;
  46994. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  46995. return null;
  46996. }
  46997. var txDiff = e - m[4], tyDiff = f - m[5];
  46998. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  46999. return null;
  47000. }
  47001. var tx, ty, denominator = a * d - b * c;
  47002. if (font.vertical) {
  47003. tx = -tyDiff * c / denominator;
  47004. ty = tyDiff * a / denominator;
  47005. } else {
  47006. tx = txDiff * d / denominator;
  47007. ty = -txDiff * b / denominator;
  47008. }
  47009. return {
  47010. width: tx,
  47011. height: ty,
  47012. value: font.vertical ? ty : tx
  47013. };
  47014. },
  47015. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  47016. var tsm = [
  47017. this.fontSize * this.textHScale,
  47018. 0,
  47019. 0,
  47020. this.fontSize,
  47021. 0,
  47022. this.textRise
  47023. ];
  47024. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  47025. },
  47026. carriageReturn: function TextState_carriageReturn() {
  47027. this.translateTextLineMatrix(0, -this.leading);
  47028. this.textMatrix = this.textLineMatrix.slice();
  47029. },
  47030. clone: function TextState_clone() {
  47031. var clone = Object.create(this);
  47032. clone.textMatrix = this.textMatrix.slice();
  47033. clone.textLineMatrix = this.textLineMatrix.slice();
  47034. clone.fontMatrix = this.fontMatrix.slice();
  47035. return clone;
  47036. }
  47037. };
  47038. return TextState;
  47039. }();
  47040. var EvalState = function EvalStateClosure() {
  47041. function EvalState() {
  47042. this.ctm = new Float32Array(IDENTITY_MATRIX);
  47043. this.font = null;
  47044. this.textRenderingMode = TextRenderingMode.FILL;
  47045. this.fillColorSpace = ColorSpace.singletons.gray;
  47046. this.strokeColorSpace = ColorSpace.singletons.gray;
  47047. }
  47048. EvalState.prototype = {
  47049. clone: function CanvasExtraState_clone() {
  47050. return Object.create(this);
  47051. }
  47052. };
  47053. return EvalState;
  47054. }();
  47055. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  47056. var getOPMap = getLookupTableFactory(function (t) {
  47057. t['w'] = {
  47058. id: OPS.setLineWidth,
  47059. numArgs: 1,
  47060. variableArgs: false
  47061. };
  47062. t['J'] = {
  47063. id: OPS.setLineCap,
  47064. numArgs: 1,
  47065. variableArgs: false
  47066. };
  47067. t['j'] = {
  47068. id: OPS.setLineJoin,
  47069. numArgs: 1,
  47070. variableArgs: false
  47071. };
  47072. t['M'] = {
  47073. id: OPS.setMiterLimit,
  47074. numArgs: 1,
  47075. variableArgs: false
  47076. };
  47077. t['d'] = {
  47078. id: OPS.setDash,
  47079. numArgs: 2,
  47080. variableArgs: false
  47081. };
  47082. t['ri'] = {
  47083. id: OPS.setRenderingIntent,
  47084. numArgs: 1,
  47085. variableArgs: false
  47086. };
  47087. t['i'] = {
  47088. id: OPS.setFlatness,
  47089. numArgs: 1,
  47090. variableArgs: false
  47091. };
  47092. t['gs'] = {
  47093. id: OPS.setGState,
  47094. numArgs: 1,
  47095. variableArgs: false
  47096. };
  47097. t['q'] = {
  47098. id: OPS.save,
  47099. numArgs: 0,
  47100. variableArgs: false
  47101. };
  47102. t['Q'] = {
  47103. id: OPS.restore,
  47104. numArgs: 0,
  47105. variableArgs: false
  47106. };
  47107. t['cm'] = {
  47108. id: OPS.transform,
  47109. numArgs: 6,
  47110. variableArgs: false
  47111. };
  47112. t['m'] = {
  47113. id: OPS.moveTo,
  47114. numArgs: 2,
  47115. variableArgs: false
  47116. };
  47117. t['l'] = {
  47118. id: OPS.lineTo,
  47119. numArgs: 2,
  47120. variableArgs: false
  47121. };
  47122. t['c'] = {
  47123. id: OPS.curveTo,
  47124. numArgs: 6,
  47125. variableArgs: false
  47126. };
  47127. t['v'] = {
  47128. id: OPS.curveTo2,
  47129. numArgs: 4,
  47130. variableArgs: false
  47131. };
  47132. t['y'] = {
  47133. id: OPS.curveTo3,
  47134. numArgs: 4,
  47135. variableArgs: false
  47136. };
  47137. t['h'] = {
  47138. id: OPS.closePath,
  47139. numArgs: 0,
  47140. variableArgs: false
  47141. };
  47142. t['re'] = {
  47143. id: OPS.rectangle,
  47144. numArgs: 4,
  47145. variableArgs: false
  47146. };
  47147. t['S'] = {
  47148. id: OPS.stroke,
  47149. numArgs: 0,
  47150. variableArgs: false
  47151. };
  47152. t['s'] = {
  47153. id: OPS.closeStroke,
  47154. numArgs: 0,
  47155. variableArgs: false
  47156. };
  47157. t['f'] = {
  47158. id: OPS.fill,
  47159. numArgs: 0,
  47160. variableArgs: false
  47161. };
  47162. t['F'] = {
  47163. id: OPS.fill,
  47164. numArgs: 0,
  47165. variableArgs: false
  47166. };
  47167. t['f*'] = {
  47168. id: OPS.eoFill,
  47169. numArgs: 0,
  47170. variableArgs: false
  47171. };
  47172. t['B'] = {
  47173. id: OPS.fillStroke,
  47174. numArgs: 0,
  47175. variableArgs: false
  47176. };
  47177. t['B*'] = {
  47178. id: OPS.eoFillStroke,
  47179. numArgs: 0,
  47180. variableArgs: false
  47181. };
  47182. t['b'] = {
  47183. id: OPS.closeFillStroke,
  47184. numArgs: 0,
  47185. variableArgs: false
  47186. };
  47187. t['b*'] = {
  47188. id: OPS.closeEOFillStroke,
  47189. numArgs: 0,
  47190. variableArgs: false
  47191. };
  47192. t['n'] = {
  47193. id: OPS.endPath,
  47194. numArgs: 0,
  47195. variableArgs: false
  47196. };
  47197. t['W'] = {
  47198. id: OPS.clip,
  47199. numArgs: 0,
  47200. variableArgs: false
  47201. };
  47202. t['W*'] = {
  47203. id: OPS.eoClip,
  47204. numArgs: 0,
  47205. variableArgs: false
  47206. };
  47207. t['BT'] = {
  47208. id: OPS.beginText,
  47209. numArgs: 0,
  47210. variableArgs: false
  47211. };
  47212. t['ET'] = {
  47213. id: OPS.endText,
  47214. numArgs: 0,
  47215. variableArgs: false
  47216. };
  47217. t['Tc'] = {
  47218. id: OPS.setCharSpacing,
  47219. numArgs: 1,
  47220. variableArgs: false
  47221. };
  47222. t['Tw'] = {
  47223. id: OPS.setWordSpacing,
  47224. numArgs: 1,
  47225. variableArgs: false
  47226. };
  47227. t['Tz'] = {
  47228. id: OPS.setHScale,
  47229. numArgs: 1,
  47230. variableArgs: false
  47231. };
  47232. t['TL'] = {
  47233. id: OPS.setLeading,
  47234. numArgs: 1,
  47235. variableArgs: false
  47236. };
  47237. t['Tf'] = {
  47238. id: OPS.setFont,
  47239. numArgs: 2,
  47240. variableArgs: false
  47241. };
  47242. t['Tr'] = {
  47243. id: OPS.setTextRenderingMode,
  47244. numArgs: 1,
  47245. variableArgs: false
  47246. };
  47247. t['Ts'] = {
  47248. id: OPS.setTextRise,
  47249. numArgs: 1,
  47250. variableArgs: false
  47251. };
  47252. t['Td'] = {
  47253. id: OPS.moveText,
  47254. numArgs: 2,
  47255. variableArgs: false
  47256. };
  47257. t['TD'] = {
  47258. id: OPS.setLeadingMoveText,
  47259. numArgs: 2,
  47260. variableArgs: false
  47261. };
  47262. t['Tm'] = {
  47263. id: OPS.setTextMatrix,
  47264. numArgs: 6,
  47265. variableArgs: false
  47266. };
  47267. t['T*'] = {
  47268. id: OPS.nextLine,
  47269. numArgs: 0,
  47270. variableArgs: false
  47271. };
  47272. t['Tj'] = {
  47273. id: OPS.showText,
  47274. numArgs: 1,
  47275. variableArgs: false
  47276. };
  47277. t['TJ'] = {
  47278. id: OPS.showSpacedText,
  47279. numArgs: 1,
  47280. variableArgs: false
  47281. };
  47282. t['\''] = {
  47283. id: OPS.nextLineShowText,
  47284. numArgs: 1,
  47285. variableArgs: false
  47286. };
  47287. t['"'] = {
  47288. id: OPS.nextLineSetSpacingShowText,
  47289. numArgs: 3,
  47290. variableArgs: false
  47291. };
  47292. t['d0'] = {
  47293. id: OPS.setCharWidth,
  47294. numArgs: 2,
  47295. variableArgs: false
  47296. };
  47297. t['d1'] = {
  47298. id: OPS.setCharWidthAndBounds,
  47299. numArgs: 6,
  47300. variableArgs: false
  47301. };
  47302. t['CS'] = {
  47303. id: OPS.setStrokeColorSpace,
  47304. numArgs: 1,
  47305. variableArgs: false
  47306. };
  47307. t['cs'] = {
  47308. id: OPS.setFillColorSpace,
  47309. numArgs: 1,
  47310. variableArgs: false
  47311. };
  47312. t['SC'] = {
  47313. id: OPS.setStrokeColor,
  47314. numArgs: 4,
  47315. variableArgs: true
  47316. };
  47317. t['SCN'] = {
  47318. id: OPS.setStrokeColorN,
  47319. numArgs: 33,
  47320. variableArgs: true
  47321. };
  47322. t['sc'] = {
  47323. id: OPS.setFillColor,
  47324. numArgs: 4,
  47325. variableArgs: true
  47326. };
  47327. t['scn'] = {
  47328. id: OPS.setFillColorN,
  47329. numArgs: 33,
  47330. variableArgs: true
  47331. };
  47332. t['G'] = {
  47333. id: OPS.setStrokeGray,
  47334. numArgs: 1,
  47335. variableArgs: false
  47336. };
  47337. t['g'] = {
  47338. id: OPS.setFillGray,
  47339. numArgs: 1,
  47340. variableArgs: false
  47341. };
  47342. t['RG'] = {
  47343. id: OPS.setStrokeRGBColor,
  47344. numArgs: 3,
  47345. variableArgs: false
  47346. };
  47347. t['rg'] = {
  47348. id: OPS.setFillRGBColor,
  47349. numArgs: 3,
  47350. variableArgs: false
  47351. };
  47352. t['K'] = {
  47353. id: OPS.setStrokeCMYKColor,
  47354. numArgs: 4,
  47355. variableArgs: false
  47356. };
  47357. t['k'] = {
  47358. id: OPS.setFillCMYKColor,
  47359. numArgs: 4,
  47360. variableArgs: false
  47361. };
  47362. t['sh'] = {
  47363. id: OPS.shadingFill,
  47364. numArgs: 1,
  47365. variableArgs: false
  47366. };
  47367. t['BI'] = {
  47368. id: OPS.beginInlineImage,
  47369. numArgs: 0,
  47370. variableArgs: false
  47371. };
  47372. t['ID'] = {
  47373. id: OPS.beginImageData,
  47374. numArgs: 0,
  47375. variableArgs: false
  47376. };
  47377. t['EI'] = {
  47378. id: OPS.endInlineImage,
  47379. numArgs: 1,
  47380. variableArgs: false
  47381. };
  47382. t['Do'] = {
  47383. id: OPS.paintXObject,
  47384. numArgs: 1,
  47385. variableArgs: false
  47386. };
  47387. t['MP'] = {
  47388. id: OPS.markPoint,
  47389. numArgs: 1,
  47390. variableArgs: false
  47391. };
  47392. t['DP'] = {
  47393. id: OPS.markPointProps,
  47394. numArgs: 2,
  47395. variableArgs: false
  47396. };
  47397. t['BMC'] = {
  47398. id: OPS.beginMarkedContent,
  47399. numArgs: 1,
  47400. variableArgs: false
  47401. };
  47402. t['BDC'] = {
  47403. id: OPS.beginMarkedContentProps,
  47404. numArgs: 2,
  47405. variableArgs: false
  47406. };
  47407. t['EMC'] = {
  47408. id: OPS.endMarkedContent,
  47409. numArgs: 0,
  47410. variableArgs: false
  47411. };
  47412. t['BX'] = {
  47413. id: OPS.beginCompat,
  47414. numArgs: 0,
  47415. variableArgs: false
  47416. };
  47417. t['EX'] = {
  47418. id: OPS.endCompat,
  47419. numArgs: 0,
  47420. variableArgs: false
  47421. };
  47422. t['BM'] = null;
  47423. t['BD'] = null;
  47424. t['true'] = null;
  47425. t['fa'] = null;
  47426. t['fal'] = null;
  47427. t['fals'] = null;
  47428. t['false'] = null;
  47429. t['nu'] = null;
  47430. t['nul'] = null;
  47431. t['null'] = null;
  47432. });
  47433. function EvaluatorPreprocessor(stream, xref, stateManager) {
  47434. this.opMap = getOPMap();
  47435. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  47436. this.stateManager = stateManager;
  47437. this.nonProcessedArgs = [];
  47438. }
  47439. EvaluatorPreprocessor.prototype = {
  47440. get savedStatesDepth() {
  47441. return this.stateManager.stateStack.length;
  47442. },
  47443. read: function EvaluatorPreprocessor_read(operation) {
  47444. var args = operation.args;
  47445. while (true) {
  47446. var obj = this.parser.getObj();
  47447. if (isCmd(obj)) {
  47448. var cmd = obj.cmd;
  47449. var opSpec = this.opMap[cmd];
  47450. if (!opSpec) {
  47451. warn('Unknown command "' + cmd + '"');
  47452. continue;
  47453. }
  47454. var fn = opSpec.id;
  47455. var numArgs = opSpec.numArgs;
  47456. var argsLength = args !== null ? args.length : 0;
  47457. if (!opSpec.variableArgs) {
  47458. if (argsLength !== numArgs) {
  47459. var nonProcessedArgs = this.nonProcessedArgs;
  47460. while (argsLength > numArgs) {
  47461. nonProcessedArgs.push(args.shift());
  47462. argsLength--;
  47463. }
  47464. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  47465. if (args === null) {
  47466. args = [];
  47467. }
  47468. args.unshift(nonProcessedArgs.pop());
  47469. argsLength++;
  47470. }
  47471. }
  47472. if (argsLength < numArgs) {
  47473. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  47474. if (args !== null) {
  47475. args.length = 0;
  47476. }
  47477. continue;
  47478. }
  47479. } else if (argsLength > numArgs) {
  47480. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  47481. }
  47482. this.preprocessCommand(fn, args);
  47483. operation.fn = fn;
  47484. operation.args = args;
  47485. return true;
  47486. } else {
  47487. if (isEOF(obj)) {
  47488. return false;
  47489. }
  47490. if (obj !== null) {
  47491. if (args === null) {
  47492. args = [];
  47493. }
  47494. args.push(obj);
  47495. assert(args.length <= 33, 'Too many arguments');
  47496. }
  47497. }
  47498. }
  47499. },
  47500. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  47501. switch (fn | 0) {
  47502. case OPS.save:
  47503. this.stateManager.save();
  47504. break;
  47505. case OPS.restore:
  47506. this.stateManager.restore();
  47507. break;
  47508. case OPS.transform:
  47509. this.stateManager.transform(args);
  47510. break;
  47511. }
  47512. }
  47513. };
  47514. return EvaluatorPreprocessor;
  47515. }();
  47516. var QueueOptimizer = function QueueOptimizerClosure() {
  47517. function addState(parentState, pattern, fn) {
  47518. var state = parentState;
  47519. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  47520. var item = pattern[i];
  47521. state = state[item] || (state[item] = []);
  47522. }
  47523. state[pattern[pattern.length - 1]] = fn;
  47524. }
  47525. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  47526. var iFirstPIMXO = iFirstSave + 2;
  47527. for (var i = 0; i < count; i++) {
  47528. var arg = argsArray[iFirstPIMXO + 4 * i];
  47529. var imageMask = arg.length === 1 && arg[0];
  47530. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  47531. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  47532. continue;
  47533. }
  47534. break;
  47535. }
  47536. return count - i;
  47537. }
  47538. var InitialState = [];
  47539. addState(InitialState, [
  47540. OPS.save,
  47541. OPS.transform,
  47542. OPS.paintInlineImageXObject,
  47543. OPS.restore
  47544. ], function foundInlineImageGroup(context) {
  47545. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  47546. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  47547. var MAX_WIDTH = 1000;
  47548. var IMAGE_PADDING = 1;
  47549. var fnArray = context.fnArray, argsArray = context.argsArray;
  47550. var curr = context.iCurr;
  47551. var iFirstSave = curr - 3;
  47552. var iFirstTransform = curr - 2;
  47553. var iFirstPIIXO = curr - 1;
  47554. var i = iFirstSave + 4;
  47555. var ii = fnArray.length;
  47556. while (i + 3 < ii) {
  47557. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  47558. break;
  47559. }
  47560. i += 4;
  47561. }
  47562. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  47563. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  47564. return i;
  47565. }
  47566. var maxX = 0;
  47567. var map = [], maxLineHeight = 0;
  47568. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  47569. var q;
  47570. for (q = 0; q < count; q++) {
  47571. var transform = argsArray[iFirstTransform + (q << 2)];
  47572. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  47573. if (currentX + img.width > MAX_WIDTH) {
  47574. maxX = Math.max(maxX, currentX);
  47575. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  47576. currentX = 0;
  47577. maxLineHeight = 0;
  47578. }
  47579. map.push({
  47580. transform: transform,
  47581. x: currentX,
  47582. y: currentY,
  47583. w: img.width,
  47584. h: img.height
  47585. });
  47586. currentX += img.width + 2 * IMAGE_PADDING;
  47587. maxLineHeight = Math.max(maxLineHeight, img.height);
  47588. }
  47589. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  47590. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  47591. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  47592. var imgRowSize = imgWidth << 2;
  47593. for (q = 0; q < count; q++) {
  47594. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  47595. var rowSize = map[q].w << 2;
  47596. var dataOffset = 0;
  47597. var offset = map[q].x + map[q].y * imgWidth << 2;
  47598. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  47599. for (var k = 0, kk = map[q].h; k < kk; k++) {
  47600. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  47601. dataOffset += rowSize;
  47602. offset += imgRowSize;
  47603. }
  47604. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  47605. while (offset >= 0) {
  47606. data[offset - 4] = data[offset];
  47607. data[offset - 3] = data[offset + 1];
  47608. data[offset - 2] = data[offset + 2];
  47609. data[offset - 1] = data[offset + 3];
  47610. data[offset + rowSize] = data[offset + rowSize - 4];
  47611. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  47612. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  47613. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  47614. offset -= imgRowSize;
  47615. }
  47616. }
  47617. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  47618. argsArray.splice(iFirstSave, count * 4, [
  47619. {
  47620. width: imgWidth,
  47621. height: imgHeight,
  47622. kind: ImageKind.RGBA_32BPP,
  47623. data: imgData
  47624. },
  47625. map
  47626. ]);
  47627. return iFirstSave + 1;
  47628. });
  47629. addState(InitialState, [
  47630. OPS.save,
  47631. OPS.transform,
  47632. OPS.paintImageMaskXObject,
  47633. OPS.restore
  47634. ], function foundImageMaskGroup(context) {
  47635. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  47636. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  47637. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  47638. var fnArray = context.fnArray, argsArray = context.argsArray;
  47639. var curr = context.iCurr;
  47640. var iFirstSave = curr - 3;
  47641. var iFirstTransform = curr - 2;
  47642. var iFirstPIMXO = curr - 1;
  47643. var i = iFirstSave + 4;
  47644. var ii = fnArray.length;
  47645. while (i + 3 < ii) {
  47646. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  47647. break;
  47648. }
  47649. i += 4;
  47650. }
  47651. var count = (i - iFirstSave) / 4;
  47652. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  47653. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  47654. return i;
  47655. }
  47656. var q;
  47657. var isSameImage = false;
  47658. var iTransform, transformArgs;
  47659. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  47660. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  47661. isSameImage = true;
  47662. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47663. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47664. iTransform = iFirstTransform + 4;
  47665. var iPIMXO = iFirstPIMXO + 4;
  47666. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  47667. transformArgs = argsArray[iTransform];
  47668. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  47669. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  47670. isSameImage = false;
  47671. } else {
  47672. count = q;
  47673. }
  47674. break;
  47675. }
  47676. }
  47677. }
  47678. if (isSameImage) {
  47679. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  47680. var positions = new Float32Array(count * 2);
  47681. iTransform = iFirstTransform;
  47682. for (q = 0; q < count; q++, iTransform += 4) {
  47683. transformArgs = argsArray[iTransform];
  47684. positions[q << 1] = transformArgs[4];
  47685. positions[(q << 1) + 1] = transformArgs[5];
  47686. }
  47687. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  47688. argsArray.splice(iFirstSave, count * 4, [
  47689. firstPIMXOArg0,
  47690. firstTransformArg0,
  47691. firstTransformArg3,
  47692. positions
  47693. ]);
  47694. } else {
  47695. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  47696. var images = [];
  47697. for (q = 0; q < count; q++) {
  47698. transformArgs = argsArray[iFirstTransform + (q << 2)];
  47699. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  47700. images.push({
  47701. data: maskParams.data,
  47702. width: maskParams.width,
  47703. height: maskParams.height,
  47704. transform: transformArgs
  47705. });
  47706. }
  47707. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  47708. argsArray.splice(iFirstSave, count * 4, [images]);
  47709. }
  47710. return iFirstSave + 1;
  47711. });
  47712. addState(InitialState, [
  47713. OPS.save,
  47714. OPS.transform,
  47715. OPS.paintImageXObject,
  47716. OPS.restore
  47717. ], function (context) {
  47718. var MIN_IMAGES_IN_BLOCK = 3;
  47719. var MAX_IMAGES_IN_BLOCK = 1000;
  47720. var fnArray = context.fnArray, argsArray = context.argsArray;
  47721. var curr = context.iCurr;
  47722. var iFirstSave = curr - 3;
  47723. var iFirstTransform = curr - 2;
  47724. var iFirstPIXO = curr - 1;
  47725. var iFirstRestore = curr;
  47726. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  47727. return iFirstRestore + 1;
  47728. }
  47729. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  47730. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47731. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47732. var i = iFirstSave + 4;
  47733. var ii = fnArray.length;
  47734. while (i + 3 < ii) {
  47735. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  47736. break;
  47737. }
  47738. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  47739. break;
  47740. }
  47741. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  47742. break;
  47743. }
  47744. i += 4;
  47745. }
  47746. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  47747. if (count < MIN_IMAGES_IN_BLOCK) {
  47748. return i;
  47749. }
  47750. var positions = new Float32Array(count * 2);
  47751. var iTransform = iFirstTransform;
  47752. for (var q = 0; q < count; q++, iTransform += 4) {
  47753. var transformArgs = argsArray[iTransform];
  47754. positions[q << 1] = transformArgs[4];
  47755. positions[(q << 1) + 1] = transformArgs[5];
  47756. }
  47757. var args = [
  47758. firstPIXOArg0,
  47759. firstTransformArg0,
  47760. firstTransformArg3,
  47761. positions
  47762. ];
  47763. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  47764. argsArray.splice(iFirstSave, count * 4, args);
  47765. return iFirstSave + 1;
  47766. });
  47767. addState(InitialState, [
  47768. OPS.beginText,
  47769. OPS.setFont,
  47770. OPS.setTextMatrix,
  47771. OPS.showText,
  47772. OPS.endText
  47773. ], function (context) {
  47774. var MIN_CHARS_IN_BLOCK = 3;
  47775. var MAX_CHARS_IN_BLOCK = 1000;
  47776. var fnArray = context.fnArray, argsArray = context.argsArray;
  47777. var curr = context.iCurr;
  47778. var iFirstBeginText = curr - 4;
  47779. var iFirstSetFont = curr - 3;
  47780. var iFirstSetTextMatrix = curr - 2;
  47781. var iFirstShowText = curr - 1;
  47782. var iFirstEndText = curr;
  47783. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  47784. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  47785. var i = iFirstBeginText + 5;
  47786. var ii = fnArray.length;
  47787. while (i + 4 < ii) {
  47788. 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) {
  47789. break;
  47790. }
  47791. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  47792. break;
  47793. }
  47794. i += 5;
  47795. }
  47796. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  47797. if (count < MIN_CHARS_IN_BLOCK) {
  47798. return i;
  47799. }
  47800. var iFirst = iFirstBeginText;
  47801. 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) {
  47802. count++;
  47803. iFirst -= 5;
  47804. }
  47805. var iEndText = iFirst + 4;
  47806. for (var q = 1; q < count; q++) {
  47807. fnArray.splice(iEndText, 3);
  47808. argsArray.splice(iEndText, 3);
  47809. iEndText += 2;
  47810. }
  47811. return iEndText + 1;
  47812. });
  47813. function QueueOptimizer() {
  47814. }
  47815. QueueOptimizer.prototype = {
  47816. optimize: function QueueOptimizer_optimize(queue) {
  47817. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  47818. var context = {
  47819. iCurr: 0,
  47820. fnArray: fnArray,
  47821. argsArray: argsArray
  47822. };
  47823. var state;
  47824. var i = 0, ii = fnArray.length;
  47825. while (i < ii) {
  47826. state = (state || InitialState)[fnArray[i]];
  47827. if (typeof state === 'function') {
  47828. context.iCurr = i;
  47829. i = state(context);
  47830. state = undefined;
  47831. ii = context.fnArray.length;
  47832. } else {
  47833. i++;
  47834. }
  47835. }
  47836. }
  47837. };
  47838. return QueueOptimizer;
  47839. }();
  47840. exports.OperatorList = OperatorList;
  47841. exports.PartialEvaluator = PartialEvaluator;
  47842. }));
  47843. (function (root, factory) {
  47844. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  47845. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  47846. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  47847. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  47848. var AnnotationFlag = sharedUtil.AnnotationFlag;
  47849. var AnnotationType = sharedUtil.AnnotationType;
  47850. var OPS = sharedUtil.OPS;
  47851. var Util = sharedUtil.Util;
  47852. var isString = sharedUtil.isString;
  47853. var isArray = sharedUtil.isArray;
  47854. var isInt = sharedUtil.isInt;
  47855. var stringToBytes = sharedUtil.stringToBytes;
  47856. var stringToPDFString = sharedUtil.stringToPDFString;
  47857. var warn = sharedUtil.warn;
  47858. var Dict = corePrimitives.Dict;
  47859. var isDict = corePrimitives.isDict;
  47860. var isName = corePrimitives.isName;
  47861. var isRef = corePrimitives.isRef;
  47862. var Stream = coreStream.Stream;
  47863. var ColorSpace = coreColorSpace.ColorSpace;
  47864. var Catalog = coreObj.Catalog;
  47865. var ObjectLoader = coreObj.ObjectLoader;
  47866. var FileSpec = coreObj.FileSpec;
  47867. var OperatorList = coreEvaluator.OperatorList;
  47868. function AnnotationFactory() {
  47869. }
  47870. AnnotationFactory.prototype = {
  47871. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  47872. var dict = xref.fetchIfRef(ref);
  47873. if (!isDict(dict)) {
  47874. return;
  47875. }
  47876. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  47877. var subtype = dict.get('Subtype');
  47878. subtype = isName(subtype) ? subtype.name : null;
  47879. var parameters = {
  47880. xref: xref,
  47881. dict: dict,
  47882. ref: isRef(ref) ? ref : null,
  47883. subtype: subtype,
  47884. id: id,
  47885. pdfManager: pdfManager
  47886. };
  47887. switch (subtype) {
  47888. case 'Link':
  47889. return new LinkAnnotation(parameters);
  47890. case 'Text':
  47891. return new TextAnnotation(parameters);
  47892. case 'Widget':
  47893. var fieldType = Util.getInheritableProperty(dict, 'FT');
  47894. fieldType = isName(fieldType) ? fieldType.name : null;
  47895. switch (fieldType) {
  47896. case 'Tx':
  47897. return new TextWidgetAnnotation(parameters);
  47898. case 'Ch':
  47899. return new ChoiceWidgetAnnotation(parameters);
  47900. }
  47901. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  47902. return new WidgetAnnotation(parameters);
  47903. case 'Popup':
  47904. return new PopupAnnotation(parameters);
  47905. case 'Highlight':
  47906. return new HighlightAnnotation(parameters);
  47907. case 'Underline':
  47908. return new UnderlineAnnotation(parameters);
  47909. case 'Squiggly':
  47910. return new SquigglyAnnotation(parameters);
  47911. case 'StrikeOut':
  47912. return new StrikeOutAnnotation(parameters);
  47913. case 'FileAttachment':
  47914. return new FileAttachmentAnnotation(parameters);
  47915. default:
  47916. if (!subtype) {
  47917. warn('Annotation is missing the required /Subtype.');
  47918. } else {
  47919. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  47920. }
  47921. return new Annotation(parameters);
  47922. }
  47923. }
  47924. };
  47925. var Annotation = function AnnotationClosure() {
  47926. function getTransformMatrix(rect, bbox, matrix) {
  47927. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  47928. var minX = bounds[0];
  47929. var minY = bounds[1];
  47930. var maxX = bounds[2];
  47931. var maxY = bounds[3];
  47932. if (minX === maxX || minY === maxY) {
  47933. return [
  47934. 1,
  47935. 0,
  47936. 0,
  47937. 1,
  47938. rect[0],
  47939. rect[1]
  47940. ];
  47941. }
  47942. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  47943. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  47944. return [
  47945. xRatio,
  47946. 0,
  47947. 0,
  47948. yRatio,
  47949. rect[0] - minX * xRatio,
  47950. rect[1] - minY * yRatio
  47951. ];
  47952. }
  47953. function getDefaultAppearance(dict) {
  47954. var appearanceState = dict.get('AP');
  47955. if (!isDict(appearanceState)) {
  47956. return;
  47957. }
  47958. var appearance;
  47959. var appearances = appearanceState.get('N');
  47960. if (isDict(appearances)) {
  47961. var as = dict.get('AS');
  47962. if (as && appearances.has(as.name)) {
  47963. appearance = appearances.get(as.name);
  47964. }
  47965. } else {
  47966. appearance = appearances;
  47967. }
  47968. return appearance;
  47969. }
  47970. function Annotation(params) {
  47971. var dict = params.dict;
  47972. this.setFlags(dict.get('F'));
  47973. this.setRectangle(dict.getArray('Rect'));
  47974. this.setColor(dict.getArray('C'));
  47975. this.setBorderStyle(dict);
  47976. this.appearance = getDefaultAppearance(dict);
  47977. this.data = {};
  47978. this.data.id = params.id;
  47979. this.data.subtype = params.subtype;
  47980. this.data.annotationFlags = this.flags;
  47981. this.data.rect = this.rectangle;
  47982. this.data.color = this.color;
  47983. this.data.borderStyle = this.borderStyle;
  47984. this.data.hasAppearance = !!this.appearance;
  47985. }
  47986. Annotation.prototype = {
  47987. _hasFlag: function Annotation_hasFlag(flags, flag) {
  47988. return !!(flags & flag);
  47989. },
  47990. _isViewable: function Annotation_isViewable(flags) {
  47991. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  47992. },
  47993. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  47994. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  47995. },
  47996. get viewable() {
  47997. if (this.flags === 0) {
  47998. return true;
  47999. }
  48000. return this._isViewable(this.flags);
  48001. },
  48002. get printable() {
  48003. if (this.flags === 0) {
  48004. return false;
  48005. }
  48006. return this._isPrintable(this.flags);
  48007. },
  48008. setFlags: function Annotation_setFlags(flags) {
  48009. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  48010. },
  48011. hasFlag: function Annotation_hasFlag(flag) {
  48012. return this._hasFlag(this.flags, flag);
  48013. },
  48014. setRectangle: function Annotation_setRectangle(rectangle) {
  48015. if (isArray(rectangle) && rectangle.length === 4) {
  48016. this.rectangle = Util.normalizeRect(rectangle);
  48017. } else {
  48018. this.rectangle = [
  48019. 0,
  48020. 0,
  48021. 0,
  48022. 0
  48023. ];
  48024. }
  48025. },
  48026. setColor: function Annotation_setColor(color) {
  48027. var rgbColor = new Uint8Array(3);
  48028. if (!isArray(color)) {
  48029. this.color = rgbColor;
  48030. return;
  48031. }
  48032. switch (color.length) {
  48033. case 0:
  48034. this.color = null;
  48035. break;
  48036. case 1:
  48037. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  48038. this.color = rgbColor;
  48039. break;
  48040. case 3:
  48041. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  48042. this.color = rgbColor;
  48043. break;
  48044. case 4:
  48045. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  48046. this.color = rgbColor;
  48047. break;
  48048. default:
  48049. this.color = rgbColor;
  48050. break;
  48051. }
  48052. },
  48053. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  48054. this.borderStyle = new AnnotationBorderStyle();
  48055. if (!isDict(borderStyle)) {
  48056. return;
  48057. }
  48058. if (borderStyle.has('BS')) {
  48059. var dict = borderStyle.get('BS');
  48060. var dictType = dict.get('Type');
  48061. if (!dictType || isName(dictType, 'Border')) {
  48062. this.borderStyle.setWidth(dict.get('W'));
  48063. this.borderStyle.setStyle(dict.get('S'));
  48064. this.borderStyle.setDashArray(dict.getArray('D'));
  48065. }
  48066. } else if (borderStyle.has('Border')) {
  48067. var array = borderStyle.getArray('Border');
  48068. if (isArray(array) && array.length >= 3) {
  48069. this.borderStyle.setHorizontalCornerRadius(array[0]);
  48070. this.borderStyle.setVerticalCornerRadius(array[1]);
  48071. this.borderStyle.setWidth(array[2]);
  48072. if (array.length === 4) {
  48073. this.borderStyle.setDashArray(array[3]);
  48074. }
  48075. }
  48076. } else {
  48077. this.borderStyle.setWidth(0);
  48078. }
  48079. },
  48080. _preparePopup: function Annotation_preparePopup(dict) {
  48081. if (!dict.has('C')) {
  48082. this.data.color = null;
  48083. }
  48084. this.data.hasPopup = dict.has('Popup');
  48085. this.data.title = stringToPDFString(dict.get('T') || '');
  48086. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  48087. },
  48088. loadResources: function Annotation_loadResources(keys) {
  48089. return new Promise(function (resolve, reject) {
  48090. this.appearance.dict.getAsync('Resources').then(function (resources) {
  48091. if (!resources) {
  48092. resolve();
  48093. return;
  48094. }
  48095. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  48096. objectLoader.load().then(function () {
  48097. resolve(resources);
  48098. }, reject);
  48099. }, reject);
  48100. }.bind(this));
  48101. },
  48102. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  48103. if (!this.appearance) {
  48104. return Promise.resolve(new OperatorList());
  48105. }
  48106. var data = this.data;
  48107. var appearanceDict = this.appearance.dict;
  48108. var resourcesPromise = this.loadResources([
  48109. 'ExtGState',
  48110. 'ColorSpace',
  48111. 'Pattern',
  48112. 'Shading',
  48113. 'XObject',
  48114. 'Font'
  48115. ]);
  48116. var bbox = appearanceDict.getArray('BBox') || [
  48117. 0,
  48118. 0,
  48119. 1,
  48120. 1
  48121. ];
  48122. var matrix = appearanceDict.getArray('Matrix') || [
  48123. 1,
  48124. 0,
  48125. 0,
  48126. 1,
  48127. 0,
  48128. 0
  48129. ];
  48130. var transform = getTransformMatrix(data.rect, bbox, matrix);
  48131. var self = this;
  48132. return resourcesPromise.then(function (resources) {
  48133. var opList = new OperatorList();
  48134. opList.addOp(OPS.beginAnnotation, [
  48135. data.rect,
  48136. transform,
  48137. matrix
  48138. ]);
  48139. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  48140. opList.addOp(OPS.endAnnotation, []);
  48141. self.appearance.reset();
  48142. return opList;
  48143. });
  48144. });
  48145. }
  48146. };
  48147. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  48148. var annotationPromises = [];
  48149. for (var i = 0, n = annotations.length; i < n; ++i) {
  48150. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  48151. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  48152. }
  48153. }
  48154. return Promise.all(annotationPromises).then(function (operatorLists) {
  48155. opList.addOp(OPS.beginAnnotations, []);
  48156. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  48157. opList.addOpList(operatorLists[i]);
  48158. }
  48159. opList.addOp(OPS.endAnnotations, []);
  48160. });
  48161. };
  48162. return Annotation;
  48163. }();
  48164. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  48165. function AnnotationBorderStyle() {
  48166. this.width = 1;
  48167. this.style = AnnotationBorderStyleType.SOLID;
  48168. this.dashArray = [3];
  48169. this.horizontalCornerRadius = 0;
  48170. this.verticalCornerRadius = 0;
  48171. }
  48172. AnnotationBorderStyle.prototype = {
  48173. setWidth: function AnnotationBorderStyle_setWidth(width) {
  48174. if (width === (width | 0)) {
  48175. this.width = width;
  48176. }
  48177. },
  48178. setStyle: function AnnotationBorderStyle_setStyle(style) {
  48179. if (!style) {
  48180. return;
  48181. }
  48182. switch (style.name) {
  48183. case 'S':
  48184. this.style = AnnotationBorderStyleType.SOLID;
  48185. break;
  48186. case 'D':
  48187. this.style = AnnotationBorderStyleType.DASHED;
  48188. break;
  48189. case 'B':
  48190. this.style = AnnotationBorderStyleType.BEVELED;
  48191. break;
  48192. case 'I':
  48193. this.style = AnnotationBorderStyleType.INSET;
  48194. break;
  48195. case 'U':
  48196. this.style = AnnotationBorderStyleType.UNDERLINE;
  48197. break;
  48198. default:
  48199. break;
  48200. }
  48201. },
  48202. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  48203. if (isArray(dashArray) && dashArray.length > 0) {
  48204. var isValid = true;
  48205. var allZeros = true;
  48206. for (var i = 0, len = dashArray.length; i < len; i++) {
  48207. var element = dashArray[i];
  48208. var validNumber = +element >= 0;
  48209. if (!validNumber) {
  48210. isValid = false;
  48211. break;
  48212. } else if (element > 0) {
  48213. allZeros = false;
  48214. }
  48215. }
  48216. if (isValid && !allZeros) {
  48217. this.dashArray = dashArray;
  48218. } else {
  48219. this.width = 0;
  48220. }
  48221. } else if (dashArray) {
  48222. this.width = 0;
  48223. }
  48224. },
  48225. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  48226. if (radius === (radius | 0)) {
  48227. this.horizontalCornerRadius = radius;
  48228. }
  48229. },
  48230. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  48231. if (radius === (radius | 0)) {
  48232. this.verticalCornerRadius = radius;
  48233. }
  48234. }
  48235. };
  48236. return AnnotationBorderStyle;
  48237. }();
  48238. var WidgetAnnotation = function WidgetAnnotationClosure() {
  48239. function WidgetAnnotation(params) {
  48240. Annotation.call(this, params);
  48241. var dict = params.dict;
  48242. var data = this.data;
  48243. data.annotationType = AnnotationType.WIDGET;
  48244. data.fieldName = this._constructFieldName(dict);
  48245. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  48246. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  48247. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  48248. var fieldType = Util.getInheritableProperty(dict, 'FT');
  48249. data.fieldType = isName(fieldType) ? fieldType.name : null;
  48250. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  48251. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  48252. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  48253. data.fieldFlags = 0;
  48254. }
  48255. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  48256. if (data.fieldType === 'Sig') {
  48257. this.setFlags(AnnotationFlag.HIDDEN);
  48258. }
  48259. }
  48260. Util.inherit(WidgetAnnotation, Annotation, {
  48261. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  48262. if (!dict.has('T') && !dict.has('Parent')) {
  48263. warn('Unknown field name, falling back to empty field name.');
  48264. return '';
  48265. }
  48266. if (!dict.has('Parent')) {
  48267. return stringToPDFString(dict.get('T'));
  48268. }
  48269. var fieldName = [];
  48270. if (dict.has('T')) {
  48271. fieldName.unshift(stringToPDFString(dict.get('T')));
  48272. }
  48273. var loopDict = dict;
  48274. while (loopDict.has('Parent')) {
  48275. loopDict = loopDict.get('Parent');
  48276. if (loopDict.has('T')) {
  48277. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  48278. }
  48279. }
  48280. return fieldName.join('.');
  48281. },
  48282. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  48283. return !!(this.data.fieldFlags & flag);
  48284. }
  48285. });
  48286. return WidgetAnnotation;
  48287. }();
  48288. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  48289. function TextWidgetAnnotation(params) {
  48290. WidgetAnnotation.call(this, params);
  48291. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  48292. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  48293. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  48294. alignment = null;
  48295. }
  48296. this.data.textAlignment = alignment;
  48297. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  48298. if (!isInt(maximumLength) || maximumLength < 0) {
  48299. maximumLength = null;
  48300. }
  48301. this.data.maxLen = maximumLength;
  48302. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  48303. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  48304. }
  48305. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  48306. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48307. var operatorList = new OperatorList();
  48308. if (renderForms) {
  48309. return Promise.resolve(operatorList);
  48310. }
  48311. if (this.appearance) {
  48312. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48313. }
  48314. if (!this.data.defaultAppearance) {
  48315. return Promise.resolve(operatorList);
  48316. }
  48317. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  48318. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  48319. return operatorList;
  48320. });
  48321. }
  48322. });
  48323. return TextWidgetAnnotation;
  48324. }();
  48325. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  48326. function ChoiceWidgetAnnotation(params) {
  48327. WidgetAnnotation.call(this, params);
  48328. this.data.options = [];
  48329. var options = params.dict.getArray('Opt');
  48330. if (isArray(options)) {
  48331. for (var i = 0, ii = options.length; i < ii; i++) {
  48332. var option = options[i];
  48333. this.data.options[i] = {
  48334. exportValue: isArray(option) ? option[0] : option,
  48335. displayValue: isArray(option) ? option[1] : option
  48336. };
  48337. }
  48338. }
  48339. if (!isArray(this.data.fieldValue)) {
  48340. this.data.fieldValue = [this.data.fieldValue];
  48341. }
  48342. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  48343. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  48344. }
  48345. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  48346. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48347. var operatorList = new OperatorList();
  48348. if (renderForms) {
  48349. return Promise.resolve(operatorList);
  48350. }
  48351. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48352. }
  48353. });
  48354. return ChoiceWidgetAnnotation;
  48355. }();
  48356. var TextAnnotation = function TextAnnotationClosure() {
  48357. var DEFAULT_ICON_SIZE = 22;
  48358. function TextAnnotation(parameters) {
  48359. Annotation.call(this, parameters);
  48360. this.data.annotationType = AnnotationType.TEXT;
  48361. if (this.data.hasAppearance) {
  48362. this.data.name = 'NoIcon';
  48363. } else {
  48364. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  48365. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  48366. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  48367. }
  48368. this._preparePopup(parameters.dict);
  48369. }
  48370. Util.inherit(TextAnnotation, Annotation, {});
  48371. return TextAnnotation;
  48372. }();
  48373. var LinkAnnotation = function LinkAnnotationClosure() {
  48374. function LinkAnnotation(params) {
  48375. Annotation.call(this, params);
  48376. var data = this.data;
  48377. data.annotationType = AnnotationType.LINK;
  48378. Catalog.parseDestDictionary({
  48379. destDict: params.dict,
  48380. resultObj: data,
  48381. docBaseUrl: params.pdfManager.docBaseUrl
  48382. });
  48383. }
  48384. Util.inherit(LinkAnnotation, Annotation, {});
  48385. return LinkAnnotation;
  48386. }();
  48387. var PopupAnnotation = function PopupAnnotationClosure() {
  48388. function PopupAnnotation(parameters) {
  48389. Annotation.call(this, parameters);
  48390. this.data.annotationType = AnnotationType.POPUP;
  48391. var dict = parameters.dict;
  48392. var parentItem = dict.get('Parent');
  48393. if (!parentItem) {
  48394. warn('Popup annotation has a missing or invalid parent annotation.');
  48395. return;
  48396. }
  48397. this.data.parentId = dict.getRaw('Parent').toString();
  48398. this.data.title = stringToPDFString(parentItem.get('T') || '');
  48399. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  48400. if (!parentItem.has('C')) {
  48401. this.data.color = null;
  48402. } else {
  48403. this.setColor(parentItem.getArray('C'));
  48404. this.data.color = this.color;
  48405. }
  48406. if (!this.viewable) {
  48407. var parentFlags = parentItem.get('F');
  48408. if (this._isViewable(parentFlags)) {
  48409. this.setFlags(parentFlags);
  48410. }
  48411. }
  48412. }
  48413. Util.inherit(PopupAnnotation, Annotation, {});
  48414. return PopupAnnotation;
  48415. }();
  48416. var HighlightAnnotation = function HighlightAnnotationClosure() {
  48417. function HighlightAnnotation(parameters) {
  48418. Annotation.call(this, parameters);
  48419. this.data.annotationType = AnnotationType.HIGHLIGHT;
  48420. this._preparePopup(parameters.dict);
  48421. this.data.borderStyle.setWidth(0);
  48422. }
  48423. Util.inherit(HighlightAnnotation, Annotation, {});
  48424. return HighlightAnnotation;
  48425. }();
  48426. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  48427. function UnderlineAnnotation(parameters) {
  48428. Annotation.call(this, parameters);
  48429. this.data.annotationType = AnnotationType.UNDERLINE;
  48430. this._preparePopup(parameters.dict);
  48431. this.data.borderStyle.setWidth(0);
  48432. }
  48433. Util.inherit(UnderlineAnnotation, Annotation, {});
  48434. return UnderlineAnnotation;
  48435. }();
  48436. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  48437. function SquigglyAnnotation(parameters) {
  48438. Annotation.call(this, parameters);
  48439. this.data.annotationType = AnnotationType.SQUIGGLY;
  48440. this._preparePopup(parameters.dict);
  48441. this.data.borderStyle.setWidth(0);
  48442. }
  48443. Util.inherit(SquigglyAnnotation, Annotation, {});
  48444. return SquigglyAnnotation;
  48445. }();
  48446. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  48447. function StrikeOutAnnotation(parameters) {
  48448. Annotation.call(this, parameters);
  48449. this.data.annotationType = AnnotationType.STRIKEOUT;
  48450. this._preparePopup(parameters.dict);
  48451. this.data.borderStyle.setWidth(0);
  48452. }
  48453. Util.inherit(StrikeOutAnnotation, Annotation, {});
  48454. return StrikeOutAnnotation;
  48455. }();
  48456. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  48457. function FileAttachmentAnnotation(parameters) {
  48458. Annotation.call(this, parameters);
  48459. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  48460. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  48461. this.data.file = file.serializable;
  48462. this._preparePopup(parameters.dict);
  48463. }
  48464. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  48465. return FileAttachmentAnnotation;
  48466. }();
  48467. exports.Annotation = Annotation;
  48468. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  48469. exports.AnnotationFactory = AnnotationFactory;
  48470. }));
  48471. (function (root, factory) {
  48472. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  48473. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  48474. var MissingDataException = sharedUtil.MissingDataException;
  48475. var Util = sharedUtil.Util;
  48476. var assert = sharedUtil.assert;
  48477. var error = sharedUtil.error;
  48478. var info = sharedUtil.info;
  48479. var isArray = sharedUtil.isArray;
  48480. var isArrayBuffer = sharedUtil.isArrayBuffer;
  48481. var isNum = sharedUtil.isNum;
  48482. var isString = sharedUtil.isString;
  48483. var shadow = sharedUtil.shadow;
  48484. var stringToBytes = sharedUtil.stringToBytes;
  48485. var stringToPDFString = sharedUtil.stringToPDFString;
  48486. var warn = sharedUtil.warn;
  48487. var isSpace = sharedUtil.isSpace;
  48488. var Dict = corePrimitives.Dict;
  48489. var isDict = corePrimitives.isDict;
  48490. var isName = corePrimitives.isName;
  48491. var isStream = corePrimitives.isStream;
  48492. var NullStream = coreStream.NullStream;
  48493. var Stream = coreStream.Stream;
  48494. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  48495. var Catalog = coreObj.Catalog;
  48496. var ObjectLoader = coreObj.ObjectLoader;
  48497. var XRef = coreObj.XRef;
  48498. var Linearization = coreParser.Linearization;
  48499. var calculateMD5 = coreCrypto.calculateMD5;
  48500. var OperatorList = coreEvaluator.OperatorList;
  48501. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  48502. var Annotation = coreAnnotation.Annotation;
  48503. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  48504. var Page = function PageClosure() {
  48505. var DEFAULT_USER_UNIT = 1.0;
  48506. var LETTER_SIZE_MEDIABOX = [
  48507. 0,
  48508. 0,
  48509. 612,
  48510. 792
  48511. ];
  48512. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  48513. this.pdfManager = pdfManager;
  48514. this.pageIndex = pageIndex;
  48515. this.pageDict = pageDict;
  48516. this.xref = xref;
  48517. this.ref = ref;
  48518. this.fontCache = fontCache;
  48519. this.uniquePrefix = 'p' + this.pageIndex + '_';
  48520. this.idCounters = { obj: 0 };
  48521. this.evaluatorOptions = pdfManager.evaluatorOptions;
  48522. this.resourcesPromise = null;
  48523. }
  48524. Page.prototype = {
  48525. getPageProp: function Page_getPageProp(key) {
  48526. return this.pageDict.get(key);
  48527. },
  48528. getInheritedPageProp: function Page_getInheritedPageProp(key) {
  48529. var dict = this.pageDict, valueArray = null, loopCount = 0;
  48530. var MAX_LOOP_COUNT = 100;
  48531. while (dict) {
  48532. var value = dict.get(key);
  48533. if (value) {
  48534. if (!valueArray) {
  48535. valueArray = [];
  48536. }
  48537. valueArray.push(value);
  48538. }
  48539. if (++loopCount > MAX_LOOP_COUNT) {
  48540. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  48541. break;
  48542. }
  48543. dict = dict.get('Parent');
  48544. }
  48545. if (!valueArray) {
  48546. return Dict.empty;
  48547. }
  48548. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  48549. return valueArray[0];
  48550. }
  48551. return Dict.merge(this.xref, valueArray);
  48552. },
  48553. get content() {
  48554. return this.getPageProp('Contents');
  48555. },
  48556. get resources() {
  48557. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  48558. },
  48559. get mediaBox() {
  48560. var obj = this.getInheritedPageProp('MediaBox');
  48561. if (!isArray(obj) || obj.length !== 4) {
  48562. obj = LETTER_SIZE_MEDIABOX;
  48563. }
  48564. return shadow(this, 'mediaBox', obj);
  48565. },
  48566. get userUnit() {
  48567. var obj = this.getPageProp('UserUnit');
  48568. if (!isNum(obj) || obj <= 0) {
  48569. obj = DEFAULT_USER_UNIT;
  48570. }
  48571. return shadow(this, 'userUnit', obj);
  48572. },
  48573. get view() {
  48574. var mediaBox = this.mediaBox;
  48575. var cropBox = this.getInheritedPageProp('CropBox');
  48576. if (!isArray(cropBox) || cropBox.length !== 4) {
  48577. return shadow(this, 'view', mediaBox);
  48578. }
  48579. cropBox = Util.intersect(cropBox, mediaBox);
  48580. if (!cropBox) {
  48581. return shadow(this, 'view', mediaBox);
  48582. }
  48583. return shadow(this, 'view', cropBox);
  48584. },
  48585. get rotate() {
  48586. var rotate = this.getInheritedPageProp('Rotate') || 0;
  48587. if (rotate % 90 !== 0) {
  48588. rotate = 0;
  48589. } else if (rotate >= 360) {
  48590. rotate = rotate % 360;
  48591. } else if (rotate < 0) {
  48592. rotate = (rotate % 360 + 360) % 360;
  48593. }
  48594. return shadow(this, 'rotate', rotate);
  48595. },
  48596. getContentStream: function Page_getContentStream() {
  48597. var content = this.content;
  48598. var stream;
  48599. if (isArray(content)) {
  48600. var xref = this.xref;
  48601. var i, n = content.length;
  48602. var streams = [];
  48603. for (i = 0; i < n; ++i) {
  48604. streams.push(xref.fetchIfRef(content[i]));
  48605. }
  48606. stream = new StreamsSequenceStream(streams);
  48607. } else if (isStream(content)) {
  48608. stream = content;
  48609. } else {
  48610. stream = new NullStream();
  48611. }
  48612. return stream;
  48613. },
  48614. loadResources: function Page_loadResources(keys) {
  48615. if (!this.resourcesPromise) {
  48616. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  48617. }
  48618. return this.resourcesPromise.then(function resourceSuccess() {
  48619. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  48620. return objectLoader.load();
  48621. }.bind(this));
  48622. },
  48623. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  48624. var self = this;
  48625. var pdfManager = this.pdfManager;
  48626. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48627. var resourcesPromise = this.loadResources([
  48628. 'ExtGState',
  48629. 'ColorSpace',
  48630. 'Pattern',
  48631. 'Shading',
  48632. 'XObject',
  48633. 'Font'
  48634. ]);
  48635. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  48636. var dataPromises = Promise.all([
  48637. contentStreamPromise,
  48638. resourcesPromise
  48639. ]);
  48640. var pageListPromise = dataPromises.then(function (data) {
  48641. var contentStream = data[0];
  48642. var opList = new OperatorList(intent, handler, self.pageIndex);
  48643. handler.send('StartRenderPage', {
  48644. transparency: partialEvaluator.hasBlendModes(self.resources),
  48645. pageIndex: self.pageIndex,
  48646. intent: intent
  48647. });
  48648. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  48649. return opList;
  48650. });
  48651. });
  48652. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  48653. return Promise.all([
  48654. pageListPromise,
  48655. annotationsPromise
  48656. ]).then(function (datas) {
  48657. var pageOpList = datas[0];
  48658. var annotations = datas[1];
  48659. if (annotations.length === 0) {
  48660. pageOpList.flush(true);
  48661. return pageOpList;
  48662. }
  48663. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  48664. return annotationsReadyPromise.then(function () {
  48665. pageOpList.flush(true);
  48666. return pageOpList;
  48667. });
  48668. });
  48669. },
  48670. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  48671. var handler = {
  48672. on: function nullHandlerOn() {
  48673. },
  48674. send: function nullHandlerSend() {
  48675. }
  48676. };
  48677. var self = this;
  48678. var pdfManager = this.pdfManager;
  48679. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48680. var resourcesPromise = this.loadResources([
  48681. 'ExtGState',
  48682. 'XObject',
  48683. 'Font'
  48684. ]);
  48685. var dataPromises = Promise.all([
  48686. contentStreamPromise,
  48687. resourcesPromise
  48688. ]);
  48689. return dataPromises.then(function (data) {
  48690. var contentStream = data[0];
  48691. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  48692. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  48693. });
  48694. },
  48695. getAnnotationsData: function Page_getAnnotationsData(intent) {
  48696. var annotations = this.annotations;
  48697. var annotationsData = [];
  48698. for (var i = 0, n = annotations.length; i < n; ++i) {
  48699. if (intent) {
  48700. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  48701. continue;
  48702. }
  48703. }
  48704. annotationsData.push(annotations[i].data);
  48705. }
  48706. return annotationsData;
  48707. },
  48708. get annotations() {
  48709. var annotations = [];
  48710. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  48711. var annotationFactory = new AnnotationFactory();
  48712. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  48713. var annotationRef = annotationRefs[i];
  48714. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  48715. if (annotation) {
  48716. annotations.push(annotation);
  48717. }
  48718. }
  48719. return shadow(this, 'annotations', annotations);
  48720. }
  48721. };
  48722. return Page;
  48723. }();
  48724. var PDFDocument = function PDFDocumentClosure() {
  48725. var FINGERPRINT_FIRST_BYTES = 1024;
  48726. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  48727. function PDFDocument(pdfManager, arg, password) {
  48728. if (isStream(arg)) {
  48729. init.call(this, pdfManager, arg, password);
  48730. } else if (isArrayBuffer(arg)) {
  48731. init.call(this, pdfManager, new Stream(arg), password);
  48732. } else {
  48733. error('PDFDocument: Unknown argument type');
  48734. }
  48735. }
  48736. function init(pdfManager, stream, password) {
  48737. assert(stream.length > 0, 'stream must have data');
  48738. this.pdfManager = pdfManager;
  48739. this.stream = stream;
  48740. var xref = new XRef(this.stream, password, pdfManager);
  48741. this.xref = xref;
  48742. }
  48743. function find(stream, needle, limit, backwards) {
  48744. var pos = stream.pos;
  48745. var end = stream.end;
  48746. var strBuf = [];
  48747. if (pos + limit > end) {
  48748. limit = end - pos;
  48749. }
  48750. for (var n = 0; n < limit; ++n) {
  48751. strBuf.push(String.fromCharCode(stream.getByte()));
  48752. }
  48753. var str = strBuf.join('');
  48754. stream.pos = pos;
  48755. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  48756. if (index === -1) {
  48757. return false;
  48758. }
  48759. stream.pos += index;
  48760. return true;
  48761. }
  48762. var DocumentInfoValidators = {
  48763. get entries() {
  48764. return shadow(this, 'entries', {
  48765. Title: isString,
  48766. Author: isString,
  48767. Subject: isString,
  48768. Keywords: isString,
  48769. Creator: isString,
  48770. Producer: isString,
  48771. CreationDate: isString,
  48772. ModDate: isString,
  48773. Trapped: isName
  48774. });
  48775. }
  48776. };
  48777. PDFDocument.prototype = {
  48778. parse: function PDFDocument_parse(recoveryMode) {
  48779. this.setup(recoveryMode);
  48780. var version = this.catalog.catDict.get('Version');
  48781. if (isName(version)) {
  48782. this.pdfFormatVersion = version.name;
  48783. }
  48784. try {
  48785. this.acroForm = this.catalog.catDict.get('AcroForm');
  48786. if (this.acroForm) {
  48787. this.xfa = this.acroForm.get('XFA');
  48788. var fields = this.acroForm.get('Fields');
  48789. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  48790. this.acroForm = null;
  48791. }
  48792. }
  48793. } catch (ex) {
  48794. info('Something wrong with AcroForm entry');
  48795. this.acroForm = null;
  48796. }
  48797. },
  48798. get linearization() {
  48799. var linearization = null;
  48800. if (this.stream.length) {
  48801. try {
  48802. linearization = Linearization.create(this.stream);
  48803. } catch (err) {
  48804. if (err instanceof MissingDataException) {
  48805. throw err;
  48806. }
  48807. info(err);
  48808. }
  48809. }
  48810. return shadow(this, 'linearization', linearization);
  48811. },
  48812. get startXRef() {
  48813. var stream = this.stream;
  48814. var startXRef = 0;
  48815. var linearization = this.linearization;
  48816. if (linearization) {
  48817. stream.reset();
  48818. if (find(stream, 'endobj', 1024)) {
  48819. startXRef = stream.pos + 6;
  48820. }
  48821. } else {
  48822. var step = 1024;
  48823. var found = false, pos = stream.end;
  48824. while (!found && pos > 0) {
  48825. pos -= step - 'startxref'.length;
  48826. if (pos < 0) {
  48827. pos = 0;
  48828. }
  48829. stream.pos = pos;
  48830. found = find(stream, 'startxref', step, true);
  48831. }
  48832. if (found) {
  48833. stream.skip(9);
  48834. var ch;
  48835. do {
  48836. ch = stream.getByte();
  48837. } while (isSpace(ch));
  48838. var str = '';
  48839. while (ch >= 0x20 && ch <= 0x39) {
  48840. str += String.fromCharCode(ch);
  48841. ch = stream.getByte();
  48842. }
  48843. startXRef = parseInt(str, 10);
  48844. if (isNaN(startXRef)) {
  48845. startXRef = 0;
  48846. }
  48847. }
  48848. }
  48849. return shadow(this, 'startXRef', startXRef);
  48850. },
  48851. get mainXRefEntriesOffset() {
  48852. var mainXRefEntriesOffset = 0;
  48853. var linearization = this.linearization;
  48854. if (linearization) {
  48855. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  48856. }
  48857. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  48858. },
  48859. checkHeader: function PDFDocument_checkHeader() {
  48860. var stream = this.stream;
  48861. stream.reset();
  48862. if (find(stream, '%PDF-', 1024)) {
  48863. stream.moveStart();
  48864. var MAX_VERSION_LENGTH = 12;
  48865. var version = '', ch;
  48866. while ((ch = stream.getByte()) > 0x20) {
  48867. if (version.length >= MAX_VERSION_LENGTH) {
  48868. break;
  48869. }
  48870. version += String.fromCharCode(ch);
  48871. }
  48872. if (!this.pdfFormatVersion) {
  48873. this.pdfFormatVersion = version.substring(5);
  48874. }
  48875. return;
  48876. }
  48877. },
  48878. parseStartXRef: function PDFDocument_parseStartXRef() {
  48879. var startXRef = this.startXRef;
  48880. this.xref.setStartXRef(startXRef);
  48881. },
  48882. setup: function PDFDocument_setup(recoveryMode) {
  48883. this.xref.parse(recoveryMode);
  48884. var self = this;
  48885. var pageFactory = {
  48886. createPage: function (pageIndex, dict, ref, fontCache) {
  48887. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  48888. }
  48889. };
  48890. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  48891. },
  48892. get numPages() {
  48893. var linearization = this.linearization;
  48894. var num = linearization ? linearization.numPages : this.catalog.numPages;
  48895. return shadow(this, 'numPages', num);
  48896. },
  48897. get documentInfo() {
  48898. var docInfo = {
  48899. PDFFormatVersion: this.pdfFormatVersion,
  48900. IsAcroFormPresent: !!this.acroForm,
  48901. IsXFAPresent: !!this.xfa
  48902. };
  48903. var infoDict;
  48904. try {
  48905. infoDict = this.xref.trailer.get('Info');
  48906. } catch (err) {
  48907. info('The document information dictionary is invalid.');
  48908. }
  48909. if (infoDict) {
  48910. var validEntries = DocumentInfoValidators.entries;
  48911. for (var key in validEntries) {
  48912. if (infoDict.has(key)) {
  48913. var value = infoDict.get(key);
  48914. if (validEntries[key](value)) {
  48915. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  48916. } else {
  48917. info('Bad value in document info for "' + key + '"');
  48918. }
  48919. }
  48920. }
  48921. }
  48922. return shadow(this, 'documentInfo', docInfo);
  48923. },
  48924. get fingerprint() {
  48925. var xref = this.xref, hash, fileID = '';
  48926. var idArray = xref.trailer.get('ID');
  48927. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  48928. hash = stringToBytes(idArray[0]);
  48929. } else {
  48930. if (this.stream.ensureRange) {
  48931. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  48932. }
  48933. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  48934. }
  48935. for (var i = 0, n = hash.length; i < n; i++) {
  48936. var hex = hash[i].toString(16);
  48937. fileID += hex.length === 1 ? '0' + hex : hex;
  48938. }
  48939. return shadow(this, 'fingerprint', fileID);
  48940. },
  48941. getPage: function PDFDocument_getPage(pageIndex) {
  48942. return this.catalog.getPage(pageIndex);
  48943. },
  48944. cleanup: function PDFDocument_cleanup() {
  48945. return this.catalog.cleanup();
  48946. }
  48947. };
  48948. return PDFDocument;
  48949. }();
  48950. exports.Page = Page;
  48951. exports.PDFDocument = PDFDocument;
  48952. }));
  48953. (function (root, factory) {
  48954. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  48955. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  48956. var warn = sharedUtil.warn;
  48957. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  48958. var shadow = sharedUtil.shadow;
  48959. var NotImplementedException = sharedUtil.NotImplementedException;
  48960. var MissingDataException = sharedUtil.MissingDataException;
  48961. var createPromiseCapability = sharedUtil.createPromiseCapability;
  48962. var Util = sharedUtil.Util;
  48963. var Stream = coreStream.Stream;
  48964. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  48965. var PDFDocument = coreDocument.PDFDocument;
  48966. var BasePdfManager = function BasePdfManagerClosure() {
  48967. function BasePdfManager() {
  48968. throw new Error('Cannot initialize BaseManagerManager');
  48969. }
  48970. BasePdfManager.prototype = {
  48971. get docId() {
  48972. return this._docId;
  48973. },
  48974. get docBaseUrl() {
  48975. var docBaseUrl = null;
  48976. if (this._docBaseUrl) {
  48977. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  48978. if (absoluteUrl) {
  48979. docBaseUrl = absoluteUrl.href;
  48980. } else {
  48981. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  48982. }
  48983. }
  48984. return shadow(this, 'docBaseUrl', docBaseUrl);
  48985. },
  48986. onLoadedStream: function BasePdfManager_onLoadedStream() {
  48987. throw new NotImplementedException();
  48988. },
  48989. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  48990. return this.ensure(this.pdfDocument, prop, args);
  48991. },
  48992. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  48993. return this.ensure(this.pdfDocument.xref, prop, args);
  48994. },
  48995. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  48996. return this.ensure(this.pdfDocument.catalog, prop, args);
  48997. },
  48998. getPage: function BasePdfManager_getPage(pageIndex) {
  48999. return this.pdfDocument.getPage(pageIndex);
  49000. },
  49001. cleanup: function BasePdfManager_cleanup() {
  49002. return this.pdfDocument.cleanup();
  49003. },
  49004. ensure: function BasePdfManager_ensure(obj, prop, args) {
  49005. return new NotImplementedException();
  49006. },
  49007. requestRange: function BasePdfManager_requestRange(begin, end) {
  49008. return new NotImplementedException();
  49009. },
  49010. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  49011. return new NotImplementedException();
  49012. },
  49013. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  49014. return new NotImplementedException();
  49015. },
  49016. updatePassword: function BasePdfManager_updatePassword(password) {
  49017. this.pdfDocument.xref.password = this.password = password;
  49018. if (this._passwordChangedCapability) {
  49019. this._passwordChangedCapability.resolve();
  49020. }
  49021. },
  49022. passwordChanged: function BasePdfManager_passwordChanged() {
  49023. this._passwordChangedCapability = createPromiseCapability();
  49024. return this._passwordChangedCapability.promise;
  49025. },
  49026. terminate: function BasePdfManager_terminate() {
  49027. return new NotImplementedException();
  49028. }
  49029. };
  49030. return BasePdfManager;
  49031. }();
  49032. var LocalPdfManager = function LocalPdfManagerClosure() {
  49033. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  49034. this._docId = docId;
  49035. this._docBaseUrl = docBaseUrl;
  49036. this.evaluatorOptions = evaluatorOptions;
  49037. var stream = new Stream(data);
  49038. this.pdfDocument = new PDFDocument(this, stream, password);
  49039. this._loadedStreamCapability = createPromiseCapability();
  49040. this._loadedStreamCapability.resolve(stream);
  49041. }
  49042. Util.inherit(LocalPdfManager, BasePdfManager, {
  49043. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  49044. return new Promise(function (resolve, reject) {
  49045. try {
  49046. var value = obj[prop];
  49047. var result;
  49048. if (typeof value === 'function') {
  49049. result = value.apply(obj, args);
  49050. } else {
  49051. result = value;
  49052. }
  49053. resolve(result);
  49054. } catch (e) {
  49055. reject(e);
  49056. }
  49057. });
  49058. },
  49059. requestRange: function LocalPdfManager_requestRange(begin, end) {
  49060. return Promise.resolve();
  49061. },
  49062. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  49063. return;
  49064. },
  49065. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  49066. return this._loadedStreamCapability.promise;
  49067. },
  49068. terminate: function LocalPdfManager_terminate() {
  49069. return;
  49070. }
  49071. });
  49072. return LocalPdfManager;
  49073. }();
  49074. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  49075. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  49076. this._docId = docId;
  49077. this._docBaseUrl = docBaseUrl;
  49078. this.msgHandler = args.msgHandler;
  49079. this.evaluatorOptions = evaluatorOptions;
  49080. var params = {
  49081. msgHandler: args.msgHandler,
  49082. url: args.url,
  49083. length: args.length,
  49084. disableAutoFetch: args.disableAutoFetch,
  49085. rangeChunkSize: args.rangeChunkSize
  49086. };
  49087. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  49088. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  49089. }
  49090. Util.inherit(NetworkPdfManager, BasePdfManager, {
  49091. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  49092. var pdfManager = this;
  49093. return new Promise(function (resolve, reject) {
  49094. function ensureHelper() {
  49095. try {
  49096. var result;
  49097. var value = obj[prop];
  49098. if (typeof value === 'function') {
  49099. result = value.apply(obj, args);
  49100. } else {
  49101. result = value;
  49102. }
  49103. resolve(result);
  49104. } catch (e) {
  49105. if (!(e instanceof MissingDataException)) {
  49106. reject(e);
  49107. return;
  49108. }
  49109. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  49110. }
  49111. }
  49112. ensureHelper();
  49113. });
  49114. },
  49115. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  49116. return this.streamManager.requestRange(begin, end);
  49117. },
  49118. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  49119. this.streamManager.requestAllChunks();
  49120. },
  49121. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  49122. this.streamManager.onReceiveData({ chunk: chunk });
  49123. },
  49124. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  49125. return this.streamManager.onLoadedStream();
  49126. },
  49127. terminate: function NetworkPdfManager_terminate() {
  49128. this.streamManager.abort();
  49129. }
  49130. });
  49131. return NetworkPdfManager;
  49132. }();
  49133. exports.LocalPdfManager = LocalPdfManager;
  49134. exports.NetworkPdfManager = NetworkPdfManager;
  49135. }));
  49136. (function (root, factory) {
  49137. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  49138. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  49139. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  49140. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49141. var MessageHandler = sharedUtil.MessageHandler;
  49142. var MissingPDFException = sharedUtil.MissingPDFException;
  49143. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  49144. var PasswordException = sharedUtil.PasswordException;
  49145. var PasswordResponses = sharedUtil.PasswordResponses;
  49146. var UnknownErrorException = sharedUtil.UnknownErrorException;
  49147. var XRefParseException = sharedUtil.XRefParseException;
  49148. var arrayByteLength = sharedUtil.arrayByteLength;
  49149. var arraysToBytes = sharedUtil.arraysToBytes;
  49150. var assert = sharedUtil.assert;
  49151. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49152. var error = sharedUtil.error;
  49153. var info = sharedUtil.info;
  49154. var warn = sharedUtil.warn;
  49155. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  49156. var Ref = corePrimitives.Ref;
  49157. var LocalPdfManager = corePdfManager.LocalPdfManager;
  49158. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  49159. var globalScope = sharedUtil.globalScope;
  49160. var WorkerTask = function WorkerTaskClosure() {
  49161. function WorkerTask(name) {
  49162. this.name = name;
  49163. this.terminated = false;
  49164. this._capability = createPromiseCapability();
  49165. }
  49166. WorkerTask.prototype = {
  49167. get finished() {
  49168. return this._capability.promise;
  49169. },
  49170. finish: function () {
  49171. this._capability.resolve();
  49172. },
  49173. terminate: function () {
  49174. this.terminated = true;
  49175. },
  49176. ensureNotTerminated: function () {
  49177. if (this.terminated) {
  49178. throw new Error('Worker task was terminated');
  49179. }
  49180. }
  49181. };
  49182. return WorkerTask;
  49183. }();
  49184. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  49185. function PDFWorkerStream(params, msgHandler) {
  49186. this._queuedChunks = [];
  49187. var initialData = params.initialData;
  49188. if (initialData && initialData.length > 0) {
  49189. this._queuedChunks.push(initialData);
  49190. }
  49191. this._msgHandler = msgHandler;
  49192. this._isRangeSupported = !params.disableRange;
  49193. this._isStreamingSupported = !params.disableStream;
  49194. this._contentLength = params.length;
  49195. this._fullRequestReader = null;
  49196. this._rangeReaders = [];
  49197. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  49198. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  49199. }
  49200. PDFWorkerStream.prototype = {
  49201. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  49202. if (args.begin === undefined) {
  49203. if (this._fullRequestReader) {
  49204. this._fullRequestReader._enqueue(args.chunk);
  49205. } else {
  49206. this._queuedChunks.push(args.chunk);
  49207. }
  49208. } else {
  49209. var found = this._rangeReaders.some(function (rangeReader) {
  49210. if (rangeReader._begin !== args.begin) {
  49211. return false;
  49212. }
  49213. rangeReader._enqueue(args.chunk);
  49214. return true;
  49215. });
  49216. assert(found);
  49217. }
  49218. },
  49219. _onProgress: function PDFWorkerStream_onProgress(evt) {
  49220. if (this._rangeReaders.length > 0) {
  49221. var firstReader = this._rangeReaders[0];
  49222. if (firstReader.onProgress) {
  49223. firstReader.onProgress({ loaded: evt.loaded });
  49224. }
  49225. }
  49226. },
  49227. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  49228. var i = this._rangeReaders.indexOf(reader);
  49229. if (i >= 0) {
  49230. this._rangeReaders.splice(i, 1);
  49231. }
  49232. },
  49233. getFullReader: function PDFWorkerStream_getFullReader() {
  49234. assert(!this._fullRequestReader);
  49235. var queuedChunks = this._queuedChunks;
  49236. this._queuedChunks = null;
  49237. return new PDFWorkerStreamReader(this, queuedChunks);
  49238. },
  49239. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  49240. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  49241. this._msgHandler.send('RequestDataRange', {
  49242. begin: begin,
  49243. end: end
  49244. });
  49245. this._rangeReaders.push(reader);
  49246. return reader;
  49247. },
  49248. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  49249. if (this._fullRequestReader) {
  49250. this._fullRequestReader.cancel(reason);
  49251. }
  49252. var readers = this._rangeReaders.slice(0);
  49253. readers.forEach(function (rangeReader) {
  49254. rangeReader.cancel(reason);
  49255. });
  49256. }
  49257. };
  49258. function PDFWorkerStreamReader(stream, queuedChunks) {
  49259. this._stream = stream;
  49260. this._done = false;
  49261. this._queuedChunks = queuedChunks || [];
  49262. this._requests = [];
  49263. this._headersReady = Promise.resolve();
  49264. stream._fullRequestReader = this;
  49265. this.onProgress = null;
  49266. }
  49267. PDFWorkerStreamReader.prototype = {
  49268. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  49269. if (this._done) {
  49270. return;
  49271. }
  49272. if (this._requests.length > 0) {
  49273. var requestCapability = this._requests.shift();
  49274. requestCapability.resolve({
  49275. value: chunk,
  49276. done: false
  49277. });
  49278. return;
  49279. }
  49280. this._queuedChunks.push(chunk);
  49281. },
  49282. get headersReady() {
  49283. return this._headersReady;
  49284. },
  49285. get isRangeSupported() {
  49286. return this._stream._isRangeSupported;
  49287. },
  49288. get isStreamingSupported() {
  49289. return this._stream._isStreamingSupported;
  49290. },
  49291. get contentLength() {
  49292. return this._stream._contentLength;
  49293. },
  49294. read: function PDFWorkerStreamReader_read() {
  49295. if (this._queuedChunks.length > 0) {
  49296. var chunk = this._queuedChunks.shift();
  49297. return Promise.resolve({
  49298. value: chunk,
  49299. done: false
  49300. });
  49301. }
  49302. if (this._done) {
  49303. return Promise.resolve({
  49304. value: undefined,
  49305. done: true
  49306. });
  49307. }
  49308. var requestCapability = createPromiseCapability();
  49309. this._requests.push(requestCapability);
  49310. return requestCapability.promise;
  49311. },
  49312. cancel: function PDFWorkerStreamReader_cancel(reason) {
  49313. this._done = true;
  49314. this._requests.forEach(function (requestCapability) {
  49315. requestCapability.resolve({
  49316. value: undefined,
  49317. done: true
  49318. });
  49319. });
  49320. this._requests = [];
  49321. }
  49322. };
  49323. function PDFWorkerStreamRangeReader(stream, begin, end) {
  49324. this._stream = stream;
  49325. this._begin = begin;
  49326. this._end = end;
  49327. this._queuedChunk = null;
  49328. this._requests = [];
  49329. this._done = false;
  49330. this.onProgress = null;
  49331. }
  49332. PDFWorkerStreamRangeReader.prototype = {
  49333. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  49334. if (this._done) {
  49335. return;
  49336. }
  49337. if (this._requests.length === 0) {
  49338. this._queuedChunk = chunk;
  49339. } else {
  49340. var requestsCapability = this._requests.shift();
  49341. requestsCapability.resolve({
  49342. value: chunk,
  49343. done: false
  49344. });
  49345. this._requests.forEach(function (requestCapability) {
  49346. requestCapability.resolve({
  49347. value: undefined,
  49348. done: true
  49349. });
  49350. });
  49351. this._requests = [];
  49352. }
  49353. this._done = true;
  49354. this._stream._removeRangeReader(this);
  49355. },
  49356. get isStreamingSupported() {
  49357. return false;
  49358. },
  49359. read: function PDFWorkerStreamRangeReader_read() {
  49360. if (this._queuedChunk) {
  49361. return Promise.resolve({
  49362. value: this._queuedChunk,
  49363. done: false
  49364. });
  49365. }
  49366. if (this._done) {
  49367. return Promise.resolve({
  49368. value: undefined,
  49369. done: true
  49370. });
  49371. }
  49372. var requestCapability = createPromiseCapability();
  49373. this._requests.push(requestCapability);
  49374. return requestCapability.promise;
  49375. },
  49376. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  49377. this._done = true;
  49378. this._requests.forEach(function (requestCapability) {
  49379. requestCapability.resolve({
  49380. value: undefined,
  49381. done: true
  49382. });
  49383. });
  49384. this._requests = [];
  49385. this._stream._removeRangeReader(this);
  49386. }
  49387. };
  49388. return PDFWorkerStream;
  49389. }();
  49390. var PDFNetworkStream;
  49391. function setPDFNetworkStreamClass(cls) {
  49392. PDFNetworkStream = cls;
  49393. }
  49394. var WorkerMessageHandler = {
  49395. setup: function wphSetup(handler, port) {
  49396. var testMessageProcessed = false;
  49397. handler.on('test', function wphSetupTest(data) {
  49398. if (testMessageProcessed) {
  49399. return;
  49400. }
  49401. testMessageProcessed = true;
  49402. if (!(data instanceof Uint8Array)) {
  49403. handler.send('test', 'main', false);
  49404. return;
  49405. }
  49406. var supportTransfers = data[0] === 255;
  49407. handler.postMessageTransfers = supportTransfers;
  49408. var xhr = new XMLHttpRequest();
  49409. var responseExists = 'response' in xhr;
  49410. try {
  49411. var dummy = xhr.responseType;
  49412. } catch (e) {
  49413. responseExists = false;
  49414. }
  49415. if (!responseExists) {
  49416. handler.send('test', false);
  49417. return;
  49418. }
  49419. handler.send('test', {
  49420. supportTypedArray: true,
  49421. supportTransfers: supportTransfers
  49422. });
  49423. });
  49424. handler.on('configure', function wphConfigure(data) {
  49425. setVerbosityLevel(data.verbosity);
  49426. });
  49427. handler.on('GetDocRequest', function wphSetupDoc(data) {
  49428. return WorkerMessageHandler.createDocumentHandler(data, port);
  49429. });
  49430. },
  49431. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  49432. var pdfManager;
  49433. var terminated = false;
  49434. var cancelXHRs = null;
  49435. var WorkerTasks = [];
  49436. var docId = docParams.docId;
  49437. var docBaseUrl = docParams.docBaseUrl;
  49438. var workerHandlerName = docParams.docId + '_worker';
  49439. var handler = new MessageHandler(workerHandlerName, docId, port);
  49440. handler.postMessageTransfers = docParams.postMessageTransfers;
  49441. function ensureNotTerminated() {
  49442. if (terminated) {
  49443. throw new Error('Worker was terminated');
  49444. }
  49445. }
  49446. function startWorkerTask(task) {
  49447. WorkerTasks.push(task);
  49448. }
  49449. function finishWorkerTask(task) {
  49450. task.finish();
  49451. var i = WorkerTasks.indexOf(task);
  49452. WorkerTasks.splice(i, 1);
  49453. }
  49454. function loadDocument(recoveryMode) {
  49455. var loadDocumentCapability = createPromiseCapability();
  49456. var parseSuccess = function parseSuccess() {
  49457. var numPagesPromise = pdfManager.ensureDoc('numPages');
  49458. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  49459. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  49460. Promise.all([
  49461. numPagesPromise,
  49462. fingerprintPromise,
  49463. encryptedPromise
  49464. ]).then(function onDocReady(results) {
  49465. var doc = {
  49466. numPages: results[0],
  49467. fingerprint: results[1],
  49468. encrypted: !!results[2]
  49469. };
  49470. loadDocumentCapability.resolve(doc);
  49471. }, parseFailure);
  49472. };
  49473. var parseFailure = function parseFailure(e) {
  49474. loadDocumentCapability.reject(e);
  49475. };
  49476. pdfManager.ensureDoc('checkHeader', []).then(function () {
  49477. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  49478. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  49479. }, parseFailure);
  49480. }, parseFailure);
  49481. return loadDocumentCapability.promise;
  49482. }
  49483. function getPdfManager(data, evaluatorOptions) {
  49484. var pdfManagerCapability = createPromiseCapability();
  49485. var pdfManager;
  49486. var source = data.source;
  49487. if (source.data) {
  49488. try {
  49489. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  49490. pdfManagerCapability.resolve(pdfManager);
  49491. } catch (ex) {
  49492. pdfManagerCapability.reject(ex);
  49493. }
  49494. return pdfManagerCapability.promise;
  49495. }
  49496. var pdfStream;
  49497. try {
  49498. if (source.chunkedViewerLoading) {
  49499. pdfStream = new PDFWorkerStream(source, handler);
  49500. } else {
  49501. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  49502. pdfStream = new PDFNetworkStream(data);
  49503. }
  49504. } catch (ex) {
  49505. pdfManagerCapability.reject(ex);
  49506. return pdfManagerCapability.promise;
  49507. }
  49508. var fullRequest = pdfStream.getFullReader();
  49509. fullRequest.headersReady.then(function () {
  49510. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  49511. fullRequest.onProgress = function (evt) {
  49512. handler.send('DocProgress', {
  49513. loaded: evt.loaded,
  49514. total: evt.total
  49515. });
  49516. };
  49517. }
  49518. if (!fullRequest.isRangeSupported) {
  49519. return;
  49520. }
  49521. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  49522. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  49523. msgHandler: handler,
  49524. url: source.url,
  49525. password: source.password,
  49526. length: fullRequest.contentLength,
  49527. disableAutoFetch: disableAutoFetch,
  49528. rangeChunkSize: source.rangeChunkSize
  49529. }, evaluatorOptions, docBaseUrl);
  49530. pdfManagerCapability.resolve(pdfManager);
  49531. cancelXHRs = null;
  49532. }).catch(function (reason) {
  49533. pdfManagerCapability.reject(reason);
  49534. cancelXHRs = null;
  49535. });
  49536. var cachedChunks = [], loaded = 0;
  49537. var flushChunks = function () {
  49538. var pdfFile = arraysToBytes(cachedChunks);
  49539. if (source.length && pdfFile.length !== source.length) {
  49540. warn('reported HTTP length is different from actual');
  49541. }
  49542. try {
  49543. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  49544. pdfManagerCapability.resolve(pdfManager);
  49545. } catch (ex) {
  49546. pdfManagerCapability.reject(ex);
  49547. }
  49548. cachedChunks = [];
  49549. };
  49550. var readPromise = new Promise(function (resolve, reject) {
  49551. var readChunk = function (chunk) {
  49552. try {
  49553. ensureNotTerminated();
  49554. if (chunk.done) {
  49555. if (!pdfManager) {
  49556. flushChunks();
  49557. }
  49558. cancelXHRs = null;
  49559. return;
  49560. }
  49561. var data = chunk.value;
  49562. loaded += arrayByteLength(data);
  49563. if (!fullRequest.isStreamingSupported) {
  49564. handler.send('DocProgress', {
  49565. loaded: loaded,
  49566. total: Math.max(loaded, fullRequest.contentLength || 0)
  49567. });
  49568. }
  49569. if (pdfManager) {
  49570. pdfManager.sendProgressiveData(data);
  49571. } else {
  49572. cachedChunks.push(data);
  49573. }
  49574. fullRequest.read().then(readChunk, reject);
  49575. } catch (e) {
  49576. reject(e);
  49577. }
  49578. };
  49579. fullRequest.read().then(readChunk, reject);
  49580. });
  49581. readPromise.catch(function (e) {
  49582. pdfManagerCapability.reject(e);
  49583. cancelXHRs = null;
  49584. });
  49585. cancelXHRs = function () {
  49586. pdfStream.cancelAllRequests('abort');
  49587. };
  49588. return pdfManagerCapability.promise;
  49589. }
  49590. var setupDoc = function (data) {
  49591. var onSuccess = function (doc) {
  49592. ensureNotTerminated();
  49593. handler.send('GetDoc', { pdfInfo: doc });
  49594. };
  49595. var onFailure = function (e) {
  49596. if (e instanceof PasswordException) {
  49597. if (e.code === PasswordResponses.NEED_PASSWORD) {
  49598. handler.send('NeedPassword', e);
  49599. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  49600. handler.send('IncorrectPassword', e);
  49601. }
  49602. } else if (e instanceof InvalidPDFException) {
  49603. handler.send('InvalidPDF', e);
  49604. } else if (e instanceof MissingPDFException) {
  49605. handler.send('MissingPDF', e);
  49606. } else if (e instanceof UnexpectedResponseException) {
  49607. handler.send('UnexpectedResponse', e);
  49608. } else {
  49609. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  49610. }
  49611. };
  49612. ensureNotTerminated();
  49613. var cMapOptions = {
  49614. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  49615. packed: data.cMapPacked === true
  49616. };
  49617. var evaluatorOptions = {
  49618. forceDataSchema: data.disableCreateObjectURL,
  49619. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  49620. disableFontFace: data.disableFontFace,
  49621. cMapOptions: cMapOptions
  49622. };
  49623. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  49624. if (terminated) {
  49625. newPdfManager.terminate();
  49626. throw new Error('Worker was terminated');
  49627. }
  49628. pdfManager = newPdfManager;
  49629. handler.send('PDFManagerReady', null);
  49630. pdfManager.onLoadedStream().then(function (stream) {
  49631. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  49632. });
  49633. }).then(function pdfManagerReady() {
  49634. ensureNotTerminated();
  49635. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  49636. ensureNotTerminated();
  49637. if (!(ex instanceof XRefParseException)) {
  49638. if (ex instanceof PasswordException) {
  49639. pdfManager.passwordChanged().then(pdfManagerReady);
  49640. }
  49641. onFailure(ex);
  49642. return;
  49643. }
  49644. pdfManager.requestLoadedStream();
  49645. pdfManager.onLoadedStream().then(function () {
  49646. ensureNotTerminated();
  49647. loadDocument(true).then(onSuccess, onFailure);
  49648. });
  49649. }, onFailure);
  49650. }, onFailure);
  49651. };
  49652. handler.on('GetPage', function wphSetupGetPage(data) {
  49653. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49654. var rotatePromise = pdfManager.ensure(page, 'rotate');
  49655. var refPromise = pdfManager.ensure(page, 'ref');
  49656. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  49657. var viewPromise = pdfManager.ensure(page, 'view');
  49658. return Promise.all([
  49659. rotatePromise,
  49660. refPromise,
  49661. userUnitPromise,
  49662. viewPromise
  49663. ]).then(function (results) {
  49664. return {
  49665. rotate: results[0],
  49666. ref: results[1],
  49667. userUnit: results[2],
  49668. view: results[3]
  49669. };
  49670. });
  49671. });
  49672. });
  49673. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  49674. var ref = new Ref(data.ref.num, data.ref.gen);
  49675. var catalog = pdfManager.pdfDocument.catalog;
  49676. return catalog.getPageIndex(ref);
  49677. });
  49678. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  49679. return pdfManager.ensureCatalog('destinations');
  49680. });
  49681. handler.on('GetDestination', function wphSetupGetDestination(data) {
  49682. return pdfManager.ensureCatalog('getDestination', [data.id]);
  49683. });
  49684. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  49685. return pdfManager.ensureCatalog('pageLabels');
  49686. });
  49687. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  49688. return pdfManager.ensureCatalog('attachments');
  49689. });
  49690. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  49691. return pdfManager.ensureCatalog('javaScript');
  49692. });
  49693. handler.on('GetOutline', function wphSetupGetOutline(data) {
  49694. return pdfManager.ensureCatalog('documentOutline');
  49695. });
  49696. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  49697. return Promise.all([
  49698. pdfManager.ensureDoc('documentInfo'),
  49699. pdfManager.ensureCatalog('metadata')
  49700. ]);
  49701. });
  49702. handler.on('GetData', function wphSetupGetData(data) {
  49703. pdfManager.requestLoadedStream();
  49704. return pdfManager.onLoadedStream().then(function (stream) {
  49705. return stream.bytes;
  49706. });
  49707. });
  49708. handler.on('GetStats', function wphSetupGetStats(data) {
  49709. return pdfManager.pdfDocument.xref.stats;
  49710. });
  49711. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  49712. pdfManager.updatePassword(data);
  49713. });
  49714. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  49715. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49716. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  49717. });
  49718. });
  49719. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  49720. var pageIndex = data.pageIndex;
  49721. pdfManager.getPage(pageIndex).then(function (page) {
  49722. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  49723. startWorkerTask(task);
  49724. var pageNum = pageIndex + 1;
  49725. var start = Date.now();
  49726. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  49727. finishWorkerTask(task);
  49728. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  49729. }, function (e) {
  49730. finishWorkerTask(task);
  49731. if (task.terminated) {
  49732. return;
  49733. }
  49734. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  49735. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  49736. var wrappedException;
  49737. if (typeof e === 'string') {
  49738. wrappedException = {
  49739. message: e,
  49740. stack: minimumStackMessage
  49741. };
  49742. } else if (typeof e === 'object') {
  49743. wrappedException = {
  49744. message: e.message || e.toString(),
  49745. stack: e.stack || minimumStackMessage
  49746. };
  49747. } else {
  49748. wrappedException = {
  49749. message: 'Unknown exception type: ' + typeof e,
  49750. stack: minimumStackMessage
  49751. };
  49752. }
  49753. handler.send('PageError', {
  49754. pageNum: pageNum,
  49755. error: wrappedException,
  49756. intent: data.intent
  49757. });
  49758. });
  49759. });
  49760. }, this);
  49761. handler.on('GetTextContent', function wphExtractText(data) {
  49762. var pageIndex = data.pageIndex;
  49763. var normalizeWhitespace = data.normalizeWhitespace;
  49764. var combineTextItems = data.combineTextItems;
  49765. return pdfManager.getPage(pageIndex).then(function (page) {
  49766. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  49767. startWorkerTask(task);
  49768. var pageNum = pageIndex + 1;
  49769. var start = Date.now();
  49770. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  49771. finishWorkerTask(task);
  49772. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  49773. return textContent;
  49774. }, function (reason) {
  49775. finishWorkerTask(task);
  49776. if (task.terminated) {
  49777. return;
  49778. }
  49779. throw reason;
  49780. });
  49781. });
  49782. });
  49783. handler.on('Cleanup', function wphCleanup(data) {
  49784. return pdfManager.cleanup();
  49785. });
  49786. handler.on('Terminate', function wphTerminate(data) {
  49787. terminated = true;
  49788. if (pdfManager) {
  49789. pdfManager.terminate();
  49790. pdfManager = null;
  49791. }
  49792. if (cancelXHRs) {
  49793. cancelXHRs();
  49794. }
  49795. var waitOn = [];
  49796. WorkerTasks.forEach(function (task) {
  49797. waitOn.push(task.finished);
  49798. task.terminate();
  49799. });
  49800. return Promise.all(waitOn).then(function () {
  49801. handler.destroy();
  49802. handler = null;
  49803. });
  49804. });
  49805. handler.on('Ready', function wphReady(data) {
  49806. setupDoc(docParams);
  49807. docParams = null;
  49808. });
  49809. return workerHandlerName;
  49810. }
  49811. };
  49812. function initializeWorker() {
  49813. if (!('console' in globalScope)) {
  49814. var consoleTimer = {};
  49815. var workerConsole = {
  49816. log: function log() {
  49817. var args = Array.prototype.slice.call(arguments);
  49818. globalScope.postMessage({
  49819. targetName: 'main',
  49820. action: 'console_log',
  49821. data: args
  49822. });
  49823. },
  49824. error: function error() {
  49825. var args = Array.prototype.slice.call(arguments);
  49826. globalScope.postMessage({
  49827. targetName: 'main',
  49828. action: 'console_error',
  49829. data: args
  49830. });
  49831. throw 'pdf.js execution error';
  49832. },
  49833. time: function time(name) {
  49834. consoleTimer[name] = Date.now();
  49835. },
  49836. timeEnd: function timeEnd(name) {
  49837. var time = consoleTimer[name];
  49838. if (!time) {
  49839. error('Unknown timer name ' + name);
  49840. }
  49841. this.log('Timer:', name, Date.now() - time);
  49842. }
  49843. };
  49844. globalScope.console = workerConsole;
  49845. }
  49846. var handler = new MessageHandler('worker', 'main', self);
  49847. WorkerMessageHandler.setup(handler, self);
  49848. handler.send('ready', null);
  49849. }
  49850. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  49851. initializeWorker();
  49852. }
  49853. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  49854. exports.WorkerTask = WorkerTask;
  49855. exports.WorkerMessageHandler = WorkerMessageHandler;
  49856. }));
  49857. (function (root, factory) {
  49858. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  49859. }(this, function (exports, sharedUtil, coreWorker) {
  49860. var OK_RESPONSE = 200;
  49861. var PARTIAL_CONTENT_RESPONSE = 206;
  49862. function NetworkManager(url, args) {
  49863. this.url = url;
  49864. args = args || {};
  49865. this.isHttp = /^https?:/i.test(url);
  49866. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  49867. this.withCredentials = args.withCredentials || false;
  49868. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  49869. return new XMLHttpRequest();
  49870. };
  49871. this.currXhrId = 0;
  49872. this.pendingRequests = Object.create(null);
  49873. this.loadedRequests = Object.create(null);
  49874. }
  49875. function getArrayBuffer(xhr) {
  49876. var data = xhr.response;
  49877. if (typeof data !== 'string') {
  49878. return data;
  49879. }
  49880. var length = data.length;
  49881. var array = new Uint8Array(length);
  49882. for (var i = 0; i < length; i++) {
  49883. array[i] = data.charCodeAt(i) & 0xFF;
  49884. }
  49885. return array.buffer;
  49886. }
  49887. var supportsMozChunked = function supportsMozChunkedClosure() {
  49888. try {
  49889. var x = new XMLHttpRequest();
  49890. x.open('GET', 'https://example.com');
  49891. x.responseType = 'moz-chunked-arraybuffer';
  49892. return x.responseType === 'moz-chunked-arraybuffer';
  49893. } catch (e) {
  49894. return false;
  49895. }
  49896. }();
  49897. NetworkManager.prototype = {
  49898. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  49899. var args = {
  49900. begin: begin,
  49901. end: end
  49902. };
  49903. for (var prop in listeners) {
  49904. args[prop] = listeners[prop];
  49905. }
  49906. return this.request(args);
  49907. },
  49908. requestFull: function NetworkManager_requestFull(listeners) {
  49909. return this.request(listeners);
  49910. },
  49911. request: function NetworkManager_request(args) {
  49912. var xhr = this.getXhr();
  49913. var xhrId = this.currXhrId++;
  49914. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  49915. xhr.open('GET', this.url);
  49916. xhr.withCredentials = this.withCredentials;
  49917. for (var property in this.httpHeaders) {
  49918. var value = this.httpHeaders[property];
  49919. if (typeof value === 'undefined') {
  49920. continue;
  49921. }
  49922. xhr.setRequestHeader(property, value);
  49923. }
  49924. if (this.isHttp && 'begin' in args && 'end' in args) {
  49925. var rangeStr = args.begin + '-' + (args.end - 1);
  49926. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  49927. pendingRequest.expectedStatus = 206;
  49928. } else {
  49929. pendingRequest.expectedStatus = 200;
  49930. }
  49931. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  49932. if (useMozChunkedLoading) {
  49933. xhr.responseType = 'moz-chunked-arraybuffer';
  49934. pendingRequest.onProgressiveData = args.onProgressiveData;
  49935. pendingRequest.mozChunked = true;
  49936. } else {
  49937. xhr.responseType = 'arraybuffer';
  49938. }
  49939. if (args.onError) {
  49940. xhr.onerror = function (evt) {
  49941. args.onError(xhr.status);
  49942. };
  49943. }
  49944. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  49945. xhr.onprogress = this.onProgress.bind(this, xhrId);
  49946. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  49947. pendingRequest.onDone = args.onDone;
  49948. pendingRequest.onError = args.onError;
  49949. pendingRequest.onProgress = args.onProgress;
  49950. xhr.send(null);
  49951. return xhrId;
  49952. },
  49953. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  49954. var pendingRequest = this.pendingRequests[xhrId];
  49955. if (!pendingRequest) {
  49956. return;
  49957. }
  49958. if (pendingRequest.mozChunked) {
  49959. var chunk = getArrayBuffer(pendingRequest.xhr);
  49960. pendingRequest.onProgressiveData(chunk);
  49961. }
  49962. var onProgress = pendingRequest.onProgress;
  49963. if (onProgress) {
  49964. onProgress(evt);
  49965. }
  49966. },
  49967. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  49968. var pendingRequest = this.pendingRequests[xhrId];
  49969. if (!pendingRequest) {
  49970. return;
  49971. }
  49972. var xhr = pendingRequest.xhr;
  49973. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  49974. pendingRequest.onHeadersReceived();
  49975. delete pendingRequest.onHeadersReceived;
  49976. }
  49977. if (xhr.readyState !== 4) {
  49978. return;
  49979. }
  49980. if (!(xhrId in this.pendingRequests)) {
  49981. return;
  49982. }
  49983. delete this.pendingRequests[xhrId];
  49984. if (xhr.status === 0 && this.isHttp) {
  49985. if (pendingRequest.onError) {
  49986. pendingRequest.onError(xhr.status);
  49987. }
  49988. return;
  49989. }
  49990. var xhrStatus = xhr.status || OK_RESPONSE;
  49991. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  49992. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  49993. if (pendingRequest.onError) {
  49994. pendingRequest.onError(xhr.status);
  49995. }
  49996. return;
  49997. }
  49998. this.loadedRequests[xhrId] = true;
  49999. var chunk = getArrayBuffer(xhr);
  50000. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  50001. var rangeHeader = xhr.getResponseHeader('Content-Range');
  50002. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  50003. var begin = parseInt(matches[1], 10);
  50004. pendingRequest.onDone({
  50005. begin: begin,
  50006. chunk: chunk
  50007. });
  50008. } else if (pendingRequest.onProgressiveData) {
  50009. pendingRequest.onDone(null);
  50010. } else if (chunk) {
  50011. pendingRequest.onDone({
  50012. begin: 0,
  50013. chunk: chunk
  50014. });
  50015. } else if (pendingRequest.onError) {
  50016. pendingRequest.onError(xhr.status);
  50017. }
  50018. },
  50019. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  50020. for (var xhrId in this.pendingRequests) {
  50021. return true;
  50022. }
  50023. return false;
  50024. },
  50025. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  50026. return this.pendingRequests[xhrId].xhr;
  50027. },
  50028. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  50029. return !!this.pendingRequests[xhrId].onProgressiveData;
  50030. },
  50031. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  50032. return xhrId in this.pendingRequests;
  50033. },
  50034. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  50035. return xhrId in this.loadedRequests;
  50036. },
  50037. abortAllRequests: function NetworkManager_abortAllRequests() {
  50038. for (var xhrId in this.pendingRequests) {
  50039. this.abortRequest(xhrId | 0);
  50040. }
  50041. },
  50042. abortRequest: function NetworkManager_abortRequest(xhrId) {
  50043. var xhr = this.pendingRequests[xhrId].xhr;
  50044. delete this.pendingRequests[xhrId];
  50045. xhr.abort();
  50046. }
  50047. };
  50048. var assert = sharedUtil.assert;
  50049. var createPromiseCapability = sharedUtil.createPromiseCapability;
  50050. var isInt = sharedUtil.isInt;
  50051. var MissingPDFException = sharedUtil.MissingPDFException;
  50052. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  50053. function PDFNetworkStream(options) {
  50054. this._options = options;
  50055. var source = options.source;
  50056. this._manager = new NetworkManager(source.url, {
  50057. httpHeaders: source.httpHeaders,
  50058. withCredentials: source.withCredentials
  50059. });
  50060. this._rangeChunkSize = source.rangeChunkSize;
  50061. this._fullRequestReader = null;
  50062. this._rangeRequestReaders = [];
  50063. }
  50064. PDFNetworkStream.prototype = {
  50065. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  50066. var i = this._rangeRequestReaders.indexOf(reader);
  50067. if (i >= 0) {
  50068. this._rangeRequestReaders.splice(i, 1);
  50069. }
  50070. },
  50071. getFullReader: function PDFNetworkStream_getFullReader() {
  50072. assert(!this._fullRequestReader);
  50073. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  50074. return this._fullRequestReader;
  50075. },
  50076. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  50077. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  50078. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  50079. this._rangeRequestReaders.push(reader);
  50080. return reader;
  50081. },
  50082. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  50083. if (this._fullRequestReader) {
  50084. this._fullRequestReader.cancel(reason);
  50085. }
  50086. var readers = this._rangeRequestReaders.slice(0);
  50087. readers.forEach(function (reader) {
  50088. reader.cancel(reason);
  50089. });
  50090. }
  50091. };
  50092. function PDFNetworkStreamFullRequestReader(manager, options) {
  50093. this._manager = manager;
  50094. var source = options.source;
  50095. var args = {
  50096. onHeadersReceived: this._onHeadersReceived.bind(this),
  50097. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  50098. onDone: this._onDone.bind(this),
  50099. onError: this._onError.bind(this),
  50100. onProgress: this._onProgress.bind(this)
  50101. };
  50102. this._url = source.url;
  50103. this._fullRequestId = manager.requestFull(args);
  50104. this._headersReceivedCapability = createPromiseCapability();
  50105. this._disableRange = options.disableRange || false;
  50106. this._contentLength = source.length;
  50107. this._rangeChunkSize = source.rangeChunkSize;
  50108. if (!this._rangeChunkSize && !this._disableRange) {
  50109. this._disableRange = true;
  50110. }
  50111. this._isStreamingSupported = false;
  50112. this._isRangeSupported = false;
  50113. this._cachedChunks = [];
  50114. this._requests = [];
  50115. this._done = false;
  50116. this._storedError = undefined;
  50117. this.onProgress = null;
  50118. }
  50119. PDFNetworkStreamFullRequestReader.prototype = {
  50120. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  50121. if (this._disableRange) {
  50122. return false;
  50123. }
  50124. var networkManager = this._manager;
  50125. if (!networkManager.isHttp) {
  50126. return false;
  50127. }
  50128. var fullRequestXhrId = this._fullRequestId;
  50129. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  50130. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  50131. return false;
  50132. }
  50133. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  50134. if (contentEncoding !== 'identity') {
  50135. return false;
  50136. }
  50137. var length = fullRequestXhr.getResponseHeader('Content-Length');
  50138. length = parseInt(length, 10);
  50139. if (!isInt(length)) {
  50140. return false;
  50141. }
  50142. this._contentLength = length;
  50143. if (length <= 2 * this._rangeChunkSize) {
  50144. return false;
  50145. }
  50146. return true;
  50147. },
  50148. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  50149. if (this._validateRangeRequestCapabilities()) {
  50150. this._isRangeSupported = true;
  50151. }
  50152. var networkManager = this._manager;
  50153. var fullRequestXhrId = this._fullRequestId;
  50154. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  50155. this._isStreamingSupported = true;
  50156. } else if (this._isRangeSupported) {
  50157. networkManager.abortRequest(fullRequestXhrId);
  50158. }
  50159. this._headersReceivedCapability.resolve();
  50160. },
  50161. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  50162. if (this._requests.length > 0) {
  50163. var requestCapability = this._requests.shift();
  50164. requestCapability.resolve({
  50165. value: chunk,
  50166. done: false
  50167. });
  50168. } else {
  50169. this._cachedChunks.push(chunk);
  50170. }
  50171. },
  50172. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  50173. if (args) {
  50174. this._onProgressiveData(args.chunk);
  50175. }
  50176. this._done = true;
  50177. if (this._cachedChunks.length > 0) {
  50178. return;
  50179. }
  50180. this._requests.forEach(function (requestCapability) {
  50181. requestCapability.resolve({
  50182. value: undefined,
  50183. done: true
  50184. });
  50185. });
  50186. this._requests = [];
  50187. },
  50188. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  50189. var url = this._url;
  50190. var exception;
  50191. if (status === 404 || status === 0 && /^file:/.test(url)) {
  50192. exception = new MissingPDFException('Missing PDF "' + url + '".');
  50193. } else {
  50194. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  50195. }
  50196. this._storedError = exception;
  50197. this._headersReceivedCapability.reject(exception);
  50198. this._requests.forEach(function (requestCapability) {
  50199. requestCapability.reject(exception);
  50200. });
  50201. this._requests = [];
  50202. this._cachedChunks = [];
  50203. },
  50204. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  50205. if (this.onProgress) {
  50206. this.onProgress({
  50207. loaded: data.loaded,
  50208. total: data.lengthComputable ? data.total : this._contentLength
  50209. });
  50210. }
  50211. },
  50212. get isRangeSupported() {
  50213. return this._isRangeSupported;
  50214. },
  50215. get isStreamingSupported() {
  50216. return this._isStreamingSupported;
  50217. },
  50218. get contentLength() {
  50219. return this._contentLength;
  50220. },
  50221. get headersReady() {
  50222. return this._headersReceivedCapability.promise;
  50223. },
  50224. read: function PDFNetworkStreamFullRequestReader_read() {
  50225. if (this._storedError) {
  50226. return Promise.reject(this._storedError);
  50227. }
  50228. if (this._cachedChunks.length > 0) {
  50229. var chunk = this._cachedChunks.shift();
  50230. return Promise.resolve(chunk);
  50231. }
  50232. if (this._done) {
  50233. return Promise.resolve({
  50234. value: undefined,
  50235. done: true
  50236. });
  50237. }
  50238. var requestCapability = createPromiseCapability();
  50239. this._requests.push(requestCapability);
  50240. return requestCapability.promise;
  50241. },
  50242. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  50243. this._done = true;
  50244. this._headersReceivedCapability.reject(reason);
  50245. this._requests.forEach(function (requestCapability) {
  50246. requestCapability.resolve({
  50247. value: undefined,
  50248. done: true
  50249. });
  50250. });
  50251. this._requests = [];
  50252. if (this._manager.isPendingRequest(this._fullRequestId)) {
  50253. this._manager.abortRequest(this._fullRequestId);
  50254. }
  50255. this._fullRequestReader = null;
  50256. }
  50257. };
  50258. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  50259. this._manager = manager;
  50260. var args = {
  50261. onDone: this._onDone.bind(this),
  50262. onProgress: this._onProgress.bind(this)
  50263. };
  50264. this._requestId = manager.requestRange(begin, end, args);
  50265. this._requests = [];
  50266. this._queuedChunk = null;
  50267. this._done = false;
  50268. this.onProgress = null;
  50269. this.onClosed = null;
  50270. }
  50271. PDFNetworkStreamRangeRequestReader.prototype = {
  50272. _close: function PDFNetworkStreamRangeRequestReader_close() {
  50273. if (this.onClosed) {
  50274. this.onClosed(this);
  50275. }
  50276. },
  50277. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  50278. var chunk = data.chunk;
  50279. if (this._requests.length > 0) {
  50280. var requestCapability = this._requests.shift();
  50281. requestCapability.resolve({
  50282. value: chunk,
  50283. done: false
  50284. });
  50285. } else {
  50286. this._queuedChunk = chunk;
  50287. }
  50288. this._done = true;
  50289. this._requests.forEach(function (requestCapability) {
  50290. requestCapability.resolve({
  50291. value: undefined,
  50292. done: true
  50293. });
  50294. });
  50295. this._requests = [];
  50296. this._close();
  50297. },
  50298. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  50299. if (!this.isStreamingSupported && this.onProgress) {
  50300. this.onProgress({ loaded: evt.loaded });
  50301. }
  50302. },
  50303. get isStreamingSupported() {
  50304. return false;
  50305. },
  50306. read: function PDFNetworkStreamRangeRequestReader_read() {
  50307. if (this._queuedChunk !== null) {
  50308. var chunk = this._queuedChunk;
  50309. this._queuedChunk = null;
  50310. return Promise.resolve({
  50311. value: chunk,
  50312. done: false
  50313. });
  50314. }
  50315. if (this._done) {
  50316. return Promise.resolve({
  50317. value: undefined,
  50318. done: true
  50319. });
  50320. }
  50321. var requestCapability = createPromiseCapability();
  50322. this._requests.push(requestCapability);
  50323. return requestCapability.promise;
  50324. },
  50325. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  50326. this._done = true;
  50327. this._requests.forEach(function (requestCapability) {
  50328. requestCapability.resolve({
  50329. value: undefined,
  50330. done: true
  50331. });
  50332. });
  50333. this._requests = [];
  50334. if (this._manager.isPendingRequest(this._requestId)) {
  50335. this._manager.abortRequest(this._requestId);
  50336. }
  50337. this._close();
  50338. }
  50339. };
  50340. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  50341. exports.PDFNetworkStream = PDFNetworkStream;
  50342. exports.NetworkManager = NetworkManager;
  50343. }));
  50344. }.call(pdfjsLibs));
  50345. exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  50346. }));