pdf.worker.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498
  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.411';
  27. var pdfjsBuild = '017e9b9';
  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['controlNULL'] = 0x0000;
  9985. t['controlRS'] = 0x001E;
  9986. t['controlSI'] = 0x000F;
  9987. t['controlSO'] = 0x000E;
  9988. t['controlSOT'] = 0x0002;
  9989. t['controlSTX'] = 0x0001;
  9990. t['controlSUB'] = 0x001A;
  9991. t['controlSYN'] = 0x0016;
  9992. t['controlUS'] = 0x001F;
  9993. t['controlVT'] = 0x000B;
  9994. t['copyright'] = 0x00A9;
  9995. t['copyrightsans'] = 0xF8E9;
  9996. t['copyrightserif'] = 0xF6D9;
  9997. t['cornerbracketleft'] = 0x300C;
  9998. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9999. t['cornerbracketleftvertical'] = 0xFE41;
  10000. t['cornerbracketright'] = 0x300D;
  10001. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10002. t['cornerbracketrightvertical'] = 0xFE42;
  10003. t['corporationsquare'] = 0x337F;
  10004. t['cosquare'] = 0x33C7;
  10005. t['coverkgsquare'] = 0x33C6;
  10006. t['cparen'] = 0x249E;
  10007. t['cruzeiro'] = 0x20A2;
  10008. t['cstretched'] = 0x0297;
  10009. t['curlyand'] = 0x22CF;
  10010. t['curlyor'] = 0x22CE;
  10011. t['currency'] = 0x00A4;
  10012. t['cyrBreve'] = 0xF6D1;
  10013. t['cyrFlex'] = 0xF6D2;
  10014. t['cyrbreve'] = 0xF6D4;
  10015. t['cyrflex'] = 0xF6D5;
  10016. t['d'] = 0x0064;
  10017. t['daarmenian'] = 0x0564;
  10018. t['dabengali'] = 0x09A6;
  10019. t['dadarabic'] = 0x0636;
  10020. t['dadeva'] = 0x0926;
  10021. t['dadfinalarabic'] = 0xFEBE;
  10022. t['dadinitialarabic'] = 0xFEBF;
  10023. t['dadmedialarabic'] = 0xFEC0;
  10024. t['dagesh'] = 0x05BC;
  10025. t['dageshhebrew'] = 0x05BC;
  10026. t['dagger'] = 0x2020;
  10027. t['daggerdbl'] = 0x2021;
  10028. t['dagujarati'] = 0x0AA6;
  10029. t['dagurmukhi'] = 0x0A26;
  10030. t['dahiragana'] = 0x3060;
  10031. t['dakatakana'] = 0x30C0;
  10032. t['dalarabic'] = 0x062F;
  10033. t['dalet'] = 0x05D3;
  10034. t['daletdagesh'] = 0xFB33;
  10035. t['daletdageshhebrew'] = 0xFB33;
  10036. t['dalethebrew'] = 0x05D3;
  10037. t['dalfinalarabic'] = 0xFEAA;
  10038. t['dammaarabic'] = 0x064F;
  10039. t['dammalowarabic'] = 0x064F;
  10040. t['dammatanaltonearabic'] = 0x064C;
  10041. t['dammatanarabic'] = 0x064C;
  10042. t['danda'] = 0x0964;
  10043. t['dargahebrew'] = 0x05A7;
  10044. t['dargalefthebrew'] = 0x05A7;
  10045. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10046. t['dblGrave'] = 0xF6D3;
  10047. t['dblanglebracketleft'] = 0x300A;
  10048. t['dblanglebracketleftvertical'] = 0xFE3D;
  10049. t['dblanglebracketright'] = 0x300B;
  10050. t['dblanglebracketrightvertical'] = 0xFE3E;
  10051. t['dblarchinvertedbelowcmb'] = 0x032B;
  10052. t['dblarrowleft'] = 0x21D4;
  10053. t['dblarrowright'] = 0x21D2;
  10054. t['dbldanda'] = 0x0965;
  10055. t['dblgrave'] = 0xF6D6;
  10056. t['dblgravecmb'] = 0x030F;
  10057. t['dblintegral'] = 0x222C;
  10058. t['dbllowline'] = 0x2017;
  10059. t['dbllowlinecmb'] = 0x0333;
  10060. t['dbloverlinecmb'] = 0x033F;
  10061. t['dblprimemod'] = 0x02BA;
  10062. t['dblverticalbar'] = 0x2016;
  10063. t['dblverticallineabovecmb'] = 0x030E;
  10064. t['dbopomofo'] = 0x3109;
  10065. t['dbsquare'] = 0x33C8;
  10066. t['dcaron'] = 0x010F;
  10067. t['dcedilla'] = 0x1E11;
  10068. t['dcircle'] = 0x24D3;
  10069. t['dcircumflexbelow'] = 0x1E13;
  10070. t['dcroat'] = 0x0111;
  10071. t['ddabengali'] = 0x09A1;
  10072. t['ddadeva'] = 0x0921;
  10073. t['ddagujarati'] = 0x0AA1;
  10074. t['ddagurmukhi'] = 0x0A21;
  10075. t['ddalarabic'] = 0x0688;
  10076. t['ddalfinalarabic'] = 0xFB89;
  10077. t['dddhadeva'] = 0x095C;
  10078. t['ddhabengali'] = 0x09A2;
  10079. t['ddhadeva'] = 0x0922;
  10080. t['ddhagujarati'] = 0x0AA2;
  10081. t['ddhagurmukhi'] = 0x0A22;
  10082. t['ddotaccent'] = 0x1E0B;
  10083. t['ddotbelow'] = 0x1E0D;
  10084. t['decimalseparatorarabic'] = 0x066B;
  10085. t['decimalseparatorpersian'] = 0x066B;
  10086. t['decyrillic'] = 0x0434;
  10087. t['degree'] = 0x00B0;
  10088. t['dehihebrew'] = 0x05AD;
  10089. t['dehiragana'] = 0x3067;
  10090. t['deicoptic'] = 0x03EF;
  10091. t['dekatakana'] = 0x30C7;
  10092. t['deleteleft'] = 0x232B;
  10093. t['deleteright'] = 0x2326;
  10094. t['delta'] = 0x03B4;
  10095. t['deltaturned'] = 0x018D;
  10096. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10097. t['dezh'] = 0x02A4;
  10098. t['dhabengali'] = 0x09A7;
  10099. t['dhadeva'] = 0x0927;
  10100. t['dhagujarati'] = 0x0AA7;
  10101. t['dhagurmukhi'] = 0x0A27;
  10102. t['dhook'] = 0x0257;
  10103. t['dialytikatonos'] = 0x0385;
  10104. t['dialytikatonoscmb'] = 0x0344;
  10105. t['diamond'] = 0x2666;
  10106. t['diamondsuitwhite'] = 0x2662;
  10107. t['dieresis'] = 0x00A8;
  10108. t['dieresisacute'] = 0xF6D7;
  10109. t['dieresisbelowcmb'] = 0x0324;
  10110. t['dieresiscmb'] = 0x0308;
  10111. t['dieresisgrave'] = 0xF6D8;
  10112. t['dieresistonos'] = 0x0385;
  10113. t['dihiragana'] = 0x3062;
  10114. t['dikatakana'] = 0x30C2;
  10115. t['dittomark'] = 0x3003;
  10116. t['divide'] = 0x00F7;
  10117. t['divides'] = 0x2223;
  10118. t['divisionslash'] = 0x2215;
  10119. t['djecyrillic'] = 0x0452;
  10120. t['dkshade'] = 0x2593;
  10121. t['dlinebelow'] = 0x1E0F;
  10122. t['dlsquare'] = 0x3397;
  10123. t['dmacron'] = 0x0111;
  10124. t['dmonospace'] = 0xFF44;
  10125. t['dnblock'] = 0x2584;
  10126. t['dochadathai'] = 0x0E0E;
  10127. t['dodekthai'] = 0x0E14;
  10128. t['dohiragana'] = 0x3069;
  10129. t['dokatakana'] = 0x30C9;
  10130. t['dollar'] = 0x0024;
  10131. t['dollarinferior'] = 0xF6E3;
  10132. t['dollarmonospace'] = 0xFF04;
  10133. t['dollaroldstyle'] = 0xF724;
  10134. t['dollarsmall'] = 0xFE69;
  10135. t['dollarsuperior'] = 0xF6E4;
  10136. t['dong'] = 0x20AB;
  10137. t['dorusquare'] = 0x3326;
  10138. t['dotaccent'] = 0x02D9;
  10139. t['dotaccentcmb'] = 0x0307;
  10140. t['dotbelowcmb'] = 0x0323;
  10141. t['dotbelowcomb'] = 0x0323;
  10142. t['dotkatakana'] = 0x30FB;
  10143. t['dotlessi'] = 0x0131;
  10144. t['dotlessj'] = 0xF6BE;
  10145. t['dotlessjstrokehook'] = 0x0284;
  10146. t['dotmath'] = 0x22C5;
  10147. t['dottedcircle'] = 0x25CC;
  10148. t['doubleyodpatah'] = 0xFB1F;
  10149. t['doubleyodpatahhebrew'] = 0xFB1F;
  10150. t['downtackbelowcmb'] = 0x031E;
  10151. t['downtackmod'] = 0x02D5;
  10152. t['dparen'] = 0x249F;
  10153. t['dsuperior'] = 0xF6EB;
  10154. t['dtail'] = 0x0256;
  10155. t['dtopbar'] = 0x018C;
  10156. t['duhiragana'] = 0x3065;
  10157. t['dukatakana'] = 0x30C5;
  10158. t['dz'] = 0x01F3;
  10159. t['dzaltone'] = 0x02A3;
  10160. t['dzcaron'] = 0x01C6;
  10161. t['dzcurl'] = 0x02A5;
  10162. t['dzeabkhasiancyrillic'] = 0x04E1;
  10163. t['dzecyrillic'] = 0x0455;
  10164. t['dzhecyrillic'] = 0x045F;
  10165. t['e'] = 0x0065;
  10166. t['eacute'] = 0x00E9;
  10167. t['earth'] = 0x2641;
  10168. t['ebengali'] = 0x098F;
  10169. t['ebopomofo'] = 0x311C;
  10170. t['ebreve'] = 0x0115;
  10171. t['ecandradeva'] = 0x090D;
  10172. t['ecandragujarati'] = 0x0A8D;
  10173. t['ecandravowelsigndeva'] = 0x0945;
  10174. t['ecandravowelsigngujarati'] = 0x0AC5;
  10175. t['ecaron'] = 0x011B;
  10176. t['ecedillabreve'] = 0x1E1D;
  10177. t['echarmenian'] = 0x0565;
  10178. t['echyiwnarmenian'] = 0x0587;
  10179. t['ecircle'] = 0x24D4;
  10180. t['ecircumflex'] = 0x00EA;
  10181. t['ecircumflexacute'] = 0x1EBF;
  10182. t['ecircumflexbelow'] = 0x1E19;
  10183. t['ecircumflexdotbelow'] = 0x1EC7;
  10184. t['ecircumflexgrave'] = 0x1EC1;
  10185. t['ecircumflexhookabove'] = 0x1EC3;
  10186. t['ecircumflextilde'] = 0x1EC5;
  10187. t['ecyrillic'] = 0x0454;
  10188. t['edblgrave'] = 0x0205;
  10189. t['edeva'] = 0x090F;
  10190. t['edieresis'] = 0x00EB;
  10191. t['edot'] = 0x0117;
  10192. t['edotaccent'] = 0x0117;
  10193. t['edotbelow'] = 0x1EB9;
  10194. t['eegurmukhi'] = 0x0A0F;
  10195. t['eematragurmukhi'] = 0x0A47;
  10196. t['efcyrillic'] = 0x0444;
  10197. t['egrave'] = 0x00E8;
  10198. t['egujarati'] = 0x0A8F;
  10199. t['eharmenian'] = 0x0567;
  10200. t['ehbopomofo'] = 0x311D;
  10201. t['ehiragana'] = 0x3048;
  10202. t['ehookabove'] = 0x1EBB;
  10203. t['eibopomofo'] = 0x311F;
  10204. t['eight'] = 0x0038;
  10205. t['eightarabic'] = 0x0668;
  10206. t['eightbengali'] = 0x09EE;
  10207. t['eightcircle'] = 0x2467;
  10208. t['eightcircleinversesansserif'] = 0x2791;
  10209. t['eightdeva'] = 0x096E;
  10210. t['eighteencircle'] = 0x2471;
  10211. t['eighteenparen'] = 0x2485;
  10212. t['eighteenperiod'] = 0x2499;
  10213. t['eightgujarati'] = 0x0AEE;
  10214. t['eightgurmukhi'] = 0x0A6E;
  10215. t['eighthackarabic'] = 0x0668;
  10216. t['eighthangzhou'] = 0x3028;
  10217. t['eighthnotebeamed'] = 0x266B;
  10218. t['eightideographicparen'] = 0x3227;
  10219. t['eightinferior'] = 0x2088;
  10220. t['eightmonospace'] = 0xFF18;
  10221. t['eightoldstyle'] = 0xF738;
  10222. t['eightparen'] = 0x247B;
  10223. t['eightperiod'] = 0x248F;
  10224. t['eightpersian'] = 0x06F8;
  10225. t['eightroman'] = 0x2177;
  10226. t['eightsuperior'] = 0x2078;
  10227. t['eightthai'] = 0x0E58;
  10228. t['einvertedbreve'] = 0x0207;
  10229. t['eiotifiedcyrillic'] = 0x0465;
  10230. t['ekatakana'] = 0x30A8;
  10231. t['ekatakanahalfwidth'] = 0xFF74;
  10232. t['ekonkargurmukhi'] = 0x0A74;
  10233. t['ekorean'] = 0x3154;
  10234. t['elcyrillic'] = 0x043B;
  10235. t['element'] = 0x2208;
  10236. t['elevencircle'] = 0x246A;
  10237. t['elevenparen'] = 0x247E;
  10238. t['elevenperiod'] = 0x2492;
  10239. t['elevenroman'] = 0x217A;
  10240. t['ellipsis'] = 0x2026;
  10241. t['ellipsisvertical'] = 0x22EE;
  10242. t['emacron'] = 0x0113;
  10243. t['emacronacute'] = 0x1E17;
  10244. t['emacrongrave'] = 0x1E15;
  10245. t['emcyrillic'] = 0x043C;
  10246. t['emdash'] = 0x2014;
  10247. t['emdashvertical'] = 0xFE31;
  10248. t['emonospace'] = 0xFF45;
  10249. t['emphasismarkarmenian'] = 0x055B;
  10250. t['emptyset'] = 0x2205;
  10251. t['enbopomofo'] = 0x3123;
  10252. t['encyrillic'] = 0x043D;
  10253. t['endash'] = 0x2013;
  10254. t['endashvertical'] = 0xFE32;
  10255. t['endescendercyrillic'] = 0x04A3;
  10256. t['eng'] = 0x014B;
  10257. t['engbopomofo'] = 0x3125;
  10258. t['enghecyrillic'] = 0x04A5;
  10259. t['enhookcyrillic'] = 0x04C8;
  10260. t['enspace'] = 0x2002;
  10261. t['eogonek'] = 0x0119;
  10262. t['eokorean'] = 0x3153;
  10263. t['eopen'] = 0x025B;
  10264. t['eopenclosed'] = 0x029A;
  10265. t['eopenreversed'] = 0x025C;
  10266. t['eopenreversedclosed'] = 0x025E;
  10267. t['eopenreversedhook'] = 0x025D;
  10268. t['eparen'] = 0x24A0;
  10269. t['epsilon'] = 0x03B5;
  10270. t['epsilontonos'] = 0x03AD;
  10271. t['equal'] = 0x003D;
  10272. t['equalmonospace'] = 0xFF1D;
  10273. t['equalsmall'] = 0xFE66;
  10274. t['equalsuperior'] = 0x207C;
  10275. t['equivalence'] = 0x2261;
  10276. t['erbopomofo'] = 0x3126;
  10277. t['ercyrillic'] = 0x0440;
  10278. t['ereversed'] = 0x0258;
  10279. t['ereversedcyrillic'] = 0x044D;
  10280. t['escyrillic'] = 0x0441;
  10281. t['esdescendercyrillic'] = 0x04AB;
  10282. t['esh'] = 0x0283;
  10283. t['eshcurl'] = 0x0286;
  10284. t['eshortdeva'] = 0x090E;
  10285. t['eshortvowelsigndeva'] = 0x0946;
  10286. t['eshreversedloop'] = 0x01AA;
  10287. t['eshsquatreversed'] = 0x0285;
  10288. t['esmallhiragana'] = 0x3047;
  10289. t['esmallkatakana'] = 0x30A7;
  10290. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10291. t['estimated'] = 0x212E;
  10292. t['esuperior'] = 0xF6EC;
  10293. t['eta'] = 0x03B7;
  10294. t['etarmenian'] = 0x0568;
  10295. t['etatonos'] = 0x03AE;
  10296. t['eth'] = 0x00F0;
  10297. t['etilde'] = 0x1EBD;
  10298. t['etildebelow'] = 0x1E1B;
  10299. t['etnahtafoukhhebrew'] = 0x0591;
  10300. t['etnahtafoukhlefthebrew'] = 0x0591;
  10301. t['etnahtahebrew'] = 0x0591;
  10302. t['etnahtalefthebrew'] = 0x0591;
  10303. t['eturned'] = 0x01DD;
  10304. t['eukorean'] = 0x3161;
  10305. t['euro'] = 0x20AC;
  10306. t['evowelsignbengali'] = 0x09C7;
  10307. t['evowelsigndeva'] = 0x0947;
  10308. t['evowelsigngujarati'] = 0x0AC7;
  10309. t['exclam'] = 0x0021;
  10310. t['exclamarmenian'] = 0x055C;
  10311. t['exclamdbl'] = 0x203C;
  10312. t['exclamdown'] = 0x00A1;
  10313. t['exclamdownsmall'] = 0xF7A1;
  10314. t['exclammonospace'] = 0xFF01;
  10315. t['exclamsmall'] = 0xF721;
  10316. t['existential'] = 0x2203;
  10317. t['ezh'] = 0x0292;
  10318. t['ezhcaron'] = 0x01EF;
  10319. t['ezhcurl'] = 0x0293;
  10320. t['ezhreversed'] = 0x01B9;
  10321. t['ezhtail'] = 0x01BA;
  10322. t['f'] = 0x0066;
  10323. t['fadeva'] = 0x095E;
  10324. t['fagurmukhi'] = 0x0A5E;
  10325. t['fahrenheit'] = 0x2109;
  10326. t['fathaarabic'] = 0x064E;
  10327. t['fathalowarabic'] = 0x064E;
  10328. t['fathatanarabic'] = 0x064B;
  10329. t['fbopomofo'] = 0x3108;
  10330. t['fcircle'] = 0x24D5;
  10331. t['fdotaccent'] = 0x1E1F;
  10332. t['feharabic'] = 0x0641;
  10333. t['feharmenian'] = 0x0586;
  10334. t['fehfinalarabic'] = 0xFED2;
  10335. t['fehinitialarabic'] = 0xFED3;
  10336. t['fehmedialarabic'] = 0xFED4;
  10337. t['feicoptic'] = 0x03E5;
  10338. t['female'] = 0x2640;
  10339. t['ff'] = 0xFB00;
  10340. t['ffi'] = 0xFB03;
  10341. t['ffl'] = 0xFB04;
  10342. t['fi'] = 0xFB01;
  10343. t['fifteencircle'] = 0x246E;
  10344. t['fifteenparen'] = 0x2482;
  10345. t['fifteenperiod'] = 0x2496;
  10346. t['figuredash'] = 0x2012;
  10347. t['filledbox'] = 0x25A0;
  10348. t['filledrect'] = 0x25AC;
  10349. t['finalkaf'] = 0x05DA;
  10350. t['finalkafdagesh'] = 0xFB3A;
  10351. t['finalkafdageshhebrew'] = 0xFB3A;
  10352. t['finalkafhebrew'] = 0x05DA;
  10353. t['finalmem'] = 0x05DD;
  10354. t['finalmemhebrew'] = 0x05DD;
  10355. t['finalnun'] = 0x05DF;
  10356. t['finalnunhebrew'] = 0x05DF;
  10357. t['finalpe'] = 0x05E3;
  10358. t['finalpehebrew'] = 0x05E3;
  10359. t['finaltsadi'] = 0x05E5;
  10360. t['finaltsadihebrew'] = 0x05E5;
  10361. t['firsttonechinese'] = 0x02C9;
  10362. t['fisheye'] = 0x25C9;
  10363. t['fitacyrillic'] = 0x0473;
  10364. t['five'] = 0x0035;
  10365. t['fivearabic'] = 0x0665;
  10366. t['fivebengali'] = 0x09EB;
  10367. t['fivecircle'] = 0x2464;
  10368. t['fivecircleinversesansserif'] = 0x278E;
  10369. t['fivedeva'] = 0x096B;
  10370. t['fiveeighths'] = 0x215D;
  10371. t['fivegujarati'] = 0x0AEB;
  10372. t['fivegurmukhi'] = 0x0A6B;
  10373. t['fivehackarabic'] = 0x0665;
  10374. t['fivehangzhou'] = 0x3025;
  10375. t['fiveideographicparen'] = 0x3224;
  10376. t['fiveinferior'] = 0x2085;
  10377. t['fivemonospace'] = 0xFF15;
  10378. t['fiveoldstyle'] = 0xF735;
  10379. t['fiveparen'] = 0x2478;
  10380. t['fiveperiod'] = 0x248C;
  10381. t['fivepersian'] = 0x06F5;
  10382. t['fiveroman'] = 0x2174;
  10383. t['fivesuperior'] = 0x2075;
  10384. t['fivethai'] = 0x0E55;
  10385. t['fl'] = 0xFB02;
  10386. t['florin'] = 0x0192;
  10387. t['fmonospace'] = 0xFF46;
  10388. t['fmsquare'] = 0x3399;
  10389. t['fofanthai'] = 0x0E1F;
  10390. t['fofathai'] = 0x0E1D;
  10391. t['fongmanthai'] = 0x0E4F;
  10392. t['forall'] = 0x2200;
  10393. t['four'] = 0x0034;
  10394. t['fourarabic'] = 0x0664;
  10395. t['fourbengali'] = 0x09EA;
  10396. t['fourcircle'] = 0x2463;
  10397. t['fourcircleinversesansserif'] = 0x278D;
  10398. t['fourdeva'] = 0x096A;
  10399. t['fourgujarati'] = 0x0AEA;
  10400. t['fourgurmukhi'] = 0x0A6A;
  10401. t['fourhackarabic'] = 0x0664;
  10402. t['fourhangzhou'] = 0x3024;
  10403. t['fourideographicparen'] = 0x3223;
  10404. t['fourinferior'] = 0x2084;
  10405. t['fourmonospace'] = 0xFF14;
  10406. t['fournumeratorbengali'] = 0x09F7;
  10407. t['fouroldstyle'] = 0xF734;
  10408. t['fourparen'] = 0x2477;
  10409. t['fourperiod'] = 0x248B;
  10410. t['fourpersian'] = 0x06F4;
  10411. t['fourroman'] = 0x2173;
  10412. t['foursuperior'] = 0x2074;
  10413. t['fourteencircle'] = 0x246D;
  10414. t['fourteenparen'] = 0x2481;
  10415. t['fourteenperiod'] = 0x2495;
  10416. t['fourthai'] = 0x0E54;
  10417. t['fourthtonechinese'] = 0x02CB;
  10418. t['fparen'] = 0x24A1;
  10419. t['fraction'] = 0x2044;
  10420. t['franc'] = 0x20A3;
  10421. t['g'] = 0x0067;
  10422. t['gabengali'] = 0x0997;
  10423. t['gacute'] = 0x01F5;
  10424. t['gadeva'] = 0x0917;
  10425. t['gafarabic'] = 0x06AF;
  10426. t['gaffinalarabic'] = 0xFB93;
  10427. t['gafinitialarabic'] = 0xFB94;
  10428. t['gafmedialarabic'] = 0xFB95;
  10429. t['gagujarati'] = 0x0A97;
  10430. t['gagurmukhi'] = 0x0A17;
  10431. t['gahiragana'] = 0x304C;
  10432. t['gakatakana'] = 0x30AC;
  10433. t['gamma'] = 0x03B3;
  10434. t['gammalatinsmall'] = 0x0263;
  10435. t['gammasuperior'] = 0x02E0;
  10436. t['gangiacoptic'] = 0x03EB;
  10437. t['gbopomofo'] = 0x310D;
  10438. t['gbreve'] = 0x011F;
  10439. t['gcaron'] = 0x01E7;
  10440. t['gcedilla'] = 0x0123;
  10441. t['gcircle'] = 0x24D6;
  10442. t['gcircumflex'] = 0x011D;
  10443. t['gcommaaccent'] = 0x0123;
  10444. t['gdot'] = 0x0121;
  10445. t['gdotaccent'] = 0x0121;
  10446. t['gecyrillic'] = 0x0433;
  10447. t['gehiragana'] = 0x3052;
  10448. t['gekatakana'] = 0x30B2;
  10449. t['geometricallyequal'] = 0x2251;
  10450. t['gereshaccenthebrew'] = 0x059C;
  10451. t['gereshhebrew'] = 0x05F3;
  10452. t['gereshmuqdamhebrew'] = 0x059D;
  10453. t['germandbls'] = 0x00DF;
  10454. t['gershayimaccenthebrew'] = 0x059E;
  10455. t['gershayimhebrew'] = 0x05F4;
  10456. t['getamark'] = 0x3013;
  10457. t['ghabengali'] = 0x0998;
  10458. t['ghadarmenian'] = 0x0572;
  10459. t['ghadeva'] = 0x0918;
  10460. t['ghagujarati'] = 0x0A98;
  10461. t['ghagurmukhi'] = 0x0A18;
  10462. t['ghainarabic'] = 0x063A;
  10463. t['ghainfinalarabic'] = 0xFECE;
  10464. t['ghaininitialarabic'] = 0xFECF;
  10465. t['ghainmedialarabic'] = 0xFED0;
  10466. t['ghemiddlehookcyrillic'] = 0x0495;
  10467. t['ghestrokecyrillic'] = 0x0493;
  10468. t['gheupturncyrillic'] = 0x0491;
  10469. t['ghhadeva'] = 0x095A;
  10470. t['ghhagurmukhi'] = 0x0A5A;
  10471. t['ghook'] = 0x0260;
  10472. t['ghzsquare'] = 0x3393;
  10473. t['gihiragana'] = 0x304E;
  10474. t['gikatakana'] = 0x30AE;
  10475. t['gimarmenian'] = 0x0563;
  10476. t['gimel'] = 0x05D2;
  10477. t['gimeldagesh'] = 0xFB32;
  10478. t['gimeldageshhebrew'] = 0xFB32;
  10479. t['gimelhebrew'] = 0x05D2;
  10480. t['gjecyrillic'] = 0x0453;
  10481. t['glottalinvertedstroke'] = 0x01BE;
  10482. t['glottalstop'] = 0x0294;
  10483. t['glottalstopinverted'] = 0x0296;
  10484. t['glottalstopmod'] = 0x02C0;
  10485. t['glottalstopreversed'] = 0x0295;
  10486. t['glottalstopreversedmod'] = 0x02C1;
  10487. t['glottalstopreversedsuperior'] = 0x02E4;
  10488. t['glottalstopstroke'] = 0x02A1;
  10489. t['glottalstopstrokereversed'] = 0x02A2;
  10490. t['gmacron'] = 0x1E21;
  10491. t['gmonospace'] = 0xFF47;
  10492. t['gohiragana'] = 0x3054;
  10493. t['gokatakana'] = 0x30B4;
  10494. t['gparen'] = 0x24A2;
  10495. t['gpasquare'] = 0x33AC;
  10496. t['gradient'] = 0x2207;
  10497. t['grave'] = 0x0060;
  10498. t['gravebelowcmb'] = 0x0316;
  10499. t['gravecmb'] = 0x0300;
  10500. t['gravecomb'] = 0x0300;
  10501. t['gravedeva'] = 0x0953;
  10502. t['gravelowmod'] = 0x02CE;
  10503. t['gravemonospace'] = 0xFF40;
  10504. t['gravetonecmb'] = 0x0340;
  10505. t['greater'] = 0x003E;
  10506. t['greaterequal'] = 0x2265;
  10507. t['greaterequalorless'] = 0x22DB;
  10508. t['greatermonospace'] = 0xFF1E;
  10509. t['greaterorequivalent'] = 0x2273;
  10510. t['greaterorless'] = 0x2277;
  10511. t['greateroverequal'] = 0x2267;
  10512. t['greatersmall'] = 0xFE65;
  10513. t['gscript'] = 0x0261;
  10514. t['gstroke'] = 0x01E5;
  10515. t['guhiragana'] = 0x3050;
  10516. t['guillemotleft'] = 0x00AB;
  10517. t['guillemotright'] = 0x00BB;
  10518. t['guilsinglleft'] = 0x2039;
  10519. t['guilsinglright'] = 0x203A;
  10520. t['gukatakana'] = 0x30B0;
  10521. t['guramusquare'] = 0x3318;
  10522. t['gysquare'] = 0x33C9;
  10523. t['h'] = 0x0068;
  10524. t['haabkhasiancyrillic'] = 0x04A9;
  10525. t['haaltonearabic'] = 0x06C1;
  10526. t['habengali'] = 0x09B9;
  10527. t['hadescendercyrillic'] = 0x04B3;
  10528. t['hadeva'] = 0x0939;
  10529. t['hagujarati'] = 0x0AB9;
  10530. t['hagurmukhi'] = 0x0A39;
  10531. t['haharabic'] = 0x062D;
  10532. t['hahfinalarabic'] = 0xFEA2;
  10533. t['hahinitialarabic'] = 0xFEA3;
  10534. t['hahiragana'] = 0x306F;
  10535. t['hahmedialarabic'] = 0xFEA4;
  10536. t['haitusquare'] = 0x332A;
  10537. t['hakatakana'] = 0x30CF;
  10538. t['hakatakanahalfwidth'] = 0xFF8A;
  10539. t['halantgurmukhi'] = 0x0A4D;
  10540. t['hamzaarabic'] = 0x0621;
  10541. t['hamzalowarabic'] = 0x0621;
  10542. t['hangulfiller'] = 0x3164;
  10543. t['hardsigncyrillic'] = 0x044A;
  10544. t['harpoonleftbarbup'] = 0x21BC;
  10545. t['harpoonrightbarbup'] = 0x21C0;
  10546. t['hasquare'] = 0x33CA;
  10547. t['hatafpatah'] = 0x05B2;
  10548. t['hatafpatah16'] = 0x05B2;
  10549. t['hatafpatah23'] = 0x05B2;
  10550. t['hatafpatah2f'] = 0x05B2;
  10551. t['hatafpatahhebrew'] = 0x05B2;
  10552. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10553. t['hatafpatahquarterhebrew'] = 0x05B2;
  10554. t['hatafpatahwidehebrew'] = 0x05B2;
  10555. t['hatafqamats'] = 0x05B3;
  10556. t['hatafqamats1b'] = 0x05B3;
  10557. t['hatafqamats28'] = 0x05B3;
  10558. t['hatafqamats34'] = 0x05B3;
  10559. t['hatafqamatshebrew'] = 0x05B3;
  10560. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10561. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10562. t['hatafqamatswidehebrew'] = 0x05B3;
  10563. t['hatafsegol'] = 0x05B1;
  10564. t['hatafsegol17'] = 0x05B1;
  10565. t['hatafsegol24'] = 0x05B1;
  10566. t['hatafsegol30'] = 0x05B1;
  10567. t['hatafsegolhebrew'] = 0x05B1;
  10568. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10569. t['hatafsegolquarterhebrew'] = 0x05B1;
  10570. t['hatafsegolwidehebrew'] = 0x05B1;
  10571. t['hbar'] = 0x0127;
  10572. t['hbopomofo'] = 0x310F;
  10573. t['hbrevebelow'] = 0x1E2B;
  10574. t['hcedilla'] = 0x1E29;
  10575. t['hcircle'] = 0x24D7;
  10576. t['hcircumflex'] = 0x0125;
  10577. t['hdieresis'] = 0x1E27;
  10578. t['hdotaccent'] = 0x1E23;
  10579. t['hdotbelow'] = 0x1E25;
  10580. t['he'] = 0x05D4;
  10581. t['heart'] = 0x2665;
  10582. t['heartsuitblack'] = 0x2665;
  10583. t['heartsuitwhite'] = 0x2661;
  10584. t['hedagesh'] = 0xFB34;
  10585. t['hedageshhebrew'] = 0xFB34;
  10586. t['hehaltonearabic'] = 0x06C1;
  10587. t['heharabic'] = 0x0647;
  10588. t['hehebrew'] = 0x05D4;
  10589. t['hehfinalaltonearabic'] = 0xFBA7;
  10590. t['hehfinalalttwoarabic'] = 0xFEEA;
  10591. t['hehfinalarabic'] = 0xFEEA;
  10592. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10593. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10594. t['hehinitialaltonearabic'] = 0xFBA8;
  10595. t['hehinitialarabic'] = 0xFEEB;
  10596. t['hehiragana'] = 0x3078;
  10597. t['hehmedialaltonearabic'] = 0xFBA9;
  10598. t['hehmedialarabic'] = 0xFEEC;
  10599. t['heiseierasquare'] = 0x337B;
  10600. t['hekatakana'] = 0x30D8;
  10601. t['hekatakanahalfwidth'] = 0xFF8D;
  10602. t['hekutaarusquare'] = 0x3336;
  10603. t['henghook'] = 0x0267;
  10604. t['herutusquare'] = 0x3339;
  10605. t['het'] = 0x05D7;
  10606. t['hethebrew'] = 0x05D7;
  10607. t['hhook'] = 0x0266;
  10608. t['hhooksuperior'] = 0x02B1;
  10609. t['hieuhacirclekorean'] = 0x327B;
  10610. t['hieuhaparenkorean'] = 0x321B;
  10611. t['hieuhcirclekorean'] = 0x326D;
  10612. t['hieuhkorean'] = 0x314E;
  10613. t['hieuhparenkorean'] = 0x320D;
  10614. t['hihiragana'] = 0x3072;
  10615. t['hikatakana'] = 0x30D2;
  10616. t['hikatakanahalfwidth'] = 0xFF8B;
  10617. t['hiriq'] = 0x05B4;
  10618. t['hiriq14'] = 0x05B4;
  10619. t['hiriq21'] = 0x05B4;
  10620. t['hiriq2d'] = 0x05B4;
  10621. t['hiriqhebrew'] = 0x05B4;
  10622. t['hiriqnarrowhebrew'] = 0x05B4;
  10623. t['hiriqquarterhebrew'] = 0x05B4;
  10624. t['hiriqwidehebrew'] = 0x05B4;
  10625. t['hlinebelow'] = 0x1E96;
  10626. t['hmonospace'] = 0xFF48;
  10627. t['hoarmenian'] = 0x0570;
  10628. t['hohipthai'] = 0x0E2B;
  10629. t['hohiragana'] = 0x307B;
  10630. t['hokatakana'] = 0x30DB;
  10631. t['hokatakanahalfwidth'] = 0xFF8E;
  10632. t['holam'] = 0x05B9;
  10633. t['holam19'] = 0x05B9;
  10634. t['holam26'] = 0x05B9;
  10635. t['holam32'] = 0x05B9;
  10636. t['holamhebrew'] = 0x05B9;
  10637. t['holamnarrowhebrew'] = 0x05B9;
  10638. t['holamquarterhebrew'] = 0x05B9;
  10639. t['holamwidehebrew'] = 0x05B9;
  10640. t['honokhukthai'] = 0x0E2E;
  10641. t['hookabovecomb'] = 0x0309;
  10642. t['hookcmb'] = 0x0309;
  10643. t['hookpalatalizedbelowcmb'] = 0x0321;
  10644. t['hookretroflexbelowcmb'] = 0x0322;
  10645. t['hoonsquare'] = 0x3342;
  10646. t['horicoptic'] = 0x03E9;
  10647. t['horizontalbar'] = 0x2015;
  10648. t['horncmb'] = 0x031B;
  10649. t['hotsprings'] = 0x2668;
  10650. t['house'] = 0x2302;
  10651. t['hparen'] = 0x24A3;
  10652. t['hsuperior'] = 0x02B0;
  10653. t['hturned'] = 0x0265;
  10654. t['huhiragana'] = 0x3075;
  10655. t['huiitosquare'] = 0x3333;
  10656. t['hukatakana'] = 0x30D5;
  10657. t['hukatakanahalfwidth'] = 0xFF8C;
  10658. t['hungarumlaut'] = 0x02DD;
  10659. t['hungarumlautcmb'] = 0x030B;
  10660. t['hv'] = 0x0195;
  10661. t['hyphen'] = 0x002D;
  10662. t['hypheninferior'] = 0xF6E5;
  10663. t['hyphenmonospace'] = 0xFF0D;
  10664. t['hyphensmall'] = 0xFE63;
  10665. t['hyphensuperior'] = 0xF6E6;
  10666. t['hyphentwo'] = 0x2010;
  10667. t['i'] = 0x0069;
  10668. t['iacute'] = 0x00ED;
  10669. t['iacyrillic'] = 0x044F;
  10670. t['ibengali'] = 0x0987;
  10671. t['ibopomofo'] = 0x3127;
  10672. t['ibreve'] = 0x012D;
  10673. t['icaron'] = 0x01D0;
  10674. t['icircle'] = 0x24D8;
  10675. t['icircumflex'] = 0x00EE;
  10676. t['icyrillic'] = 0x0456;
  10677. t['idblgrave'] = 0x0209;
  10678. t['ideographearthcircle'] = 0x328F;
  10679. t['ideographfirecircle'] = 0x328B;
  10680. t['ideographicallianceparen'] = 0x323F;
  10681. t['ideographiccallparen'] = 0x323A;
  10682. t['ideographiccentrecircle'] = 0x32A5;
  10683. t['ideographicclose'] = 0x3006;
  10684. t['ideographiccomma'] = 0x3001;
  10685. t['ideographiccommaleft'] = 0xFF64;
  10686. t['ideographiccongratulationparen'] = 0x3237;
  10687. t['ideographiccorrectcircle'] = 0x32A3;
  10688. t['ideographicearthparen'] = 0x322F;
  10689. t['ideographicenterpriseparen'] = 0x323D;
  10690. t['ideographicexcellentcircle'] = 0x329D;
  10691. t['ideographicfestivalparen'] = 0x3240;
  10692. t['ideographicfinancialcircle'] = 0x3296;
  10693. t['ideographicfinancialparen'] = 0x3236;
  10694. t['ideographicfireparen'] = 0x322B;
  10695. t['ideographichaveparen'] = 0x3232;
  10696. t['ideographichighcircle'] = 0x32A4;
  10697. t['ideographiciterationmark'] = 0x3005;
  10698. t['ideographiclaborcircle'] = 0x3298;
  10699. t['ideographiclaborparen'] = 0x3238;
  10700. t['ideographicleftcircle'] = 0x32A7;
  10701. t['ideographiclowcircle'] = 0x32A6;
  10702. t['ideographicmedicinecircle'] = 0x32A9;
  10703. t['ideographicmetalparen'] = 0x322E;
  10704. t['ideographicmoonparen'] = 0x322A;
  10705. t['ideographicnameparen'] = 0x3234;
  10706. t['ideographicperiod'] = 0x3002;
  10707. t['ideographicprintcircle'] = 0x329E;
  10708. t['ideographicreachparen'] = 0x3243;
  10709. t['ideographicrepresentparen'] = 0x3239;
  10710. t['ideographicresourceparen'] = 0x323E;
  10711. t['ideographicrightcircle'] = 0x32A8;
  10712. t['ideographicsecretcircle'] = 0x3299;
  10713. t['ideographicselfparen'] = 0x3242;
  10714. t['ideographicsocietyparen'] = 0x3233;
  10715. t['ideographicspace'] = 0x3000;
  10716. t['ideographicspecialparen'] = 0x3235;
  10717. t['ideographicstockparen'] = 0x3231;
  10718. t['ideographicstudyparen'] = 0x323B;
  10719. t['ideographicsunparen'] = 0x3230;
  10720. t['ideographicsuperviseparen'] = 0x323C;
  10721. t['ideographicwaterparen'] = 0x322C;
  10722. t['ideographicwoodparen'] = 0x322D;
  10723. t['ideographiczero'] = 0x3007;
  10724. t['ideographmetalcircle'] = 0x328E;
  10725. t['ideographmooncircle'] = 0x328A;
  10726. t['ideographnamecircle'] = 0x3294;
  10727. t['ideographsuncircle'] = 0x3290;
  10728. t['ideographwatercircle'] = 0x328C;
  10729. t['ideographwoodcircle'] = 0x328D;
  10730. t['ideva'] = 0x0907;
  10731. t['idieresis'] = 0x00EF;
  10732. t['idieresisacute'] = 0x1E2F;
  10733. t['idieresiscyrillic'] = 0x04E5;
  10734. t['idotbelow'] = 0x1ECB;
  10735. t['iebrevecyrillic'] = 0x04D7;
  10736. t['iecyrillic'] = 0x0435;
  10737. t['ieungacirclekorean'] = 0x3275;
  10738. t['ieungaparenkorean'] = 0x3215;
  10739. t['ieungcirclekorean'] = 0x3267;
  10740. t['ieungkorean'] = 0x3147;
  10741. t['ieungparenkorean'] = 0x3207;
  10742. t['igrave'] = 0x00EC;
  10743. t['igujarati'] = 0x0A87;
  10744. t['igurmukhi'] = 0x0A07;
  10745. t['ihiragana'] = 0x3044;
  10746. t['ihookabove'] = 0x1EC9;
  10747. t['iibengali'] = 0x0988;
  10748. t['iicyrillic'] = 0x0438;
  10749. t['iideva'] = 0x0908;
  10750. t['iigujarati'] = 0x0A88;
  10751. t['iigurmukhi'] = 0x0A08;
  10752. t['iimatragurmukhi'] = 0x0A40;
  10753. t['iinvertedbreve'] = 0x020B;
  10754. t['iishortcyrillic'] = 0x0439;
  10755. t['iivowelsignbengali'] = 0x09C0;
  10756. t['iivowelsigndeva'] = 0x0940;
  10757. t['iivowelsigngujarati'] = 0x0AC0;
  10758. t['ij'] = 0x0133;
  10759. t['ikatakana'] = 0x30A4;
  10760. t['ikatakanahalfwidth'] = 0xFF72;
  10761. t['ikorean'] = 0x3163;
  10762. t['ilde'] = 0x02DC;
  10763. t['iluyhebrew'] = 0x05AC;
  10764. t['imacron'] = 0x012B;
  10765. t['imacroncyrillic'] = 0x04E3;
  10766. t['imageorapproximatelyequal'] = 0x2253;
  10767. t['imatragurmukhi'] = 0x0A3F;
  10768. t['imonospace'] = 0xFF49;
  10769. t['increment'] = 0x2206;
  10770. t['infinity'] = 0x221E;
  10771. t['iniarmenian'] = 0x056B;
  10772. t['integral'] = 0x222B;
  10773. t['integralbottom'] = 0x2321;
  10774. t['integralbt'] = 0x2321;
  10775. t['integralex'] = 0xF8F5;
  10776. t['integraltop'] = 0x2320;
  10777. t['integraltp'] = 0x2320;
  10778. t['intersection'] = 0x2229;
  10779. t['intisquare'] = 0x3305;
  10780. t['invbullet'] = 0x25D8;
  10781. t['invcircle'] = 0x25D9;
  10782. t['invsmileface'] = 0x263B;
  10783. t['iocyrillic'] = 0x0451;
  10784. t['iogonek'] = 0x012F;
  10785. t['iota'] = 0x03B9;
  10786. t['iotadieresis'] = 0x03CA;
  10787. t['iotadieresistonos'] = 0x0390;
  10788. t['iotalatin'] = 0x0269;
  10789. t['iotatonos'] = 0x03AF;
  10790. t['iparen'] = 0x24A4;
  10791. t['irigurmukhi'] = 0x0A72;
  10792. t['ismallhiragana'] = 0x3043;
  10793. t['ismallkatakana'] = 0x30A3;
  10794. t['ismallkatakanahalfwidth'] = 0xFF68;
  10795. t['issharbengali'] = 0x09FA;
  10796. t['istroke'] = 0x0268;
  10797. t['isuperior'] = 0xF6ED;
  10798. t['iterationhiragana'] = 0x309D;
  10799. t['iterationkatakana'] = 0x30FD;
  10800. t['itilde'] = 0x0129;
  10801. t['itildebelow'] = 0x1E2D;
  10802. t['iubopomofo'] = 0x3129;
  10803. t['iucyrillic'] = 0x044E;
  10804. t['ivowelsignbengali'] = 0x09BF;
  10805. t['ivowelsigndeva'] = 0x093F;
  10806. t['ivowelsigngujarati'] = 0x0ABF;
  10807. t['izhitsacyrillic'] = 0x0475;
  10808. t['izhitsadblgravecyrillic'] = 0x0477;
  10809. t['j'] = 0x006A;
  10810. t['jaarmenian'] = 0x0571;
  10811. t['jabengali'] = 0x099C;
  10812. t['jadeva'] = 0x091C;
  10813. t['jagujarati'] = 0x0A9C;
  10814. t['jagurmukhi'] = 0x0A1C;
  10815. t['jbopomofo'] = 0x3110;
  10816. t['jcaron'] = 0x01F0;
  10817. t['jcircle'] = 0x24D9;
  10818. t['jcircumflex'] = 0x0135;
  10819. t['jcrossedtail'] = 0x029D;
  10820. t['jdotlessstroke'] = 0x025F;
  10821. t['jecyrillic'] = 0x0458;
  10822. t['jeemarabic'] = 0x062C;
  10823. t['jeemfinalarabic'] = 0xFE9E;
  10824. t['jeeminitialarabic'] = 0xFE9F;
  10825. t['jeemmedialarabic'] = 0xFEA0;
  10826. t['jeharabic'] = 0x0698;
  10827. t['jehfinalarabic'] = 0xFB8B;
  10828. t['jhabengali'] = 0x099D;
  10829. t['jhadeva'] = 0x091D;
  10830. t['jhagujarati'] = 0x0A9D;
  10831. t['jhagurmukhi'] = 0x0A1D;
  10832. t['jheharmenian'] = 0x057B;
  10833. t['jis'] = 0x3004;
  10834. t['jmonospace'] = 0xFF4A;
  10835. t['jparen'] = 0x24A5;
  10836. t['jsuperior'] = 0x02B2;
  10837. t['k'] = 0x006B;
  10838. t['kabashkircyrillic'] = 0x04A1;
  10839. t['kabengali'] = 0x0995;
  10840. t['kacute'] = 0x1E31;
  10841. t['kacyrillic'] = 0x043A;
  10842. t['kadescendercyrillic'] = 0x049B;
  10843. t['kadeva'] = 0x0915;
  10844. t['kaf'] = 0x05DB;
  10845. t['kafarabic'] = 0x0643;
  10846. t['kafdagesh'] = 0xFB3B;
  10847. t['kafdageshhebrew'] = 0xFB3B;
  10848. t['kaffinalarabic'] = 0xFEDA;
  10849. t['kafhebrew'] = 0x05DB;
  10850. t['kafinitialarabic'] = 0xFEDB;
  10851. t['kafmedialarabic'] = 0xFEDC;
  10852. t['kafrafehebrew'] = 0xFB4D;
  10853. t['kagujarati'] = 0x0A95;
  10854. t['kagurmukhi'] = 0x0A15;
  10855. t['kahiragana'] = 0x304B;
  10856. t['kahookcyrillic'] = 0x04C4;
  10857. t['kakatakana'] = 0x30AB;
  10858. t['kakatakanahalfwidth'] = 0xFF76;
  10859. t['kappa'] = 0x03BA;
  10860. t['kappasymbolgreek'] = 0x03F0;
  10861. t['kapyeounmieumkorean'] = 0x3171;
  10862. t['kapyeounphieuphkorean'] = 0x3184;
  10863. t['kapyeounpieupkorean'] = 0x3178;
  10864. t['kapyeounssangpieupkorean'] = 0x3179;
  10865. t['karoriisquare'] = 0x330D;
  10866. t['kashidaautoarabic'] = 0x0640;
  10867. t['kashidaautonosidebearingarabic'] = 0x0640;
  10868. t['kasmallkatakana'] = 0x30F5;
  10869. t['kasquare'] = 0x3384;
  10870. t['kasraarabic'] = 0x0650;
  10871. t['kasratanarabic'] = 0x064D;
  10872. t['kastrokecyrillic'] = 0x049F;
  10873. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10874. t['kaverticalstrokecyrillic'] = 0x049D;
  10875. t['kbopomofo'] = 0x310E;
  10876. t['kcalsquare'] = 0x3389;
  10877. t['kcaron'] = 0x01E9;
  10878. t['kcedilla'] = 0x0137;
  10879. t['kcircle'] = 0x24DA;
  10880. t['kcommaaccent'] = 0x0137;
  10881. t['kdotbelow'] = 0x1E33;
  10882. t['keharmenian'] = 0x0584;
  10883. t['kehiragana'] = 0x3051;
  10884. t['kekatakana'] = 0x30B1;
  10885. t['kekatakanahalfwidth'] = 0xFF79;
  10886. t['kenarmenian'] = 0x056F;
  10887. t['kesmallkatakana'] = 0x30F6;
  10888. t['kgreenlandic'] = 0x0138;
  10889. t['khabengali'] = 0x0996;
  10890. t['khacyrillic'] = 0x0445;
  10891. t['khadeva'] = 0x0916;
  10892. t['khagujarati'] = 0x0A96;
  10893. t['khagurmukhi'] = 0x0A16;
  10894. t['khaharabic'] = 0x062E;
  10895. t['khahfinalarabic'] = 0xFEA6;
  10896. t['khahinitialarabic'] = 0xFEA7;
  10897. t['khahmedialarabic'] = 0xFEA8;
  10898. t['kheicoptic'] = 0x03E7;
  10899. t['khhadeva'] = 0x0959;
  10900. t['khhagurmukhi'] = 0x0A59;
  10901. t['khieukhacirclekorean'] = 0x3278;
  10902. t['khieukhaparenkorean'] = 0x3218;
  10903. t['khieukhcirclekorean'] = 0x326A;
  10904. t['khieukhkorean'] = 0x314B;
  10905. t['khieukhparenkorean'] = 0x320A;
  10906. t['khokhaithai'] = 0x0E02;
  10907. t['khokhonthai'] = 0x0E05;
  10908. t['khokhuatthai'] = 0x0E03;
  10909. t['khokhwaithai'] = 0x0E04;
  10910. t['khomutthai'] = 0x0E5B;
  10911. t['khook'] = 0x0199;
  10912. t['khorakhangthai'] = 0x0E06;
  10913. t['khzsquare'] = 0x3391;
  10914. t['kihiragana'] = 0x304D;
  10915. t['kikatakana'] = 0x30AD;
  10916. t['kikatakanahalfwidth'] = 0xFF77;
  10917. t['kiroguramusquare'] = 0x3315;
  10918. t['kiromeetorusquare'] = 0x3316;
  10919. t['kirosquare'] = 0x3314;
  10920. t['kiyeokacirclekorean'] = 0x326E;
  10921. t['kiyeokaparenkorean'] = 0x320E;
  10922. t['kiyeokcirclekorean'] = 0x3260;
  10923. t['kiyeokkorean'] = 0x3131;
  10924. t['kiyeokparenkorean'] = 0x3200;
  10925. t['kiyeoksioskorean'] = 0x3133;
  10926. t['kjecyrillic'] = 0x045C;
  10927. t['klinebelow'] = 0x1E35;
  10928. t['klsquare'] = 0x3398;
  10929. t['kmcubedsquare'] = 0x33A6;
  10930. t['kmonospace'] = 0xFF4B;
  10931. t['kmsquaredsquare'] = 0x33A2;
  10932. t['kohiragana'] = 0x3053;
  10933. t['kohmsquare'] = 0x33C0;
  10934. t['kokaithai'] = 0x0E01;
  10935. t['kokatakana'] = 0x30B3;
  10936. t['kokatakanahalfwidth'] = 0xFF7A;
  10937. t['kooposquare'] = 0x331E;
  10938. t['koppacyrillic'] = 0x0481;
  10939. t['koreanstandardsymbol'] = 0x327F;
  10940. t['koroniscmb'] = 0x0343;
  10941. t['kparen'] = 0x24A6;
  10942. t['kpasquare'] = 0x33AA;
  10943. t['ksicyrillic'] = 0x046F;
  10944. t['ktsquare'] = 0x33CF;
  10945. t['kturned'] = 0x029E;
  10946. t['kuhiragana'] = 0x304F;
  10947. t['kukatakana'] = 0x30AF;
  10948. t['kukatakanahalfwidth'] = 0xFF78;
  10949. t['kvsquare'] = 0x33B8;
  10950. t['kwsquare'] = 0x33BE;
  10951. t['l'] = 0x006C;
  10952. t['labengali'] = 0x09B2;
  10953. t['lacute'] = 0x013A;
  10954. t['ladeva'] = 0x0932;
  10955. t['lagujarati'] = 0x0AB2;
  10956. t['lagurmukhi'] = 0x0A32;
  10957. t['lakkhangyaothai'] = 0x0E45;
  10958. t['lamaleffinalarabic'] = 0xFEFC;
  10959. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10960. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10961. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10962. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10963. t['lamalefisolatedarabic'] = 0xFEFB;
  10964. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10965. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10966. t['lamarabic'] = 0x0644;
  10967. t['lambda'] = 0x03BB;
  10968. t['lambdastroke'] = 0x019B;
  10969. t['lamed'] = 0x05DC;
  10970. t['lameddagesh'] = 0xFB3C;
  10971. t['lameddageshhebrew'] = 0xFB3C;
  10972. t['lamedhebrew'] = 0x05DC;
  10973. t['lamfinalarabic'] = 0xFEDE;
  10974. t['lamhahinitialarabic'] = 0xFCCA;
  10975. t['laminitialarabic'] = 0xFEDF;
  10976. t['lamjeeminitialarabic'] = 0xFCC9;
  10977. t['lamkhahinitialarabic'] = 0xFCCB;
  10978. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10979. t['lammedialarabic'] = 0xFEE0;
  10980. t['lammeemhahinitialarabic'] = 0xFD88;
  10981. t['lammeeminitialarabic'] = 0xFCCC;
  10982. t['largecircle'] = 0x25EF;
  10983. t['lbar'] = 0x019A;
  10984. t['lbelt'] = 0x026C;
  10985. t['lbopomofo'] = 0x310C;
  10986. t['lcaron'] = 0x013E;
  10987. t['lcedilla'] = 0x013C;
  10988. t['lcircle'] = 0x24DB;
  10989. t['lcircumflexbelow'] = 0x1E3D;
  10990. t['lcommaaccent'] = 0x013C;
  10991. t['ldot'] = 0x0140;
  10992. t['ldotaccent'] = 0x0140;
  10993. t['ldotbelow'] = 0x1E37;
  10994. t['ldotbelowmacron'] = 0x1E39;
  10995. t['leftangleabovecmb'] = 0x031A;
  10996. t['lefttackbelowcmb'] = 0x0318;
  10997. t['less'] = 0x003C;
  10998. t['lessequal'] = 0x2264;
  10999. t['lessequalorgreater'] = 0x22DA;
  11000. t['lessmonospace'] = 0xFF1C;
  11001. t['lessorequivalent'] = 0x2272;
  11002. t['lessorgreater'] = 0x2276;
  11003. t['lessoverequal'] = 0x2266;
  11004. t['lesssmall'] = 0xFE64;
  11005. t['lezh'] = 0x026E;
  11006. t['lfblock'] = 0x258C;
  11007. t['lhookretroflex'] = 0x026D;
  11008. t['lira'] = 0x20A4;
  11009. t['liwnarmenian'] = 0x056C;
  11010. t['lj'] = 0x01C9;
  11011. t['ljecyrillic'] = 0x0459;
  11012. t['ll'] = 0xF6C0;
  11013. t['lladeva'] = 0x0933;
  11014. t['llagujarati'] = 0x0AB3;
  11015. t['llinebelow'] = 0x1E3B;
  11016. t['llladeva'] = 0x0934;
  11017. t['llvocalicbengali'] = 0x09E1;
  11018. t['llvocalicdeva'] = 0x0961;
  11019. t['llvocalicvowelsignbengali'] = 0x09E3;
  11020. t['llvocalicvowelsigndeva'] = 0x0963;
  11021. t['lmiddletilde'] = 0x026B;
  11022. t['lmonospace'] = 0xFF4C;
  11023. t['lmsquare'] = 0x33D0;
  11024. t['lochulathai'] = 0x0E2C;
  11025. t['logicaland'] = 0x2227;
  11026. t['logicalnot'] = 0x00AC;
  11027. t['logicalnotreversed'] = 0x2310;
  11028. t['logicalor'] = 0x2228;
  11029. t['lolingthai'] = 0x0E25;
  11030. t['longs'] = 0x017F;
  11031. t['lowlinecenterline'] = 0xFE4E;
  11032. t['lowlinecmb'] = 0x0332;
  11033. t['lowlinedashed'] = 0xFE4D;
  11034. t['lozenge'] = 0x25CA;
  11035. t['lparen'] = 0x24A7;
  11036. t['lslash'] = 0x0142;
  11037. t['lsquare'] = 0x2113;
  11038. t['lsuperior'] = 0xF6EE;
  11039. t['ltshade'] = 0x2591;
  11040. t['luthai'] = 0x0E26;
  11041. t['lvocalicbengali'] = 0x098C;
  11042. t['lvocalicdeva'] = 0x090C;
  11043. t['lvocalicvowelsignbengali'] = 0x09E2;
  11044. t['lvocalicvowelsigndeva'] = 0x0962;
  11045. t['lxsquare'] = 0x33D3;
  11046. t['m'] = 0x006D;
  11047. t['mabengali'] = 0x09AE;
  11048. t['macron'] = 0x00AF;
  11049. t['macronbelowcmb'] = 0x0331;
  11050. t['macroncmb'] = 0x0304;
  11051. t['macronlowmod'] = 0x02CD;
  11052. t['macronmonospace'] = 0xFFE3;
  11053. t['macute'] = 0x1E3F;
  11054. t['madeva'] = 0x092E;
  11055. t['magujarati'] = 0x0AAE;
  11056. t['magurmukhi'] = 0x0A2E;
  11057. t['mahapakhhebrew'] = 0x05A4;
  11058. t['mahapakhlefthebrew'] = 0x05A4;
  11059. t['mahiragana'] = 0x307E;
  11060. t['maichattawalowleftthai'] = 0xF895;
  11061. t['maichattawalowrightthai'] = 0xF894;
  11062. t['maichattawathai'] = 0x0E4B;
  11063. t['maichattawaupperleftthai'] = 0xF893;
  11064. t['maieklowleftthai'] = 0xF88C;
  11065. t['maieklowrightthai'] = 0xF88B;
  11066. t['maiekthai'] = 0x0E48;
  11067. t['maiekupperleftthai'] = 0xF88A;
  11068. t['maihanakatleftthai'] = 0xF884;
  11069. t['maihanakatthai'] = 0x0E31;
  11070. t['maitaikhuleftthai'] = 0xF889;
  11071. t['maitaikhuthai'] = 0x0E47;
  11072. t['maitholowleftthai'] = 0xF88F;
  11073. t['maitholowrightthai'] = 0xF88E;
  11074. t['maithothai'] = 0x0E49;
  11075. t['maithoupperleftthai'] = 0xF88D;
  11076. t['maitrilowleftthai'] = 0xF892;
  11077. t['maitrilowrightthai'] = 0xF891;
  11078. t['maitrithai'] = 0x0E4A;
  11079. t['maitriupperleftthai'] = 0xF890;
  11080. t['maiyamokthai'] = 0x0E46;
  11081. t['makatakana'] = 0x30DE;
  11082. t['makatakanahalfwidth'] = 0xFF8F;
  11083. t['male'] = 0x2642;
  11084. t['mansyonsquare'] = 0x3347;
  11085. t['maqafhebrew'] = 0x05BE;
  11086. t['mars'] = 0x2642;
  11087. t['masoracirclehebrew'] = 0x05AF;
  11088. t['masquare'] = 0x3383;
  11089. t['mbopomofo'] = 0x3107;
  11090. t['mbsquare'] = 0x33D4;
  11091. t['mcircle'] = 0x24DC;
  11092. t['mcubedsquare'] = 0x33A5;
  11093. t['mdotaccent'] = 0x1E41;
  11094. t['mdotbelow'] = 0x1E43;
  11095. t['meemarabic'] = 0x0645;
  11096. t['meemfinalarabic'] = 0xFEE2;
  11097. t['meeminitialarabic'] = 0xFEE3;
  11098. t['meemmedialarabic'] = 0xFEE4;
  11099. t['meemmeeminitialarabic'] = 0xFCD1;
  11100. t['meemmeemisolatedarabic'] = 0xFC48;
  11101. t['meetorusquare'] = 0x334D;
  11102. t['mehiragana'] = 0x3081;
  11103. t['meizierasquare'] = 0x337E;
  11104. t['mekatakana'] = 0x30E1;
  11105. t['mekatakanahalfwidth'] = 0xFF92;
  11106. t['mem'] = 0x05DE;
  11107. t['memdagesh'] = 0xFB3E;
  11108. t['memdageshhebrew'] = 0xFB3E;
  11109. t['memhebrew'] = 0x05DE;
  11110. t['menarmenian'] = 0x0574;
  11111. t['merkhahebrew'] = 0x05A5;
  11112. t['merkhakefulahebrew'] = 0x05A6;
  11113. t['merkhakefulalefthebrew'] = 0x05A6;
  11114. t['merkhalefthebrew'] = 0x05A5;
  11115. t['mhook'] = 0x0271;
  11116. t['mhzsquare'] = 0x3392;
  11117. t['middledotkatakanahalfwidth'] = 0xFF65;
  11118. t['middot'] = 0x00B7;
  11119. t['mieumacirclekorean'] = 0x3272;
  11120. t['mieumaparenkorean'] = 0x3212;
  11121. t['mieumcirclekorean'] = 0x3264;
  11122. t['mieumkorean'] = 0x3141;
  11123. t['mieumpansioskorean'] = 0x3170;
  11124. t['mieumparenkorean'] = 0x3204;
  11125. t['mieumpieupkorean'] = 0x316E;
  11126. t['mieumsioskorean'] = 0x316F;
  11127. t['mihiragana'] = 0x307F;
  11128. t['mikatakana'] = 0x30DF;
  11129. t['mikatakanahalfwidth'] = 0xFF90;
  11130. t['minus'] = 0x2212;
  11131. t['minusbelowcmb'] = 0x0320;
  11132. t['minuscircle'] = 0x2296;
  11133. t['minusmod'] = 0x02D7;
  11134. t['minusplus'] = 0x2213;
  11135. t['minute'] = 0x2032;
  11136. t['miribaarusquare'] = 0x334A;
  11137. t['mirisquare'] = 0x3349;
  11138. t['mlonglegturned'] = 0x0270;
  11139. t['mlsquare'] = 0x3396;
  11140. t['mmcubedsquare'] = 0x33A3;
  11141. t['mmonospace'] = 0xFF4D;
  11142. t['mmsquaredsquare'] = 0x339F;
  11143. t['mohiragana'] = 0x3082;
  11144. t['mohmsquare'] = 0x33C1;
  11145. t['mokatakana'] = 0x30E2;
  11146. t['mokatakanahalfwidth'] = 0xFF93;
  11147. t['molsquare'] = 0x33D6;
  11148. t['momathai'] = 0x0E21;
  11149. t['moverssquare'] = 0x33A7;
  11150. t['moverssquaredsquare'] = 0x33A8;
  11151. t['mparen'] = 0x24A8;
  11152. t['mpasquare'] = 0x33AB;
  11153. t['mssquare'] = 0x33B3;
  11154. t['msuperior'] = 0xF6EF;
  11155. t['mturned'] = 0x026F;
  11156. t['mu'] = 0x00B5;
  11157. t['mu1'] = 0x00B5;
  11158. t['muasquare'] = 0x3382;
  11159. t['muchgreater'] = 0x226B;
  11160. t['muchless'] = 0x226A;
  11161. t['mufsquare'] = 0x338C;
  11162. t['mugreek'] = 0x03BC;
  11163. t['mugsquare'] = 0x338D;
  11164. t['muhiragana'] = 0x3080;
  11165. t['mukatakana'] = 0x30E0;
  11166. t['mukatakanahalfwidth'] = 0xFF91;
  11167. t['mulsquare'] = 0x3395;
  11168. t['multiply'] = 0x00D7;
  11169. t['mumsquare'] = 0x339B;
  11170. t['munahhebrew'] = 0x05A3;
  11171. t['munahlefthebrew'] = 0x05A3;
  11172. t['musicalnote'] = 0x266A;
  11173. t['musicalnotedbl'] = 0x266B;
  11174. t['musicflatsign'] = 0x266D;
  11175. t['musicsharpsign'] = 0x266F;
  11176. t['mussquare'] = 0x33B2;
  11177. t['muvsquare'] = 0x33B6;
  11178. t['muwsquare'] = 0x33BC;
  11179. t['mvmegasquare'] = 0x33B9;
  11180. t['mvsquare'] = 0x33B7;
  11181. t['mwmegasquare'] = 0x33BF;
  11182. t['mwsquare'] = 0x33BD;
  11183. t['n'] = 0x006E;
  11184. t['nabengali'] = 0x09A8;
  11185. t['nabla'] = 0x2207;
  11186. t['nacute'] = 0x0144;
  11187. t['nadeva'] = 0x0928;
  11188. t['nagujarati'] = 0x0AA8;
  11189. t['nagurmukhi'] = 0x0A28;
  11190. t['nahiragana'] = 0x306A;
  11191. t['nakatakana'] = 0x30CA;
  11192. t['nakatakanahalfwidth'] = 0xFF85;
  11193. t['napostrophe'] = 0x0149;
  11194. t['nasquare'] = 0x3381;
  11195. t['nbopomofo'] = 0x310B;
  11196. t['nbspace'] = 0x00A0;
  11197. t['ncaron'] = 0x0148;
  11198. t['ncedilla'] = 0x0146;
  11199. t['ncircle'] = 0x24DD;
  11200. t['ncircumflexbelow'] = 0x1E4B;
  11201. t['ncommaaccent'] = 0x0146;
  11202. t['ndotaccent'] = 0x1E45;
  11203. t['ndotbelow'] = 0x1E47;
  11204. t['nehiragana'] = 0x306D;
  11205. t['nekatakana'] = 0x30CD;
  11206. t['nekatakanahalfwidth'] = 0xFF88;
  11207. t['newsheqelsign'] = 0x20AA;
  11208. t['nfsquare'] = 0x338B;
  11209. t['ngabengali'] = 0x0999;
  11210. t['ngadeva'] = 0x0919;
  11211. t['ngagujarati'] = 0x0A99;
  11212. t['ngagurmukhi'] = 0x0A19;
  11213. t['ngonguthai'] = 0x0E07;
  11214. t['nhiragana'] = 0x3093;
  11215. t['nhookleft'] = 0x0272;
  11216. t['nhookretroflex'] = 0x0273;
  11217. t['nieunacirclekorean'] = 0x326F;
  11218. t['nieunaparenkorean'] = 0x320F;
  11219. t['nieuncieuckorean'] = 0x3135;
  11220. t['nieuncirclekorean'] = 0x3261;
  11221. t['nieunhieuhkorean'] = 0x3136;
  11222. t['nieunkorean'] = 0x3134;
  11223. t['nieunpansioskorean'] = 0x3168;
  11224. t['nieunparenkorean'] = 0x3201;
  11225. t['nieunsioskorean'] = 0x3167;
  11226. t['nieuntikeutkorean'] = 0x3166;
  11227. t['nihiragana'] = 0x306B;
  11228. t['nikatakana'] = 0x30CB;
  11229. t['nikatakanahalfwidth'] = 0xFF86;
  11230. t['nikhahitleftthai'] = 0xF899;
  11231. t['nikhahitthai'] = 0x0E4D;
  11232. t['nine'] = 0x0039;
  11233. t['ninearabic'] = 0x0669;
  11234. t['ninebengali'] = 0x09EF;
  11235. t['ninecircle'] = 0x2468;
  11236. t['ninecircleinversesansserif'] = 0x2792;
  11237. t['ninedeva'] = 0x096F;
  11238. t['ninegujarati'] = 0x0AEF;
  11239. t['ninegurmukhi'] = 0x0A6F;
  11240. t['ninehackarabic'] = 0x0669;
  11241. t['ninehangzhou'] = 0x3029;
  11242. t['nineideographicparen'] = 0x3228;
  11243. t['nineinferior'] = 0x2089;
  11244. t['ninemonospace'] = 0xFF19;
  11245. t['nineoldstyle'] = 0xF739;
  11246. t['nineparen'] = 0x247C;
  11247. t['nineperiod'] = 0x2490;
  11248. t['ninepersian'] = 0x06F9;
  11249. t['nineroman'] = 0x2178;
  11250. t['ninesuperior'] = 0x2079;
  11251. t['nineteencircle'] = 0x2472;
  11252. t['nineteenparen'] = 0x2486;
  11253. t['nineteenperiod'] = 0x249A;
  11254. t['ninethai'] = 0x0E59;
  11255. t['nj'] = 0x01CC;
  11256. t['njecyrillic'] = 0x045A;
  11257. t['nkatakana'] = 0x30F3;
  11258. t['nkatakanahalfwidth'] = 0xFF9D;
  11259. t['nlegrightlong'] = 0x019E;
  11260. t['nlinebelow'] = 0x1E49;
  11261. t['nmonospace'] = 0xFF4E;
  11262. t['nmsquare'] = 0x339A;
  11263. t['nnabengali'] = 0x09A3;
  11264. t['nnadeva'] = 0x0923;
  11265. t['nnagujarati'] = 0x0AA3;
  11266. t['nnagurmukhi'] = 0x0A23;
  11267. t['nnnadeva'] = 0x0929;
  11268. t['nohiragana'] = 0x306E;
  11269. t['nokatakana'] = 0x30CE;
  11270. t['nokatakanahalfwidth'] = 0xFF89;
  11271. t['nonbreakingspace'] = 0x00A0;
  11272. t['nonenthai'] = 0x0E13;
  11273. t['nonuthai'] = 0x0E19;
  11274. t['noonarabic'] = 0x0646;
  11275. t['noonfinalarabic'] = 0xFEE6;
  11276. t['noonghunnaarabic'] = 0x06BA;
  11277. t['noonghunnafinalarabic'] = 0xFB9F;
  11278. t['nooninitialarabic'] = 0xFEE7;
  11279. t['noonjeeminitialarabic'] = 0xFCD2;
  11280. t['noonjeemisolatedarabic'] = 0xFC4B;
  11281. t['noonmedialarabic'] = 0xFEE8;
  11282. t['noonmeeminitialarabic'] = 0xFCD5;
  11283. t['noonmeemisolatedarabic'] = 0xFC4E;
  11284. t['noonnoonfinalarabic'] = 0xFC8D;
  11285. t['notcontains'] = 0x220C;
  11286. t['notelement'] = 0x2209;
  11287. t['notelementof'] = 0x2209;
  11288. t['notequal'] = 0x2260;
  11289. t['notgreater'] = 0x226F;
  11290. t['notgreaternorequal'] = 0x2271;
  11291. t['notgreaternorless'] = 0x2279;
  11292. t['notidentical'] = 0x2262;
  11293. t['notless'] = 0x226E;
  11294. t['notlessnorequal'] = 0x2270;
  11295. t['notparallel'] = 0x2226;
  11296. t['notprecedes'] = 0x2280;
  11297. t['notsubset'] = 0x2284;
  11298. t['notsucceeds'] = 0x2281;
  11299. t['notsuperset'] = 0x2285;
  11300. t['nowarmenian'] = 0x0576;
  11301. t['nparen'] = 0x24A9;
  11302. t['nssquare'] = 0x33B1;
  11303. t['nsuperior'] = 0x207F;
  11304. t['ntilde'] = 0x00F1;
  11305. t['nu'] = 0x03BD;
  11306. t['nuhiragana'] = 0x306C;
  11307. t['nukatakana'] = 0x30CC;
  11308. t['nukatakanahalfwidth'] = 0xFF87;
  11309. t['nuktabengali'] = 0x09BC;
  11310. t['nuktadeva'] = 0x093C;
  11311. t['nuktagujarati'] = 0x0ABC;
  11312. t['nuktagurmukhi'] = 0x0A3C;
  11313. t['numbersign'] = 0x0023;
  11314. t['numbersignmonospace'] = 0xFF03;
  11315. t['numbersignsmall'] = 0xFE5F;
  11316. t['numeralsigngreek'] = 0x0374;
  11317. t['numeralsignlowergreek'] = 0x0375;
  11318. t['numero'] = 0x2116;
  11319. t['nun'] = 0x05E0;
  11320. t['nundagesh'] = 0xFB40;
  11321. t['nundageshhebrew'] = 0xFB40;
  11322. t['nunhebrew'] = 0x05E0;
  11323. t['nvsquare'] = 0x33B5;
  11324. t['nwsquare'] = 0x33BB;
  11325. t['nyabengali'] = 0x099E;
  11326. t['nyadeva'] = 0x091E;
  11327. t['nyagujarati'] = 0x0A9E;
  11328. t['nyagurmukhi'] = 0x0A1E;
  11329. t['o'] = 0x006F;
  11330. t['oacute'] = 0x00F3;
  11331. t['oangthai'] = 0x0E2D;
  11332. t['obarred'] = 0x0275;
  11333. t['obarredcyrillic'] = 0x04E9;
  11334. t['obarreddieresiscyrillic'] = 0x04EB;
  11335. t['obengali'] = 0x0993;
  11336. t['obopomofo'] = 0x311B;
  11337. t['obreve'] = 0x014F;
  11338. t['ocandradeva'] = 0x0911;
  11339. t['ocandragujarati'] = 0x0A91;
  11340. t['ocandravowelsigndeva'] = 0x0949;
  11341. t['ocandravowelsigngujarati'] = 0x0AC9;
  11342. t['ocaron'] = 0x01D2;
  11343. t['ocircle'] = 0x24DE;
  11344. t['ocircumflex'] = 0x00F4;
  11345. t['ocircumflexacute'] = 0x1ED1;
  11346. t['ocircumflexdotbelow'] = 0x1ED9;
  11347. t['ocircumflexgrave'] = 0x1ED3;
  11348. t['ocircumflexhookabove'] = 0x1ED5;
  11349. t['ocircumflextilde'] = 0x1ED7;
  11350. t['ocyrillic'] = 0x043E;
  11351. t['odblacute'] = 0x0151;
  11352. t['odblgrave'] = 0x020D;
  11353. t['odeva'] = 0x0913;
  11354. t['odieresis'] = 0x00F6;
  11355. t['odieresiscyrillic'] = 0x04E7;
  11356. t['odotbelow'] = 0x1ECD;
  11357. t['oe'] = 0x0153;
  11358. t['oekorean'] = 0x315A;
  11359. t['ogonek'] = 0x02DB;
  11360. t['ogonekcmb'] = 0x0328;
  11361. t['ograve'] = 0x00F2;
  11362. t['ogujarati'] = 0x0A93;
  11363. t['oharmenian'] = 0x0585;
  11364. t['ohiragana'] = 0x304A;
  11365. t['ohookabove'] = 0x1ECF;
  11366. t['ohorn'] = 0x01A1;
  11367. t['ohornacute'] = 0x1EDB;
  11368. t['ohorndotbelow'] = 0x1EE3;
  11369. t['ohorngrave'] = 0x1EDD;
  11370. t['ohornhookabove'] = 0x1EDF;
  11371. t['ohorntilde'] = 0x1EE1;
  11372. t['ohungarumlaut'] = 0x0151;
  11373. t['oi'] = 0x01A3;
  11374. t['oinvertedbreve'] = 0x020F;
  11375. t['okatakana'] = 0x30AA;
  11376. t['okatakanahalfwidth'] = 0xFF75;
  11377. t['okorean'] = 0x3157;
  11378. t['olehebrew'] = 0x05AB;
  11379. t['omacron'] = 0x014D;
  11380. t['omacronacute'] = 0x1E53;
  11381. t['omacrongrave'] = 0x1E51;
  11382. t['omdeva'] = 0x0950;
  11383. t['omega'] = 0x03C9;
  11384. t['omega1'] = 0x03D6;
  11385. t['omegacyrillic'] = 0x0461;
  11386. t['omegalatinclosed'] = 0x0277;
  11387. t['omegaroundcyrillic'] = 0x047B;
  11388. t['omegatitlocyrillic'] = 0x047D;
  11389. t['omegatonos'] = 0x03CE;
  11390. t['omgujarati'] = 0x0AD0;
  11391. t['omicron'] = 0x03BF;
  11392. t['omicrontonos'] = 0x03CC;
  11393. t['omonospace'] = 0xFF4F;
  11394. t['one'] = 0x0031;
  11395. t['onearabic'] = 0x0661;
  11396. t['onebengali'] = 0x09E7;
  11397. t['onecircle'] = 0x2460;
  11398. t['onecircleinversesansserif'] = 0x278A;
  11399. t['onedeva'] = 0x0967;
  11400. t['onedotenleader'] = 0x2024;
  11401. t['oneeighth'] = 0x215B;
  11402. t['onefitted'] = 0xF6DC;
  11403. t['onegujarati'] = 0x0AE7;
  11404. t['onegurmukhi'] = 0x0A67;
  11405. t['onehackarabic'] = 0x0661;
  11406. t['onehalf'] = 0x00BD;
  11407. t['onehangzhou'] = 0x3021;
  11408. t['oneideographicparen'] = 0x3220;
  11409. t['oneinferior'] = 0x2081;
  11410. t['onemonospace'] = 0xFF11;
  11411. t['onenumeratorbengali'] = 0x09F4;
  11412. t['oneoldstyle'] = 0xF731;
  11413. t['oneparen'] = 0x2474;
  11414. t['oneperiod'] = 0x2488;
  11415. t['onepersian'] = 0x06F1;
  11416. t['onequarter'] = 0x00BC;
  11417. t['oneroman'] = 0x2170;
  11418. t['onesuperior'] = 0x00B9;
  11419. t['onethai'] = 0x0E51;
  11420. t['onethird'] = 0x2153;
  11421. t['oogonek'] = 0x01EB;
  11422. t['oogonekmacron'] = 0x01ED;
  11423. t['oogurmukhi'] = 0x0A13;
  11424. t['oomatragurmukhi'] = 0x0A4B;
  11425. t['oopen'] = 0x0254;
  11426. t['oparen'] = 0x24AA;
  11427. t['openbullet'] = 0x25E6;
  11428. t['option'] = 0x2325;
  11429. t['ordfeminine'] = 0x00AA;
  11430. t['ordmasculine'] = 0x00BA;
  11431. t['orthogonal'] = 0x221F;
  11432. t['oshortdeva'] = 0x0912;
  11433. t['oshortvowelsigndeva'] = 0x094A;
  11434. t['oslash'] = 0x00F8;
  11435. t['oslashacute'] = 0x01FF;
  11436. t['osmallhiragana'] = 0x3049;
  11437. t['osmallkatakana'] = 0x30A9;
  11438. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11439. t['ostrokeacute'] = 0x01FF;
  11440. t['osuperior'] = 0xF6F0;
  11441. t['otcyrillic'] = 0x047F;
  11442. t['otilde'] = 0x00F5;
  11443. t['otildeacute'] = 0x1E4D;
  11444. t['otildedieresis'] = 0x1E4F;
  11445. t['oubopomofo'] = 0x3121;
  11446. t['overline'] = 0x203E;
  11447. t['overlinecenterline'] = 0xFE4A;
  11448. t['overlinecmb'] = 0x0305;
  11449. t['overlinedashed'] = 0xFE49;
  11450. t['overlinedblwavy'] = 0xFE4C;
  11451. t['overlinewavy'] = 0xFE4B;
  11452. t['overscore'] = 0x00AF;
  11453. t['ovowelsignbengali'] = 0x09CB;
  11454. t['ovowelsigndeva'] = 0x094B;
  11455. t['ovowelsigngujarati'] = 0x0ACB;
  11456. t['p'] = 0x0070;
  11457. t['paampssquare'] = 0x3380;
  11458. t['paasentosquare'] = 0x332B;
  11459. t['pabengali'] = 0x09AA;
  11460. t['pacute'] = 0x1E55;
  11461. t['padeva'] = 0x092A;
  11462. t['pagedown'] = 0x21DF;
  11463. t['pageup'] = 0x21DE;
  11464. t['pagujarati'] = 0x0AAA;
  11465. t['pagurmukhi'] = 0x0A2A;
  11466. t['pahiragana'] = 0x3071;
  11467. t['paiyannoithai'] = 0x0E2F;
  11468. t['pakatakana'] = 0x30D1;
  11469. t['palatalizationcyrilliccmb'] = 0x0484;
  11470. t['palochkacyrillic'] = 0x04C0;
  11471. t['pansioskorean'] = 0x317F;
  11472. t['paragraph'] = 0x00B6;
  11473. t['parallel'] = 0x2225;
  11474. t['parenleft'] = 0x0028;
  11475. t['parenleftaltonearabic'] = 0xFD3E;
  11476. t['parenleftbt'] = 0xF8ED;
  11477. t['parenleftex'] = 0xF8EC;
  11478. t['parenleftinferior'] = 0x208D;
  11479. t['parenleftmonospace'] = 0xFF08;
  11480. t['parenleftsmall'] = 0xFE59;
  11481. t['parenleftsuperior'] = 0x207D;
  11482. t['parenlefttp'] = 0xF8EB;
  11483. t['parenleftvertical'] = 0xFE35;
  11484. t['parenright'] = 0x0029;
  11485. t['parenrightaltonearabic'] = 0xFD3F;
  11486. t['parenrightbt'] = 0xF8F8;
  11487. t['parenrightex'] = 0xF8F7;
  11488. t['parenrightinferior'] = 0x208E;
  11489. t['parenrightmonospace'] = 0xFF09;
  11490. t['parenrightsmall'] = 0xFE5A;
  11491. t['parenrightsuperior'] = 0x207E;
  11492. t['parenrighttp'] = 0xF8F6;
  11493. t['parenrightvertical'] = 0xFE36;
  11494. t['partialdiff'] = 0x2202;
  11495. t['paseqhebrew'] = 0x05C0;
  11496. t['pashtahebrew'] = 0x0599;
  11497. t['pasquare'] = 0x33A9;
  11498. t['patah'] = 0x05B7;
  11499. t['patah11'] = 0x05B7;
  11500. t['patah1d'] = 0x05B7;
  11501. t['patah2a'] = 0x05B7;
  11502. t['patahhebrew'] = 0x05B7;
  11503. t['patahnarrowhebrew'] = 0x05B7;
  11504. t['patahquarterhebrew'] = 0x05B7;
  11505. t['patahwidehebrew'] = 0x05B7;
  11506. t['pazerhebrew'] = 0x05A1;
  11507. t['pbopomofo'] = 0x3106;
  11508. t['pcircle'] = 0x24DF;
  11509. t['pdotaccent'] = 0x1E57;
  11510. t['pe'] = 0x05E4;
  11511. t['pecyrillic'] = 0x043F;
  11512. t['pedagesh'] = 0xFB44;
  11513. t['pedageshhebrew'] = 0xFB44;
  11514. t['peezisquare'] = 0x333B;
  11515. t['pefinaldageshhebrew'] = 0xFB43;
  11516. t['peharabic'] = 0x067E;
  11517. t['peharmenian'] = 0x057A;
  11518. t['pehebrew'] = 0x05E4;
  11519. t['pehfinalarabic'] = 0xFB57;
  11520. t['pehinitialarabic'] = 0xFB58;
  11521. t['pehiragana'] = 0x307A;
  11522. t['pehmedialarabic'] = 0xFB59;
  11523. t['pekatakana'] = 0x30DA;
  11524. t['pemiddlehookcyrillic'] = 0x04A7;
  11525. t['perafehebrew'] = 0xFB4E;
  11526. t['percent'] = 0x0025;
  11527. t['percentarabic'] = 0x066A;
  11528. t['percentmonospace'] = 0xFF05;
  11529. t['percentsmall'] = 0xFE6A;
  11530. t['period'] = 0x002E;
  11531. t['periodarmenian'] = 0x0589;
  11532. t['periodcentered'] = 0x00B7;
  11533. t['periodhalfwidth'] = 0xFF61;
  11534. t['periodinferior'] = 0xF6E7;
  11535. t['periodmonospace'] = 0xFF0E;
  11536. t['periodsmall'] = 0xFE52;
  11537. t['periodsuperior'] = 0xF6E8;
  11538. t['perispomenigreekcmb'] = 0x0342;
  11539. t['perpendicular'] = 0x22A5;
  11540. t['perthousand'] = 0x2030;
  11541. t['peseta'] = 0x20A7;
  11542. t['pfsquare'] = 0x338A;
  11543. t['phabengali'] = 0x09AB;
  11544. t['phadeva'] = 0x092B;
  11545. t['phagujarati'] = 0x0AAB;
  11546. t['phagurmukhi'] = 0x0A2B;
  11547. t['phi'] = 0x03C6;
  11548. t['phi1'] = 0x03D5;
  11549. t['phieuphacirclekorean'] = 0x327A;
  11550. t['phieuphaparenkorean'] = 0x321A;
  11551. t['phieuphcirclekorean'] = 0x326C;
  11552. t['phieuphkorean'] = 0x314D;
  11553. t['phieuphparenkorean'] = 0x320C;
  11554. t['philatin'] = 0x0278;
  11555. t['phinthuthai'] = 0x0E3A;
  11556. t['phisymbolgreek'] = 0x03D5;
  11557. t['phook'] = 0x01A5;
  11558. t['phophanthai'] = 0x0E1E;
  11559. t['phophungthai'] = 0x0E1C;
  11560. t['phosamphaothai'] = 0x0E20;
  11561. t['pi'] = 0x03C0;
  11562. t['pieupacirclekorean'] = 0x3273;
  11563. t['pieupaparenkorean'] = 0x3213;
  11564. t['pieupcieuckorean'] = 0x3176;
  11565. t['pieupcirclekorean'] = 0x3265;
  11566. t['pieupkiyeokkorean'] = 0x3172;
  11567. t['pieupkorean'] = 0x3142;
  11568. t['pieupparenkorean'] = 0x3205;
  11569. t['pieupsioskiyeokkorean'] = 0x3174;
  11570. t['pieupsioskorean'] = 0x3144;
  11571. t['pieupsiostikeutkorean'] = 0x3175;
  11572. t['pieupthieuthkorean'] = 0x3177;
  11573. t['pieuptikeutkorean'] = 0x3173;
  11574. t['pihiragana'] = 0x3074;
  11575. t['pikatakana'] = 0x30D4;
  11576. t['pisymbolgreek'] = 0x03D6;
  11577. t['piwrarmenian'] = 0x0583;
  11578. t['plus'] = 0x002B;
  11579. t['plusbelowcmb'] = 0x031F;
  11580. t['pluscircle'] = 0x2295;
  11581. t['plusminus'] = 0x00B1;
  11582. t['plusmod'] = 0x02D6;
  11583. t['plusmonospace'] = 0xFF0B;
  11584. t['plussmall'] = 0xFE62;
  11585. t['plussuperior'] = 0x207A;
  11586. t['pmonospace'] = 0xFF50;
  11587. t['pmsquare'] = 0x33D8;
  11588. t['pohiragana'] = 0x307D;
  11589. t['pointingindexdownwhite'] = 0x261F;
  11590. t['pointingindexleftwhite'] = 0x261C;
  11591. t['pointingindexrightwhite'] = 0x261E;
  11592. t['pointingindexupwhite'] = 0x261D;
  11593. t['pokatakana'] = 0x30DD;
  11594. t['poplathai'] = 0x0E1B;
  11595. t['postalmark'] = 0x3012;
  11596. t['postalmarkface'] = 0x3020;
  11597. t['pparen'] = 0x24AB;
  11598. t['precedes'] = 0x227A;
  11599. t['prescription'] = 0x211E;
  11600. t['primemod'] = 0x02B9;
  11601. t['primereversed'] = 0x2035;
  11602. t['product'] = 0x220F;
  11603. t['projective'] = 0x2305;
  11604. t['prolongedkana'] = 0x30FC;
  11605. t['propellor'] = 0x2318;
  11606. t['propersubset'] = 0x2282;
  11607. t['propersuperset'] = 0x2283;
  11608. t['proportion'] = 0x2237;
  11609. t['proportional'] = 0x221D;
  11610. t['psi'] = 0x03C8;
  11611. t['psicyrillic'] = 0x0471;
  11612. t['psilipneumatacyrilliccmb'] = 0x0486;
  11613. t['pssquare'] = 0x33B0;
  11614. t['puhiragana'] = 0x3077;
  11615. t['pukatakana'] = 0x30D7;
  11616. t['pvsquare'] = 0x33B4;
  11617. t['pwsquare'] = 0x33BA;
  11618. t['q'] = 0x0071;
  11619. t['qadeva'] = 0x0958;
  11620. t['qadmahebrew'] = 0x05A8;
  11621. t['qafarabic'] = 0x0642;
  11622. t['qaffinalarabic'] = 0xFED6;
  11623. t['qafinitialarabic'] = 0xFED7;
  11624. t['qafmedialarabic'] = 0xFED8;
  11625. t['qamats'] = 0x05B8;
  11626. t['qamats10'] = 0x05B8;
  11627. t['qamats1a'] = 0x05B8;
  11628. t['qamats1c'] = 0x05B8;
  11629. t['qamats27'] = 0x05B8;
  11630. t['qamats29'] = 0x05B8;
  11631. t['qamats33'] = 0x05B8;
  11632. t['qamatsde'] = 0x05B8;
  11633. t['qamatshebrew'] = 0x05B8;
  11634. t['qamatsnarrowhebrew'] = 0x05B8;
  11635. t['qamatsqatanhebrew'] = 0x05B8;
  11636. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11637. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11638. t['qamatsqatanwidehebrew'] = 0x05B8;
  11639. t['qamatsquarterhebrew'] = 0x05B8;
  11640. t['qamatswidehebrew'] = 0x05B8;
  11641. t['qarneyparahebrew'] = 0x059F;
  11642. t['qbopomofo'] = 0x3111;
  11643. t['qcircle'] = 0x24E0;
  11644. t['qhook'] = 0x02A0;
  11645. t['qmonospace'] = 0xFF51;
  11646. t['qof'] = 0x05E7;
  11647. t['qofdagesh'] = 0xFB47;
  11648. t['qofdageshhebrew'] = 0xFB47;
  11649. t['qofhebrew'] = 0x05E7;
  11650. t['qparen'] = 0x24AC;
  11651. t['quarternote'] = 0x2669;
  11652. t['qubuts'] = 0x05BB;
  11653. t['qubuts18'] = 0x05BB;
  11654. t['qubuts25'] = 0x05BB;
  11655. t['qubuts31'] = 0x05BB;
  11656. t['qubutshebrew'] = 0x05BB;
  11657. t['qubutsnarrowhebrew'] = 0x05BB;
  11658. t['qubutsquarterhebrew'] = 0x05BB;
  11659. t['qubutswidehebrew'] = 0x05BB;
  11660. t['question'] = 0x003F;
  11661. t['questionarabic'] = 0x061F;
  11662. t['questionarmenian'] = 0x055E;
  11663. t['questiondown'] = 0x00BF;
  11664. t['questiondownsmall'] = 0xF7BF;
  11665. t['questiongreek'] = 0x037E;
  11666. t['questionmonospace'] = 0xFF1F;
  11667. t['questionsmall'] = 0xF73F;
  11668. t['quotedbl'] = 0x0022;
  11669. t['quotedblbase'] = 0x201E;
  11670. t['quotedblleft'] = 0x201C;
  11671. t['quotedblmonospace'] = 0xFF02;
  11672. t['quotedblprime'] = 0x301E;
  11673. t['quotedblprimereversed'] = 0x301D;
  11674. t['quotedblright'] = 0x201D;
  11675. t['quoteleft'] = 0x2018;
  11676. t['quoteleftreversed'] = 0x201B;
  11677. t['quotereversed'] = 0x201B;
  11678. t['quoteright'] = 0x2019;
  11679. t['quoterightn'] = 0x0149;
  11680. t['quotesinglbase'] = 0x201A;
  11681. t['quotesingle'] = 0x0027;
  11682. t['quotesinglemonospace'] = 0xFF07;
  11683. t['r'] = 0x0072;
  11684. t['raarmenian'] = 0x057C;
  11685. t['rabengali'] = 0x09B0;
  11686. t['racute'] = 0x0155;
  11687. t['radeva'] = 0x0930;
  11688. t['radical'] = 0x221A;
  11689. t['radicalex'] = 0xF8E5;
  11690. t['radoverssquare'] = 0x33AE;
  11691. t['radoverssquaredsquare'] = 0x33AF;
  11692. t['radsquare'] = 0x33AD;
  11693. t['rafe'] = 0x05BF;
  11694. t['rafehebrew'] = 0x05BF;
  11695. t['ragujarati'] = 0x0AB0;
  11696. t['ragurmukhi'] = 0x0A30;
  11697. t['rahiragana'] = 0x3089;
  11698. t['rakatakana'] = 0x30E9;
  11699. t['rakatakanahalfwidth'] = 0xFF97;
  11700. t['ralowerdiagonalbengali'] = 0x09F1;
  11701. t['ramiddlediagonalbengali'] = 0x09F0;
  11702. t['ramshorn'] = 0x0264;
  11703. t['ratio'] = 0x2236;
  11704. t['rbopomofo'] = 0x3116;
  11705. t['rcaron'] = 0x0159;
  11706. t['rcedilla'] = 0x0157;
  11707. t['rcircle'] = 0x24E1;
  11708. t['rcommaaccent'] = 0x0157;
  11709. t['rdblgrave'] = 0x0211;
  11710. t['rdotaccent'] = 0x1E59;
  11711. t['rdotbelow'] = 0x1E5B;
  11712. t['rdotbelowmacron'] = 0x1E5D;
  11713. t['referencemark'] = 0x203B;
  11714. t['reflexsubset'] = 0x2286;
  11715. t['reflexsuperset'] = 0x2287;
  11716. t['registered'] = 0x00AE;
  11717. t['registersans'] = 0xF8E8;
  11718. t['registerserif'] = 0xF6DA;
  11719. t['reharabic'] = 0x0631;
  11720. t['reharmenian'] = 0x0580;
  11721. t['rehfinalarabic'] = 0xFEAE;
  11722. t['rehiragana'] = 0x308C;
  11723. t['rekatakana'] = 0x30EC;
  11724. t['rekatakanahalfwidth'] = 0xFF9A;
  11725. t['resh'] = 0x05E8;
  11726. t['reshdageshhebrew'] = 0xFB48;
  11727. t['reshhebrew'] = 0x05E8;
  11728. t['reversedtilde'] = 0x223D;
  11729. t['reviahebrew'] = 0x0597;
  11730. t['reviamugrashhebrew'] = 0x0597;
  11731. t['revlogicalnot'] = 0x2310;
  11732. t['rfishhook'] = 0x027E;
  11733. t['rfishhookreversed'] = 0x027F;
  11734. t['rhabengali'] = 0x09DD;
  11735. t['rhadeva'] = 0x095D;
  11736. t['rho'] = 0x03C1;
  11737. t['rhook'] = 0x027D;
  11738. t['rhookturned'] = 0x027B;
  11739. t['rhookturnedsuperior'] = 0x02B5;
  11740. t['rhosymbolgreek'] = 0x03F1;
  11741. t['rhotichookmod'] = 0x02DE;
  11742. t['rieulacirclekorean'] = 0x3271;
  11743. t['rieulaparenkorean'] = 0x3211;
  11744. t['rieulcirclekorean'] = 0x3263;
  11745. t['rieulhieuhkorean'] = 0x3140;
  11746. t['rieulkiyeokkorean'] = 0x313A;
  11747. t['rieulkiyeoksioskorean'] = 0x3169;
  11748. t['rieulkorean'] = 0x3139;
  11749. t['rieulmieumkorean'] = 0x313B;
  11750. t['rieulpansioskorean'] = 0x316C;
  11751. t['rieulparenkorean'] = 0x3203;
  11752. t['rieulphieuphkorean'] = 0x313F;
  11753. t['rieulpieupkorean'] = 0x313C;
  11754. t['rieulpieupsioskorean'] = 0x316B;
  11755. t['rieulsioskorean'] = 0x313D;
  11756. t['rieulthieuthkorean'] = 0x313E;
  11757. t['rieultikeutkorean'] = 0x316A;
  11758. t['rieulyeorinhieuhkorean'] = 0x316D;
  11759. t['rightangle'] = 0x221F;
  11760. t['righttackbelowcmb'] = 0x0319;
  11761. t['righttriangle'] = 0x22BF;
  11762. t['rihiragana'] = 0x308A;
  11763. t['rikatakana'] = 0x30EA;
  11764. t['rikatakanahalfwidth'] = 0xFF98;
  11765. t['ring'] = 0x02DA;
  11766. t['ringbelowcmb'] = 0x0325;
  11767. t['ringcmb'] = 0x030A;
  11768. t['ringhalfleft'] = 0x02BF;
  11769. t['ringhalfleftarmenian'] = 0x0559;
  11770. t['ringhalfleftbelowcmb'] = 0x031C;
  11771. t['ringhalfleftcentered'] = 0x02D3;
  11772. t['ringhalfright'] = 0x02BE;
  11773. t['ringhalfrightbelowcmb'] = 0x0339;
  11774. t['ringhalfrightcentered'] = 0x02D2;
  11775. t['rinvertedbreve'] = 0x0213;
  11776. t['rittorusquare'] = 0x3351;
  11777. t['rlinebelow'] = 0x1E5F;
  11778. t['rlongleg'] = 0x027C;
  11779. t['rlonglegturned'] = 0x027A;
  11780. t['rmonospace'] = 0xFF52;
  11781. t['rohiragana'] = 0x308D;
  11782. t['rokatakana'] = 0x30ED;
  11783. t['rokatakanahalfwidth'] = 0xFF9B;
  11784. t['roruathai'] = 0x0E23;
  11785. t['rparen'] = 0x24AD;
  11786. t['rrabengali'] = 0x09DC;
  11787. t['rradeva'] = 0x0931;
  11788. t['rragurmukhi'] = 0x0A5C;
  11789. t['rreharabic'] = 0x0691;
  11790. t['rrehfinalarabic'] = 0xFB8D;
  11791. t['rrvocalicbengali'] = 0x09E0;
  11792. t['rrvocalicdeva'] = 0x0960;
  11793. t['rrvocalicgujarati'] = 0x0AE0;
  11794. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11795. t['rrvocalicvowelsigndeva'] = 0x0944;
  11796. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11797. t['rsuperior'] = 0xF6F1;
  11798. t['rtblock'] = 0x2590;
  11799. t['rturned'] = 0x0279;
  11800. t['rturnedsuperior'] = 0x02B4;
  11801. t['ruhiragana'] = 0x308B;
  11802. t['rukatakana'] = 0x30EB;
  11803. t['rukatakanahalfwidth'] = 0xFF99;
  11804. t['rupeemarkbengali'] = 0x09F2;
  11805. t['rupeesignbengali'] = 0x09F3;
  11806. t['rupiah'] = 0xF6DD;
  11807. t['ruthai'] = 0x0E24;
  11808. t['rvocalicbengali'] = 0x098B;
  11809. t['rvocalicdeva'] = 0x090B;
  11810. t['rvocalicgujarati'] = 0x0A8B;
  11811. t['rvocalicvowelsignbengali'] = 0x09C3;
  11812. t['rvocalicvowelsigndeva'] = 0x0943;
  11813. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11814. t['s'] = 0x0073;
  11815. t['sabengali'] = 0x09B8;
  11816. t['sacute'] = 0x015B;
  11817. t['sacutedotaccent'] = 0x1E65;
  11818. t['sadarabic'] = 0x0635;
  11819. t['sadeva'] = 0x0938;
  11820. t['sadfinalarabic'] = 0xFEBA;
  11821. t['sadinitialarabic'] = 0xFEBB;
  11822. t['sadmedialarabic'] = 0xFEBC;
  11823. t['sagujarati'] = 0x0AB8;
  11824. t['sagurmukhi'] = 0x0A38;
  11825. t['sahiragana'] = 0x3055;
  11826. t['sakatakana'] = 0x30B5;
  11827. t['sakatakanahalfwidth'] = 0xFF7B;
  11828. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11829. t['samekh'] = 0x05E1;
  11830. t['samekhdagesh'] = 0xFB41;
  11831. t['samekhdageshhebrew'] = 0xFB41;
  11832. t['samekhhebrew'] = 0x05E1;
  11833. t['saraaathai'] = 0x0E32;
  11834. t['saraaethai'] = 0x0E41;
  11835. t['saraaimaimalaithai'] = 0x0E44;
  11836. t['saraaimaimuanthai'] = 0x0E43;
  11837. t['saraamthai'] = 0x0E33;
  11838. t['saraathai'] = 0x0E30;
  11839. t['saraethai'] = 0x0E40;
  11840. t['saraiileftthai'] = 0xF886;
  11841. t['saraiithai'] = 0x0E35;
  11842. t['saraileftthai'] = 0xF885;
  11843. t['saraithai'] = 0x0E34;
  11844. t['saraothai'] = 0x0E42;
  11845. t['saraueeleftthai'] = 0xF888;
  11846. t['saraueethai'] = 0x0E37;
  11847. t['saraueleftthai'] = 0xF887;
  11848. t['sarauethai'] = 0x0E36;
  11849. t['sarauthai'] = 0x0E38;
  11850. t['sarauuthai'] = 0x0E39;
  11851. t['sbopomofo'] = 0x3119;
  11852. t['scaron'] = 0x0161;
  11853. t['scarondotaccent'] = 0x1E67;
  11854. t['scedilla'] = 0x015F;
  11855. t['schwa'] = 0x0259;
  11856. t['schwacyrillic'] = 0x04D9;
  11857. t['schwadieresiscyrillic'] = 0x04DB;
  11858. t['schwahook'] = 0x025A;
  11859. t['scircle'] = 0x24E2;
  11860. t['scircumflex'] = 0x015D;
  11861. t['scommaaccent'] = 0x0219;
  11862. t['sdotaccent'] = 0x1E61;
  11863. t['sdotbelow'] = 0x1E63;
  11864. t['sdotbelowdotaccent'] = 0x1E69;
  11865. t['seagullbelowcmb'] = 0x033C;
  11866. t['second'] = 0x2033;
  11867. t['secondtonechinese'] = 0x02CA;
  11868. t['section'] = 0x00A7;
  11869. t['seenarabic'] = 0x0633;
  11870. t['seenfinalarabic'] = 0xFEB2;
  11871. t['seeninitialarabic'] = 0xFEB3;
  11872. t['seenmedialarabic'] = 0xFEB4;
  11873. t['segol'] = 0x05B6;
  11874. t['segol13'] = 0x05B6;
  11875. t['segol1f'] = 0x05B6;
  11876. t['segol2c'] = 0x05B6;
  11877. t['segolhebrew'] = 0x05B6;
  11878. t['segolnarrowhebrew'] = 0x05B6;
  11879. t['segolquarterhebrew'] = 0x05B6;
  11880. t['segoltahebrew'] = 0x0592;
  11881. t['segolwidehebrew'] = 0x05B6;
  11882. t['seharmenian'] = 0x057D;
  11883. t['sehiragana'] = 0x305B;
  11884. t['sekatakana'] = 0x30BB;
  11885. t['sekatakanahalfwidth'] = 0xFF7E;
  11886. t['semicolon'] = 0x003B;
  11887. t['semicolonarabic'] = 0x061B;
  11888. t['semicolonmonospace'] = 0xFF1B;
  11889. t['semicolonsmall'] = 0xFE54;
  11890. t['semivoicedmarkkana'] = 0x309C;
  11891. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11892. t['sentisquare'] = 0x3322;
  11893. t['sentosquare'] = 0x3323;
  11894. t['seven'] = 0x0037;
  11895. t['sevenarabic'] = 0x0667;
  11896. t['sevenbengali'] = 0x09ED;
  11897. t['sevencircle'] = 0x2466;
  11898. t['sevencircleinversesansserif'] = 0x2790;
  11899. t['sevendeva'] = 0x096D;
  11900. t['seveneighths'] = 0x215E;
  11901. t['sevengujarati'] = 0x0AED;
  11902. t['sevengurmukhi'] = 0x0A6D;
  11903. t['sevenhackarabic'] = 0x0667;
  11904. t['sevenhangzhou'] = 0x3027;
  11905. t['sevenideographicparen'] = 0x3226;
  11906. t['seveninferior'] = 0x2087;
  11907. t['sevenmonospace'] = 0xFF17;
  11908. t['sevenoldstyle'] = 0xF737;
  11909. t['sevenparen'] = 0x247A;
  11910. t['sevenperiod'] = 0x248E;
  11911. t['sevenpersian'] = 0x06F7;
  11912. t['sevenroman'] = 0x2176;
  11913. t['sevensuperior'] = 0x2077;
  11914. t['seventeencircle'] = 0x2470;
  11915. t['seventeenparen'] = 0x2484;
  11916. t['seventeenperiod'] = 0x2498;
  11917. t['seventhai'] = 0x0E57;
  11918. t['sfthyphen'] = 0x00AD;
  11919. t['shaarmenian'] = 0x0577;
  11920. t['shabengali'] = 0x09B6;
  11921. t['shacyrillic'] = 0x0448;
  11922. t['shaddaarabic'] = 0x0651;
  11923. t['shaddadammaarabic'] = 0xFC61;
  11924. t['shaddadammatanarabic'] = 0xFC5E;
  11925. t['shaddafathaarabic'] = 0xFC60;
  11926. t['shaddakasraarabic'] = 0xFC62;
  11927. t['shaddakasratanarabic'] = 0xFC5F;
  11928. t['shade'] = 0x2592;
  11929. t['shadedark'] = 0x2593;
  11930. t['shadelight'] = 0x2591;
  11931. t['shademedium'] = 0x2592;
  11932. t['shadeva'] = 0x0936;
  11933. t['shagujarati'] = 0x0AB6;
  11934. t['shagurmukhi'] = 0x0A36;
  11935. t['shalshelethebrew'] = 0x0593;
  11936. t['shbopomofo'] = 0x3115;
  11937. t['shchacyrillic'] = 0x0449;
  11938. t['sheenarabic'] = 0x0634;
  11939. t['sheenfinalarabic'] = 0xFEB6;
  11940. t['sheeninitialarabic'] = 0xFEB7;
  11941. t['sheenmedialarabic'] = 0xFEB8;
  11942. t['sheicoptic'] = 0x03E3;
  11943. t['sheqel'] = 0x20AA;
  11944. t['sheqelhebrew'] = 0x20AA;
  11945. t['sheva'] = 0x05B0;
  11946. t['sheva115'] = 0x05B0;
  11947. t['sheva15'] = 0x05B0;
  11948. t['sheva22'] = 0x05B0;
  11949. t['sheva2e'] = 0x05B0;
  11950. t['shevahebrew'] = 0x05B0;
  11951. t['shevanarrowhebrew'] = 0x05B0;
  11952. t['shevaquarterhebrew'] = 0x05B0;
  11953. t['shevawidehebrew'] = 0x05B0;
  11954. t['shhacyrillic'] = 0x04BB;
  11955. t['shimacoptic'] = 0x03ED;
  11956. t['shin'] = 0x05E9;
  11957. t['shindagesh'] = 0xFB49;
  11958. t['shindageshhebrew'] = 0xFB49;
  11959. t['shindageshshindot'] = 0xFB2C;
  11960. t['shindageshshindothebrew'] = 0xFB2C;
  11961. t['shindageshsindot'] = 0xFB2D;
  11962. t['shindageshsindothebrew'] = 0xFB2D;
  11963. t['shindothebrew'] = 0x05C1;
  11964. t['shinhebrew'] = 0x05E9;
  11965. t['shinshindot'] = 0xFB2A;
  11966. t['shinshindothebrew'] = 0xFB2A;
  11967. t['shinsindot'] = 0xFB2B;
  11968. t['shinsindothebrew'] = 0xFB2B;
  11969. t['shook'] = 0x0282;
  11970. t['sigma'] = 0x03C3;
  11971. t['sigma1'] = 0x03C2;
  11972. t['sigmafinal'] = 0x03C2;
  11973. t['sigmalunatesymbolgreek'] = 0x03F2;
  11974. t['sihiragana'] = 0x3057;
  11975. t['sikatakana'] = 0x30B7;
  11976. t['sikatakanahalfwidth'] = 0xFF7C;
  11977. t['siluqhebrew'] = 0x05BD;
  11978. t['siluqlefthebrew'] = 0x05BD;
  11979. t['similar'] = 0x223C;
  11980. t['sindothebrew'] = 0x05C2;
  11981. t['siosacirclekorean'] = 0x3274;
  11982. t['siosaparenkorean'] = 0x3214;
  11983. t['sioscieuckorean'] = 0x317E;
  11984. t['sioscirclekorean'] = 0x3266;
  11985. t['sioskiyeokkorean'] = 0x317A;
  11986. t['sioskorean'] = 0x3145;
  11987. t['siosnieunkorean'] = 0x317B;
  11988. t['siosparenkorean'] = 0x3206;
  11989. t['siospieupkorean'] = 0x317D;
  11990. t['siostikeutkorean'] = 0x317C;
  11991. t['six'] = 0x0036;
  11992. t['sixarabic'] = 0x0666;
  11993. t['sixbengali'] = 0x09EC;
  11994. t['sixcircle'] = 0x2465;
  11995. t['sixcircleinversesansserif'] = 0x278F;
  11996. t['sixdeva'] = 0x096C;
  11997. t['sixgujarati'] = 0x0AEC;
  11998. t['sixgurmukhi'] = 0x0A6C;
  11999. t['sixhackarabic'] = 0x0666;
  12000. t['sixhangzhou'] = 0x3026;
  12001. t['sixideographicparen'] = 0x3225;
  12002. t['sixinferior'] = 0x2086;
  12003. t['sixmonospace'] = 0xFF16;
  12004. t['sixoldstyle'] = 0xF736;
  12005. t['sixparen'] = 0x2479;
  12006. t['sixperiod'] = 0x248D;
  12007. t['sixpersian'] = 0x06F6;
  12008. t['sixroman'] = 0x2175;
  12009. t['sixsuperior'] = 0x2076;
  12010. t['sixteencircle'] = 0x246F;
  12011. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12012. t['sixteenparen'] = 0x2483;
  12013. t['sixteenperiod'] = 0x2497;
  12014. t['sixthai'] = 0x0E56;
  12015. t['slash'] = 0x002F;
  12016. t['slashmonospace'] = 0xFF0F;
  12017. t['slong'] = 0x017F;
  12018. t['slongdotaccent'] = 0x1E9B;
  12019. t['smileface'] = 0x263A;
  12020. t['smonospace'] = 0xFF53;
  12021. t['sofpasuqhebrew'] = 0x05C3;
  12022. t['softhyphen'] = 0x00AD;
  12023. t['softsigncyrillic'] = 0x044C;
  12024. t['sohiragana'] = 0x305D;
  12025. t['sokatakana'] = 0x30BD;
  12026. t['sokatakanahalfwidth'] = 0xFF7F;
  12027. t['soliduslongoverlaycmb'] = 0x0338;
  12028. t['solidusshortoverlaycmb'] = 0x0337;
  12029. t['sorusithai'] = 0x0E29;
  12030. t['sosalathai'] = 0x0E28;
  12031. t['sosothai'] = 0x0E0B;
  12032. t['sosuathai'] = 0x0E2A;
  12033. t['space'] = 0x0020;
  12034. t['spacehackarabic'] = 0x0020;
  12035. t['spade'] = 0x2660;
  12036. t['spadesuitblack'] = 0x2660;
  12037. t['spadesuitwhite'] = 0x2664;
  12038. t['sparen'] = 0x24AE;
  12039. t['squarebelowcmb'] = 0x033B;
  12040. t['squarecc'] = 0x33C4;
  12041. t['squarecm'] = 0x339D;
  12042. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12043. t['squarehorizontalfill'] = 0x25A4;
  12044. t['squarekg'] = 0x338F;
  12045. t['squarekm'] = 0x339E;
  12046. t['squarekmcapital'] = 0x33CE;
  12047. t['squareln'] = 0x33D1;
  12048. t['squarelog'] = 0x33D2;
  12049. t['squaremg'] = 0x338E;
  12050. t['squaremil'] = 0x33D5;
  12051. t['squaremm'] = 0x339C;
  12052. t['squaremsquared'] = 0x33A1;
  12053. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12054. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12055. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12056. t['squareverticalfill'] = 0x25A5;
  12057. t['squarewhitewithsmallblack'] = 0x25A3;
  12058. t['srsquare'] = 0x33DB;
  12059. t['ssabengali'] = 0x09B7;
  12060. t['ssadeva'] = 0x0937;
  12061. t['ssagujarati'] = 0x0AB7;
  12062. t['ssangcieuckorean'] = 0x3149;
  12063. t['ssanghieuhkorean'] = 0x3185;
  12064. t['ssangieungkorean'] = 0x3180;
  12065. t['ssangkiyeokkorean'] = 0x3132;
  12066. t['ssangnieunkorean'] = 0x3165;
  12067. t['ssangpieupkorean'] = 0x3143;
  12068. t['ssangsioskorean'] = 0x3146;
  12069. t['ssangtikeutkorean'] = 0x3138;
  12070. t['ssuperior'] = 0xF6F2;
  12071. t['sterling'] = 0x00A3;
  12072. t['sterlingmonospace'] = 0xFFE1;
  12073. t['strokelongoverlaycmb'] = 0x0336;
  12074. t['strokeshortoverlaycmb'] = 0x0335;
  12075. t['subset'] = 0x2282;
  12076. t['subsetnotequal'] = 0x228A;
  12077. t['subsetorequal'] = 0x2286;
  12078. t['succeeds'] = 0x227B;
  12079. t['suchthat'] = 0x220B;
  12080. t['suhiragana'] = 0x3059;
  12081. t['sukatakana'] = 0x30B9;
  12082. t['sukatakanahalfwidth'] = 0xFF7D;
  12083. t['sukunarabic'] = 0x0652;
  12084. t['summation'] = 0x2211;
  12085. t['sun'] = 0x263C;
  12086. t['superset'] = 0x2283;
  12087. t['supersetnotequal'] = 0x228B;
  12088. t['supersetorequal'] = 0x2287;
  12089. t['svsquare'] = 0x33DC;
  12090. t['syouwaerasquare'] = 0x337C;
  12091. t['t'] = 0x0074;
  12092. t['tabengali'] = 0x09A4;
  12093. t['tackdown'] = 0x22A4;
  12094. t['tackleft'] = 0x22A3;
  12095. t['tadeva'] = 0x0924;
  12096. t['tagujarati'] = 0x0AA4;
  12097. t['tagurmukhi'] = 0x0A24;
  12098. t['taharabic'] = 0x0637;
  12099. t['tahfinalarabic'] = 0xFEC2;
  12100. t['tahinitialarabic'] = 0xFEC3;
  12101. t['tahiragana'] = 0x305F;
  12102. t['tahmedialarabic'] = 0xFEC4;
  12103. t['taisyouerasquare'] = 0x337D;
  12104. t['takatakana'] = 0x30BF;
  12105. t['takatakanahalfwidth'] = 0xFF80;
  12106. t['tatweelarabic'] = 0x0640;
  12107. t['tau'] = 0x03C4;
  12108. t['tav'] = 0x05EA;
  12109. t['tavdages'] = 0xFB4A;
  12110. t['tavdagesh'] = 0xFB4A;
  12111. t['tavdageshhebrew'] = 0xFB4A;
  12112. t['tavhebrew'] = 0x05EA;
  12113. t['tbar'] = 0x0167;
  12114. t['tbopomofo'] = 0x310A;
  12115. t['tcaron'] = 0x0165;
  12116. t['tccurl'] = 0x02A8;
  12117. t['tcedilla'] = 0x0163;
  12118. t['tcheharabic'] = 0x0686;
  12119. t['tchehfinalarabic'] = 0xFB7B;
  12120. t['tchehinitialarabic'] = 0xFB7C;
  12121. t['tchehmedialarabic'] = 0xFB7D;
  12122. t['tcircle'] = 0x24E3;
  12123. t['tcircumflexbelow'] = 0x1E71;
  12124. t['tcommaaccent'] = 0x0163;
  12125. t['tdieresis'] = 0x1E97;
  12126. t['tdotaccent'] = 0x1E6B;
  12127. t['tdotbelow'] = 0x1E6D;
  12128. t['tecyrillic'] = 0x0442;
  12129. t['tedescendercyrillic'] = 0x04AD;
  12130. t['teharabic'] = 0x062A;
  12131. t['tehfinalarabic'] = 0xFE96;
  12132. t['tehhahinitialarabic'] = 0xFCA2;
  12133. t['tehhahisolatedarabic'] = 0xFC0C;
  12134. t['tehinitialarabic'] = 0xFE97;
  12135. t['tehiragana'] = 0x3066;
  12136. t['tehjeeminitialarabic'] = 0xFCA1;
  12137. t['tehjeemisolatedarabic'] = 0xFC0B;
  12138. t['tehmarbutaarabic'] = 0x0629;
  12139. t['tehmarbutafinalarabic'] = 0xFE94;
  12140. t['tehmedialarabic'] = 0xFE98;
  12141. t['tehmeeminitialarabic'] = 0xFCA4;
  12142. t['tehmeemisolatedarabic'] = 0xFC0E;
  12143. t['tehnoonfinalarabic'] = 0xFC73;
  12144. t['tekatakana'] = 0x30C6;
  12145. t['tekatakanahalfwidth'] = 0xFF83;
  12146. t['telephone'] = 0x2121;
  12147. t['telephoneblack'] = 0x260E;
  12148. t['telishagedolahebrew'] = 0x05A0;
  12149. t['telishaqetanahebrew'] = 0x05A9;
  12150. t['tencircle'] = 0x2469;
  12151. t['tenideographicparen'] = 0x3229;
  12152. t['tenparen'] = 0x247D;
  12153. t['tenperiod'] = 0x2491;
  12154. t['tenroman'] = 0x2179;
  12155. t['tesh'] = 0x02A7;
  12156. t['tet'] = 0x05D8;
  12157. t['tetdagesh'] = 0xFB38;
  12158. t['tetdageshhebrew'] = 0xFB38;
  12159. t['tethebrew'] = 0x05D8;
  12160. t['tetsecyrillic'] = 0x04B5;
  12161. t['tevirhebrew'] = 0x059B;
  12162. t['tevirlefthebrew'] = 0x059B;
  12163. t['thabengali'] = 0x09A5;
  12164. t['thadeva'] = 0x0925;
  12165. t['thagujarati'] = 0x0AA5;
  12166. t['thagurmukhi'] = 0x0A25;
  12167. t['thalarabic'] = 0x0630;
  12168. t['thalfinalarabic'] = 0xFEAC;
  12169. t['thanthakhatlowleftthai'] = 0xF898;
  12170. t['thanthakhatlowrightthai'] = 0xF897;
  12171. t['thanthakhatthai'] = 0x0E4C;
  12172. t['thanthakhatupperleftthai'] = 0xF896;
  12173. t['theharabic'] = 0x062B;
  12174. t['thehfinalarabic'] = 0xFE9A;
  12175. t['thehinitialarabic'] = 0xFE9B;
  12176. t['thehmedialarabic'] = 0xFE9C;
  12177. t['thereexists'] = 0x2203;
  12178. t['therefore'] = 0x2234;
  12179. t['theta'] = 0x03B8;
  12180. t['theta1'] = 0x03D1;
  12181. t['thetasymbolgreek'] = 0x03D1;
  12182. t['thieuthacirclekorean'] = 0x3279;
  12183. t['thieuthaparenkorean'] = 0x3219;
  12184. t['thieuthcirclekorean'] = 0x326B;
  12185. t['thieuthkorean'] = 0x314C;
  12186. t['thieuthparenkorean'] = 0x320B;
  12187. t['thirteencircle'] = 0x246C;
  12188. t['thirteenparen'] = 0x2480;
  12189. t['thirteenperiod'] = 0x2494;
  12190. t['thonangmonthothai'] = 0x0E11;
  12191. t['thook'] = 0x01AD;
  12192. t['thophuthaothai'] = 0x0E12;
  12193. t['thorn'] = 0x00FE;
  12194. t['thothahanthai'] = 0x0E17;
  12195. t['thothanthai'] = 0x0E10;
  12196. t['thothongthai'] = 0x0E18;
  12197. t['thothungthai'] = 0x0E16;
  12198. t['thousandcyrillic'] = 0x0482;
  12199. t['thousandsseparatorarabic'] = 0x066C;
  12200. t['thousandsseparatorpersian'] = 0x066C;
  12201. t['three'] = 0x0033;
  12202. t['threearabic'] = 0x0663;
  12203. t['threebengali'] = 0x09E9;
  12204. t['threecircle'] = 0x2462;
  12205. t['threecircleinversesansserif'] = 0x278C;
  12206. t['threedeva'] = 0x0969;
  12207. t['threeeighths'] = 0x215C;
  12208. t['threegujarati'] = 0x0AE9;
  12209. t['threegurmukhi'] = 0x0A69;
  12210. t['threehackarabic'] = 0x0663;
  12211. t['threehangzhou'] = 0x3023;
  12212. t['threeideographicparen'] = 0x3222;
  12213. t['threeinferior'] = 0x2083;
  12214. t['threemonospace'] = 0xFF13;
  12215. t['threenumeratorbengali'] = 0x09F6;
  12216. t['threeoldstyle'] = 0xF733;
  12217. t['threeparen'] = 0x2476;
  12218. t['threeperiod'] = 0x248A;
  12219. t['threepersian'] = 0x06F3;
  12220. t['threequarters'] = 0x00BE;
  12221. t['threequartersemdash'] = 0xF6DE;
  12222. t['threeroman'] = 0x2172;
  12223. t['threesuperior'] = 0x00B3;
  12224. t['threethai'] = 0x0E53;
  12225. t['thzsquare'] = 0x3394;
  12226. t['tihiragana'] = 0x3061;
  12227. t['tikatakana'] = 0x30C1;
  12228. t['tikatakanahalfwidth'] = 0xFF81;
  12229. t['tikeutacirclekorean'] = 0x3270;
  12230. t['tikeutaparenkorean'] = 0x3210;
  12231. t['tikeutcirclekorean'] = 0x3262;
  12232. t['tikeutkorean'] = 0x3137;
  12233. t['tikeutparenkorean'] = 0x3202;
  12234. t['tilde'] = 0x02DC;
  12235. t['tildebelowcmb'] = 0x0330;
  12236. t['tildecmb'] = 0x0303;
  12237. t['tildecomb'] = 0x0303;
  12238. t['tildedoublecmb'] = 0x0360;
  12239. t['tildeoperator'] = 0x223C;
  12240. t['tildeoverlaycmb'] = 0x0334;
  12241. t['tildeverticalcmb'] = 0x033E;
  12242. t['timescircle'] = 0x2297;
  12243. t['tipehahebrew'] = 0x0596;
  12244. t['tipehalefthebrew'] = 0x0596;
  12245. t['tippigurmukhi'] = 0x0A70;
  12246. t['titlocyrilliccmb'] = 0x0483;
  12247. t['tiwnarmenian'] = 0x057F;
  12248. t['tlinebelow'] = 0x1E6F;
  12249. t['tmonospace'] = 0xFF54;
  12250. t['toarmenian'] = 0x0569;
  12251. t['tohiragana'] = 0x3068;
  12252. t['tokatakana'] = 0x30C8;
  12253. t['tokatakanahalfwidth'] = 0xFF84;
  12254. t['tonebarextrahighmod'] = 0x02E5;
  12255. t['tonebarextralowmod'] = 0x02E9;
  12256. t['tonebarhighmod'] = 0x02E6;
  12257. t['tonebarlowmod'] = 0x02E8;
  12258. t['tonebarmidmod'] = 0x02E7;
  12259. t['tonefive'] = 0x01BD;
  12260. t['tonesix'] = 0x0185;
  12261. t['tonetwo'] = 0x01A8;
  12262. t['tonos'] = 0x0384;
  12263. t['tonsquare'] = 0x3327;
  12264. t['topatakthai'] = 0x0E0F;
  12265. t['tortoiseshellbracketleft'] = 0x3014;
  12266. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12267. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12268. t['tortoiseshellbracketright'] = 0x3015;
  12269. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12270. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12271. t['totaothai'] = 0x0E15;
  12272. t['tpalatalhook'] = 0x01AB;
  12273. t['tparen'] = 0x24AF;
  12274. t['trademark'] = 0x2122;
  12275. t['trademarksans'] = 0xF8EA;
  12276. t['trademarkserif'] = 0xF6DB;
  12277. t['tretroflexhook'] = 0x0288;
  12278. t['triagdn'] = 0x25BC;
  12279. t['triaglf'] = 0x25C4;
  12280. t['triagrt'] = 0x25BA;
  12281. t['triagup'] = 0x25B2;
  12282. t['ts'] = 0x02A6;
  12283. t['tsadi'] = 0x05E6;
  12284. t['tsadidagesh'] = 0xFB46;
  12285. t['tsadidageshhebrew'] = 0xFB46;
  12286. t['tsadihebrew'] = 0x05E6;
  12287. t['tsecyrillic'] = 0x0446;
  12288. t['tsere'] = 0x05B5;
  12289. t['tsere12'] = 0x05B5;
  12290. t['tsere1e'] = 0x05B5;
  12291. t['tsere2b'] = 0x05B5;
  12292. t['tserehebrew'] = 0x05B5;
  12293. t['tserenarrowhebrew'] = 0x05B5;
  12294. t['tserequarterhebrew'] = 0x05B5;
  12295. t['tserewidehebrew'] = 0x05B5;
  12296. t['tshecyrillic'] = 0x045B;
  12297. t['tsuperior'] = 0xF6F3;
  12298. t['ttabengali'] = 0x099F;
  12299. t['ttadeva'] = 0x091F;
  12300. t['ttagujarati'] = 0x0A9F;
  12301. t['ttagurmukhi'] = 0x0A1F;
  12302. t['tteharabic'] = 0x0679;
  12303. t['ttehfinalarabic'] = 0xFB67;
  12304. t['ttehinitialarabic'] = 0xFB68;
  12305. t['ttehmedialarabic'] = 0xFB69;
  12306. t['tthabengali'] = 0x09A0;
  12307. t['tthadeva'] = 0x0920;
  12308. t['tthagujarati'] = 0x0AA0;
  12309. t['tthagurmukhi'] = 0x0A20;
  12310. t['tturned'] = 0x0287;
  12311. t['tuhiragana'] = 0x3064;
  12312. t['tukatakana'] = 0x30C4;
  12313. t['tukatakanahalfwidth'] = 0xFF82;
  12314. t['tusmallhiragana'] = 0x3063;
  12315. t['tusmallkatakana'] = 0x30C3;
  12316. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12317. t['twelvecircle'] = 0x246B;
  12318. t['twelveparen'] = 0x247F;
  12319. t['twelveperiod'] = 0x2493;
  12320. t['twelveroman'] = 0x217B;
  12321. t['twentycircle'] = 0x2473;
  12322. t['twentyhangzhou'] = 0x5344;
  12323. t['twentyparen'] = 0x2487;
  12324. t['twentyperiod'] = 0x249B;
  12325. t['two'] = 0x0032;
  12326. t['twoarabic'] = 0x0662;
  12327. t['twobengali'] = 0x09E8;
  12328. t['twocircle'] = 0x2461;
  12329. t['twocircleinversesansserif'] = 0x278B;
  12330. t['twodeva'] = 0x0968;
  12331. t['twodotenleader'] = 0x2025;
  12332. t['twodotleader'] = 0x2025;
  12333. t['twodotleadervertical'] = 0xFE30;
  12334. t['twogujarati'] = 0x0AE8;
  12335. t['twogurmukhi'] = 0x0A68;
  12336. t['twohackarabic'] = 0x0662;
  12337. t['twohangzhou'] = 0x3022;
  12338. t['twoideographicparen'] = 0x3221;
  12339. t['twoinferior'] = 0x2082;
  12340. t['twomonospace'] = 0xFF12;
  12341. t['twonumeratorbengali'] = 0x09F5;
  12342. t['twooldstyle'] = 0xF732;
  12343. t['twoparen'] = 0x2475;
  12344. t['twoperiod'] = 0x2489;
  12345. t['twopersian'] = 0x06F2;
  12346. t['tworoman'] = 0x2171;
  12347. t['twostroke'] = 0x01BB;
  12348. t['twosuperior'] = 0x00B2;
  12349. t['twothai'] = 0x0E52;
  12350. t['twothirds'] = 0x2154;
  12351. t['u'] = 0x0075;
  12352. t['uacute'] = 0x00FA;
  12353. t['ubar'] = 0x0289;
  12354. t['ubengali'] = 0x0989;
  12355. t['ubopomofo'] = 0x3128;
  12356. t['ubreve'] = 0x016D;
  12357. t['ucaron'] = 0x01D4;
  12358. t['ucircle'] = 0x24E4;
  12359. t['ucircumflex'] = 0x00FB;
  12360. t['ucircumflexbelow'] = 0x1E77;
  12361. t['ucyrillic'] = 0x0443;
  12362. t['udattadeva'] = 0x0951;
  12363. t['udblacute'] = 0x0171;
  12364. t['udblgrave'] = 0x0215;
  12365. t['udeva'] = 0x0909;
  12366. t['udieresis'] = 0x00FC;
  12367. t['udieresisacute'] = 0x01D8;
  12368. t['udieresisbelow'] = 0x1E73;
  12369. t['udieresiscaron'] = 0x01DA;
  12370. t['udieresiscyrillic'] = 0x04F1;
  12371. t['udieresisgrave'] = 0x01DC;
  12372. t['udieresismacron'] = 0x01D6;
  12373. t['udotbelow'] = 0x1EE5;
  12374. t['ugrave'] = 0x00F9;
  12375. t['ugujarati'] = 0x0A89;
  12376. t['ugurmukhi'] = 0x0A09;
  12377. t['uhiragana'] = 0x3046;
  12378. t['uhookabove'] = 0x1EE7;
  12379. t['uhorn'] = 0x01B0;
  12380. t['uhornacute'] = 0x1EE9;
  12381. t['uhorndotbelow'] = 0x1EF1;
  12382. t['uhorngrave'] = 0x1EEB;
  12383. t['uhornhookabove'] = 0x1EED;
  12384. t['uhorntilde'] = 0x1EEF;
  12385. t['uhungarumlaut'] = 0x0171;
  12386. t['uhungarumlautcyrillic'] = 0x04F3;
  12387. t['uinvertedbreve'] = 0x0217;
  12388. t['ukatakana'] = 0x30A6;
  12389. t['ukatakanahalfwidth'] = 0xFF73;
  12390. t['ukcyrillic'] = 0x0479;
  12391. t['ukorean'] = 0x315C;
  12392. t['umacron'] = 0x016B;
  12393. t['umacroncyrillic'] = 0x04EF;
  12394. t['umacrondieresis'] = 0x1E7B;
  12395. t['umatragurmukhi'] = 0x0A41;
  12396. t['umonospace'] = 0xFF55;
  12397. t['underscore'] = 0x005F;
  12398. t['underscoredbl'] = 0x2017;
  12399. t['underscoremonospace'] = 0xFF3F;
  12400. t['underscorevertical'] = 0xFE33;
  12401. t['underscorewavy'] = 0xFE4F;
  12402. t['union'] = 0x222A;
  12403. t['universal'] = 0x2200;
  12404. t['uogonek'] = 0x0173;
  12405. t['uparen'] = 0x24B0;
  12406. t['upblock'] = 0x2580;
  12407. t['upperdothebrew'] = 0x05C4;
  12408. t['upsilon'] = 0x03C5;
  12409. t['upsilondieresis'] = 0x03CB;
  12410. t['upsilondieresistonos'] = 0x03B0;
  12411. t['upsilonlatin'] = 0x028A;
  12412. t['upsilontonos'] = 0x03CD;
  12413. t['uptackbelowcmb'] = 0x031D;
  12414. t['uptackmod'] = 0x02D4;
  12415. t['uragurmukhi'] = 0x0A73;
  12416. t['uring'] = 0x016F;
  12417. t['ushortcyrillic'] = 0x045E;
  12418. t['usmallhiragana'] = 0x3045;
  12419. t['usmallkatakana'] = 0x30A5;
  12420. t['usmallkatakanahalfwidth'] = 0xFF69;
  12421. t['ustraightcyrillic'] = 0x04AF;
  12422. t['ustraightstrokecyrillic'] = 0x04B1;
  12423. t['utilde'] = 0x0169;
  12424. t['utildeacute'] = 0x1E79;
  12425. t['utildebelow'] = 0x1E75;
  12426. t['uubengali'] = 0x098A;
  12427. t['uudeva'] = 0x090A;
  12428. t['uugujarati'] = 0x0A8A;
  12429. t['uugurmukhi'] = 0x0A0A;
  12430. t['uumatragurmukhi'] = 0x0A42;
  12431. t['uuvowelsignbengali'] = 0x09C2;
  12432. t['uuvowelsigndeva'] = 0x0942;
  12433. t['uuvowelsigngujarati'] = 0x0AC2;
  12434. t['uvowelsignbengali'] = 0x09C1;
  12435. t['uvowelsigndeva'] = 0x0941;
  12436. t['uvowelsigngujarati'] = 0x0AC1;
  12437. t['v'] = 0x0076;
  12438. t['vadeva'] = 0x0935;
  12439. t['vagujarati'] = 0x0AB5;
  12440. t['vagurmukhi'] = 0x0A35;
  12441. t['vakatakana'] = 0x30F7;
  12442. t['vav'] = 0x05D5;
  12443. t['vavdagesh'] = 0xFB35;
  12444. t['vavdagesh65'] = 0xFB35;
  12445. t['vavdageshhebrew'] = 0xFB35;
  12446. t['vavhebrew'] = 0x05D5;
  12447. t['vavholam'] = 0xFB4B;
  12448. t['vavholamhebrew'] = 0xFB4B;
  12449. t['vavvavhebrew'] = 0x05F0;
  12450. t['vavyodhebrew'] = 0x05F1;
  12451. t['vcircle'] = 0x24E5;
  12452. t['vdotbelow'] = 0x1E7F;
  12453. t['vecyrillic'] = 0x0432;
  12454. t['veharabic'] = 0x06A4;
  12455. t['vehfinalarabic'] = 0xFB6B;
  12456. t['vehinitialarabic'] = 0xFB6C;
  12457. t['vehmedialarabic'] = 0xFB6D;
  12458. t['vekatakana'] = 0x30F9;
  12459. t['venus'] = 0x2640;
  12460. t['verticalbar'] = 0x007C;
  12461. t['verticallineabovecmb'] = 0x030D;
  12462. t['verticallinebelowcmb'] = 0x0329;
  12463. t['verticallinelowmod'] = 0x02CC;
  12464. t['verticallinemod'] = 0x02C8;
  12465. t['vewarmenian'] = 0x057E;
  12466. t['vhook'] = 0x028B;
  12467. t['vikatakana'] = 0x30F8;
  12468. t['viramabengali'] = 0x09CD;
  12469. t['viramadeva'] = 0x094D;
  12470. t['viramagujarati'] = 0x0ACD;
  12471. t['visargabengali'] = 0x0983;
  12472. t['visargadeva'] = 0x0903;
  12473. t['visargagujarati'] = 0x0A83;
  12474. t['vmonospace'] = 0xFF56;
  12475. t['voarmenian'] = 0x0578;
  12476. t['voicediterationhiragana'] = 0x309E;
  12477. t['voicediterationkatakana'] = 0x30FE;
  12478. t['voicedmarkkana'] = 0x309B;
  12479. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12480. t['vokatakana'] = 0x30FA;
  12481. t['vparen'] = 0x24B1;
  12482. t['vtilde'] = 0x1E7D;
  12483. t['vturned'] = 0x028C;
  12484. t['vuhiragana'] = 0x3094;
  12485. t['vukatakana'] = 0x30F4;
  12486. t['w'] = 0x0077;
  12487. t['wacute'] = 0x1E83;
  12488. t['waekorean'] = 0x3159;
  12489. t['wahiragana'] = 0x308F;
  12490. t['wakatakana'] = 0x30EF;
  12491. t['wakatakanahalfwidth'] = 0xFF9C;
  12492. t['wakorean'] = 0x3158;
  12493. t['wasmallhiragana'] = 0x308E;
  12494. t['wasmallkatakana'] = 0x30EE;
  12495. t['wattosquare'] = 0x3357;
  12496. t['wavedash'] = 0x301C;
  12497. t['wavyunderscorevertical'] = 0xFE34;
  12498. t['wawarabic'] = 0x0648;
  12499. t['wawfinalarabic'] = 0xFEEE;
  12500. t['wawhamzaabovearabic'] = 0x0624;
  12501. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12502. t['wbsquare'] = 0x33DD;
  12503. t['wcircle'] = 0x24E6;
  12504. t['wcircumflex'] = 0x0175;
  12505. t['wdieresis'] = 0x1E85;
  12506. t['wdotaccent'] = 0x1E87;
  12507. t['wdotbelow'] = 0x1E89;
  12508. t['wehiragana'] = 0x3091;
  12509. t['weierstrass'] = 0x2118;
  12510. t['wekatakana'] = 0x30F1;
  12511. t['wekorean'] = 0x315E;
  12512. t['weokorean'] = 0x315D;
  12513. t['wgrave'] = 0x1E81;
  12514. t['whitebullet'] = 0x25E6;
  12515. t['whitecircle'] = 0x25CB;
  12516. t['whitecircleinverse'] = 0x25D9;
  12517. t['whitecornerbracketleft'] = 0x300E;
  12518. t['whitecornerbracketleftvertical'] = 0xFE43;
  12519. t['whitecornerbracketright'] = 0x300F;
  12520. t['whitecornerbracketrightvertical'] = 0xFE44;
  12521. t['whitediamond'] = 0x25C7;
  12522. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12523. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12524. t['whitedownpointingtriangle'] = 0x25BD;
  12525. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12526. t['whiteleftpointingtriangle'] = 0x25C1;
  12527. t['whitelenticularbracketleft'] = 0x3016;
  12528. t['whitelenticularbracketright'] = 0x3017;
  12529. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12530. t['whiterightpointingtriangle'] = 0x25B7;
  12531. t['whitesmallsquare'] = 0x25AB;
  12532. t['whitesmilingface'] = 0x263A;
  12533. t['whitesquare'] = 0x25A1;
  12534. t['whitestar'] = 0x2606;
  12535. t['whitetelephone'] = 0x260F;
  12536. t['whitetortoiseshellbracketleft'] = 0x3018;
  12537. t['whitetortoiseshellbracketright'] = 0x3019;
  12538. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12539. t['whiteuppointingtriangle'] = 0x25B3;
  12540. t['wihiragana'] = 0x3090;
  12541. t['wikatakana'] = 0x30F0;
  12542. t['wikorean'] = 0x315F;
  12543. t['wmonospace'] = 0xFF57;
  12544. t['wohiragana'] = 0x3092;
  12545. t['wokatakana'] = 0x30F2;
  12546. t['wokatakanahalfwidth'] = 0xFF66;
  12547. t['won'] = 0x20A9;
  12548. t['wonmonospace'] = 0xFFE6;
  12549. t['wowaenthai'] = 0x0E27;
  12550. t['wparen'] = 0x24B2;
  12551. t['wring'] = 0x1E98;
  12552. t['wsuperior'] = 0x02B7;
  12553. t['wturned'] = 0x028D;
  12554. t['wynn'] = 0x01BF;
  12555. t['x'] = 0x0078;
  12556. t['xabovecmb'] = 0x033D;
  12557. t['xbopomofo'] = 0x3112;
  12558. t['xcircle'] = 0x24E7;
  12559. t['xdieresis'] = 0x1E8D;
  12560. t['xdotaccent'] = 0x1E8B;
  12561. t['xeharmenian'] = 0x056D;
  12562. t['xi'] = 0x03BE;
  12563. t['xmonospace'] = 0xFF58;
  12564. t['xparen'] = 0x24B3;
  12565. t['xsuperior'] = 0x02E3;
  12566. t['y'] = 0x0079;
  12567. t['yaadosquare'] = 0x334E;
  12568. t['yabengali'] = 0x09AF;
  12569. t['yacute'] = 0x00FD;
  12570. t['yadeva'] = 0x092F;
  12571. t['yaekorean'] = 0x3152;
  12572. t['yagujarati'] = 0x0AAF;
  12573. t['yagurmukhi'] = 0x0A2F;
  12574. t['yahiragana'] = 0x3084;
  12575. t['yakatakana'] = 0x30E4;
  12576. t['yakatakanahalfwidth'] = 0xFF94;
  12577. t['yakorean'] = 0x3151;
  12578. t['yamakkanthai'] = 0x0E4E;
  12579. t['yasmallhiragana'] = 0x3083;
  12580. t['yasmallkatakana'] = 0x30E3;
  12581. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12582. t['yatcyrillic'] = 0x0463;
  12583. t['ycircle'] = 0x24E8;
  12584. t['ycircumflex'] = 0x0177;
  12585. t['ydieresis'] = 0x00FF;
  12586. t['ydotaccent'] = 0x1E8F;
  12587. t['ydotbelow'] = 0x1EF5;
  12588. t['yeharabic'] = 0x064A;
  12589. t['yehbarreearabic'] = 0x06D2;
  12590. t['yehbarreefinalarabic'] = 0xFBAF;
  12591. t['yehfinalarabic'] = 0xFEF2;
  12592. t['yehhamzaabovearabic'] = 0x0626;
  12593. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12594. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12595. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12596. t['yehinitialarabic'] = 0xFEF3;
  12597. t['yehmedialarabic'] = 0xFEF4;
  12598. t['yehmeeminitialarabic'] = 0xFCDD;
  12599. t['yehmeemisolatedarabic'] = 0xFC58;
  12600. t['yehnoonfinalarabic'] = 0xFC94;
  12601. t['yehthreedotsbelowarabic'] = 0x06D1;
  12602. t['yekorean'] = 0x3156;
  12603. t['yen'] = 0x00A5;
  12604. t['yenmonospace'] = 0xFFE5;
  12605. t['yeokorean'] = 0x3155;
  12606. t['yeorinhieuhkorean'] = 0x3186;
  12607. t['yerahbenyomohebrew'] = 0x05AA;
  12608. t['yerahbenyomolefthebrew'] = 0x05AA;
  12609. t['yericyrillic'] = 0x044B;
  12610. t['yerudieresiscyrillic'] = 0x04F9;
  12611. t['yesieungkorean'] = 0x3181;
  12612. t['yesieungpansioskorean'] = 0x3183;
  12613. t['yesieungsioskorean'] = 0x3182;
  12614. t['yetivhebrew'] = 0x059A;
  12615. t['ygrave'] = 0x1EF3;
  12616. t['yhook'] = 0x01B4;
  12617. t['yhookabove'] = 0x1EF7;
  12618. t['yiarmenian'] = 0x0575;
  12619. t['yicyrillic'] = 0x0457;
  12620. t['yikorean'] = 0x3162;
  12621. t['yinyang'] = 0x262F;
  12622. t['yiwnarmenian'] = 0x0582;
  12623. t['ymonospace'] = 0xFF59;
  12624. t['yod'] = 0x05D9;
  12625. t['yoddagesh'] = 0xFB39;
  12626. t['yoddageshhebrew'] = 0xFB39;
  12627. t['yodhebrew'] = 0x05D9;
  12628. t['yodyodhebrew'] = 0x05F2;
  12629. t['yodyodpatahhebrew'] = 0xFB1F;
  12630. t['yohiragana'] = 0x3088;
  12631. t['yoikorean'] = 0x3189;
  12632. t['yokatakana'] = 0x30E8;
  12633. t['yokatakanahalfwidth'] = 0xFF96;
  12634. t['yokorean'] = 0x315B;
  12635. t['yosmallhiragana'] = 0x3087;
  12636. t['yosmallkatakana'] = 0x30E7;
  12637. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12638. t['yotgreek'] = 0x03F3;
  12639. t['yoyaekorean'] = 0x3188;
  12640. t['yoyakorean'] = 0x3187;
  12641. t['yoyakthai'] = 0x0E22;
  12642. t['yoyingthai'] = 0x0E0D;
  12643. t['yparen'] = 0x24B4;
  12644. t['ypogegrammeni'] = 0x037A;
  12645. t['ypogegrammenigreekcmb'] = 0x0345;
  12646. t['yr'] = 0x01A6;
  12647. t['yring'] = 0x1E99;
  12648. t['ysuperior'] = 0x02B8;
  12649. t['ytilde'] = 0x1EF9;
  12650. t['yturned'] = 0x028E;
  12651. t['yuhiragana'] = 0x3086;
  12652. t['yuikorean'] = 0x318C;
  12653. t['yukatakana'] = 0x30E6;
  12654. t['yukatakanahalfwidth'] = 0xFF95;
  12655. t['yukorean'] = 0x3160;
  12656. t['yusbigcyrillic'] = 0x046B;
  12657. t['yusbigiotifiedcyrillic'] = 0x046D;
  12658. t['yuslittlecyrillic'] = 0x0467;
  12659. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12660. t['yusmallhiragana'] = 0x3085;
  12661. t['yusmallkatakana'] = 0x30E5;
  12662. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12663. t['yuyekorean'] = 0x318B;
  12664. t['yuyeokorean'] = 0x318A;
  12665. t['yyabengali'] = 0x09DF;
  12666. t['yyadeva'] = 0x095F;
  12667. t['z'] = 0x007A;
  12668. t['zaarmenian'] = 0x0566;
  12669. t['zacute'] = 0x017A;
  12670. t['zadeva'] = 0x095B;
  12671. t['zagurmukhi'] = 0x0A5B;
  12672. t['zaharabic'] = 0x0638;
  12673. t['zahfinalarabic'] = 0xFEC6;
  12674. t['zahinitialarabic'] = 0xFEC7;
  12675. t['zahiragana'] = 0x3056;
  12676. t['zahmedialarabic'] = 0xFEC8;
  12677. t['zainarabic'] = 0x0632;
  12678. t['zainfinalarabic'] = 0xFEB0;
  12679. t['zakatakana'] = 0x30B6;
  12680. t['zaqefgadolhebrew'] = 0x0595;
  12681. t['zaqefqatanhebrew'] = 0x0594;
  12682. t['zarqahebrew'] = 0x0598;
  12683. t['zayin'] = 0x05D6;
  12684. t['zayindagesh'] = 0xFB36;
  12685. t['zayindageshhebrew'] = 0xFB36;
  12686. t['zayinhebrew'] = 0x05D6;
  12687. t['zbopomofo'] = 0x3117;
  12688. t['zcaron'] = 0x017E;
  12689. t['zcircle'] = 0x24E9;
  12690. t['zcircumflex'] = 0x1E91;
  12691. t['zcurl'] = 0x0291;
  12692. t['zdot'] = 0x017C;
  12693. t['zdotaccent'] = 0x017C;
  12694. t['zdotbelow'] = 0x1E93;
  12695. t['zecyrillic'] = 0x0437;
  12696. t['zedescendercyrillic'] = 0x0499;
  12697. t['zedieresiscyrillic'] = 0x04DF;
  12698. t['zehiragana'] = 0x305C;
  12699. t['zekatakana'] = 0x30BC;
  12700. t['zero'] = 0x0030;
  12701. t['zeroarabic'] = 0x0660;
  12702. t['zerobengali'] = 0x09E6;
  12703. t['zerodeva'] = 0x0966;
  12704. t['zerogujarati'] = 0x0AE6;
  12705. t['zerogurmukhi'] = 0x0A66;
  12706. t['zerohackarabic'] = 0x0660;
  12707. t['zeroinferior'] = 0x2080;
  12708. t['zeromonospace'] = 0xFF10;
  12709. t['zerooldstyle'] = 0xF730;
  12710. t['zeropersian'] = 0x06F0;
  12711. t['zerosuperior'] = 0x2070;
  12712. t['zerothai'] = 0x0E50;
  12713. t['zerowidthjoiner'] = 0xFEFF;
  12714. t['zerowidthnonjoiner'] = 0x200C;
  12715. t['zerowidthspace'] = 0x200B;
  12716. t['zeta'] = 0x03B6;
  12717. t['zhbopomofo'] = 0x3113;
  12718. t['zhearmenian'] = 0x056A;
  12719. t['zhebrevecyrillic'] = 0x04C2;
  12720. t['zhecyrillic'] = 0x0436;
  12721. t['zhedescendercyrillic'] = 0x0497;
  12722. t['zhedieresiscyrillic'] = 0x04DD;
  12723. t['zihiragana'] = 0x3058;
  12724. t['zikatakana'] = 0x30B8;
  12725. t['zinorhebrew'] = 0x05AE;
  12726. t['zlinebelow'] = 0x1E95;
  12727. t['zmonospace'] = 0xFF5A;
  12728. t['zohiragana'] = 0x305E;
  12729. t['zokatakana'] = 0x30BE;
  12730. t['zparen'] = 0x24B5;
  12731. t['zretroflexhook'] = 0x0290;
  12732. t['zstroke'] = 0x01B6;
  12733. t['zuhiragana'] = 0x305A;
  12734. t['zukatakana'] = 0x30BA;
  12735. t['.notdef'] = 0x0000;
  12736. t['angbracketleftbig'] = 0x2329;
  12737. t['angbracketleftBig'] = 0x2329;
  12738. t['angbracketleftbigg'] = 0x2329;
  12739. t['angbracketleftBigg'] = 0x2329;
  12740. t['angbracketrightBig'] = 0x232A;
  12741. t['angbracketrightbig'] = 0x232A;
  12742. t['angbracketrightBigg'] = 0x232A;
  12743. t['angbracketrightbigg'] = 0x232A;
  12744. t['arrowhookleft'] = 0x21AA;
  12745. t['arrowhookright'] = 0x21A9;
  12746. t['arrowlefttophalf'] = 0x21BC;
  12747. t['arrowleftbothalf'] = 0x21BD;
  12748. t['arrownortheast'] = 0x2197;
  12749. t['arrownorthwest'] = 0x2196;
  12750. t['arrowrighttophalf'] = 0x21C0;
  12751. t['arrowrightbothalf'] = 0x21C1;
  12752. t['arrowsoutheast'] = 0x2198;
  12753. t['arrowsouthwest'] = 0x2199;
  12754. t['backslashbig'] = 0x2216;
  12755. t['backslashBig'] = 0x2216;
  12756. t['backslashBigg'] = 0x2216;
  12757. t['backslashbigg'] = 0x2216;
  12758. t['bardbl'] = 0x2016;
  12759. t['bracehtipdownleft'] = 0xFE37;
  12760. t['bracehtipdownright'] = 0xFE37;
  12761. t['bracehtipupleft'] = 0xFE38;
  12762. t['bracehtipupright'] = 0xFE38;
  12763. t['braceleftBig'] = 0x007B;
  12764. t['braceleftbig'] = 0x007B;
  12765. t['braceleftbigg'] = 0x007B;
  12766. t['braceleftBigg'] = 0x007B;
  12767. t['bracerightBig'] = 0x007D;
  12768. t['bracerightbig'] = 0x007D;
  12769. t['bracerightbigg'] = 0x007D;
  12770. t['bracerightBigg'] = 0x007D;
  12771. t['bracketleftbig'] = 0x005B;
  12772. t['bracketleftBig'] = 0x005B;
  12773. t['bracketleftbigg'] = 0x005B;
  12774. t['bracketleftBigg'] = 0x005B;
  12775. t['bracketrightBig'] = 0x005D;
  12776. t['bracketrightbig'] = 0x005D;
  12777. t['bracketrightbigg'] = 0x005D;
  12778. t['bracketrightBigg'] = 0x005D;
  12779. t['ceilingleftbig'] = 0x2308;
  12780. t['ceilingleftBig'] = 0x2308;
  12781. t['ceilingleftBigg'] = 0x2308;
  12782. t['ceilingleftbigg'] = 0x2308;
  12783. t['ceilingrightbig'] = 0x2309;
  12784. t['ceilingrightBig'] = 0x2309;
  12785. t['ceilingrightbigg'] = 0x2309;
  12786. t['ceilingrightBigg'] = 0x2309;
  12787. t['circledotdisplay'] = 0x2299;
  12788. t['circledottext'] = 0x2299;
  12789. t['circlemultiplydisplay'] = 0x2297;
  12790. t['circlemultiplytext'] = 0x2297;
  12791. t['circleplusdisplay'] = 0x2295;
  12792. t['circleplustext'] = 0x2295;
  12793. t['contintegraldisplay'] = 0x222E;
  12794. t['contintegraltext'] = 0x222E;
  12795. t['coproductdisplay'] = 0x2210;
  12796. t['coproducttext'] = 0x2210;
  12797. t['floorleftBig'] = 0x230A;
  12798. t['floorleftbig'] = 0x230A;
  12799. t['floorleftbigg'] = 0x230A;
  12800. t['floorleftBigg'] = 0x230A;
  12801. t['floorrightbig'] = 0x230B;
  12802. t['floorrightBig'] = 0x230B;
  12803. t['floorrightBigg'] = 0x230B;
  12804. t['floorrightbigg'] = 0x230B;
  12805. t['hatwide'] = 0x0302;
  12806. t['hatwider'] = 0x0302;
  12807. t['hatwidest'] = 0x0302;
  12808. t['intercal'] = 0x1D40;
  12809. t['integraldisplay'] = 0x222B;
  12810. t['integraltext'] = 0x222B;
  12811. t['intersectiondisplay'] = 0x22C2;
  12812. t['intersectiontext'] = 0x22C2;
  12813. t['logicalanddisplay'] = 0x2227;
  12814. t['logicalandtext'] = 0x2227;
  12815. t['logicalordisplay'] = 0x2228;
  12816. t['logicalortext'] = 0x2228;
  12817. t['parenleftBig'] = 0x0028;
  12818. t['parenleftbig'] = 0x0028;
  12819. t['parenleftBigg'] = 0x0028;
  12820. t['parenleftbigg'] = 0x0028;
  12821. t['parenrightBig'] = 0x0029;
  12822. t['parenrightbig'] = 0x0029;
  12823. t['parenrightBigg'] = 0x0029;
  12824. t['parenrightbigg'] = 0x0029;
  12825. t['prime'] = 0x2032;
  12826. t['productdisplay'] = 0x220F;
  12827. t['producttext'] = 0x220F;
  12828. t['radicalbig'] = 0x221A;
  12829. t['radicalBig'] = 0x221A;
  12830. t['radicalBigg'] = 0x221A;
  12831. t['radicalbigg'] = 0x221A;
  12832. t['radicalbt'] = 0x221A;
  12833. t['radicaltp'] = 0x221A;
  12834. t['radicalvertex'] = 0x221A;
  12835. t['slashbig'] = 0x002F;
  12836. t['slashBig'] = 0x002F;
  12837. t['slashBigg'] = 0x002F;
  12838. t['slashbigg'] = 0x002F;
  12839. t['summationdisplay'] = 0x2211;
  12840. t['summationtext'] = 0x2211;
  12841. t['tildewide'] = 0x02DC;
  12842. t['tildewider'] = 0x02DC;
  12843. t['tildewidest'] = 0x02DC;
  12844. t['uniondisplay'] = 0x22C3;
  12845. t['unionmultidisplay'] = 0x228E;
  12846. t['unionmultitext'] = 0x228E;
  12847. t['unionsqdisplay'] = 0x2294;
  12848. t['unionsqtext'] = 0x2294;
  12849. t['uniontext'] = 0x22C3;
  12850. t['vextenddouble'] = 0x2225;
  12851. t['vextendsingle'] = 0x2223;
  12852. });
  12853. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12854. t['space'] = 0x0020;
  12855. t['a1'] = 0x2701;
  12856. t['a2'] = 0x2702;
  12857. t['a202'] = 0x2703;
  12858. t['a3'] = 0x2704;
  12859. t['a4'] = 0x260E;
  12860. t['a5'] = 0x2706;
  12861. t['a119'] = 0x2707;
  12862. t['a118'] = 0x2708;
  12863. t['a117'] = 0x2709;
  12864. t['a11'] = 0x261B;
  12865. t['a12'] = 0x261E;
  12866. t['a13'] = 0x270C;
  12867. t['a14'] = 0x270D;
  12868. t['a15'] = 0x270E;
  12869. t['a16'] = 0x270F;
  12870. t['a105'] = 0x2710;
  12871. t['a17'] = 0x2711;
  12872. t['a18'] = 0x2712;
  12873. t['a19'] = 0x2713;
  12874. t['a20'] = 0x2714;
  12875. t['a21'] = 0x2715;
  12876. t['a22'] = 0x2716;
  12877. t['a23'] = 0x2717;
  12878. t['a24'] = 0x2718;
  12879. t['a25'] = 0x2719;
  12880. t['a26'] = 0x271A;
  12881. t['a27'] = 0x271B;
  12882. t['a28'] = 0x271C;
  12883. t['a6'] = 0x271D;
  12884. t['a7'] = 0x271E;
  12885. t['a8'] = 0x271F;
  12886. t['a9'] = 0x2720;
  12887. t['a10'] = 0x2721;
  12888. t['a29'] = 0x2722;
  12889. t['a30'] = 0x2723;
  12890. t['a31'] = 0x2724;
  12891. t['a32'] = 0x2725;
  12892. t['a33'] = 0x2726;
  12893. t['a34'] = 0x2727;
  12894. t['a35'] = 0x2605;
  12895. t['a36'] = 0x2729;
  12896. t['a37'] = 0x272A;
  12897. t['a38'] = 0x272B;
  12898. t['a39'] = 0x272C;
  12899. t['a40'] = 0x272D;
  12900. t['a41'] = 0x272E;
  12901. t['a42'] = 0x272F;
  12902. t['a43'] = 0x2730;
  12903. t['a44'] = 0x2731;
  12904. t['a45'] = 0x2732;
  12905. t['a46'] = 0x2733;
  12906. t['a47'] = 0x2734;
  12907. t['a48'] = 0x2735;
  12908. t['a49'] = 0x2736;
  12909. t['a50'] = 0x2737;
  12910. t['a51'] = 0x2738;
  12911. t['a52'] = 0x2739;
  12912. t['a53'] = 0x273A;
  12913. t['a54'] = 0x273B;
  12914. t['a55'] = 0x273C;
  12915. t['a56'] = 0x273D;
  12916. t['a57'] = 0x273E;
  12917. t['a58'] = 0x273F;
  12918. t['a59'] = 0x2740;
  12919. t['a60'] = 0x2741;
  12920. t['a61'] = 0x2742;
  12921. t['a62'] = 0x2743;
  12922. t['a63'] = 0x2744;
  12923. t['a64'] = 0x2745;
  12924. t['a65'] = 0x2746;
  12925. t['a66'] = 0x2747;
  12926. t['a67'] = 0x2748;
  12927. t['a68'] = 0x2749;
  12928. t['a69'] = 0x274A;
  12929. t['a70'] = 0x274B;
  12930. t['a71'] = 0x25CF;
  12931. t['a72'] = 0x274D;
  12932. t['a73'] = 0x25A0;
  12933. t['a74'] = 0x274F;
  12934. t['a203'] = 0x2750;
  12935. t['a75'] = 0x2751;
  12936. t['a204'] = 0x2752;
  12937. t['a76'] = 0x25B2;
  12938. t['a77'] = 0x25BC;
  12939. t['a78'] = 0x25C6;
  12940. t['a79'] = 0x2756;
  12941. t['a81'] = 0x25D7;
  12942. t['a82'] = 0x2758;
  12943. t['a83'] = 0x2759;
  12944. t['a84'] = 0x275A;
  12945. t['a97'] = 0x275B;
  12946. t['a98'] = 0x275C;
  12947. t['a99'] = 0x275D;
  12948. t['a100'] = 0x275E;
  12949. t['a101'] = 0x2761;
  12950. t['a102'] = 0x2762;
  12951. t['a103'] = 0x2763;
  12952. t['a104'] = 0x2764;
  12953. t['a106'] = 0x2765;
  12954. t['a107'] = 0x2766;
  12955. t['a108'] = 0x2767;
  12956. t['a112'] = 0x2663;
  12957. t['a111'] = 0x2666;
  12958. t['a110'] = 0x2665;
  12959. t['a109'] = 0x2660;
  12960. t['a120'] = 0x2460;
  12961. t['a121'] = 0x2461;
  12962. t['a122'] = 0x2462;
  12963. t['a123'] = 0x2463;
  12964. t['a124'] = 0x2464;
  12965. t['a125'] = 0x2465;
  12966. t['a126'] = 0x2466;
  12967. t['a127'] = 0x2467;
  12968. t['a128'] = 0x2468;
  12969. t['a129'] = 0x2469;
  12970. t['a130'] = 0x2776;
  12971. t['a131'] = 0x2777;
  12972. t['a132'] = 0x2778;
  12973. t['a133'] = 0x2779;
  12974. t['a134'] = 0x277A;
  12975. t['a135'] = 0x277B;
  12976. t['a136'] = 0x277C;
  12977. t['a137'] = 0x277D;
  12978. t['a138'] = 0x277E;
  12979. t['a139'] = 0x277F;
  12980. t['a140'] = 0x2780;
  12981. t['a141'] = 0x2781;
  12982. t['a142'] = 0x2782;
  12983. t['a143'] = 0x2783;
  12984. t['a144'] = 0x2784;
  12985. t['a145'] = 0x2785;
  12986. t['a146'] = 0x2786;
  12987. t['a147'] = 0x2787;
  12988. t['a148'] = 0x2788;
  12989. t['a149'] = 0x2789;
  12990. t['a150'] = 0x278A;
  12991. t['a151'] = 0x278B;
  12992. t['a152'] = 0x278C;
  12993. t['a153'] = 0x278D;
  12994. t['a154'] = 0x278E;
  12995. t['a155'] = 0x278F;
  12996. t['a156'] = 0x2790;
  12997. t['a157'] = 0x2791;
  12998. t['a158'] = 0x2792;
  12999. t['a159'] = 0x2793;
  13000. t['a160'] = 0x2794;
  13001. t['a161'] = 0x2192;
  13002. t['a163'] = 0x2194;
  13003. t['a164'] = 0x2195;
  13004. t['a196'] = 0x2798;
  13005. t['a165'] = 0x2799;
  13006. t['a192'] = 0x279A;
  13007. t['a166'] = 0x279B;
  13008. t['a167'] = 0x279C;
  13009. t['a168'] = 0x279D;
  13010. t['a169'] = 0x279E;
  13011. t['a170'] = 0x279F;
  13012. t['a171'] = 0x27A0;
  13013. t['a172'] = 0x27A1;
  13014. t['a173'] = 0x27A2;
  13015. t['a162'] = 0x27A3;
  13016. t['a174'] = 0x27A4;
  13017. t['a175'] = 0x27A5;
  13018. t['a176'] = 0x27A6;
  13019. t['a177'] = 0x27A7;
  13020. t['a178'] = 0x27A8;
  13021. t['a179'] = 0x27A9;
  13022. t['a193'] = 0x27AA;
  13023. t['a180'] = 0x27AB;
  13024. t['a199'] = 0x27AC;
  13025. t['a181'] = 0x27AD;
  13026. t['a200'] = 0x27AE;
  13027. t['a182'] = 0x27AF;
  13028. t['a201'] = 0x27B1;
  13029. t['a183'] = 0x27B2;
  13030. t['a184'] = 0x27B3;
  13031. t['a197'] = 0x27B4;
  13032. t['a185'] = 0x27B5;
  13033. t['a194'] = 0x27B6;
  13034. t['a198'] = 0x27B7;
  13035. t['a186'] = 0x27B8;
  13036. t['a195'] = 0x27B9;
  13037. t['a187'] = 0x27BA;
  13038. t['a188'] = 0x27BB;
  13039. t['a189'] = 0x27BC;
  13040. t['a190'] = 0x27BD;
  13041. t['a191'] = 0x27BE;
  13042. t['a89'] = 0x2768;
  13043. t['a90'] = 0x2769;
  13044. t['a93'] = 0x276A;
  13045. t['a94'] = 0x276B;
  13046. t['a91'] = 0x276C;
  13047. t['a92'] = 0x276D;
  13048. t['a205'] = 0x276E;
  13049. t['a85'] = 0x276F;
  13050. t['a206'] = 0x2770;
  13051. t['a86'] = 0x2771;
  13052. t['a87'] = 0x2772;
  13053. t['a88'] = 0x2773;
  13054. t['a95'] = 0x2774;
  13055. t['a96'] = 0x2775;
  13056. t['.notdef'] = 0x0000;
  13057. });
  13058. exports.getGlyphsUnicode = getGlyphsUnicode;
  13059. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  13060. }));
  13061. (function (root, factory) {
  13062. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  13063. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  13064. var error = sharedUtil.error;
  13065. var log2 = sharedUtil.log2;
  13066. var readInt8 = sharedUtil.readInt8;
  13067. var readUint16 = sharedUtil.readUint16;
  13068. var readUint32 = sharedUtil.readUint32;
  13069. var shadow = sharedUtil.shadow;
  13070. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  13071. var Jbig2Image = function Jbig2ImageClosure() {
  13072. function ContextCache() {
  13073. }
  13074. ContextCache.prototype = {
  13075. getContexts: function (id) {
  13076. if (id in this) {
  13077. return this[id];
  13078. }
  13079. return this[id] = new Int8Array(1 << 16);
  13080. }
  13081. };
  13082. function DecodingContext(data, start, end) {
  13083. this.data = data;
  13084. this.start = start;
  13085. this.end = end;
  13086. }
  13087. DecodingContext.prototype = {
  13088. get decoder() {
  13089. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  13090. return shadow(this, 'decoder', decoder);
  13091. },
  13092. get contextCache() {
  13093. var cache = new ContextCache();
  13094. return shadow(this, 'contextCache', cache);
  13095. }
  13096. };
  13097. function decodeInteger(contextCache, procedure, decoder) {
  13098. var contexts = contextCache.getContexts(procedure);
  13099. var prev = 1;
  13100. function readBits(length) {
  13101. var v = 0;
  13102. for (var i = 0; i < length; i++) {
  13103. var bit = decoder.readBit(contexts, prev);
  13104. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  13105. v = v << 1 | bit;
  13106. }
  13107. return v >>> 0;
  13108. }
  13109. var sign = readBits(1);
  13110. 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);
  13111. return sign === 0 ? value : value > 0 ? -value : null;
  13112. }
  13113. function decodeIAID(contextCache, decoder, codeLength) {
  13114. var contexts = contextCache.getContexts('IAID');
  13115. var prev = 1;
  13116. for (var i = 0; i < codeLength; i++) {
  13117. var bit = decoder.readBit(contexts, prev);
  13118. prev = prev << 1 | bit;
  13119. }
  13120. if (codeLength < 31) {
  13121. return prev & (1 << codeLength) - 1;
  13122. }
  13123. return prev & 0x7FFFFFFF;
  13124. }
  13125. var SegmentTypes = [
  13126. 'SymbolDictionary',
  13127. null,
  13128. null,
  13129. null,
  13130. 'IntermediateTextRegion',
  13131. null,
  13132. 'ImmediateTextRegion',
  13133. 'ImmediateLosslessTextRegion',
  13134. null,
  13135. null,
  13136. null,
  13137. null,
  13138. null,
  13139. null,
  13140. null,
  13141. null,
  13142. 'patternDictionary',
  13143. null,
  13144. null,
  13145. null,
  13146. 'IntermediateHalftoneRegion',
  13147. null,
  13148. 'ImmediateHalftoneRegion',
  13149. 'ImmediateLosslessHalftoneRegion',
  13150. null,
  13151. null,
  13152. null,
  13153. null,
  13154. null,
  13155. null,
  13156. null,
  13157. null,
  13158. null,
  13159. null,
  13160. null,
  13161. null,
  13162. 'IntermediateGenericRegion',
  13163. null,
  13164. 'ImmediateGenericRegion',
  13165. 'ImmediateLosslessGenericRegion',
  13166. 'IntermediateGenericRefinementRegion',
  13167. null,
  13168. 'ImmediateGenericRefinementRegion',
  13169. 'ImmediateLosslessGenericRefinementRegion',
  13170. null,
  13171. null,
  13172. null,
  13173. null,
  13174. 'PageInformation',
  13175. 'EndOfPage',
  13176. 'EndOfStripe',
  13177. 'EndOfFile',
  13178. 'Profiles',
  13179. 'Tables',
  13180. null,
  13181. null,
  13182. null,
  13183. null,
  13184. null,
  13185. null,
  13186. null,
  13187. null,
  13188. 'Extension'
  13189. ];
  13190. var CodingTemplates = [
  13191. [
  13192. {
  13193. x: -1,
  13194. y: -2
  13195. },
  13196. {
  13197. x: 0,
  13198. y: -2
  13199. },
  13200. {
  13201. x: 1,
  13202. y: -2
  13203. },
  13204. {
  13205. x: -2,
  13206. y: -1
  13207. },
  13208. {
  13209. x: -1,
  13210. y: -1
  13211. },
  13212. {
  13213. x: 0,
  13214. y: -1
  13215. },
  13216. {
  13217. x: 1,
  13218. y: -1
  13219. },
  13220. {
  13221. x: 2,
  13222. y: -1
  13223. },
  13224. {
  13225. x: -4,
  13226. y: 0
  13227. },
  13228. {
  13229. x: -3,
  13230. y: 0
  13231. },
  13232. {
  13233. x: -2,
  13234. y: 0
  13235. },
  13236. {
  13237. x: -1,
  13238. y: 0
  13239. }
  13240. ],
  13241. [
  13242. {
  13243. x: -1,
  13244. y: -2
  13245. },
  13246. {
  13247. x: 0,
  13248. y: -2
  13249. },
  13250. {
  13251. x: 1,
  13252. y: -2
  13253. },
  13254. {
  13255. x: 2,
  13256. y: -2
  13257. },
  13258. {
  13259. x: -2,
  13260. y: -1
  13261. },
  13262. {
  13263. x: -1,
  13264. y: -1
  13265. },
  13266. {
  13267. x: 0,
  13268. y: -1
  13269. },
  13270. {
  13271. x: 1,
  13272. y: -1
  13273. },
  13274. {
  13275. x: 2,
  13276. y: -1
  13277. },
  13278. {
  13279. x: -3,
  13280. y: 0
  13281. },
  13282. {
  13283. x: -2,
  13284. y: 0
  13285. },
  13286. {
  13287. x: -1,
  13288. y: 0
  13289. }
  13290. ],
  13291. [
  13292. {
  13293. x: -1,
  13294. y: -2
  13295. },
  13296. {
  13297. x: 0,
  13298. y: -2
  13299. },
  13300. {
  13301. x: 1,
  13302. y: -2
  13303. },
  13304. {
  13305. x: -2,
  13306. y: -1
  13307. },
  13308. {
  13309. x: -1,
  13310. y: -1
  13311. },
  13312. {
  13313. x: 0,
  13314. y: -1
  13315. },
  13316. {
  13317. x: 1,
  13318. y: -1
  13319. },
  13320. {
  13321. x: -2,
  13322. y: 0
  13323. },
  13324. {
  13325. x: -1,
  13326. y: 0
  13327. }
  13328. ],
  13329. [
  13330. {
  13331. x: -3,
  13332. y: -1
  13333. },
  13334. {
  13335. x: -2,
  13336. y: -1
  13337. },
  13338. {
  13339. x: -1,
  13340. y: -1
  13341. },
  13342. {
  13343. x: 0,
  13344. y: -1
  13345. },
  13346. {
  13347. x: 1,
  13348. y: -1
  13349. },
  13350. {
  13351. x: -4,
  13352. y: 0
  13353. },
  13354. {
  13355. x: -3,
  13356. y: 0
  13357. },
  13358. {
  13359. x: -2,
  13360. y: 0
  13361. },
  13362. {
  13363. x: -1,
  13364. y: 0
  13365. }
  13366. ]
  13367. ];
  13368. var RefinementTemplates = [
  13369. {
  13370. coding: [
  13371. {
  13372. x: 0,
  13373. y: -1
  13374. },
  13375. {
  13376. x: 1,
  13377. y: -1
  13378. },
  13379. {
  13380. x: -1,
  13381. y: 0
  13382. }
  13383. ],
  13384. reference: [
  13385. {
  13386. x: 0,
  13387. y: -1
  13388. },
  13389. {
  13390. x: 1,
  13391. y: -1
  13392. },
  13393. {
  13394. x: -1,
  13395. y: 0
  13396. },
  13397. {
  13398. x: 0,
  13399. y: 0
  13400. },
  13401. {
  13402. x: 1,
  13403. y: 0
  13404. },
  13405. {
  13406. x: -1,
  13407. y: 1
  13408. },
  13409. {
  13410. x: 0,
  13411. y: 1
  13412. },
  13413. {
  13414. x: 1,
  13415. y: 1
  13416. }
  13417. ]
  13418. },
  13419. {
  13420. coding: [
  13421. {
  13422. x: -1,
  13423. y: -1
  13424. },
  13425. {
  13426. x: 0,
  13427. y: -1
  13428. },
  13429. {
  13430. x: 1,
  13431. y: -1
  13432. },
  13433. {
  13434. x: -1,
  13435. y: 0
  13436. }
  13437. ],
  13438. reference: [
  13439. {
  13440. x: 0,
  13441. y: -1
  13442. },
  13443. {
  13444. x: -1,
  13445. y: 0
  13446. },
  13447. {
  13448. x: 0,
  13449. y: 0
  13450. },
  13451. {
  13452. x: 1,
  13453. y: 0
  13454. },
  13455. {
  13456. x: 0,
  13457. y: 1
  13458. },
  13459. {
  13460. x: 1,
  13461. y: 1
  13462. }
  13463. ]
  13464. }
  13465. ];
  13466. var ReusedContexts = [
  13467. 0x9B25,
  13468. 0x0795,
  13469. 0x00E5,
  13470. 0x0195
  13471. ];
  13472. var RefinementReusedContexts = [
  13473. 0x0020,
  13474. 0x0008
  13475. ];
  13476. function decodeBitmapTemplate0(width, height, decodingContext) {
  13477. var decoder = decodingContext.decoder;
  13478. var contexts = decodingContext.contextCache.getContexts('GB');
  13479. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13480. var OLD_PIXEL_MASK = 0x7BF7;
  13481. for (i = 0; i < height; i++) {
  13482. row = bitmap[i] = new Uint8Array(width);
  13483. row1 = i < 1 ? row : bitmap[i - 1];
  13484. row2 = i < 2 ? row : bitmap[i - 2];
  13485. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13486. for (j = 0; j < width; j++) {
  13487. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13488. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13489. }
  13490. }
  13491. return bitmap;
  13492. }
  13493. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13494. if (mmr) {
  13495. error('JBIG2 error: MMR encoding is not supported');
  13496. }
  13497. 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) {
  13498. return decodeBitmapTemplate0(width, height, decodingContext);
  13499. }
  13500. var useskip = !!skip;
  13501. var template = CodingTemplates[templateIndex].concat(at);
  13502. template.sort(function (a, b) {
  13503. return a.y - b.y || a.x - b.x;
  13504. });
  13505. var templateLength = template.length;
  13506. var templateX = new Int8Array(templateLength);
  13507. var templateY = new Int8Array(templateLength);
  13508. var changingTemplateEntries = [];
  13509. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13510. var c, k;
  13511. for (k = 0; k < templateLength; k++) {
  13512. templateX[k] = template[k].x;
  13513. templateY[k] = template[k].y;
  13514. minX = Math.min(minX, template[k].x);
  13515. maxX = Math.max(maxX, template[k].x);
  13516. minY = Math.min(minY, template[k].y);
  13517. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13518. reuseMask |= 1 << templateLength - 1 - k;
  13519. } else {
  13520. changingTemplateEntries.push(k);
  13521. }
  13522. }
  13523. var changingEntriesLength = changingTemplateEntries.length;
  13524. var changingTemplateX = new Int8Array(changingEntriesLength);
  13525. var changingTemplateY = new Int8Array(changingEntriesLength);
  13526. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13527. for (c = 0; c < changingEntriesLength; c++) {
  13528. k = changingTemplateEntries[c];
  13529. changingTemplateX[c] = template[k].x;
  13530. changingTemplateY[c] = template[k].y;
  13531. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13532. }
  13533. var sbb_left = -minX;
  13534. var sbb_top = -minY;
  13535. var sbb_right = width - maxX;
  13536. var pseudoPixelContext = ReusedContexts[templateIndex];
  13537. var row = new Uint8Array(width);
  13538. var bitmap = [];
  13539. var decoder = decodingContext.decoder;
  13540. var contexts = decodingContext.contextCache.getContexts('GB');
  13541. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13542. for (var i = 0; i < height; i++) {
  13543. if (prediction) {
  13544. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13545. ltp ^= sltp;
  13546. if (ltp) {
  13547. bitmap.push(row);
  13548. continue;
  13549. }
  13550. }
  13551. row = new Uint8Array(row);
  13552. bitmap.push(row);
  13553. for (j = 0; j < width; j++) {
  13554. if (useskip && skip[i][j]) {
  13555. row[j] = 0;
  13556. continue;
  13557. }
  13558. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13559. contextLabel = contextLabel << 1 & reuseMask;
  13560. for (k = 0; k < changingEntriesLength; k++) {
  13561. i0 = i + changingTemplateY[k];
  13562. j0 = j + changingTemplateX[k];
  13563. bit = bitmap[i0][j0];
  13564. if (bit) {
  13565. bit = changingTemplateBit[k];
  13566. contextLabel |= bit;
  13567. }
  13568. }
  13569. } else {
  13570. contextLabel = 0;
  13571. shift = templateLength - 1;
  13572. for (k = 0; k < templateLength; k++, shift--) {
  13573. j0 = j + templateX[k];
  13574. if (j0 >= 0 && j0 < width) {
  13575. i0 = i + templateY[k];
  13576. if (i0 >= 0) {
  13577. bit = bitmap[i0][j0];
  13578. if (bit) {
  13579. contextLabel |= bit << shift;
  13580. }
  13581. }
  13582. }
  13583. }
  13584. }
  13585. var pixel = decoder.readBit(contexts, contextLabel);
  13586. row[j] = pixel;
  13587. }
  13588. }
  13589. return bitmap;
  13590. }
  13591. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13592. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13593. if (templateIndex === 0) {
  13594. codingTemplate = codingTemplate.concat([at[0]]);
  13595. }
  13596. var codingTemplateLength = codingTemplate.length;
  13597. var codingTemplateX = new Int32Array(codingTemplateLength);
  13598. var codingTemplateY = new Int32Array(codingTemplateLength);
  13599. var k;
  13600. for (k = 0; k < codingTemplateLength; k++) {
  13601. codingTemplateX[k] = codingTemplate[k].x;
  13602. codingTemplateY[k] = codingTemplate[k].y;
  13603. }
  13604. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13605. if (templateIndex === 0) {
  13606. referenceTemplate = referenceTemplate.concat([at[1]]);
  13607. }
  13608. var referenceTemplateLength = referenceTemplate.length;
  13609. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13610. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13611. for (k = 0; k < referenceTemplateLength; k++) {
  13612. referenceTemplateX[k] = referenceTemplate[k].x;
  13613. referenceTemplateY[k] = referenceTemplate[k].y;
  13614. }
  13615. var referenceWidth = referenceBitmap[0].length;
  13616. var referenceHeight = referenceBitmap.length;
  13617. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13618. var bitmap = [];
  13619. var decoder = decodingContext.decoder;
  13620. var contexts = decodingContext.contextCache.getContexts('GR');
  13621. var ltp = 0;
  13622. for (var i = 0; i < height; i++) {
  13623. if (prediction) {
  13624. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13625. ltp ^= sltp;
  13626. if (ltp) {
  13627. error('JBIG2 error: prediction is not supported');
  13628. }
  13629. }
  13630. var row = new Uint8Array(width);
  13631. bitmap.push(row);
  13632. for (var j = 0; j < width; j++) {
  13633. var i0, j0;
  13634. var contextLabel = 0;
  13635. for (k = 0; k < codingTemplateLength; k++) {
  13636. i0 = i + codingTemplateY[k];
  13637. j0 = j + codingTemplateX[k];
  13638. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13639. contextLabel <<= 1;
  13640. } else
  13641. {
  13642. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13643. }
  13644. }
  13645. for (k = 0; k < referenceTemplateLength; k++) {
  13646. i0 = i + referenceTemplateY[k] + offsetY;
  13647. j0 = j + referenceTemplateX[k] + offsetX;
  13648. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13649. contextLabel <<= 1;
  13650. } else
  13651. {
  13652. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13653. }
  13654. }
  13655. var pixel = decoder.readBit(contexts, contextLabel);
  13656. row[j] = pixel;
  13657. }
  13658. }
  13659. return bitmap;
  13660. }
  13661. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13662. if (huffman) {
  13663. error('JBIG2 error: huffman is not supported');
  13664. }
  13665. var newSymbols = [];
  13666. var currentHeight = 0;
  13667. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13668. var decoder = decodingContext.decoder;
  13669. var contextCache = decodingContext.contextCache;
  13670. while (newSymbols.length < numberOfNewSymbols) {
  13671. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13672. currentHeight += deltaHeight;
  13673. var currentWidth = 0;
  13674. var totalWidth = 0;
  13675. while (true) {
  13676. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13677. if (deltaWidth === null) {
  13678. break;
  13679. }
  13680. currentWidth += deltaWidth;
  13681. totalWidth += currentWidth;
  13682. var bitmap;
  13683. if (refinement) {
  13684. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13685. if (numberOfInstances > 1) {
  13686. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13687. } else {
  13688. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13689. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13690. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13691. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13692. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13693. }
  13694. } else {
  13695. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13696. }
  13697. newSymbols.push(bitmap);
  13698. }
  13699. }
  13700. var exportedSymbols = [];
  13701. var flags = [], currentFlag = false;
  13702. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13703. while (flags.length < totalSymbolsLength) {
  13704. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13705. while (runLength--) {
  13706. flags.push(currentFlag);
  13707. }
  13708. currentFlag = !currentFlag;
  13709. }
  13710. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13711. if (flags[i]) {
  13712. exportedSymbols.push(symbols[i]);
  13713. }
  13714. }
  13715. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13716. if (flags[i]) {
  13717. exportedSymbols.push(newSymbols[j]);
  13718. }
  13719. }
  13720. return exportedSymbols;
  13721. }
  13722. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13723. if (huffman) {
  13724. error('JBIG2 error: huffman is not supported');
  13725. }
  13726. var bitmap = [];
  13727. var i, row;
  13728. for (i = 0; i < height; i++) {
  13729. row = new Uint8Array(width);
  13730. if (defaultPixelValue) {
  13731. for (var j = 0; j < width; j++) {
  13732. row[j] = defaultPixelValue;
  13733. }
  13734. }
  13735. bitmap.push(row);
  13736. }
  13737. var decoder = decodingContext.decoder;
  13738. var contextCache = decodingContext.contextCache;
  13739. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13740. var firstS = 0;
  13741. i = 0;
  13742. while (i < numberOfSymbolInstances) {
  13743. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13744. stripT += deltaT;
  13745. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13746. firstS += deltaFirstS;
  13747. var currentS = firstS;
  13748. do {
  13749. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13750. var t = stripSize * stripT + currentT;
  13751. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13752. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13753. var symbolBitmap = inputSymbols[symbolId];
  13754. var symbolWidth = symbolBitmap[0].length;
  13755. var symbolHeight = symbolBitmap.length;
  13756. if (applyRefinement) {
  13757. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13758. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13759. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13760. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13761. symbolWidth += rdw;
  13762. symbolHeight += rdh;
  13763. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13764. }
  13765. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13766. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13767. var s2, t2, symbolRow;
  13768. if (transposed) {
  13769. for (s2 = 0; s2 < symbolHeight; s2++) {
  13770. row = bitmap[offsetS + s2];
  13771. if (!row) {
  13772. continue;
  13773. }
  13774. symbolRow = symbolBitmap[s2];
  13775. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13776. switch (combinationOperator) {
  13777. case 0:
  13778. for (t2 = 0; t2 < maxWidth; t2++) {
  13779. row[offsetT + t2] |= symbolRow[t2];
  13780. }
  13781. break;
  13782. case 2:
  13783. for (t2 = 0; t2 < maxWidth; t2++) {
  13784. row[offsetT + t2] ^= symbolRow[t2];
  13785. }
  13786. break;
  13787. default:
  13788. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13789. }
  13790. }
  13791. currentS += symbolHeight - 1;
  13792. } else {
  13793. for (t2 = 0; t2 < symbolHeight; t2++) {
  13794. row = bitmap[offsetT + t2];
  13795. if (!row) {
  13796. continue;
  13797. }
  13798. symbolRow = symbolBitmap[t2];
  13799. switch (combinationOperator) {
  13800. case 0:
  13801. for (s2 = 0; s2 < symbolWidth; s2++) {
  13802. row[offsetS + s2] |= symbolRow[s2];
  13803. }
  13804. break;
  13805. case 2:
  13806. for (s2 = 0; s2 < symbolWidth; s2++) {
  13807. row[offsetS + s2] ^= symbolRow[s2];
  13808. }
  13809. break;
  13810. default:
  13811. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13812. }
  13813. }
  13814. currentS += symbolWidth - 1;
  13815. }
  13816. i++;
  13817. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13818. if (deltaS === null) {
  13819. break;
  13820. }
  13821. currentS += deltaS + dsOffset;
  13822. } while (true);
  13823. }
  13824. return bitmap;
  13825. }
  13826. function readSegmentHeader(data, start) {
  13827. var segmentHeader = {};
  13828. segmentHeader.number = readUint32(data, start);
  13829. var flags = data[start + 4];
  13830. var segmentType = flags & 0x3F;
  13831. if (!SegmentTypes[segmentType]) {
  13832. error('JBIG2 error: invalid segment type: ' + segmentType);
  13833. }
  13834. segmentHeader.type = segmentType;
  13835. segmentHeader.typeName = SegmentTypes[segmentType];
  13836. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13837. var pageAssociationFieldSize = !!(flags & 0x40);
  13838. var referredFlags = data[start + 5];
  13839. var referredToCount = referredFlags >> 5 & 7;
  13840. var retainBits = [referredFlags & 31];
  13841. var position = start + 6;
  13842. if (referredFlags === 7) {
  13843. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13844. position += 3;
  13845. var bytes = referredToCount + 7 >> 3;
  13846. retainBits[0] = data[position++];
  13847. while (--bytes > 0) {
  13848. retainBits.push(data[position++]);
  13849. }
  13850. } else if (referredFlags === 5 || referredFlags === 6) {
  13851. error('JBIG2 error: invalid referred-to flags');
  13852. }
  13853. segmentHeader.retainBits = retainBits;
  13854. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13855. var referredTo = [];
  13856. var i, ii;
  13857. for (i = 0; i < referredToCount; i++) {
  13858. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13859. referredTo.push(number);
  13860. position += referredToSegmentNumberSize;
  13861. }
  13862. segmentHeader.referredTo = referredTo;
  13863. if (!pageAssociationFieldSize) {
  13864. segmentHeader.pageAssociation = data[position++];
  13865. } else {
  13866. segmentHeader.pageAssociation = readUint32(data, position);
  13867. position += 4;
  13868. }
  13869. segmentHeader.length = readUint32(data, position);
  13870. position += 4;
  13871. if (segmentHeader.length === 0xFFFFFFFF) {
  13872. if (segmentType === 38) {
  13873. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13874. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13875. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13876. var searchPatternLength = 6;
  13877. var searchPattern = new Uint8Array(searchPatternLength);
  13878. if (!genericRegionMmr) {
  13879. searchPattern[0] = 0xFF;
  13880. searchPattern[1] = 0xAC;
  13881. }
  13882. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13883. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13884. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13885. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13886. for (i = position, ii = data.length; i < ii; i++) {
  13887. var j = 0;
  13888. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13889. j++;
  13890. }
  13891. if (j === searchPatternLength) {
  13892. segmentHeader.length = i + searchPatternLength;
  13893. break;
  13894. }
  13895. }
  13896. if (segmentHeader.length === 0xFFFFFFFF) {
  13897. error('JBIG2 error: segment end was not found');
  13898. }
  13899. } else {
  13900. error('JBIG2 error: invalid unknown segment length');
  13901. }
  13902. }
  13903. segmentHeader.headerEnd = position;
  13904. return segmentHeader;
  13905. }
  13906. function readSegments(header, data, start, end) {
  13907. var segments = [];
  13908. var position = start;
  13909. while (position < end) {
  13910. var segmentHeader = readSegmentHeader(data, position);
  13911. position = segmentHeader.headerEnd;
  13912. var segment = {
  13913. header: segmentHeader,
  13914. data: data
  13915. };
  13916. if (!header.randomAccess) {
  13917. segment.start = position;
  13918. position += segmentHeader.length;
  13919. segment.end = position;
  13920. }
  13921. segments.push(segment);
  13922. if (segmentHeader.type === 51) {
  13923. break;
  13924. }
  13925. }
  13926. if (header.randomAccess) {
  13927. for (var i = 0, ii = segments.length; i < ii; i++) {
  13928. segments[i].start = position;
  13929. position += segments[i].header.length;
  13930. segments[i].end = position;
  13931. }
  13932. }
  13933. return segments;
  13934. }
  13935. function readRegionSegmentInformation(data, start) {
  13936. return {
  13937. width: readUint32(data, start),
  13938. height: readUint32(data, start + 4),
  13939. x: readUint32(data, start + 8),
  13940. y: readUint32(data, start + 12),
  13941. combinationOperator: data[start + 16] & 7
  13942. };
  13943. }
  13944. var RegionSegmentInformationFieldLength = 17;
  13945. function processSegment(segment, visitor) {
  13946. var header = segment.header;
  13947. var data = segment.data, position = segment.start, end = segment.end;
  13948. var args, at, i, atLength;
  13949. switch (header.type) {
  13950. case 0:
  13951. var dictionary = {};
  13952. var dictionaryFlags = readUint16(data, position);
  13953. dictionary.huffman = !!(dictionaryFlags & 1);
  13954. dictionary.refinement = !!(dictionaryFlags & 2);
  13955. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13956. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13957. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13958. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13959. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13960. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13961. dictionary.template = dictionaryFlags >> 10 & 3;
  13962. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13963. position += 2;
  13964. if (!dictionary.huffman) {
  13965. atLength = dictionary.template === 0 ? 4 : 1;
  13966. at = [];
  13967. for (i = 0; i < atLength; i++) {
  13968. at.push({
  13969. x: readInt8(data, position),
  13970. y: readInt8(data, position + 1)
  13971. });
  13972. position += 2;
  13973. }
  13974. dictionary.at = at;
  13975. }
  13976. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13977. at = [];
  13978. for (i = 0; i < 2; i++) {
  13979. at.push({
  13980. x: readInt8(data, position),
  13981. y: readInt8(data, position + 1)
  13982. });
  13983. position += 2;
  13984. }
  13985. dictionary.refinementAt = at;
  13986. }
  13987. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13988. position += 4;
  13989. dictionary.numberOfNewSymbols = readUint32(data, position);
  13990. position += 4;
  13991. args = [
  13992. dictionary,
  13993. header.number,
  13994. header.referredTo,
  13995. data,
  13996. position,
  13997. end
  13998. ];
  13999. break;
  14000. case 6:
  14001. case 7:
  14002. var textRegion = {};
  14003. textRegion.info = readRegionSegmentInformation(data, position);
  14004. position += RegionSegmentInformationFieldLength;
  14005. var textRegionSegmentFlags = readUint16(data, position);
  14006. position += 2;
  14007. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  14008. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  14009. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  14010. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  14011. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  14012. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  14013. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  14014. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  14015. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  14016. if (textRegion.huffman) {
  14017. var textRegionHuffmanFlags = readUint16(data, position);
  14018. position += 2;
  14019. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  14020. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  14021. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  14022. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  14023. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  14024. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  14025. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  14026. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  14027. }
  14028. if (textRegion.refinement && !textRegion.refinementTemplate) {
  14029. at = [];
  14030. for (i = 0; i < 2; i++) {
  14031. at.push({
  14032. x: readInt8(data, position),
  14033. y: readInt8(data, position + 1)
  14034. });
  14035. position += 2;
  14036. }
  14037. textRegion.refinementAt = at;
  14038. }
  14039. textRegion.numberOfSymbolInstances = readUint32(data, position);
  14040. position += 4;
  14041. if (textRegion.huffman) {
  14042. error('JBIG2 error: huffman is not supported');
  14043. }
  14044. args = [
  14045. textRegion,
  14046. header.referredTo,
  14047. data,
  14048. position,
  14049. end
  14050. ];
  14051. break;
  14052. case 38:
  14053. case 39:
  14054. var genericRegion = {};
  14055. genericRegion.info = readRegionSegmentInformation(data, position);
  14056. position += RegionSegmentInformationFieldLength;
  14057. var genericRegionSegmentFlags = data[position++];
  14058. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  14059. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  14060. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  14061. if (!genericRegion.mmr) {
  14062. atLength = genericRegion.template === 0 ? 4 : 1;
  14063. at = [];
  14064. for (i = 0; i < atLength; i++) {
  14065. at.push({
  14066. x: readInt8(data, position),
  14067. y: readInt8(data, position + 1)
  14068. });
  14069. position += 2;
  14070. }
  14071. genericRegion.at = at;
  14072. }
  14073. args = [
  14074. genericRegion,
  14075. data,
  14076. position,
  14077. end
  14078. ];
  14079. break;
  14080. case 48:
  14081. var pageInfo = {
  14082. width: readUint32(data, position),
  14083. height: readUint32(data, position + 4),
  14084. resolutionX: readUint32(data, position + 8),
  14085. resolutionY: readUint32(data, position + 12)
  14086. };
  14087. if (pageInfo.height === 0xFFFFFFFF) {
  14088. delete pageInfo.height;
  14089. }
  14090. var pageSegmentFlags = data[position + 16];
  14091. var pageStripingInformation = readUint16(data, position + 17);
  14092. pageInfo.lossless = !!(pageSegmentFlags & 1);
  14093. pageInfo.refinement = !!(pageSegmentFlags & 2);
  14094. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  14095. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  14096. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  14097. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  14098. args = [pageInfo];
  14099. break;
  14100. case 49:
  14101. break;
  14102. case 50:
  14103. break;
  14104. case 51:
  14105. break;
  14106. case 62:
  14107. break;
  14108. default:
  14109. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  14110. }
  14111. var callbackName = 'on' + header.typeName;
  14112. if (callbackName in visitor) {
  14113. visitor[callbackName].apply(visitor, args);
  14114. }
  14115. }
  14116. function processSegments(segments, visitor) {
  14117. for (var i = 0, ii = segments.length; i < ii; i++) {
  14118. processSegment(segments[i], visitor);
  14119. }
  14120. }
  14121. function parseJbig2(data, start, end) {
  14122. var position = start;
  14123. 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) {
  14124. error('JBIG2 error: invalid header');
  14125. }
  14126. var header = {};
  14127. position += 8;
  14128. var flags = data[position++];
  14129. header.randomAccess = !(flags & 1);
  14130. if (!(flags & 2)) {
  14131. header.numberOfPages = readUint32(data, position);
  14132. position += 4;
  14133. }
  14134. var segments = readSegments(header, data, position, end);
  14135. error('Not implemented');
  14136. }
  14137. function parseJbig2Chunks(chunks) {
  14138. var visitor = new SimpleSegmentVisitor();
  14139. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14140. var chunk = chunks[i];
  14141. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14142. processSegments(segments, visitor);
  14143. }
  14144. return visitor.buffer;
  14145. }
  14146. function SimpleSegmentVisitor() {
  14147. }
  14148. SimpleSegmentVisitor.prototype = {
  14149. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14150. this.currentPageInfo = info;
  14151. var rowSize = info.width + 7 >> 3;
  14152. var buffer = new Uint8Array(rowSize * info.height);
  14153. if (info.defaultPixelValue) {
  14154. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14155. buffer[i] = 0xFF;
  14156. }
  14157. }
  14158. this.buffer = buffer;
  14159. },
  14160. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14161. var pageInfo = this.currentPageInfo;
  14162. var width = regionInfo.width, height = regionInfo.height;
  14163. var rowSize = pageInfo.width + 7 >> 3;
  14164. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14165. var buffer = this.buffer;
  14166. var mask0 = 128 >> (regionInfo.x & 7);
  14167. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14168. var i, j, mask, offset;
  14169. switch (combinationOperator) {
  14170. case 0:
  14171. for (i = 0; i < height; i++) {
  14172. mask = mask0;
  14173. offset = offset0;
  14174. for (j = 0; j < width; j++) {
  14175. if (bitmap[i][j]) {
  14176. buffer[offset] |= mask;
  14177. }
  14178. mask >>= 1;
  14179. if (!mask) {
  14180. mask = 128;
  14181. offset++;
  14182. }
  14183. }
  14184. offset0 += rowSize;
  14185. }
  14186. break;
  14187. case 2:
  14188. for (i = 0; i < height; i++) {
  14189. mask = mask0;
  14190. offset = offset0;
  14191. for (j = 0; j < width; j++) {
  14192. if (bitmap[i][j]) {
  14193. buffer[offset] ^= mask;
  14194. }
  14195. mask >>= 1;
  14196. if (!mask) {
  14197. mask = 128;
  14198. offset++;
  14199. }
  14200. }
  14201. offset0 += rowSize;
  14202. }
  14203. break;
  14204. default:
  14205. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14206. }
  14207. },
  14208. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14209. var regionInfo = region.info;
  14210. var decodingContext = new DecodingContext(data, start, end);
  14211. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14212. this.drawBitmap(regionInfo, bitmap);
  14213. },
  14214. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14215. this.onImmediateGenericRegion.apply(this, arguments);
  14216. },
  14217. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14218. var huffmanTables;
  14219. if (dictionary.huffman) {
  14220. error('JBIG2 error: huffman is not supported');
  14221. }
  14222. var symbols = this.symbols;
  14223. if (!symbols) {
  14224. this.symbols = symbols = {};
  14225. }
  14226. var inputSymbols = [];
  14227. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14228. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14229. }
  14230. var decodingContext = new DecodingContext(data, start, end);
  14231. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14232. },
  14233. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14234. var regionInfo = region.info;
  14235. var huffmanTables;
  14236. var symbols = this.symbols;
  14237. var inputSymbols = [];
  14238. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14239. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14240. }
  14241. var symbolCodeLength = log2(inputSymbols.length);
  14242. var decodingContext = new DecodingContext(data, start, end);
  14243. 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);
  14244. this.drawBitmap(regionInfo, bitmap);
  14245. },
  14246. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14247. this.onImmediateTextRegion.apply(this, arguments);
  14248. }
  14249. };
  14250. function Jbig2Image() {
  14251. }
  14252. Jbig2Image.prototype = {
  14253. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14254. return parseJbig2Chunks(chunks);
  14255. }
  14256. };
  14257. return Jbig2Image;
  14258. }();
  14259. exports.Jbig2Image = Jbig2Image;
  14260. }));
  14261. (function (root, factory) {
  14262. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14263. }(this, function (exports, sharedUtil) {
  14264. var error = sharedUtil.error;
  14265. var JpegImage = function JpegImageClosure() {
  14266. var dctZigZag = new Uint8Array([
  14267. 0,
  14268. 1,
  14269. 8,
  14270. 16,
  14271. 9,
  14272. 2,
  14273. 3,
  14274. 10,
  14275. 17,
  14276. 24,
  14277. 32,
  14278. 25,
  14279. 18,
  14280. 11,
  14281. 4,
  14282. 5,
  14283. 12,
  14284. 19,
  14285. 26,
  14286. 33,
  14287. 40,
  14288. 48,
  14289. 41,
  14290. 34,
  14291. 27,
  14292. 20,
  14293. 13,
  14294. 6,
  14295. 7,
  14296. 14,
  14297. 21,
  14298. 28,
  14299. 35,
  14300. 42,
  14301. 49,
  14302. 56,
  14303. 57,
  14304. 50,
  14305. 43,
  14306. 36,
  14307. 29,
  14308. 22,
  14309. 15,
  14310. 23,
  14311. 30,
  14312. 37,
  14313. 44,
  14314. 51,
  14315. 58,
  14316. 59,
  14317. 52,
  14318. 45,
  14319. 38,
  14320. 31,
  14321. 39,
  14322. 46,
  14323. 53,
  14324. 60,
  14325. 61,
  14326. 54,
  14327. 47,
  14328. 55,
  14329. 62,
  14330. 63
  14331. ]);
  14332. var dctCos1 = 4017;
  14333. var dctSin1 = 799;
  14334. var dctCos3 = 3406;
  14335. var dctSin3 = 2276;
  14336. var dctCos6 = 1567;
  14337. var dctSin6 = 3784;
  14338. var dctSqrt2 = 5793;
  14339. var dctSqrt1d2 = 2896;
  14340. function JpegImage() {
  14341. this.decodeTransform = null;
  14342. this.colorTransform = -1;
  14343. }
  14344. function buildHuffmanTable(codeLengths, values) {
  14345. var k = 0, code = [], i, j, length = 16;
  14346. while (length > 0 && !codeLengths[length - 1]) {
  14347. length--;
  14348. }
  14349. code.push({
  14350. children: [],
  14351. index: 0
  14352. });
  14353. var p = code[0], q;
  14354. for (i = 0; i < length; i++) {
  14355. for (j = 0; j < codeLengths[i]; j++) {
  14356. p = code.pop();
  14357. p.children[p.index] = values[k];
  14358. while (p.index > 0) {
  14359. p = code.pop();
  14360. }
  14361. p.index++;
  14362. code.push(p);
  14363. while (code.length <= i) {
  14364. code.push(q = {
  14365. children: [],
  14366. index: 0
  14367. });
  14368. p.children[p.index] = q.children;
  14369. p = q;
  14370. }
  14371. k++;
  14372. }
  14373. if (i + 1 < length) {
  14374. code.push(q = {
  14375. children: [],
  14376. index: 0
  14377. });
  14378. p.children[p.index] = q.children;
  14379. p = q;
  14380. }
  14381. }
  14382. return code[0].children;
  14383. }
  14384. function getBlockBufferOffset(component, row, col) {
  14385. return 64 * ((component.blocksPerLine + 1) * row + col);
  14386. }
  14387. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14388. var mcusPerLine = frame.mcusPerLine;
  14389. var progressive = frame.progressive;
  14390. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14391. function readBit() {
  14392. if (bitsCount > 0) {
  14393. bitsCount--;
  14394. return bitsData >> bitsCount & 1;
  14395. }
  14396. bitsData = data[offset++];
  14397. if (bitsData === 0xFF) {
  14398. var nextByte = data[offset++];
  14399. if (nextByte) {
  14400. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14401. }
  14402. }
  14403. bitsCount = 7;
  14404. return bitsData >>> 7;
  14405. }
  14406. function decodeHuffman(tree) {
  14407. var node = tree;
  14408. while (true) {
  14409. node = node[readBit()];
  14410. if (typeof node === 'number') {
  14411. return node;
  14412. }
  14413. if (typeof node !== 'object') {
  14414. error('JPEG error: invalid huffman sequence');
  14415. }
  14416. }
  14417. }
  14418. function receive(length) {
  14419. var n = 0;
  14420. while (length > 0) {
  14421. n = n << 1 | readBit();
  14422. length--;
  14423. }
  14424. return n;
  14425. }
  14426. function receiveAndExtend(length) {
  14427. if (length === 1) {
  14428. return readBit() === 1 ? 1 : -1;
  14429. }
  14430. var n = receive(length);
  14431. if (n >= 1 << length - 1) {
  14432. return n;
  14433. }
  14434. return n + (-1 << length) + 1;
  14435. }
  14436. function decodeBaseline(component, offset) {
  14437. var t = decodeHuffman(component.huffmanTableDC);
  14438. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14439. component.blockData[offset] = component.pred += diff;
  14440. var k = 1;
  14441. while (k < 64) {
  14442. var rs = decodeHuffman(component.huffmanTableAC);
  14443. var s = rs & 15, r = rs >> 4;
  14444. if (s === 0) {
  14445. if (r < 15) {
  14446. break;
  14447. }
  14448. k += 16;
  14449. continue;
  14450. }
  14451. k += r;
  14452. var z = dctZigZag[k];
  14453. component.blockData[offset + z] = receiveAndExtend(s);
  14454. k++;
  14455. }
  14456. }
  14457. function decodeDCFirst(component, offset) {
  14458. var t = decodeHuffman(component.huffmanTableDC);
  14459. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14460. component.blockData[offset] = component.pred += diff;
  14461. }
  14462. function decodeDCSuccessive(component, offset) {
  14463. component.blockData[offset] |= readBit() << successive;
  14464. }
  14465. var eobrun = 0;
  14466. function decodeACFirst(component, offset) {
  14467. if (eobrun > 0) {
  14468. eobrun--;
  14469. return;
  14470. }
  14471. var k = spectralStart, e = spectralEnd;
  14472. while (k <= e) {
  14473. var rs = decodeHuffman(component.huffmanTableAC);
  14474. var s = rs & 15, r = rs >> 4;
  14475. if (s === 0) {
  14476. if (r < 15) {
  14477. eobrun = receive(r) + (1 << r) - 1;
  14478. break;
  14479. }
  14480. k += 16;
  14481. continue;
  14482. }
  14483. k += r;
  14484. var z = dctZigZag[k];
  14485. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14486. k++;
  14487. }
  14488. }
  14489. var successiveACState = 0, successiveACNextValue;
  14490. function decodeACSuccessive(component, offset) {
  14491. var k = spectralStart;
  14492. var e = spectralEnd;
  14493. var r = 0;
  14494. var s;
  14495. var rs;
  14496. while (k <= e) {
  14497. var z = dctZigZag[k];
  14498. switch (successiveACState) {
  14499. case 0:
  14500. rs = decodeHuffman(component.huffmanTableAC);
  14501. s = rs & 15;
  14502. r = rs >> 4;
  14503. if (s === 0) {
  14504. if (r < 15) {
  14505. eobrun = receive(r) + (1 << r);
  14506. successiveACState = 4;
  14507. } else {
  14508. r = 16;
  14509. successiveACState = 1;
  14510. }
  14511. } else {
  14512. if (s !== 1) {
  14513. error('JPEG error: invalid ACn encoding');
  14514. }
  14515. successiveACNextValue = receiveAndExtend(s);
  14516. successiveACState = r ? 2 : 3;
  14517. }
  14518. continue;
  14519. case 1:
  14520. case 2:
  14521. if (component.blockData[offset + z]) {
  14522. component.blockData[offset + z] += readBit() << successive;
  14523. } else {
  14524. r--;
  14525. if (r === 0) {
  14526. successiveACState = successiveACState === 2 ? 3 : 0;
  14527. }
  14528. }
  14529. break;
  14530. case 3:
  14531. if (component.blockData[offset + z]) {
  14532. component.blockData[offset + z] += readBit() << successive;
  14533. } else {
  14534. component.blockData[offset + z] = successiveACNextValue << successive;
  14535. successiveACState = 0;
  14536. }
  14537. break;
  14538. case 4:
  14539. if (component.blockData[offset + z]) {
  14540. component.blockData[offset + z] += readBit() << successive;
  14541. }
  14542. break;
  14543. }
  14544. k++;
  14545. }
  14546. if (successiveACState === 4) {
  14547. eobrun--;
  14548. if (eobrun === 0) {
  14549. successiveACState = 0;
  14550. }
  14551. }
  14552. }
  14553. function decodeMcu(component, decode, mcu, row, col) {
  14554. var mcuRow = mcu / mcusPerLine | 0;
  14555. var mcuCol = mcu % mcusPerLine;
  14556. var blockRow = mcuRow * component.v + row;
  14557. var blockCol = mcuCol * component.h + col;
  14558. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14559. decode(component, offset);
  14560. }
  14561. function decodeBlock(component, decode, mcu) {
  14562. var blockRow = mcu / component.blocksPerLine | 0;
  14563. var blockCol = mcu % component.blocksPerLine;
  14564. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14565. decode(component, offset);
  14566. }
  14567. var componentsLength = components.length;
  14568. var component, i, j, k, n;
  14569. var decodeFn;
  14570. if (progressive) {
  14571. if (spectralStart === 0) {
  14572. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14573. } else {
  14574. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14575. }
  14576. } else {
  14577. decodeFn = decodeBaseline;
  14578. }
  14579. var mcu = 0, marker;
  14580. var mcuExpected;
  14581. if (componentsLength === 1) {
  14582. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14583. } else {
  14584. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14585. }
  14586. if (!resetInterval) {
  14587. resetInterval = mcuExpected;
  14588. }
  14589. var h, v;
  14590. while (mcu < mcuExpected) {
  14591. for (i = 0; i < componentsLength; i++) {
  14592. components[i].pred = 0;
  14593. }
  14594. eobrun = 0;
  14595. if (componentsLength === 1) {
  14596. component = components[0];
  14597. for (n = 0; n < resetInterval; n++) {
  14598. decodeBlock(component, decodeFn, mcu);
  14599. mcu++;
  14600. }
  14601. } else {
  14602. for (n = 0; n < resetInterval; n++) {
  14603. for (i = 0; i < componentsLength; i++) {
  14604. component = components[i];
  14605. h = component.h;
  14606. v = component.v;
  14607. for (j = 0; j < v; j++) {
  14608. for (k = 0; k < h; k++) {
  14609. decodeMcu(component, decodeFn, mcu, j, k);
  14610. }
  14611. }
  14612. }
  14613. mcu++;
  14614. }
  14615. }
  14616. bitsCount = 0;
  14617. marker = data[offset] << 8 | data[offset + 1];
  14618. while (data[offset] === 0x00 && offset < data.length - 1) {
  14619. offset++;
  14620. marker = data[offset] << 8 | data[offset + 1];
  14621. }
  14622. if (marker <= 0xFF00) {
  14623. error('JPEG error: marker was not found');
  14624. }
  14625. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14626. offset += 2;
  14627. } else {
  14628. break;
  14629. }
  14630. }
  14631. return offset - startOffset;
  14632. }
  14633. function quantizeAndInverse(component, blockBufferOffset, p) {
  14634. var qt = component.quantizationTable, blockData = component.blockData;
  14635. var v0, v1, v2, v3, v4, v5, v6, v7;
  14636. var p0, p1, p2, p3, p4, p5, p6, p7;
  14637. var t;
  14638. if (!qt) {
  14639. error('JPEG error: missing required Quantization Table.');
  14640. }
  14641. for (var row = 0; row < 64; row += 8) {
  14642. p0 = blockData[blockBufferOffset + row];
  14643. p1 = blockData[blockBufferOffset + row + 1];
  14644. p2 = blockData[blockBufferOffset + row + 2];
  14645. p3 = blockData[blockBufferOffset + row + 3];
  14646. p4 = blockData[blockBufferOffset + row + 4];
  14647. p5 = blockData[blockBufferOffset + row + 5];
  14648. p6 = blockData[blockBufferOffset + row + 6];
  14649. p7 = blockData[blockBufferOffset + row + 7];
  14650. p0 *= qt[row];
  14651. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14652. t = dctSqrt2 * p0 + 512 >> 10;
  14653. p[row] = t;
  14654. p[row + 1] = t;
  14655. p[row + 2] = t;
  14656. p[row + 3] = t;
  14657. p[row + 4] = t;
  14658. p[row + 5] = t;
  14659. p[row + 6] = t;
  14660. p[row + 7] = t;
  14661. continue;
  14662. }
  14663. p1 *= qt[row + 1];
  14664. p2 *= qt[row + 2];
  14665. p3 *= qt[row + 3];
  14666. p4 *= qt[row + 4];
  14667. p5 *= qt[row + 5];
  14668. p6 *= qt[row + 6];
  14669. p7 *= qt[row + 7];
  14670. v0 = dctSqrt2 * p0 + 128 >> 8;
  14671. v1 = dctSqrt2 * p4 + 128 >> 8;
  14672. v2 = p2;
  14673. v3 = p6;
  14674. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14675. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14676. v5 = p3 << 4;
  14677. v6 = p5 << 4;
  14678. v0 = v0 + v1 + 1 >> 1;
  14679. v1 = v0 - v1;
  14680. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14681. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14682. v3 = t;
  14683. v4 = v4 + v6 + 1 >> 1;
  14684. v6 = v4 - v6;
  14685. v7 = v7 + v5 + 1 >> 1;
  14686. v5 = v7 - v5;
  14687. v0 = v0 + v3 + 1 >> 1;
  14688. v3 = v0 - v3;
  14689. v1 = v1 + v2 + 1 >> 1;
  14690. v2 = v1 - v2;
  14691. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14692. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14693. v7 = t;
  14694. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14695. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14696. v6 = t;
  14697. p[row] = v0 + v7;
  14698. p[row + 7] = v0 - v7;
  14699. p[row + 1] = v1 + v6;
  14700. p[row + 6] = v1 - v6;
  14701. p[row + 2] = v2 + v5;
  14702. p[row + 5] = v2 - v5;
  14703. p[row + 3] = v3 + v4;
  14704. p[row + 4] = v3 - v4;
  14705. }
  14706. for (var col = 0; col < 8; ++col) {
  14707. p0 = p[col];
  14708. p1 = p[col + 8];
  14709. p2 = p[col + 16];
  14710. p3 = p[col + 24];
  14711. p4 = p[col + 32];
  14712. p5 = p[col + 40];
  14713. p6 = p[col + 48];
  14714. p7 = p[col + 56];
  14715. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14716. t = dctSqrt2 * p0 + 8192 >> 14;
  14717. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14718. blockData[blockBufferOffset + col] = t;
  14719. blockData[blockBufferOffset + col + 8] = t;
  14720. blockData[blockBufferOffset + col + 16] = t;
  14721. blockData[blockBufferOffset + col + 24] = t;
  14722. blockData[blockBufferOffset + col + 32] = t;
  14723. blockData[blockBufferOffset + col + 40] = t;
  14724. blockData[blockBufferOffset + col + 48] = t;
  14725. blockData[blockBufferOffset + col + 56] = t;
  14726. continue;
  14727. }
  14728. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14729. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14730. v2 = p2;
  14731. v3 = p6;
  14732. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14733. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14734. v5 = p3;
  14735. v6 = p5;
  14736. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14737. v1 = v0 - v1;
  14738. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14739. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14740. v3 = t;
  14741. v4 = v4 + v6 + 1 >> 1;
  14742. v6 = v4 - v6;
  14743. v7 = v7 + v5 + 1 >> 1;
  14744. v5 = v7 - v5;
  14745. v0 = v0 + v3 + 1 >> 1;
  14746. v3 = v0 - v3;
  14747. v1 = v1 + v2 + 1 >> 1;
  14748. v2 = v1 - v2;
  14749. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14750. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14751. v7 = t;
  14752. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14753. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14754. v6 = t;
  14755. p0 = v0 + v7;
  14756. p7 = v0 - v7;
  14757. p1 = v1 + v6;
  14758. p6 = v1 - v6;
  14759. p2 = v2 + v5;
  14760. p5 = v2 - v5;
  14761. p3 = v3 + v4;
  14762. p4 = v3 - v4;
  14763. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14764. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14765. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14766. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14767. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14768. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14769. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14770. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14771. blockData[blockBufferOffset + col] = p0;
  14772. blockData[blockBufferOffset + col + 8] = p1;
  14773. blockData[blockBufferOffset + col + 16] = p2;
  14774. blockData[blockBufferOffset + col + 24] = p3;
  14775. blockData[blockBufferOffset + col + 32] = p4;
  14776. blockData[blockBufferOffset + col + 40] = p5;
  14777. blockData[blockBufferOffset + col + 48] = p6;
  14778. blockData[blockBufferOffset + col + 56] = p7;
  14779. }
  14780. }
  14781. function buildComponentData(frame, component) {
  14782. var blocksPerLine = component.blocksPerLine;
  14783. var blocksPerColumn = component.blocksPerColumn;
  14784. var computationBuffer = new Int16Array(64);
  14785. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14786. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14787. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14788. quantizeAndInverse(component, offset, computationBuffer);
  14789. }
  14790. }
  14791. return component.blockData;
  14792. }
  14793. function clamp0to255(a) {
  14794. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14795. }
  14796. JpegImage.prototype = {
  14797. parse: function parse(data) {
  14798. function readUint16() {
  14799. var value = data[offset] << 8 | data[offset + 1];
  14800. offset += 2;
  14801. return value;
  14802. }
  14803. function readDataBlock() {
  14804. var length = readUint16();
  14805. var array = data.subarray(offset, offset + length - 2);
  14806. offset += array.length;
  14807. return array;
  14808. }
  14809. function prepareComponents(frame) {
  14810. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14811. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14812. for (var i = 0; i < frame.components.length; i++) {
  14813. component = frame.components[i];
  14814. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14815. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14816. var blocksPerLineForMcu = mcusPerLine * component.h;
  14817. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14818. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14819. component.blockData = new Int16Array(blocksBufferSize);
  14820. component.blocksPerLine = blocksPerLine;
  14821. component.blocksPerColumn = blocksPerColumn;
  14822. }
  14823. frame.mcusPerLine = mcusPerLine;
  14824. frame.mcusPerColumn = mcusPerColumn;
  14825. }
  14826. var offset = 0;
  14827. var jfif = null;
  14828. var adobe = null;
  14829. var frame, resetInterval;
  14830. var quantizationTables = [];
  14831. var huffmanTablesAC = [], huffmanTablesDC = [];
  14832. var fileMarker = readUint16();
  14833. if (fileMarker !== 0xFFD8) {
  14834. error('JPEG error: SOI not found');
  14835. }
  14836. fileMarker = readUint16();
  14837. while (fileMarker !== 0xFFD9) {
  14838. var i, j, l;
  14839. switch (fileMarker) {
  14840. case 0xFFE0:
  14841. case 0xFFE1:
  14842. case 0xFFE2:
  14843. case 0xFFE3:
  14844. case 0xFFE4:
  14845. case 0xFFE5:
  14846. case 0xFFE6:
  14847. case 0xFFE7:
  14848. case 0xFFE8:
  14849. case 0xFFE9:
  14850. case 0xFFEA:
  14851. case 0xFFEB:
  14852. case 0xFFEC:
  14853. case 0xFFED:
  14854. case 0xFFEE:
  14855. case 0xFFEF:
  14856. case 0xFFFE:
  14857. var appData = readDataBlock();
  14858. if (fileMarker === 0xFFE0) {
  14859. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14860. jfif = {
  14861. version: {
  14862. major: appData[5],
  14863. minor: appData[6]
  14864. },
  14865. densityUnits: appData[7],
  14866. xDensity: appData[8] << 8 | appData[9],
  14867. yDensity: appData[10] << 8 | appData[11],
  14868. thumbWidth: appData[12],
  14869. thumbHeight: appData[13],
  14870. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14871. };
  14872. }
  14873. }
  14874. if (fileMarker === 0xFFEE) {
  14875. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14876. adobe = {
  14877. version: appData[5] << 8 | appData[6],
  14878. flags0: appData[7] << 8 | appData[8],
  14879. flags1: appData[9] << 8 | appData[10],
  14880. transformCode: appData[11]
  14881. };
  14882. }
  14883. }
  14884. break;
  14885. case 0xFFDB:
  14886. var quantizationTablesLength = readUint16();
  14887. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14888. var z;
  14889. while (offset < quantizationTablesEnd) {
  14890. var quantizationTableSpec = data[offset++];
  14891. var tableData = new Uint16Array(64);
  14892. if (quantizationTableSpec >> 4 === 0) {
  14893. for (j = 0; j < 64; j++) {
  14894. z = dctZigZag[j];
  14895. tableData[z] = data[offset++];
  14896. }
  14897. } else if (quantizationTableSpec >> 4 === 1) {
  14898. for (j = 0; j < 64; j++) {
  14899. z = dctZigZag[j];
  14900. tableData[z] = readUint16();
  14901. }
  14902. } else {
  14903. error('JPEG error: DQT - invalid table spec');
  14904. }
  14905. quantizationTables[quantizationTableSpec & 15] = tableData;
  14906. }
  14907. break;
  14908. case 0xFFC0:
  14909. case 0xFFC1:
  14910. case 0xFFC2:
  14911. if (frame) {
  14912. error('JPEG error: Only single frame JPEGs supported');
  14913. }
  14914. readUint16();
  14915. frame = {};
  14916. frame.extended = fileMarker === 0xFFC1;
  14917. frame.progressive = fileMarker === 0xFFC2;
  14918. frame.precision = data[offset++];
  14919. frame.scanLines = readUint16();
  14920. frame.samplesPerLine = readUint16();
  14921. frame.components = [];
  14922. frame.componentIds = {};
  14923. var componentsCount = data[offset++], componentId;
  14924. var maxH = 0, maxV = 0;
  14925. for (i = 0; i < componentsCount; i++) {
  14926. componentId = data[offset];
  14927. var h = data[offset + 1] >> 4;
  14928. var v = data[offset + 1] & 15;
  14929. if (maxH < h) {
  14930. maxH = h;
  14931. }
  14932. if (maxV < v) {
  14933. maxV = v;
  14934. }
  14935. var qId = data[offset + 2];
  14936. l = frame.components.push({
  14937. h: h,
  14938. v: v,
  14939. quantizationId: qId,
  14940. quantizationTable: null
  14941. });
  14942. frame.componentIds[componentId] = l - 1;
  14943. offset += 3;
  14944. }
  14945. frame.maxH = maxH;
  14946. frame.maxV = maxV;
  14947. prepareComponents(frame);
  14948. break;
  14949. case 0xFFC4:
  14950. var huffmanLength = readUint16();
  14951. for (i = 2; i < huffmanLength;) {
  14952. var huffmanTableSpec = data[offset++];
  14953. var codeLengths = new Uint8Array(16);
  14954. var codeLengthSum = 0;
  14955. for (j = 0; j < 16; j++, offset++) {
  14956. codeLengthSum += codeLengths[j] = data[offset];
  14957. }
  14958. var huffmanValues = new Uint8Array(codeLengthSum);
  14959. for (j = 0; j < codeLengthSum; j++, offset++) {
  14960. huffmanValues[j] = data[offset];
  14961. }
  14962. i += 17 + codeLengthSum;
  14963. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14964. }
  14965. break;
  14966. case 0xFFDD:
  14967. readUint16();
  14968. resetInterval = readUint16();
  14969. break;
  14970. case 0xFFDA:
  14971. var scanLength = readUint16();
  14972. var selectorsCount = data[offset++];
  14973. var components = [], component;
  14974. for (i = 0; i < selectorsCount; i++) {
  14975. var componentIndex = frame.componentIds[data[offset++]];
  14976. component = frame.components[componentIndex];
  14977. var tableSpec = data[offset++];
  14978. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14979. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14980. components.push(component);
  14981. }
  14982. var spectralStart = data[offset++];
  14983. var spectralEnd = data[offset++];
  14984. var successiveApproximation = data[offset++];
  14985. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14986. offset += processed;
  14987. break;
  14988. case 0xFFFF:
  14989. if (data[offset] !== 0xFF) {
  14990. offset--;
  14991. }
  14992. break;
  14993. default:
  14994. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14995. offset -= 3;
  14996. break;
  14997. }
  14998. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14999. }
  15000. fileMarker = readUint16();
  15001. }
  15002. this.width = frame.samplesPerLine;
  15003. this.height = frame.scanLines;
  15004. this.jfif = jfif;
  15005. this.adobe = adobe;
  15006. this.components = [];
  15007. for (i = 0; i < frame.components.length; i++) {
  15008. component = frame.components[i];
  15009. var quantizationTable = quantizationTables[component.quantizationId];
  15010. if (quantizationTable) {
  15011. component.quantizationTable = quantizationTable;
  15012. }
  15013. this.components.push({
  15014. output: buildComponentData(frame, component),
  15015. scaleX: component.h / frame.maxH,
  15016. scaleY: component.v / frame.maxV,
  15017. blocksPerLine: component.blocksPerLine,
  15018. blocksPerColumn: component.blocksPerColumn
  15019. });
  15020. }
  15021. this.numComponents = this.components.length;
  15022. },
  15023. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  15024. var scaleX = this.width / width, scaleY = this.height / height;
  15025. var component, componentScaleX, componentScaleY, blocksPerScanline;
  15026. var x, y, i, j, k;
  15027. var index;
  15028. var offset = 0;
  15029. var output;
  15030. var numComponents = this.components.length;
  15031. var dataLength = width * height * numComponents;
  15032. var data = new Uint8Array(dataLength);
  15033. var xScaleBlockOffset = new Uint32Array(width);
  15034. var mask3LSB = 0xfffffff8;
  15035. for (i = 0; i < numComponents; i++) {
  15036. component = this.components[i];
  15037. componentScaleX = component.scaleX * scaleX;
  15038. componentScaleY = component.scaleY * scaleY;
  15039. offset = i;
  15040. output = component.output;
  15041. blocksPerScanline = component.blocksPerLine + 1 << 3;
  15042. for (x = 0; x < width; x++) {
  15043. j = 0 | x * componentScaleX;
  15044. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  15045. }
  15046. for (y = 0; y < height; y++) {
  15047. j = 0 | y * componentScaleY;
  15048. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  15049. for (x = 0; x < width; x++) {
  15050. data[offset] = output[index + xScaleBlockOffset[x]];
  15051. offset += numComponents;
  15052. }
  15053. }
  15054. }
  15055. var transform = this.decodeTransform;
  15056. if (transform) {
  15057. for (i = 0; i < dataLength;) {
  15058. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  15059. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  15060. }
  15061. }
  15062. }
  15063. return data;
  15064. },
  15065. _isColorConversionNeeded: function isColorConversionNeeded() {
  15066. if (this.adobe && this.adobe.transformCode) {
  15067. return true;
  15068. } else if (this.numComponents === 3) {
  15069. if (!this.adobe && this.colorTransform === 0) {
  15070. return false;
  15071. }
  15072. return true;
  15073. } else {
  15074. if (!this.adobe && this.colorTransform === 1) {
  15075. return true;
  15076. }
  15077. return false;
  15078. }
  15079. },
  15080. _convertYccToRgb: function convertYccToRgb(data) {
  15081. var Y, Cb, Cr;
  15082. for (var i = 0, length = data.length; i < length; i += 3) {
  15083. Y = data[i];
  15084. Cb = data[i + 1];
  15085. Cr = data[i + 2];
  15086. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  15087. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  15088. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  15089. }
  15090. return data;
  15091. },
  15092. _convertYcckToRgb: function convertYcckToRgb(data) {
  15093. var Y, Cb, Cr, k;
  15094. var offset = 0;
  15095. for (var i = 0, length = data.length; i < length; i += 4) {
  15096. Y = data[i];
  15097. Cb = data[i + 1];
  15098. Cr = data[i + 2];
  15099. k = data[i + 3];
  15100. 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);
  15101. 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);
  15102. 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);
  15103. data[offset++] = clamp0to255(r);
  15104. data[offset++] = clamp0to255(g);
  15105. data[offset++] = clamp0to255(b);
  15106. }
  15107. return data;
  15108. },
  15109. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  15110. var Y, Cb, Cr;
  15111. for (var i = 0, length = data.length; i < length; i += 4) {
  15112. Y = data[i];
  15113. Cb = data[i + 1];
  15114. Cr = data[i + 2];
  15115. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  15116. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15117. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15118. }
  15119. return data;
  15120. },
  15121. _convertCmykToRgb: function convertCmykToRgb(data) {
  15122. var c, m, y, k;
  15123. var offset = 0;
  15124. var min = -255 * 255 * 255;
  15125. var scale = 1 / 255 / 255;
  15126. for (var i = 0, length = data.length; i < length; i += 4) {
  15127. c = data[i];
  15128. m = data[i + 1];
  15129. y = data[i + 2];
  15130. k = data[i + 3];
  15131. 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);
  15132. 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);
  15133. 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);
  15134. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15135. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15136. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15137. }
  15138. return data;
  15139. },
  15140. getData: function getData(width, height, forceRGBoutput) {
  15141. if (this.numComponents > 4) {
  15142. error('JPEG error: Unsupported color mode');
  15143. }
  15144. var data = this._getLinearizedBlockData(width, height);
  15145. if (this.numComponents === 1 && forceRGBoutput) {
  15146. var dataLength = data.length;
  15147. var rgbData = new Uint8Array(dataLength * 3);
  15148. var offset = 0;
  15149. for (var i = 0; i < dataLength; i++) {
  15150. var grayColor = data[i];
  15151. rgbData[offset++] = grayColor;
  15152. rgbData[offset++] = grayColor;
  15153. rgbData[offset++] = grayColor;
  15154. }
  15155. return rgbData;
  15156. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15157. return this._convertYccToRgb(data);
  15158. } else if (this.numComponents === 4) {
  15159. if (this._isColorConversionNeeded()) {
  15160. if (forceRGBoutput) {
  15161. return this._convertYcckToRgb(data);
  15162. } else {
  15163. return this._convertYcckToCmyk(data);
  15164. }
  15165. } else if (forceRGBoutput) {
  15166. return this._convertCmykToRgb(data);
  15167. }
  15168. }
  15169. return data;
  15170. }
  15171. };
  15172. return JpegImage;
  15173. }();
  15174. exports.JpegImage = JpegImage;
  15175. }));
  15176. (function (root, factory) {
  15177. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15178. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15179. var info = sharedUtil.info;
  15180. var warn = sharedUtil.warn;
  15181. var error = sharedUtil.error;
  15182. var log2 = sharedUtil.log2;
  15183. var readUint16 = sharedUtil.readUint16;
  15184. var readUint32 = sharedUtil.readUint32;
  15185. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15186. var JpxImage = function JpxImageClosure() {
  15187. var SubbandsGainLog2 = {
  15188. 'LL': 0,
  15189. 'LH': 1,
  15190. 'HL': 1,
  15191. 'HH': 2
  15192. };
  15193. function JpxImage() {
  15194. this.failOnCorruptedImage = false;
  15195. }
  15196. JpxImage.prototype = {
  15197. parse: function JpxImage_parse(data) {
  15198. var head = readUint16(data, 0);
  15199. if (head === 0xFF4F) {
  15200. this.parseCodestream(data, 0, data.length);
  15201. return;
  15202. }
  15203. var position = 0, length = data.length;
  15204. while (position < length) {
  15205. var headerSize = 8;
  15206. var lbox = readUint32(data, position);
  15207. var tbox = readUint32(data, position + 4);
  15208. position += headerSize;
  15209. if (lbox === 1) {
  15210. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15211. position += 8;
  15212. headerSize += 8;
  15213. }
  15214. if (lbox === 0) {
  15215. lbox = length - position + headerSize;
  15216. }
  15217. if (lbox < headerSize) {
  15218. error('JPX Error: Invalid box field size');
  15219. }
  15220. var dataLength = lbox - headerSize;
  15221. var jumpDataLength = true;
  15222. switch (tbox) {
  15223. case 0x6A703268:
  15224. jumpDataLength = false;
  15225. break;
  15226. case 0x636F6C72:
  15227. var method = data[position];
  15228. if (method === 1) {
  15229. var colorspace = readUint32(data, position + 3);
  15230. switch (colorspace) {
  15231. case 16:
  15232. case 17:
  15233. case 18:
  15234. break;
  15235. default:
  15236. warn('Unknown colorspace ' + colorspace);
  15237. break;
  15238. }
  15239. } else if (method === 2) {
  15240. info('ICC profile not supported');
  15241. }
  15242. break;
  15243. case 0x6A703263:
  15244. this.parseCodestream(data, position, position + dataLength);
  15245. break;
  15246. case 0x6A502020:
  15247. if (0x0d0a870a !== readUint32(data, position)) {
  15248. warn('Invalid JP2 signature');
  15249. }
  15250. break;
  15251. case 0x6A501A1A:
  15252. case 0x66747970:
  15253. case 0x72726571:
  15254. case 0x72657320:
  15255. case 0x69686472:
  15256. break;
  15257. default:
  15258. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15259. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15260. break;
  15261. }
  15262. if (jumpDataLength) {
  15263. position += dataLength;
  15264. }
  15265. }
  15266. },
  15267. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15268. var newByte = stream.getByte();
  15269. while (newByte >= 0) {
  15270. var oldByte = newByte;
  15271. newByte = stream.getByte();
  15272. var code = oldByte << 8 | newByte;
  15273. if (code === 0xFF51) {
  15274. stream.skip(4);
  15275. var Xsiz = stream.getInt32() >>> 0;
  15276. var Ysiz = stream.getInt32() >>> 0;
  15277. var XOsiz = stream.getInt32() >>> 0;
  15278. var YOsiz = stream.getInt32() >>> 0;
  15279. stream.skip(16);
  15280. var Csiz = stream.getUint16();
  15281. this.width = Xsiz - XOsiz;
  15282. this.height = Ysiz - YOsiz;
  15283. this.componentsCount = Csiz;
  15284. this.bitsPerComponent = 8;
  15285. return;
  15286. }
  15287. }
  15288. error('JPX Error: No size marker found in JPX stream');
  15289. },
  15290. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15291. var context = {};
  15292. var doNotRecover = false;
  15293. try {
  15294. var position = start;
  15295. while (position + 1 < end) {
  15296. var code = readUint16(data, position);
  15297. position += 2;
  15298. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15299. switch (code) {
  15300. case 0xFF4F:
  15301. context.mainHeader = true;
  15302. break;
  15303. case 0xFFD9:
  15304. break;
  15305. case 0xFF51:
  15306. length = readUint16(data, position);
  15307. var siz = {};
  15308. siz.Xsiz = readUint32(data, position + 4);
  15309. siz.Ysiz = readUint32(data, position + 8);
  15310. siz.XOsiz = readUint32(data, position + 12);
  15311. siz.YOsiz = readUint32(data, position + 16);
  15312. siz.XTsiz = readUint32(data, position + 20);
  15313. siz.YTsiz = readUint32(data, position + 24);
  15314. siz.XTOsiz = readUint32(data, position + 28);
  15315. siz.YTOsiz = readUint32(data, position + 32);
  15316. var componentsCount = readUint16(data, position + 36);
  15317. siz.Csiz = componentsCount;
  15318. var components = [];
  15319. j = position + 38;
  15320. for (var i = 0; i < componentsCount; i++) {
  15321. var component = {
  15322. precision: (data[j] & 0x7F) + 1,
  15323. isSigned: !!(data[j] & 0x80),
  15324. XRsiz: data[j + 1],
  15325. YRsiz: data[j + 1]
  15326. };
  15327. calculateComponentDimensions(component, siz);
  15328. components.push(component);
  15329. }
  15330. context.SIZ = siz;
  15331. context.components = components;
  15332. calculateTileGrids(context, components);
  15333. context.QCC = [];
  15334. context.COC = [];
  15335. break;
  15336. case 0xFF5C:
  15337. length = readUint16(data, position);
  15338. var qcd = {};
  15339. j = position + 2;
  15340. sqcd = data[j++];
  15341. switch (sqcd & 0x1F) {
  15342. case 0:
  15343. spqcdSize = 8;
  15344. scalarExpounded = true;
  15345. break;
  15346. case 1:
  15347. spqcdSize = 16;
  15348. scalarExpounded = false;
  15349. break;
  15350. case 2:
  15351. spqcdSize = 16;
  15352. scalarExpounded = true;
  15353. break;
  15354. default:
  15355. throw new Error('Invalid SQcd value ' + sqcd);
  15356. }
  15357. qcd.noQuantization = spqcdSize === 8;
  15358. qcd.scalarExpounded = scalarExpounded;
  15359. qcd.guardBits = sqcd >> 5;
  15360. spqcds = [];
  15361. while (j < length + position) {
  15362. var spqcd = {};
  15363. if (spqcdSize === 8) {
  15364. spqcd.epsilon = data[j++] >> 3;
  15365. spqcd.mu = 0;
  15366. } else {
  15367. spqcd.epsilon = data[j] >> 3;
  15368. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15369. j += 2;
  15370. }
  15371. spqcds.push(spqcd);
  15372. }
  15373. qcd.SPqcds = spqcds;
  15374. if (context.mainHeader) {
  15375. context.QCD = qcd;
  15376. } else {
  15377. context.currentTile.QCD = qcd;
  15378. context.currentTile.QCC = [];
  15379. }
  15380. break;
  15381. case 0xFF5D:
  15382. length = readUint16(data, position);
  15383. var qcc = {};
  15384. j = position + 2;
  15385. var cqcc;
  15386. if (context.SIZ.Csiz < 257) {
  15387. cqcc = data[j++];
  15388. } else {
  15389. cqcc = readUint16(data, j);
  15390. j += 2;
  15391. }
  15392. sqcd = data[j++];
  15393. switch (sqcd & 0x1F) {
  15394. case 0:
  15395. spqcdSize = 8;
  15396. scalarExpounded = true;
  15397. break;
  15398. case 1:
  15399. spqcdSize = 16;
  15400. scalarExpounded = false;
  15401. break;
  15402. case 2:
  15403. spqcdSize = 16;
  15404. scalarExpounded = true;
  15405. break;
  15406. default:
  15407. throw new Error('Invalid SQcd value ' + sqcd);
  15408. }
  15409. qcc.noQuantization = spqcdSize === 8;
  15410. qcc.scalarExpounded = scalarExpounded;
  15411. qcc.guardBits = sqcd >> 5;
  15412. spqcds = [];
  15413. while (j < length + position) {
  15414. spqcd = {};
  15415. if (spqcdSize === 8) {
  15416. spqcd.epsilon = data[j++] >> 3;
  15417. spqcd.mu = 0;
  15418. } else {
  15419. spqcd.epsilon = data[j] >> 3;
  15420. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15421. j += 2;
  15422. }
  15423. spqcds.push(spqcd);
  15424. }
  15425. qcc.SPqcds = spqcds;
  15426. if (context.mainHeader) {
  15427. context.QCC[cqcc] = qcc;
  15428. } else {
  15429. context.currentTile.QCC[cqcc] = qcc;
  15430. }
  15431. break;
  15432. case 0xFF52:
  15433. length = readUint16(data, position);
  15434. var cod = {};
  15435. j = position + 2;
  15436. var scod = data[j++];
  15437. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15438. cod.sopMarkerUsed = !!(scod & 2);
  15439. cod.ephMarkerUsed = !!(scod & 4);
  15440. cod.progressionOrder = data[j++];
  15441. cod.layersCount = readUint16(data, j);
  15442. j += 2;
  15443. cod.multipleComponentTransform = data[j++];
  15444. cod.decompositionLevelsCount = data[j++];
  15445. cod.xcb = (data[j++] & 0xF) + 2;
  15446. cod.ycb = (data[j++] & 0xF) + 2;
  15447. var blockStyle = data[j++];
  15448. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15449. cod.resetContextProbabilities = !!(blockStyle & 2);
  15450. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15451. cod.verticalyStripe = !!(blockStyle & 8);
  15452. cod.predictableTermination = !!(blockStyle & 16);
  15453. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15454. cod.reversibleTransformation = data[j++];
  15455. if (cod.entropyCoderWithCustomPrecincts) {
  15456. var precinctsSizes = [];
  15457. while (j < length + position) {
  15458. var precinctsSize = data[j++];
  15459. precinctsSizes.push({
  15460. PPx: precinctsSize & 0xF,
  15461. PPy: precinctsSize >> 4
  15462. });
  15463. }
  15464. cod.precinctsSizes = precinctsSizes;
  15465. }
  15466. var unsupported = [];
  15467. if (cod.selectiveArithmeticCodingBypass) {
  15468. unsupported.push('selectiveArithmeticCodingBypass');
  15469. }
  15470. if (cod.resetContextProbabilities) {
  15471. unsupported.push('resetContextProbabilities');
  15472. }
  15473. if (cod.terminationOnEachCodingPass) {
  15474. unsupported.push('terminationOnEachCodingPass');
  15475. }
  15476. if (cod.verticalyStripe) {
  15477. unsupported.push('verticalyStripe');
  15478. }
  15479. if (cod.predictableTermination) {
  15480. unsupported.push('predictableTermination');
  15481. }
  15482. if (unsupported.length > 0) {
  15483. doNotRecover = true;
  15484. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15485. }
  15486. if (context.mainHeader) {
  15487. context.COD = cod;
  15488. } else {
  15489. context.currentTile.COD = cod;
  15490. context.currentTile.COC = [];
  15491. }
  15492. break;
  15493. case 0xFF90:
  15494. length = readUint16(data, position);
  15495. tile = {};
  15496. tile.index = readUint16(data, position + 2);
  15497. tile.length = readUint32(data, position + 4);
  15498. tile.dataEnd = tile.length + position - 2;
  15499. tile.partIndex = data[position + 8];
  15500. tile.partsCount = data[position + 9];
  15501. context.mainHeader = false;
  15502. if (tile.partIndex === 0) {
  15503. tile.COD = context.COD;
  15504. tile.COC = context.COC.slice(0);
  15505. tile.QCD = context.QCD;
  15506. tile.QCC = context.QCC.slice(0);
  15507. }
  15508. context.currentTile = tile;
  15509. break;
  15510. case 0xFF93:
  15511. tile = context.currentTile;
  15512. if (tile.partIndex === 0) {
  15513. initializeTile(context, tile.index);
  15514. buildPackets(context);
  15515. }
  15516. length = tile.dataEnd - position;
  15517. parseTilePackets(context, data, position, length);
  15518. break;
  15519. case 0xFF55:
  15520. case 0xFF57:
  15521. case 0xFF58:
  15522. case 0xFF64:
  15523. length = readUint16(data, position);
  15524. break;
  15525. case 0xFF53:
  15526. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15527. default:
  15528. throw new Error('Unknown codestream code: ' + code.toString(16));
  15529. }
  15530. position += length;
  15531. }
  15532. } catch (e) {
  15533. if (doNotRecover || this.failOnCorruptedImage) {
  15534. error('JPX Error: ' + e.message);
  15535. } else {
  15536. warn('JPX: Trying to recover from: ' + e.message);
  15537. }
  15538. }
  15539. this.tiles = transformComponents(context);
  15540. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15541. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15542. this.componentsCount = context.SIZ.Csiz;
  15543. }
  15544. };
  15545. function calculateComponentDimensions(component, siz) {
  15546. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15547. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15548. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15549. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15550. component.width = component.x1 - component.x0;
  15551. component.height = component.y1 - component.y0;
  15552. }
  15553. function calculateTileGrids(context, components) {
  15554. var siz = context.SIZ;
  15555. var tile, tiles = [];
  15556. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15557. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15558. for (var q = 0; q < numYtiles; q++) {
  15559. for (var p = 0; p < numXtiles; p++) {
  15560. tile = {};
  15561. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15562. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15563. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15564. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15565. tile.width = tile.tx1 - tile.tx0;
  15566. tile.height = tile.ty1 - tile.ty0;
  15567. tile.components = [];
  15568. tiles.push(tile);
  15569. }
  15570. }
  15571. context.tiles = tiles;
  15572. var componentsCount = siz.Csiz;
  15573. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15574. var component = components[i];
  15575. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15576. var tileComponent = {};
  15577. tile = tiles[j];
  15578. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15579. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15580. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15581. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15582. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15583. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15584. tile.components[i] = tileComponent;
  15585. }
  15586. }
  15587. }
  15588. function getBlocksDimensions(context, component, r) {
  15589. var codOrCoc = component.codingStyleParameters;
  15590. var result = {};
  15591. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15592. result.PPx = 15;
  15593. result.PPy = 15;
  15594. } else {
  15595. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15596. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15597. }
  15598. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15599. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15600. return result;
  15601. }
  15602. function buildPrecincts(context, resolution, dimensions) {
  15603. var precinctWidth = 1 << dimensions.PPx;
  15604. var precinctHeight = 1 << dimensions.PPy;
  15605. var isZeroRes = resolution.resLevel === 0;
  15606. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15607. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15608. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15609. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15610. var numprecincts = numprecinctswide * numprecinctshigh;
  15611. resolution.precinctParameters = {
  15612. precinctWidth: precinctWidth,
  15613. precinctHeight: precinctHeight,
  15614. numprecinctswide: numprecinctswide,
  15615. numprecinctshigh: numprecinctshigh,
  15616. numprecincts: numprecincts,
  15617. precinctWidthInSubband: precinctWidthInSubband,
  15618. precinctHeightInSubband: precinctHeightInSubband
  15619. };
  15620. }
  15621. function buildCodeblocks(context, subband, dimensions) {
  15622. var xcb_ = dimensions.xcb_;
  15623. var ycb_ = dimensions.ycb_;
  15624. var codeblockWidth = 1 << xcb_;
  15625. var codeblockHeight = 1 << ycb_;
  15626. var cbx0 = subband.tbx0 >> xcb_;
  15627. var cby0 = subband.tby0 >> ycb_;
  15628. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15629. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15630. var precinctParameters = subband.resolution.precinctParameters;
  15631. var codeblocks = [];
  15632. var precincts = [];
  15633. var i, j, codeblock, precinctNumber;
  15634. for (j = cby0; j < cby1; j++) {
  15635. for (i = cbx0; i < cbx1; i++) {
  15636. codeblock = {
  15637. cbx: i,
  15638. cby: j,
  15639. tbx0: codeblockWidth * i,
  15640. tby0: codeblockHeight * j,
  15641. tbx1: codeblockWidth * (i + 1),
  15642. tby1: codeblockHeight * (j + 1)
  15643. };
  15644. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15645. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15646. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15647. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15648. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15649. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15650. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15651. codeblock.precinctNumber = precinctNumber;
  15652. codeblock.subbandType = subband.type;
  15653. codeblock.Lblock = 3;
  15654. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15655. continue;
  15656. }
  15657. codeblocks.push(codeblock);
  15658. var precinct = precincts[precinctNumber];
  15659. if (precinct !== undefined) {
  15660. if (i < precinct.cbxMin) {
  15661. precinct.cbxMin = i;
  15662. } else if (i > precinct.cbxMax) {
  15663. precinct.cbxMax = i;
  15664. }
  15665. if (j < precinct.cbyMin) {
  15666. precinct.cbxMin = j;
  15667. } else if (j > precinct.cbyMax) {
  15668. precinct.cbyMax = j;
  15669. }
  15670. } else {
  15671. precincts[precinctNumber] = precinct = {
  15672. cbxMin: i,
  15673. cbyMin: j,
  15674. cbxMax: i,
  15675. cbyMax: j
  15676. };
  15677. }
  15678. codeblock.precinct = precinct;
  15679. }
  15680. }
  15681. subband.codeblockParameters = {
  15682. codeblockWidth: xcb_,
  15683. codeblockHeight: ycb_,
  15684. numcodeblockwide: cbx1 - cbx0 + 1,
  15685. numcodeblockhigh: cby1 - cby0 + 1
  15686. };
  15687. subband.codeblocks = codeblocks;
  15688. subband.precincts = precincts;
  15689. }
  15690. function createPacket(resolution, precinctNumber, layerNumber) {
  15691. var precinctCodeblocks = [];
  15692. var subbands = resolution.subbands;
  15693. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15694. var subband = subbands[i];
  15695. var codeblocks = subband.codeblocks;
  15696. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15697. var codeblock = codeblocks[j];
  15698. if (codeblock.precinctNumber !== precinctNumber) {
  15699. continue;
  15700. }
  15701. precinctCodeblocks.push(codeblock);
  15702. }
  15703. }
  15704. return {
  15705. layerNumber: layerNumber,
  15706. codeblocks: precinctCodeblocks
  15707. };
  15708. }
  15709. function LayerResolutionComponentPositionIterator(context) {
  15710. var siz = context.SIZ;
  15711. var tileIndex = context.currentTile.index;
  15712. var tile = context.tiles[tileIndex];
  15713. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15714. var componentsCount = siz.Csiz;
  15715. var maxDecompositionLevelsCount = 0;
  15716. for (var q = 0; q < componentsCount; q++) {
  15717. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15718. }
  15719. var l = 0, r = 0, i = 0, k = 0;
  15720. this.nextPacket = function JpxImage_nextPacket() {
  15721. for (; l < layersCount; l++) {
  15722. for (; r <= maxDecompositionLevelsCount; r++) {
  15723. for (; i < componentsCount; i++) {
  15724. var component = tile.components[i];
  15725. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15726. continue;
  15727. }
  15728. var resolution = component.resolutions[r];
  15729. var numprecincts = resolution.precinctParameters.numprecincts;
  15730. for (; k < numprecincts;) {
  15731. var packet = createPacket(resolution, k, l);
  15732. k++;
  15733. return packet;
  15734. }
  15735. k = 0;
  15736. }
  15737. i = 0;
  15738. }
  15739. r = 0;
  15740. }
  15741. error('JPX Error: Out of packets');
  15742. };
  15743. }
  15744. function ResolutionLayerComponentPositionIterator(context) {
  15745. var siz = context.SIZ;
  15746. var tileIndex = context.currentTile.index;
  15747. var tile = context.tiles[tileIndex];
  15748. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15749. var componentsCount = siz.Csiz;
  15750. var maxDecompositionLevelsCount = 0;
  15751. for (var q = 0; q < componentsCount; q++) {
  15752. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15753. }
  15754. var r = 0, l = 0, i = 0, k = 0;
  15755. this.nextPacket = function JpxImage_nextPacket() {
  15756. for (; r <= maxDecompositionLevelsCount; r++) {
  15757. for (; l < layersCount; l++) {
  15758. for (; i < componentsCount; i++) {
  15759. var component = tile.components[i];
  15760. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15761. continue;
  15762. }
  15763. var resolution = component.resolutions[r];
  15764. var numprecincts = resolution.precinctParameters.numprecincts;
  15765. for (; k < numprecincts;) {
  15766. var packet = createPacket(resolution, k, l);
  15767. k++;
  15768. return packet;
  15769. }
  15770. k = 0;
  15771. }
  15772. i = 0;
  15773. }
  15774. l = 0;
  15775. }
  15776. error('JPX Error: Out of packets');
  15777. };
  15778. }
  15779. function ResolutionPositionComponentLayerIterator(context) {
  15780. var siz = context.SIZ;
  15781. var tileIndex = context.currentTile.index;
  15782. var tile = context.tiles[tileIndex];
  15783. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15784. var componentsCount = siz.Csiz;
  15785. var l, r, c, p;
  15786. var maxDecompositionLevelsCount = 0;
  15787. for (c = 0; c < componentsCount; c++) {
  15788. var component = tile.components[c];
  15789. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15790. }
  15791. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15792. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15793. var maxNumPrecincts = 0;
  15794. for (c = 0; c < componentsCount; ++c) {
  15795. var resolutions = tile.components[c].resolutions;
  15796. if (r < resolutions.length) {
  15797. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15798. }
  15799. }
  15800. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15801. }
  15802. l = 0;
  15803. r = 0;
  15804. c = 0;
  15805. p = 0;
  15806. this.nextPacket = function JpxImage_nextPacket() {
  15807. for (; r <= maxDecompositionLevelsCount; r++) {
  15808. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15809. for (; c < componentsCount; c++) {
  15810. var component = tile.components[c];
  15811. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15812. continue;
  15813. }
  15814. var resolution = component.resolutions[r];
  15815. var numprecincts = resolution.precinctParameters.numprecincts;
  15816. if (p >= numprecincts) {
  15817. continue;
  15818. }
  15819. for (; l < layersCount;) {
  15820. var packet = createPacket(resolution, p, l);
  15821. l++;
  15822. return packet;
  15823. }
  15824. l = 0;
  15825. }
  15826. c = 0;
  15827. }
  15828. p = 0;
  15829. }
  15830. error('JPX Error: Out of packets');
  15831. };
  15832. }
  15833. function PositionComponentResolutionLayerIterator(context) {
  15834. var siz = context.SIZ;
  15835. var tileIndex = context.currentTile.index;
  15836. var tile = context.tiles[tileIndex];
  15837. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15838. var componentsCount = siz.Csiz;
  15839. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15840. var precinctsIterationSizes = precinctsSizes;
  15841. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15842. this.nextPacket = function JpxImage_nextPacket() {
  15843. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15844. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15845. for (; c < componentsCount; c++) {
  15846. var component = tile.components[c];
  15847. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15848. for (; r <= decompositionLevelsCount; r++) {
  15849. var resolution = component.resolutions[r];
  15850. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15851. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15852. if (k === null) {
  15853. continue;
  15854. }
  15855. for (; l < layersCount;) {
  15856. var packet = createPacket(resolution, k, l);
  15857. l++;
  15858. return packet;
  15859. }
  15860. l = 0;
  15861. }
  15862. r = 0;
  15863. }
  15864. c = 0;
  15865. }
  15866. px = 0;
  15867. }
  15868. error('JPX Error: Out of packets');
  15869. };
  15870. }
  15871. function ComponentPositionResolutionLayerIterator(context) {
  15872. var siz = context.SIZ;
  15873. var tileIndex = context.currentTile.index;
  15874. var tile = context.tiles[tileIndex];
  15875. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15876. var componentsCount = siz.Csiz;
  15877. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15878. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15879. this.nextPacket = function JpxImage_nextPacket() {
  15880. for (; c < componentsCount; ++c) {
  15881. var component = tile.components[c];
  15882. var precinctsIterationSizes = precinctsSizes.components[c];
  15883. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15884. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15885. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15886. for (; r <= decompositionLevelsCount; r++) {
  15887. var resolution = component.resolutions[r];
  15888. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15889. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15890. if (k === null) {
  15891. continue;
  15892. }
  15893. for (; l < layersCount;) {
  15894. var packet = createPacket(resolution, k, l);
  15895. l++;
  15896. return packet;
  15897. }
  15898. l = 0;
  15899. }
  15900. r = 0;
  15901. }
  15902. px = 0;
  15903. }
  15904. py = 0;
  15905. }
  15906. error('JPX Error: Out of packets');
  15907. };
  15908. }
  15909. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15910. var posX = pxIndex * precinctIterationSizes.minWidth;
  15911. var posY = pyIndex * precinctIterationSizes.minHeight;
  15912. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15913. return null;
  15914. }
  15915. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15916. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15917. }
  15918. function getPrecinctSizesInImageScale(tile) {
  15919. var componentsCount = tile.components.length;
  15920. var minWidth = Number.MAX_VALUE;
  15921. var minHeight = Number.MAX_VALUE;
  15922. var maxNumWide = 0;
  15923. var maxNumHigh = 0;
  15924. var sizePerComponent = new Array(componentsCount);
  15925. for (var c = 0; c < componentsCount; c++) {
  15926. var component = tile.components[c];
  15927. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15928. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15929. var minWidthCurrentComponent = Number.MAX_VALUE;
  15930. var minHeightCurrentComponent = Number.MAX_VALUE;
  15931. var maxNumWideCurrentComponent = 0;
  15932. var maxNumHighCurrentComponent = 0;
  15933. var scale = 1;
  15934. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15935. var resolution = component.resolutions[r];
  15936. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15937. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15938. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15939. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15940. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15941. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15942. sizePerResolution[r] = {
  15943. width: widthCurrentResolution,
  15944. height: heightCurrentResolution
  15945. };
  15946. scale <<= 1;
  15947. }
  15948. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15949. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15950. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15951. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15952. sizePerComponent[c] = {
  15953. resolutions: sizePerResolution,
  15954. minWidth: minWidthCurrentComponent,
  15955. minHeight: minHeightCurrentComponent,
  15956. maxNumWide: maxNumWideCurrentComponent,
  15957. maxNumHigh: maxNumHighCurrentComponent
  15958. };
  15959. }
  15960. return {
  15961. components: sizePerComponent,
  15962. minWidth: minWidth,
  15963. minHeight: minHeight,
  15964. maxNumWide: maxNumWide,
  15965. maxNumHigh: maxNumHigh
  15966. };
  15967. }
  15968. function buildPackets(context) {
  15969. var siz = context.SIZ;
  15970. var tileIndex = context.currentTile.index;
  15971. var tile = context.tiles[tileIndex];
  15972. var componentsCount = siz.Csiz;
  15973. for (var c = 0; c < componentsCount; c++) {
  15974. var component = tile.components[c];
  15975. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15976. var resolutions = [];
  15977. var subbands = [];
  15978. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15979. var blocksDimensions = getBlocksDimensions(context, component, r);
  15980. var resolution = {};
  15981. var scale = 1 << decompositionLevelsCount - r;
  15982. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15983. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15984. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15985. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15986. resolution.resLevel = r;
  15987. buildPrecincts(context, resolution, blocksDimensions);
  15988. resolutions.push(resolution);
  15989. var subband;
  15990. if (r === 0) {
  15991. subband = {};
  15992. subband.type = 'LL';
  15993. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15994. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15995. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15996. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15997. subband.resolution = resolution;
  15998. buildCodeblocks(context, subband, blocksDimensions);
  15999. subbands.push(subband);
  16000. resolution.subbands = [subband];
  16001. } else {
  16002. var bscale = 1 << decompositionLevelsCount - r + 1;
  16003. var resolutionSubbands = [];
  16004. subband = {};
  16005. subband.type = 'HL';
  16006. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16007. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  16008. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16009. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  16010. subband.resolution = resolution;
  16011. buildCodeblocks(context, subband, blocksDimensions);
  16012. subbands.push(subband);
  16013. resolutionSubbands.push(subband);
  16014. subband = {};
  16015. subband.type = 'LH';
  16016. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  16017. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16018. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  16019. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16020. subband.resolution = resolution;
  16021. buildCodeblocks(context, subband, blocksDimensions);
  16022. subbands.push(subband);
  16023. resolutionSubbands.push(subband);
  16024. subband = {};
  16025. subband.type = 'HH';
  16026. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16027. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16028. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16029. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16030. subband.resolution = resolution;
  16031. buildCodeblocks(context, subband, blocksDimensions);
  16032. subbands.push(subband);
  16033. resolutionSubbands.push(subband);
  16034. resolution.subbands = resolutionSubbands;
  16035. }
  16036. }
  16037. component.resolutions = resolutions;
  16038. component.subbands = subbands;
  16039. }
  16040. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  16041. switch (progressionOrder) {
  16042. case 0:
  16043. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  16044. break;
  16045. case 1:
  16046. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  16047. break;
  16048. case 2:
  16049. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  16050. break;
  16051. case 3:
  16052. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  16053. break;
  16054. case 4:
  16055. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  16056. break;
  16057. default:
  16058. error('JPX Error: Unsupported progression order ' + progressionOrder);
  16059. }
  16060. }
  16061. function parseTilePackets(context, data, offset, dataLength) {
  16062. var position = 0;
  16063. var buffer, bufferSize = 0, skipNextBit = false;
  16064. function readBits(count) {
  16065. while (bufferSize < count) {
  16066. var b = data[offset + position];
  16067. position++;
  16068. if (skipNextBit) {
  16069. buffer = buffer << 7 | b;
  16070. bufferSize += 7;
  16071. skipNextBit = false;
  16072. } else {
  16073. buffer = buffer << 8 | b;
  16074. bufferSize += 8;
  16075. }
  16076. if (b === 0xFF) {
  16077. skipNextBit = true;
  16078. }
  16079. }
  16080. bufferSize -= count;
  16081. return buffer >>> bufferSize & (1 << count) - 1;
  16082. }
  16083. function skipMarkerIfEqual(value) {
  16084. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  16085. skipBytes(1);
  16086. return true;
  16087. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  16088. skipBytes(2);
  16089. return true;
  16090. }
  16091. return false;
  16092. }
  16093. function skipBytes(count) {
  16094. position += count;
  16095. }
  16096. function alignToByte() {
  16097. bufferSize = 0;
  16098. if (skipNextBit) {
  16099. position++;
  16100. skipNextBit = false;
  16101. }
  16102. }
  16103. function readCodingpasses() {
  16104. if (readBits(1) === 0) {
  16105. return 1;
  16106. }
  16107. if (readBits(1) === 0) {
  16108. return 2;
  16109. }
  16110. var value = readBits(2);
  16111. if (value < 3) {
  16112. return value + 3;
  16113. }
  16114. value = readBits(5);
  16115. if (value < 31) {
  16116. return value + 6;
  16117. }
  16118. value = readBits(7);
  16119. return value + 37;
  16120. }
  16121. var tileIndex = context.currentTile.index;
  16122. var tile = context.tiles[tileIndex];
  16123. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16124. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16125. var packetsIterator = tile.packetsIterator;
  16126. while (position < dataLength) {
  16127. alignToByte();
  16128. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16129. skipBytes(4);
  16130. }
  16131. var packet = packetsIterator.nextPacket();
  16132. if (!readBits(1)) {
  16133. continue;
  16134. }
  16135. var layerNumber = packet.layerNumber;
  16136. var queue = [], codeblock;
  16137. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16138. codeblock = packet.codeblocks[i];
  16139. var precinct = codeblock.precinct;
  16140. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16141. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16142. var codeblockIncluded = false;
  16143. var firstTimeInclusion = false;
  16144. var valueReady;
  16145. if (codeblock['included'] !== undefined) {
  16146. codeblockIncluded = !!readBits(1);
  16147. } else {
  16148. precinct = codeblock.precinct;
  16149. var inclusionTree, zeroBitPlanesTree;
  16150. if (precinct['inclusionTree'] !== undefined) {
  16151. inclusionTree = precinct.inclusionTree;
  16152. } else {
  16153. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16154. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16155. inclusionTree = new InclusionTree(width, height, layerNumber);
  16156. zeroBitPlanesTree = new TagTree(width, height);
  16157. precinct.inclusionTree = inclusionTree;
  16158. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16159. }
  16160. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16161. while (true) {
  16162. if (readBits(1)) {
  16163. valueReady = !inclusionTree.nextLevel();
  16164. if (valueReady) {
  16165. codeblock.included = true;
  16166. codeblockIncluded = firstTimeInclusion = true;
  16167. break;
  16168. }
  16169. } else {
  16170. inclusionTree.incrementValue(layerNumber);
  16171. break;
  16172. }
  16173. }
  16174. }
  16175. }
  16176. if (!codeblockIncluded) {
  16177. continue;
  16178. }
  16179. if (firstTimeInclusion) {
  16180. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16181. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16182. while (true) {
  16183. if (readBits(1)) {
  16184. valueReady = !zeroBitPlanesTree.nextLevel();
  16185. if (valueReady) {
  16186. break;
  16187. }
  16188. } else {
  16189. zeroBitPlanesTree.incrementValue();
  16190. }
  16191. }
  16192. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16193. }
  16194. var codingpasses = readCodingpasses();
  16195. while (readBits(1)) {
  16196. codeblock.Lblock++;
  16197. }
  16198. var codingpassesLog2 = log2(codingpasses);
  16199. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16200. var codedDataLength = readBits(bits);
  16201. queue.push({
  16202. codeblock: codeblock,
  16203. codingpasses: codingpasses,
  16204. dataLength: codedDataLength
  16205. });
  16206. }
  16207. alignToByte();
  16208. if (ephMarkerUsed) {
  16209. skipMarkerIfEqual(0x92);
  16210. }
  16211. while (queue.length > 0) {
  16212. var packetItem = queue.shift();
  16213. codeblock = packetItem.codeblock;
  16214. if (codeblock['data'] === undefined) {
  16215. codeblock.data = [];
  16216. }
  16217. codeblock.data.push({
  16218. data: data,
  16219. start: offset + position,
  16220. end: offset + position + packetItem.dataLength,
  16221. codingpasses: packetItem.codingpasses
  16222. });
  16223. position += packetItem.dataLength;
  16224. }
  16225. }
  16226. return position;
  16227. }
  16228. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16229. var x0 = subband.tbx0;
  16230. var y0 = subband.tby0;
  16231. var width = subband.tbx1 - subband.tbx0;
  16232. var codeblocks = subband.codeblocks;
  16233. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16234. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16235. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16236. var codeblock = codeblocks[i];
  16237. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16238. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16239. if (blockWidth === 0 || blockHeight === 0) {
  16240. continue;
  16241. }
  16242. if (codeblock['data'] === undefined) {
  16243. continue;
  16244. }
  16245. var bitModel, currentCodingpassType;
  16246. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16247. currentCodingpassType = 2;
  16248. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16249. var j, jj, dataItem;
  16250. for (j = 0, jj = data.length; j < jj; j++) {
  16251. dataItem = data[j];
  16252. totalLength += dataItem.end - dataItem.start;
  16253. codingpasses += dataItem.codingpasses;
  16254. }
  16255. var encodedData = new Uint8Array(totalLength);
  16256. var position = 0;
  16257. for (j = 0, jj = data.length; j < jj; j++) {
  16258. dataItem = data[j];
  16259. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16260. encodedData.set(chunk, position);
  16261. position += chunk.length;
  16262. }
  16263. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16264. bitModel.setDecoder(decoder);
  16265. for (j = 0; j < codingpasses; j++) {
  16266. switch (currentCodingpassType) {
  16267. case 0:
  16268. bitModel.runSignificancePropagationPass();
  16269. break;
  16270. case 1:
  16271. bitModel.runMagnitudeRefinementPass();
  16272. break;
  16273. case 2:
  16274. bitModel.runCleanupPass();
  16275. if (segmentationSymbolUsed) {
  16276. bitModel.checkSegmentationSymbol();
  16277. }
  16278. break;
  16279. }
  16280. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16281. }
  16282. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16283. var sign = bitModel.coefficentsSign;
  16284. var magnitude = bitModel.coefficentsMagnitude;
  16285. var bitsDecoded = bitModel.bitsDecoded;
  16286. var magnitudeCorrection = reversible ? 0 : 0.5;
  16287. var k, n, nb;
  16288. position = 0;
  16289. var interleave = subband.type !== 'LL';
  16290. for (j = 0; j < blockHeight; j++) {
  16291. var row = offset / width | 0;
  16292. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16293. for (k = 0; k < blockWidth; k++) {
  16294. n = magnitude[position];
  16295. if (n !== 0) {
  16296. n = (n + magnitudeCorrection) * delta;
  16297. if (sign[position] !== 0) {
  16298. n = -n;
  16299. }
  16300. nb = bitsDecoded[position];
  16301. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16302. if (reversible && nb >= mb) {
  16303. coefficients[pos] = n;
  16304. } else {
  16305. coefficients[pos] = n * (1 << mb - nb);
  16306. }
  16307. }
  16308. offset++;
  16309. position++;
  16310. }
  16311. offset += width - blockWidth;
  16312. }
  16313. }
  16314. }
  16315. function transformTile(context, tile, c) {
  16316. var component = tile.components[c];
  16317. var codingStyleParameters = component.codingStyleParameters;
  16318. var quantizationParameters = component.quantizationParameters;
  16319. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16320. var spqcds = quantizationParameters.SPqcds;
  16321. var scalarExpounded = quantizationParameters.scalarExpounded;
  16322. var guardBits = quantizationParameters.guardBits;
  16323. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16324. var precision = context.components[c].precision;
  16325. var reversible = codingStyleParameters.reversibleTransformation;
  16326. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16327. var subbandCoefficients = [];
  16328. var b = 0;
  16329. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16330. var resolution = component.resolutions[i];
  16331. var width = resolution.trx1 - resolution.trx0;
  16332. var height = resolution.try1 - resolution.try0;
  16333. var coefficients = new Float32Array(width * height);
  16334. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16335. var mu, epsilon;
  16336. if (!scalarExpounded) {
  16337. mu = spqcds[0].mu;
  16338. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16339. } else {
  16340. mu = spqcds[b].mu;
  16341. epsilon = spqcds[b].epsilon;
  16342. b++;
  16343. }
  16344. var subband = resolution.subbands[j];
  16345. var gainLog2 = SubbandsGainLog2[subband.type];
  16346. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16347. var mb = guardBits + epsilon - 1;
  16348. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16349. }
  16350. subbandCoefficients.push({
  16351. width: width,
  16352. height: height,
  16353. items: coefficients
  16354. });
  16355. }
  16356. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16357. return {
  16358. left: component.tcx0,
  16359. top: component.tcy0,
  16360. width: result.width,
  16361. height: result.height,
  16362. items: result.items
  16363. };
  16364. }
  16365. function transformComponents(context) {
  16366. var siz = context.SIZ;
  16367. var components = context.components;
  16368. var componentsCount = siz.Csiz;
  16369. var resultImages = [];
  16370. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16371. var tile = context.tiles[i];
  16372. var transformedTiles = [];
  16373. var c;
  16374. for (c = 0; c < componentsCount; c++) {
  16375. transformedTiles[c] = transformTile(context, tile, c);
  16376. }
  16377. var tile0 = transformedTiles[0];
  16378. var out = new Uint8Array(tile0.items.length * componentsCount);
  16379. var result = {
  16380. left: tile0.left,
  16381. top: tile0.top,
  16382. width: tile0.width,
  16383. height: tile0.height,
  16384. items: out
  16385. };
  16386. var shift, offset, max, min, maxK;
  16387. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16388. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16389. var fourComponents = componentsCount === 4;
  16390. var y0items = transformedTiles[0].items;
  16391. var y1items = transformedTiles[1].items;
  16392. var y2items = transformedTiles[2].items;
  16393. var y3items = fourComponents ? transformedTiles[3].items : null;
  16394. shift = components[0].precision - 8;
  16395. offset = (128 << shift) + 0.5;
  16396. max = 255 * (1 << shift);
  16397. maxK = max * 0.5;
  16398. min = -maxK;
  16399. var component0 = tile.components[0];
  16400. var alpha01 = componentsCount - 3;
  16401. jj = y0items.length;
  16402. if (!component0.codingStyleParameters.reversibleTransformation) {
  16403. for (j = 0; j < jj; j++, pos += alpha01) {
  16404. y0 = y0items[j] + offset;
  16405. y1 = y1items[j];
  16406. y2 = y2items[j];
  16407. r = y0 + 1.402 * y2;
  16408. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16409. b = y0 + 1.772 * y1;
  16410. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16411. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16412. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16413. }
  16414. } else {
  16415. for (j = 0; j < jj; j++, pos += alpha01) {
  16416. y0 = y0items[j] + offset;
  16417. y1 = y1items[j];
  16418. y2 = y2items[j];
  16419. g = y0 - (y2 + y1 >> 2);
  16420. r = g + y2;
  16421. b = g + y1;
  16422. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16423. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16424. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16425. }
  16426. }
  16427. if (fourComponents) {
  16428. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16429. k = y3items[j];
  16430. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16431. }
  16432. }
  16433. } else {
  16434. for (c = 0; c < componentsCount; c++) {
  16435. var items = transformedTiles[c].items;
  16436. shift = components[c].precision - 8;
  16437. offset = (128 << shift) + 0.5;
  16438. max = 127.5 * (1 << shift);
  16439. min = -max;
  16440. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16441. val = items[j];
  16442. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16443. pos += componentsCount;
  16444. }
  16445. }
  16446. }
  16447. resultImages.push(result);
  16448. }
  16449. return resultImages;
  16450. }
  16451. function initializeTile(context, tileIndex) {
  16452. var siz = context.SIZ;
  16453. var componentsCount = siz.Csiz;
  16454. var tile = context.tiles[tileIndex];
  16455. for (var c = 0; c < componentsCount; c++) {
  16456. var component = tile.components[c];
  16457. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16458. component.quantizationParameters = qcdOrQcc;
  16459. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16460. component.codingStyleParameters = codOrCoc;
  16461. }
  16462. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16463. }
  16464. var TagTree = function TagTreeClosure() {
  16465. function TagTree(width, height) {
  16466. var levelsLength = log2(Math.max(width, height)) + 1;
  16467. this.levels = [];
  16468. for (var i = 0; i < levelsLength; i++) {
  16469. var level = {
  16470. width: width,
  16471. height: height,
  16472. items: []
  16473. };
  16474. this.levels.push(level);
  16475. width = Math.ceil(width / 2);
  16476. height = Math.ceil(height / 2);
  16477. }
  16478. }
  16479. TagTree.prototype = {
  16480. reset: function TagTree_reset(i, j) {
  16481. var currentLevel = 0, value = 0, level;
  16482. while (currentLevel < this.levels.length) {
  16483. level = this.levels[currentLevel];
  16484. var index = i + j * level.width;
  16485. if (level.items[index] !== undefined) {
  16486. value = level.items[index];
  16487. break;
  16488. }
  16489. level.index = index;
  16490. i >>= 1;
  16491. j >>= 1;
  16492. currentLevel++;
  16493. }
  16494. currentLevel--;
  16495. level = this.levels[currentLevel];
  16496. level.items[level.index] = value;
  16497. this.currentLevel = currentLevel;
  16498. delete this.value;
  16499. },
  16500. incrementValue: function TagTree_incrementValue() {
  16501. var level = this.levels[this.currentLevel];
  16502. level.items[level.index]++;
  16503. },
  16504. nextLevel: function TagTree_nextLevel() {
  16505. var currentLevel = this.currentLevel;
  16506. var level = this.levels[currentLevel];
  16507. var value = level.items[level.index];
  16508. currentLevel--;
  16509. if (currentLevel < 0) {
  16510. this.value = value;
  16511. return false;
  16512. }
  16513. this.currentLevel = currentLevel;
  16514. level = this.levels[currentLevel];
  16515. level.items[level.index] = value;
  16516. return true;
  16517. }
  16518. };
  16519. return TagTree;
  16520. }();
  16521. var InclusionTree = function InclusionTreeClosure() {
  16522. function InclusionTree(width, height, defaultValue) {
  16523. var levelsLength = log2(Math.max(width, height)) + 1;
  16524. this.levels = [];
  16525. for (var i = 0; i < levelsLength; i++) {
  16526. var items = new Uint8Array(width * height);
  16527. for (var j = 0, jj = items.length; j < jj; j++) {
  16528. items[j] = defaultValue;
  16529. }
  16530. var level = {
  16531. width: width,
  16532. height: height,
  16533. items: items
  16534. };
  16535. this.levels.push(level);
  16536. width = Math.ceil(width / 2);
  16537. height = Math.ceil(height / 2);
  16538. }
  16539. }
  16540. InclusionTree.prototype = {
  16541. reset: function InclusionTree_reset(i, j, stopValue) {
  16542. var currentLevel = 0;
  16543. while (currentLevel < this.levels.length) {
  16544. var level = this.levels[currentLevel];
  16545. var index = i + j * level.width;
  16546. level.index = index;
  16547. var value = level.items[index];
  16548. if (value === 0xFF) {
  16549. break;
  16550. }
  16551. if (value > stopValue) {
  16552. this.currentLevel = currentLevel;
  16553. this.propagateValues();
  16554. return false;
  16555. }
  16556. i >>= 1;
  16557. j >>= 1;
  16558. currentLevel++;
  16559. }
  16560. this.currentLevel = currentLevel - 1;
  16561. return true;
  16562. },
  16563. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16564. var level = this.levels[this.currentLevel];
  16565. level.items[level.index] = stopValue + 1;
  16566. this.propagateValues();
  16567. },
  16568. propagateValues: function InclusionTree_propagateValues() {
  16569. var levelIndex = this.currentLevel;
  16570. var level = this.levels[levelIndex];
  16571. var currentValue = level.items[level.index];
  16572. while (--levelIndex >= 0) {
  16573. level = this.levels[levelIndex];
  16574. level.items[level.index] = currentValue;
  16575. }
  16576. },
  16577. nextLevel: function InclusionTree_nextLevel() {
  16578. var currentLevel = this.currentLevel;
  16579. var level = this.levels[currentLevel];
  16580. var value = level.items[level.index];
  16581. level.items[level.index] = 0xFF;
  16582. currentLevel--;
  16583. if (currentLevel < 0) {
  16584. return false;
  16585. }
  16586. this.currentLevel = currentLevel;
  16587. level = this.levels[currentLevel];
  16588. level.items[level.index] = value;
  16589. return true;
  16590. }
  16591. };
  16592. return InclusionTree;
  16593. }();
  16594. var BitModel = function BitModelClosure() {
  16595. var UNIFORM_CONTEXT = 17;
  16596. var RUNLENGTH_CONTEXT = 18;
  16597. var LLAndLHContextsLabel = new Uint8Array([
  16598. 0,
  16599. 5,
  16600. 8,
  16601. 0,
  16602. 3,
  16603. 7,
  16604. 8,
  16605. 0,
  16606. 4,
  16607. 7,
  16608. 8,
  16609. 0,
  16610. 0,
  16611. 0,
  16612. 0,
  16613. 0,
  16614. 1,
  16615. 6,
  16616. 8,
  16617. 0,
  16618. 3,
  16619. 7,
  16620. 8,
  16621. 0,
  16622. 4,
  16623. 7,
  16624. 8,
  16625. 0,
  16626. 0,
  16627. 0,
  16628. 0,
  16629. 0,
  16630. 2,
  16631. 6,
  16632. 8,
  16633. 0,
  16634. 3,
  16635. 7,
  16636. 8,
  16637. 0,
  16638. 4,
  16639. 7,
  16640. 8,
  16641. 0,
  16642. 0,
  16643. 0,
  16644. 0,
  16645. 0,
  16646. 2,
  16647. 6,
  16648. 8,
  16649. 0,
  16650. 3,
  16651. 7,
  16652. 8,
  16653. 0,
  16654. 4,
  16655. 7,
  16656. 8,
  16657. 0,
  16658. 0,
  16659. 0,
  16660. 0,
  16661. 0,
  16662. 2,
  16663. 6,
  16664. 8,
  16665. 0,
  16666. 3,
  16667. 7,
  16668. 8,
  16669. 0,
  16670. 4,
  16671. 7,
  16672. 8
  16673. ]);
  16674. var HLContextLabel = new Uint8Array([
  16675. 0,
  16676. 3,
  16677. 4,
  16678. 0,
  16679. 5,
  16680. 7,
  16681. 7,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 0,
  16688. 0,
  16689. 0,
  16690. 0,
  16691. 1,
  16692. 3,
  16693. 4,
  16694. 0,
  16695. 6,
  16696. 7,
  16697. 7,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 0,
  16704. 0,
  16705. 0,
  16706. 0,
  16707. 2,
  16708. 3,
  16709. 4,
  16710. 0,
  16711. 6,
  16712. 7,
  16713. 7,
  16714. 0,
  16715. 8,
  16716. 8,
  16717. 8,
  16718. 0,
  16719. 0,
  16720. 0,
  16721. 0,
  16722. 0,
  16723. 2,
  16724. 3,
  16725. 4,
  16726. 0,
  16727. 6,
  16728. 7,
  16729. 7,
  16730. 0,
  16731. 8,
  16732. 8,
  16733. 8,
  16734. 0,
  16735. 0,
  16736. 0,
  16737. 0,
  16738. 0,
  16739. 2,
  16740. 3,
  16741. 4,
  16742. 0,
  16743. 6,
  16744. 7,
  16745. 7,
  16746. 0,
  16747. 8,
  16748. 8,
  16749. 8
  16750. ]);
  16751. var HHContextLabel = new Uint8Array([
  16752. 0,
  16753. 1,
  16754. 2,
  16755. 0,
  16756. 1,
  16757. 2,
  16758. 2,
  16759. 0,
  16760. 2,
  16761. 2,
  16762. 2,
  16763. 0,
  16764. 0,
  16765. 0,
  16766. 0,
  16767. 0,
  16768. 3,
  16769. 4,
  16770. 5,
  16771. 0,
  16772. 4,
  16773. 5,
  16774. 5,
  16775. 0,
  16776. 5,
  16777. 5,
  16778. 5,
  16779. 0,
  16780. 0,
  16781. 0,
  16782. 0,
  16783. 0,
  16784. 6,
  16785. 7,
  16786. 7,
  16787. 0,
  16788. 7,
  16789. 7,
  16790. 7,
  16791. 0,
  16792. 7,
  16793. 7,
  16794. 7,
  16795. 0,
  16796. 0,
  16797. 0,
  16798. 0,
  16799. 0,
  16800. 8,
  16801. 8,
  16802. 8,
  16803. 0,
  16804. 8,
  16805. 8,
  16806. 8,
  16807. 0,
  16808. 8,
  16809. 8,
  16810. 8,
  16811. 0,
  16812. 0,
  16813. 0,
  16814. 0,
  16815. 0,
  16816. 8,
  16817. 8,
  16818. 8,
  16819. 0,
  16820. 8,
  16821. 8,
  16822. 8,
  16823. 0,
  16824. 8,
  16825. 8,
  16826. 8
  16827. ]);
  16828. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16829. this.width = width;
  16830. this.height = height;
  16831. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16832. var coefficientCount = width * height;
  16833. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16834. this.coefficentsSign = new Uint8Array(coefficientCount);
  16835. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16836. this.processingFlags = new Uint8Array(coefficientCount);
  16837. var bitsDecoded = new Uint8Array(coefficientCount);
  16838. if (zeroBitPlanes !== 0) {
  16839. for (var i = 0; i < coefficientCount; i++) {
  16840. bitsDecoded[i] = zeroBitPlanes;
  16841. }
  16842. }
  16843. this.bitsDecoded = bitsDecoded;
  16844. this.reset();
  16845. }
  16846. BitModel.prototype = {
  16847. setDecoder: function BitModel_setDecoder(decoder) {
  16848. this.decoder = decoder;
  16849. },
  16850. reset: function BitModel_reset() {
  16851. this.contexts = new Int8Array(19);
  16852. this.contexts[0] = 4 << 1 | 0;
  16853. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16854. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16855. },
  16856. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16857. var neighborsSignificance = this.neighborsSignificance;
  16858. var width = this.width, height = this.height;
  16859. var left = column > 0;
  16860. var right = column + 1 < width;
  16861. var i;
  16862. if (row > 0) {
  16863. i = index - width;
  16864. if (left) {
  16865. neighborsSignificance[i - 1] += 0x10;
  16866. }
  16867. if (right) {
  16868. neighborsSignificance[i + 1] += 0x10;
  16869. }
  16870. neighborsSignificance[i] += 0x04;
  16871. }
  16872. if (row + 1 < height) {
  16873. i = index + width;
  16874. if (left) {
  16875. neighborsSignificance[i - 1] += 0x10;
  16876. }
  16877. if (right) {
  16878. neighborsSignificance[i + 1] += 0x10;
  16879. }
  16880. neighborsSignificance[i] += 0x04;
  16881. }
  16882. if (left) {
  16883. neighborsSignificance[index - 1] += 0x01;
  16884. }
  16885. if (right) {
  16886. neighborsSignificance[index + 1] += 0x01;
  16887. }
  16888. neighborsSignificance[index] |= 0x80;
  16889. },
  16890. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16891. var decoder = this.decoder;
  16892. var width = this.width, height = this.height;
  16893. var coefficentsMagnitude = this.coefficentsMagnitude;
  16894. var coefficentsSign = this.coefficentsSign;
  16895. var neighborsSignificance = this.neighborsSignificance;
  16896. var processingFlags = this.processingFlags;
  16897. var contexts = this.contexts;
  16898. var labels = this.contextLabelTable;
  16899. var bitsDecoded = this.bitsDecoded;
  16900. var processedInverseMask = ~1;
  16901. var processedMask = 1;
  16902. var firstMagnitudeBitMask = 2;
  16903. for (var i0 = 0; i0 < height; i0 += 4) {
  16904. for (var j = 0; j < width; j++) {
  16905. var index = i0 * width + j;
  16906. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16907. var i = i0 + i1;
  16908. if (i >= height) {
  16909. break;
  16910. }
  16911. processingFlags[index] &= processedInverseMask;
  16912. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16913. continue;
  16914. }
  16915. var contextLabel = labels[neighborsSignificance[index]];
  16916. var decision = decoder.readBit(contexts, contextLabel);
  16917. if (decision) {
  16918. var sign = this.decodeSignBit(i, j, index);
  16919. coefficentsSign[index] = sign;
  16920. coefficentsMagnitude[index] = 1;
  16921. this.setNeighborsSignificance(i, j, index);
  16922. processingFlags[index] |= firstMagnitudeBitMask;
  16923. }
  16924. bitsDecoded[index]++;
  16925. processingFlags[index] |= processedMask;
  16926. }
  16927. }
  16928. }
  16929. },
  16930. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16931. var width = this.width, height = this.height;
  16932. var coefficentsMagnitude = this.coefficentsMagnitude;
  16933. var coefficentsSign = this.coefficentsSign;
  16934. var contribution, sign0, sign1, significance1;
  16935. var contextLabel, decoded;
  16936. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16937. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16938. sign1 = coefficentsSign[index + 1];
  16939. if (significance1) {
  16940. sign0 = coefficentsSign[index - 1];
  16941. contribution = 1 - sign1 - sign0;
  16942. } else {
  16943. contribution = 1 - sign1 - sign1;
  16944. }
  16945. } else if (significance1) {
  16946. sign0 = coefficentsSign[index - 1];
  16947. contribution = 1 - sign0 - sign0;
  16948. } else {
  16949. contribution = 0;
  16950. }
  16951. var horizontalContribution = 3 * contribution;
  16952. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16953. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16954. sign1 = coefficentsSign[index + width];
  16955. if (significance1) {
  16956. sign0 = coefficentsSign[index - width];
  16957. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16958. } else {
  16959. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16960. }
  16961. } else if (significance1) {
  16962. sign0 = coefficentsSign[index - width];
  16963. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16964. } else {
  16965. contribution = horizontalContribution;
  16966. }
  16967. if (contribution >= 0) {
  16968. contextLabel = 9 + contribution;
  16969. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16970. } else {
  16971. contextLabel = 9 - contribution;
  16972. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16973. }
  16974. return decoded;
  16975. },
  16976. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16977. var decoder = this.decoder;
  16978. var width = this.width, height = this.height;
  16979. var coefficentsMagnitude = this.coefficentsMagnitude;
  16980. var neighborsSignificance = this.neighborsSignificance;
  16981. var contexts = this.contexts;
  16982. var bitsDecoded = this.bitsDecoded;
  16983. var processingFlags = this.processingFlags;
  16984. var processedMask = 1;
  16985. var firstMagnitudeBitMask = 2;
  16986. var length = width * height;
  16987. var width4 = width * 4;
  16988. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16989. indexNext = Math.min(length, index0 + width4);
  16990. for (var j = 0; j < width; j++) {
  16991. for (var index = index0 + j; index < indexNext; index += width) {
  16992. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16993. continue;
  16994. }
  16995. var contextLabel = 16;
  16996. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16997. processingFlags[index] ^= firstMagnitudeBitMask;
  16998. var significance = neighborsSignificance[index] & 127;
  16999. contextLabel = significance === 0 ? 15 : 14;
  17000. }
  17001. var bit = decoder.readBit(contexts, contextLabel);
  17002. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  17003. bitsDecoded[index]++;
  17004. processingFlags[index] |= processedMask;
  17005. }
  17006. }
  17007. }
  17008. },
  17009. runCleanupPass: function BitModel_runCleanupPass() {
  17010. var decoder = this.decoder;
  17011. var width = this.width, height = this.height;
  17012. var neighborsSignificance = this.neighborsSignificance;
  17013. var coefficentsMagnitude = this.coefficentsMagnitude;
  17014. var coefficentsSign = this.coefficentsSign;
  17015. var contexts = this.contexts;
  17016. var labels = this.contextLabelTable;
  17017. var bitsDecoded = this.bitsDecoded;
  17018. var processingFlags = this.processingFlags;
  17019. var processedMask = 1;
  17020. var firstMagnitudeBitMask = 2;
  17021. var oneRowDown = width;
  17022. var twoRowsDown = width * 2;
  17023. var threeRowsDown = width * 3;
  17024. var iNext;
  17025. for (var i0 = 0; i0 < height; i0 = iNext) {
  17026. iNext = Math.min(i0 + 4, height);
  17027. var indexBase = i0 * width;
  17028. var checkAllEmpty = i0 + 3 < height;
  17029. for (var j = 0; j < width; j++) {
  17030. var index0 = indexBase + j;
  17031. 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;
  17032. var i1 = 0, index = index0;
  17033. var i = i0, sign;
  17034. if (allEmpty) {
  17035. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  17036. if (!hasSignificantCoefficent) {
  17037. bitsDecoded[index0]++;
  17038. bitsDecoded[index0 + oneRowDown]++;
  17039. bitsDecoded[index0 + twoRowsDown]++;
  17040. bitsDecoded[index0 + threeRowsDown]++;
  17041. continue;
  17042. }
  17043. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17044. if (i1 !== 0) {
  17045. i = i0 + i1;
  17046. index += i1 * width;
  17047. }
  17048. sign = this.decodeSignBit(i, j, index);
  17049. coefficentsSign[index] = sign;
  17050. coefficentsMagnitude[index] = 1;
  17051. this.setNeighborsSignificance(i, j, index);
  17052. processingFlags[index] |= firstMagnitudeBitMask;
  17053. index = index0;
  17054. for (var i2 = i0; i2 <= i; i2++, index += width) {
  17055. bitsDecoded[index]++;
  17056. }
  17057. i1++;
  17058. }
  17059. for (i = i0 + i1; i < iNext; i++, index += width) {
  17060. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  17061. continue;
  17062. }
  17063. var contextLabel = labels[neighborsSignificance[index]];
  17064. var decision = decoder.readBit(contexts, contextLabel);
  17065. if (decision === 1) {
  17066. sign = this.decodeSignBit(i, j, index);
  17067. coefficentsSign[index] = sign;
  17068. coefficentsMagnitude[index] = 1;
  17069. this.setNeighborsSignificance(i, j, index);
  17070. processingFlags[index] |= firstMagnitudeBitMask;
  17071. }
  17072. bitsDecoded[index]++;
  17073. }
  17074. }
  17075. }
  17076. },
  17077. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  17078. var decoder = this.decoder;
  17079. var contexts = this.contexts;
  17080. 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);
  17081. if (symbol !== 0xA) {
  17082. error('JPX Error: Invalid segmentation symbol');
  17083. }
  17084. }
  17085. };
  17086. return BitModel;
  17087. }();
  17088. var Transform = function TransformClosure() {
  17089. function Transform() {
  17090. }
  17091. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  17092. var ll = subbands[0];
  17093. for (var i = 1, ii = subbands.length; i < ii; i++) {
  17094. ll = this.iterate(ll, subbands[i], u0, v0);
  17095. }
  17096. return ll;
  17097. };
  17098. Transform.prototype.extend = function extend(buffer, offset, size) {
  17099. var i1 = offset - 1, j1 = offset + 1;
  17100. var i2 = offset + size - 2, j2 = offset + size;
  17101. buffer[i1--] = buffer[j1++];
  17102. buffer[j2++] = buffer[i2--];
  17103. buffer[i1--] = buffer[j1++];
  17104. buffer[j2++] = buffer[i2--];
  17105. buffer[i1--] = buffer[j1++];
  17106. buffer[j2++] = buffer[i2--];
  17107. buffer[i1] = buffer[j1];
  17108. buffer[j2] = buffer[i2];
  17109. };
  17110. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  17111. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  17112. var width = hl_lh_hh.width;
  17113. var height = hl_lh_hh.height;
  17114. var items = hl_lh_hh.items;
  17115. var i, j, k, l, u, v;
  17116. for (k = 0, i = 0; i < llHeight; i++) {
  17117. l = i * 2 * width;
  17118. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17119. items[l] = llItems[k];
  17120. }
  17121. }
  17122. llItems = ll.items = null;
  17123. var bufferPadding = 4;
  17124. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17125. if (width === 1) {
  17126. if ((u0 & 1) !== 0) {
  17127. for (v = 0, k = 0; v < height; v++, k += width) {
  17128. items[k] *= 0.5;
  17129. }
  17130. }
  17131. } else {
  17132. for (v = 0, k = 0; v < height; v++, k += width) {
  17133. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17134. this.extend(rowBuffer, bufferPadding, width);
  17135. this.filter(rowBuffer, bufferPadding, width);
  17136. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17137. }
  17138. }
  17139. var numBuffers = 16;
  17140. var colBuffers = [];
  17141. for (i = 0; i < numBuffers; i++) {
  17142. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17143. }
  17144. var b, currentBuffer = 0;
  17145. ll = bufferPadding + height;
  17146. if (height === 1) {
  17147. if ((v0 & 1) !== 0) {
  17148. for (u = 0; u < width; u++) {
  17149. items[u] *= 0.5;
  17150. }
  17151. }
  17152. } else {
  17153. for (u = 0; u < width; u++) {
  17154. if (currentBuffer === 0) {
  17155. numBuffers = Math.min(width - u, numBuffers);
  17156. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17157. for (b = 0; b < numBuffers; b++) {
  17158. colBuffers[b][l] = items[k + b];
  17159. }
  17160. }
  17161. currentBuffer = numBuffers;
  17162. }
  17163. currentBuffer--;
  17164. var buffer = colBuffers[currentBuffer];
  17165. this.extend(buffer, bufferPadding, height);
  17166. this.filter(buffer, bufferPadding, height);
  17167. if (currentBuffer === 0) {
  17168. k = u - numBuffers + 1;
  17169. for (l = bufferPadding; l < ll; k += width, l++) {
  17170. for (b = 0; b < numBuffers; b++) {
  17171. items[k + b] = colBuffers[b][l];
  17172. }
  17173. }
  17174. }
  17175. }
  17176. }
  17177. return {
  17178. width: width,
  17179. height: height,
  17180. items: items
  17181. };
  17182. };
  17183. return Transform;
  17184. }();
  17185. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17186. function IrreversibleTransform() {
  17187. Transform.call(this);
  17188. }
  17189. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17190. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17191. var len = length >> 1;
  17192. offset = offset | 0;
  17193. var j, n, current, next;
  17194. var alpha = -1.586134342059924;
  17195. var beta = -0.052980118572961;
  17196. var gamma = 0.882911075530934;
  17197. var delta = 0.443506852043971;
  17198. var K = 1.230174104914001;
  17199. var K_ = 1 / K;
  17200. j = offset - 3;
  17201. for (n = len + 4; n--; j += 2) {
  17202. x[j] *= K_;
  17203. }
  17204. j = offset - 2;
  17205. current = delta * x[j - 1];
  17206. for (n = len + 3; n--; j += 2) {
  17207. next = delta * x[j + 1];
  17208. x[j] = K * x[j] - current - next;
  17209. if (n--) {
  17210. j += 2;
  17211. current = delta * x[j + 1];
  17212. x[j] = K * x[j] - current - next;
  17213. } else {
  17214. break;
  17215. }
  17216. }
  17217. j = offset - 1;
  17218. current = gamma * x[j - 1];
  17219. for (n = len + 2; n--; j += 2) {
  17220. next = gamma * x[j + 1];
  17221. x[j] -= current + next;
  17222. if (n--) {
  17223. j += 2;
  17224. current = gamma * x[j + 1];
  17225. x[j] -= current + next;
  17226. } else {
  17227. break;
  17228. }
  17229. }
  17230. j = offset;
  17231. current = beta * x[j - 1];
  17232. for (n = len + 1; n--; j += 2) {
  17233. next = beta * x[j + 1];
  17234. x[j] -= current + next;
  17235. if (n--) {
  17236. j += 2;
  17237. current = beta * x[j + 1];
  17238. x[j] -= current + next;
  17239. } else {
  17240. break;
  17241. }
  17242. }
  17243. if (len !== 0) {
  17244. j = offset + 1;
  17245. current = alpha * x[j - 1];
  17246. for (n = len; n--; j += 2) {
  17247. next = alpha * x[j + 1];
  17248. x[j] -= current + next;
  17249. if (n--) {
  17250. j += 2;
  17251. current = alpha * x[j + 1];
  17252. x[j] -= current + next;
  17253. } else {
  17254. break;
  17255. }
  17256. }
  17257. }
  17258. };
  17259. return IrreversibleTransform;
  17260. }();
  17261. var ReversibleTransform = function ReversibleTransformClosure() {
  17262. function ReversibleTransform() {
  17263. Transform.call(this);
  17264. }
  17265. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17266. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17267. var len = length >> 1;
  17268. offset = offset | 0;
  17269. var j, n;
  17270. for (j = offset, n = len + 1; n--; j += 2) {
  17271. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17272. }
  17273. for (j = offset + 1, n = len; n--; j += 2) {
  17274. x[j] += x[j - 1] + x[j + 1] >> 1;
  17275. }
  17276. };
  17277. return ReversibleTransform;
  17278. }();
  17279. return JpxImage;
  17280. }();
  17281. exports.JpxImage = JpxImage;
  17282. }));
  17283. (function (root, factory) {
  17284. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17285. }(this, function (exports, sharedUtil) {
  17286. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17287. var getMetrics = getLookupTableFactory(function (t) {
  17288. t['Courier'] = 600;
  17289. t['Courier-Bold'] = 600;
  17290. t['Courier-BoldOblique'] = 600;
  17291. t['Courier-Oblique'] = 600;
  17292. t['Helvetica'] = getLookupTableFactory(function (t) {
  17293. t['space'] = 278;
  17294. t['exclam'] = 278;
  17295. t['quotedbl'] = 355;
  17296. t['numbersign'] = 556;
  17297. t['dollar'] = 556;
  17298. t['percent'] = 889;
  17299. t['ampersand'] = 667;
  17300. t['quoteright'] = 222;
  17301. t['parenleft'] = 333;
  17302. t['parenright'] = 333;
  17303. t['asterisk'] = 389;
  17304. t['plus'] = 584;
  17305. t['comma'] = 278;
  17306. t['hyphen'] = 333;
  17307. t['period'] = 278;
  17308. t['slash'] = 278;
  17309. t['zero'] = 556;
  17310. t['one'] = 556;
  17311. t['two'] = 556;
  17312. t['three'] = 556;
  17313. t['four'] = 556;
  17314. t['five'] = 556;
  17315. t['six'] = 556;
  17316. t['seven'] = 556;
  17317. t['eight'] = 556;
  17318. t['nine'] = 556;
  17319. t['colon'] = 278;
  17320. t['semicolon'] = 278;
  17321. t['less'] = 584;
  17322. t['equal'] = 584;
  17323. t['greater'] = 584;
  17324. t['question'] = 556;
  17325. t['at'] = 1015;
  17326. t['A'] = 667;
  17327. t['B'] = 667;
  17328. t['C'] = 722;
  17329. t['D'] = 722;
  17330. t['E'] = 667;
  17331. t['F'] = 611;
  17332. t['G'] = 778;
  17333. t['H'] = 722;
  17334. t['I'] = 278;
  17335. t['J'] = 500;
  17336. t['K'] = 667;
  17337. t['L'] = 556;
  17338. t['M'] = 833;
  17339. t['N'] = 722;
  17340. t['O'] = 778;
  17341. t['P'] = 667;
  17342. t['Q'] = 778;
  17343. t['R'] = 722;
  17344. t['S'] = 667;
  17345. t['T'] = 611;
  17346. t['U'] = 722;
  17347. t['V'] = 667;
  17348. t['W'] = 944;
  17349. t['X'] = 667;
  17350. t['Y'] = 667;
  17351. t['Z'] = 611;
  17352. t['bracketleft'] = 278;
  17353. t['backslash'] = 278;
  17354. t['bracketright'] = 278;
  17355. t['asciicircum'] = 469;
  17356. t['underscore'] = 556;
  17357. t['quoteleft'] = 222;
  17358. t['a'] = 556;
  17359. t['b'] = 556;
  17360. t['c'] = 500;
  17361. t['d'] = 556;
  17362. t['e'] = 556;
  17363. t['f'] = 278;
  17364. t['g'] = 556;
  17365. t['h'] = 556;
  17366. t['i'] = 222;
  17367. t['j'] = 222;
  17368. t['k'] = 500;
  17369. t['l'] = 222;
  17370. t['m'] = 833;
  17371. t['n'] = 556;
  17372. t['o'] = 556;
  17373. t['p'] = 556;
  17374. t['q'] = 556;
  17375. t['r'] = 333;
  17376. t['s'] = 500;
  17377. t['t'] = 278;
  17378. t['u'] = 556;
  17379. t['v'] = 500;
  17380. t['w'] = 722;
  17381. t['x'] = 500;
  17382. t['y'] = 500;
  17383. t['z'] = 500;
  17384. t['braceleft'] = 334;
  17385. t['bar'] = 260;
  17386. t['braceright'] = 334;
  17387. t['asciitilde'] = 584;
  17388. t['exclamdown'] = 333;
  17389. t['cent'] = 556;
  17390. t['sterling'] = 556;
  17391. t['fraction'] = 167;
  17392. t['yen'] = 556;
  17393. t['florin'] = 556;
  17394. t['section'] = 556;
  17395. t['currency'] = 556;
  17396. t['quotesingle'] = 191;
  17397. t['quotedblleft'] = 333;
  17398. t['guillemotleft'] = 556;
  17399. t['guilsinglleft'] = 333;
  17400. t['guilsinglright'] = 333;
  17401. t['fi'] = 500;
  17402. t['fl'] = 500;
  17403. t['endash'] = 556;
  17404. t['dagger'] = 556;
  17405. t['daggerdbl'] = 556;
  17406. t['periodcentered'] = 278;
  17407. t['paragraph'] = 537;
  17408. t['bullet'] = 350;
  17409. t['quotesinglbase'] = 222;
  17410. t['quotedblbase'] = 333;
  17411. t['quotedblright'] = 333;
  17412. t['guillemotright'] = 556;
  17413. t['ellipsis'] = 1000;
  17414. t['perthousand'] = 1000;
  17415. t['questiondown'] = 611;
  17416. t['grave'] = 333;
  17417. t['acute'] = 333;
  17418. t['circumflex'] = 333;
  17419. t['tilde'] = 333;
  17420. t['macron'] = 333;
  17421. t['breve'] = 333;
  17422. t['dotaccent'] = 333;
  17423. t['dieresis'] = 333;
  17424. t['ring'] = 333;
  17425. t['cedilla'] = 333;
  17426. t['hungarumlaut'] = 333;
  17427. t['ogonek'] = 333;
  17428. t['caron'] = 333;
  17429. t['emdash'] = 1000;
  17430. t['AE'] = 1000;
  17431. t['ordfeminine'] = 370;
  17432. t['Lslash'] = 556;
  17433. t['Oslash'] = 778;
  17434. t['OE'] = 1000;
  17435. t['ordmasculine'] = 365;
  17436. t['ae'] = 889;
  17437. t['dotlessi'] = 278;
  17438. t['lslash'] = 222;
  17439. t['oslash'] = 611;
  17440. t['oe'] = 944;
  17441. t['germandbls'] = 611;
  17442. t['Idieresis'] = 278;
  17443. t['eacute'] = 556;
  17444. t['abreve'] = 556;
  17445. t['uhungarumlaut'] = 556;
  17446. t['ecaron'] = 556;
  17447. t['Ydieresis'] = 667;
  17448. t['divide'] = 584;
  17449. t['Yacute'] = 667;
  17450. t['Acircumflex'] = 667;
  17451. t['aacute'] = 556;
  17452. t['Ucircumflex'] = 722;
  17453. t['yacute'] = 500;
  17454. t['scommaaccent'] = 500;
  17455. t['ecircumflex'] = 556;
  17456. t['Uring'] = 722;
  17457. t['Udieresis'] = 722;
  17458. t['aogonek'] = 556;
  17459. t['Uacute'] = 722;
  17460. t['uogonek'] = 556;
  17461. t['Edieresis'] = 667;
  17462. t['Dcroat'] = 722;
  17463. t['commaaccent'] = 250;
  17464. t['copyright'] = 737;
  17465. t['Emacron'] = 667;
  17466. t['ccaron'] = 500;
  17467. t['aring'] = 556;
  17468. t['Ncommaaccent'] = 722;
  17469. t['lacute'] = 222;
  17470. t['agrave'] = 556;
  17471. t['Tcommaaccent'] = 611;
  17472. t['Cacute'] = 722;
  17473. t['atilde'] = 556;
  17474. t['Edotaccent'] = 667;
  17475. t['scaron'] = 500;
  17476. t['scedilla'] = 500;
  17477. t['iacute'] = 278;
  17478. t['lozenge'] = 471;
  17479. t['Rcaron'] = 722;
  17480. t['Gcommaaccent'] = 778;
  17481. t['ucircumflex'] = 556;
  17482. t['acircumflex'] = 556;
  17483. t['Amacron'] = 667;
  17484. t['rcaron'] = 333;
  17485. t['ccedilla'] = 500;
  17486. t['Zdotaccent'] = 611;
  17487. t['Thorn'] = 667;
  17488. t['Omacron'] = 778;
  17489. t['Racute'] = 722;
  17490. t['Sacute'] = 667;
  17491. t['dcaron'] = 643;
  17492. t['Umacron'] = 722;
  17493. t['uring'] = 556;
  17494. t['threesuperior'] = 333;
  17495. t['Ograve'] = 778;
  17496. t['Agrave'] = 667;
  17497. t['Abreve'] = 667;
  17498. t['multiply'] = 584;
  17499. t['uacute'] = 556;
  17500. t['Tcaron'] = 611;
  17501. t['partialdiff'] = 476;
  17502. t['ydieresis'] = 500;
  17503. t['Nacute'] = 722;
  17504. t['icircumflex'] = 278;
  17505. t['Ecircumflex'] = 667;
  17506. t['adieresis'] = 556;
  17507. t['edieresis'] = 556;
  17508. t['cacute'] = 500;
  17509. t['nacute'] = 556;
  17510. t['umacron'] = 556;
  17511. t['Ncaron'] = 722;
  17512. t['Iacute'] = 278;
  17513. t['plusminus'] = 584;
  17514. t['brokenbar'] = 260;
  17515. t['registered'] = 737;
  17516. t['Gbreve'] = 778;
  17517. t['Idotaccent'] = 278;
  17518. t['summation'] = 600;
  17519. t['Egrave'] = 667;
  17520. t['racute'] = 333;
  17521. t['omacron'] = 556;
  17522. t['Zacute'] = 611;
  17523. t['Zcaron'] = 611;
  17524. t['greaterequal'] = 549;
  17525. t['Eth'] = 722;
  17526. t['Ccedilla'] = 722;
  17527. t['lcommaaccent'] = 222;
  17528. t['tcaron'] = 317;
  17529. t['eogonek'] = 556;
  17530. t['Uogonek'] = 722;
  17531. t['Aacute'] = 667;
  17532. t['Adieresis'] = 667;
  17533. t['egrave'] = 556;
  17534. t['zacute'] = 500;
  17535. t['iogonek'] = 222;
  17536. t['Oacute'] = 778;
  17537. t['oacute'] = 556;
  17538. t['amacron'] = 556;
  17539. t['sacute'] = 500;
  17540. t['idieresis'] = 278;
  17541. t['Ocircumflex'] = 778;
  17542. t['Ugrave'] = 722;
  17543. t['Delta'] = 612;
  17544. t['thorn'] = 556;
  17545. t['twosuperior'] = 333;
  17546. t['Odieresis'] = 778;
  17547. t['mu'] = 556;
  17548. t['igrave'] = 278;
  17549. t['ohungarumlaut'] = 556;
  17550. t['Eogonek'] = 667;
  17551. t['dcroat'] = 556;
  17552. t['threequarters'] = 834;
  17553. t['Scedilla'] = 667;
  17554. t['lcaron'] = 299;
  17555. t['Kcommaaccent'] = 667;
  17556. t['Lacute'] = 556;
  17557. t['trademark'] = 1000;
  17558. t['edotaccent'] = 556;
  17559. t['Igrave'] = 278;
  17560. t['Imacron'] = 278;
  17561. t['Lcaron'] = 556;
  17562. t['onehalf'] = 834;
  17563. t['lessequal'] = 549;
  17564. t['ocircumflex'] = 556;
  17565. t['ntilde'] = 556;
  17566. t['Uhungarumlaut'] = 722;
  17567. t['Eacute'] = 667;
  17568. t['emacron'] = 556;
  17569. t['gbreve'] = 556;
  17570. t['onequarter'] = 834;
  17571. t['Scaron'] = 667;
  17572. t['Scommaaccent'] = 667;
  17573. t['Ohungarumlaut'] = 778;
  17574. t['degree'] = 400;
  17575. t['ograve'] = 556;
  17576. t['Ccaron'] = 722;
  17577. t['ugrave'] = 556;
  17578. t['radical'] = 453;
  17579. t['Dcaron'] = 722;
  17580. t['rcommaaccent'] = 333;
  17581. t['Ntilde'] = 722;
  17582. t['otilde'] = 556;
  17583. t['Rcommaaccent'] = 722;
  17584. t['Lcommaaccent'] = 556;
  17585. t['Atilde'] = 667;
  17586. t['Aogonek'] = 667;
  17587. t['Aring'] = 667;
  17588. t['Otilde'] = 778;
  17589. t['zdotaccent'] = 500;
  17590. t['Ecaron'] = 667;
  17591. t['Iogonek'] = 278;
  17592. t['kcommaaccent'] = 500;
  17593. t['minus'] = 584;
  17594. t['Icircumflex'] = 278;
  17595. t['ncaron'] = 556;
  17596. t['tcommaaccent'] = 278;
  17597. t['logicalnot'] = 584;
  17598. t['odieresis'] = 556;
  17599. t['udieresis'] = 556;
  17600. t['notequal'] = 549;
  17601. t['gcommaaccent'] = 556;
  17602. t['eth'] = 556;
  17603. t['zcaron'] = 500;
  17604. t['ncommaaccent'] = 556;
  17605. t['onesuperior'] = 333;
  17606. t['imacron'] = 278;
  17607. t['Euro'] = 556;
  17608. });
  17609. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17610. t['space'] = 278;
  17611. t['exclam'] = 333;
  17612. t['quotedbl'] = 474;
  17613. t['numbersign'] = 556;
  17614. t['dollar'] = 556;
  17615. t['percent'] = 889;
  17616. t['ampersand'] = 722;
  17617. t['quoteright'] = 278;
  17618. t['parenleft'] = 333;
  17619. t['parenright'] = 333;
  17620. t['asterisk'] = 389;
  17621. t['plus'] = 584;
  17622. t['comma'] = 278;
  17623. t['hyphen'] = 333;
  17624. t['period'] = 278;
  17625. t['slash'] = 278;
  17626. t['zero'] = 556;
  17627. t['one'] = 556;
  17628. t['two'] = 556;
  17629. t['three'] = 556;
  17630. t['four'] = 556;
  17631. t['five'] = 556;
  17632. t['six'] = 556;
  17633. t['seven'] = 556;
  17634. t['eight'] = 556;
  17635. t['nine'] = 556;
  17636. t['colon'] = 333;
  17637. t['semicolon'] = 333;
  17638. t['less'] = 584;
  17639. t['equal'] = 584;
  17640. t['greater'] = 584;
  17641. t['question'] = 611;
  17642. t['at'] = 975;
  17643. t['A'] = 722;
  17644. t['B'] = 722;
  17645. t['C'] = 722;
  17646. t['D'] = 722;
  17647. t['E'] = 667;
  17648. t['F'] = 611;
  17649. t['G'] = 778;
  17650. t['H'] = 722;
  17651. t['I'] = 278;
  17652. t['J'] = 556;
  17653. t['K'] = 722;
  17654. t['L'] = 611;
  17655. t['M'] = 833;
  17656. t['N'] = 722;
  17657. t['O'] = 778;
  17658. t['P'] = 667;
  17659. t['Q'] = 778;
  17660. t['R'] = 722;
  17661. t['S'] = 667;
  17662. t['T'] = 611;
  17663. t['U'] = 722;
  17664. t['V'] = 667;
  17665. t['W'] = 944;
  17666. t['X'] = 667;
  17667. t['Y'] = 667;
  17668. t['Z'] = 611;
  17669. t['bracketleft'] = 333;
  17670. t['backslash'] = 278;
  17671. t['bracketright'] = 333;
  17672. t['asciicircum'] = 584;
  17673. t['underscore'] = 556;
  17674. t['quoteleft'] = 278;
  17675. t['a'] = 556;
  17676. t['b'] = 611;
  17677. t['c'] = 556;
  17678. t['d'] = 611;
  17679. t['e'] = 556;
  17680. t['f'] = 333;
  17681. t['g'] = 611;
  17682. t['h'] = 611;
  17683. t['i'] = 278;
  17684. t['j'] = 278;
  17685. t['k'] = 556;
  17686. t['l'] = 278;
  17687. t['m'] = 889;
  17688. t['n'] = 611;
  17689. t['o'] = 611;
  17690. t['p'] = 611;
  17691. t['q'] = 611;
  17692. t['r'] = 389;
  17693. t['s'] = 556;
  17694. t['t'] = 333;
  17695. t['u'] = 611;
  17696. t['v'] = 556;
  17697. t['w'] = 778;
  17698. t['x'] = 556;
  17699. t['y'] = 556;
  17700. t['z'] = 500;
  17701. t['braceleft'] = 389;
  17702. t['bar'] = 280;
  17703. t['braceright'] = 389;
  17704. t['asciitilde'] = 584;
  17705. t['exclamdown'] = 333;
  17706. t['cent'] = 556;
  17707. t['sterling'] = 556;
  17708. t['fraction'] = 167;
  17709. t['yen'] = 556;
  17710. t['florin'] = 556;
  17711. t['section'] = 556;
  17712. t['currency'] = 556;
  17713. t['quotesingle'] = 238;
  17714. t['quotedblleft'] = 500;
  17715. t['guillemotleft'] = 556;
  17716. t['guilsinglleft'] = 333;
  17717. t['guilsinglright'] = 333;
  17718. t['fi'] = 611;
  17719. t['fl'] = 611;
  17720. t['endash'] = 556;
  17721. t['dagger'] = 556;
  17722. t['daggerdbl'] = 556;
  17723. t['periodcentered'] = 278;
  17724. t['paragraph'] = 556;
  17725. t['bullet'] = 350;
  17726. t['quotesinglbase'] = 278;
  17727. t['quotedblbase'] = 500;
  17728. t['quotedblright'] = 500;
  17729. t['guillemotright'] = 556;
  17730. t['ellipsis'] = 1000;
  17731. t['perthousand'] = 1000;
  17732. t['questiondown'] = 611;
  17733. t['grave'] = 333;
  17734. t['acute'] = 333;
  17735. t['circumflex'] = 333;
  17736. t['tilde'] = 333;
  17737. t['macron'] = 333;
  17738. t['breve'] = 333;
  17739. t['dotaccent'] = 333;
  17740. t['dieresis'] = 333;
  17741. t['ring'] = 333;
  17742. t['cedilla'] = 333;
  17743. t['hungarumlaut'] = 333;
  17744. t['ogonek'] = 333;
  17745. t['caron'] = 333;
  17746. t['emdash'] = 1000;
  17747. t['AE'] = 1000;
  17748. t['ordfeminine'] = 370;
  17749. t['Lslash'] = 611;
  17750. t['Oslash'] = 778;
  17751. t['OE'] = 1000;
  17752. t['ordmasculine'] = 365;
  17753. t['ae'] = 889;
  17754. t['dotlessi'] = 278;
  17755. t['lslash'] = 278;
  17756. t['oslash'] = 611;
  17757. t['oe'] = 944;
  17758. t['germandbls'] = 611;
  17759. t['Idieresis'] = 278;
  17760. t['eacute'] = 556;
  17761. t['abreve'] = 556;
  17762. t['uhungarumlaut'] = 611;
  17763. t['ecaron'] = 556;
  17764. t['Ydieresis'] = 667;
  17765. t['divide'] = 584;
  17766. t['Yacute'] = 667;
  17767. t['Acircumflex'] = 722;
  17768. t['aacute'] = 556;
  17769. t['Ucircumflex'] = 722;
  17770. t['yacute'] = 556;
  17771. t['scommaaccent'] = 556;
  17772. t['ecircumflex'] = 556;
  17773. t['Uring'] = 722;
  17774. t['Udieresis'] = 722;
  17775. t['aogonek'] = 556;
  17776. t['Uacute'] = 722;
  17777. t['uogonek'] = 611;
  17778. t['Edieresis'] = 667;
  17779. t['Dcroat'] = 722;
  17780. t['commaaccent'] = 250;
  17781. t['copyright'] = 737;
  17782. t['Emacron'] = 667;
  17783. t['ccaron'] = 556;
  17784. t['aring'] = 556;
  17785. t['Ncommaaccent'] = 722;
  17786. t['lacute'] = 278;
  17787. t['agrave'] = 556;
  17788. t['Tcommaaccent'] = 611;
  17789. t['Cacute'] = 722;
  17790. t['atilde'] = 556;
  17791. t['Edotaccent'] = 667;
  17792. t['scaron'] = 556;
  17793. t['scedilla'] = 556;
  17794. t['iacute'] = 278;
  17795. t['lozenge'] = 494;
  17796. t['Rcaron'] = 722;
  17797. t['Gcommaaccent'] = 778;
  17798. t['ucircumflex'] = 611;
  17799. t['acircumflex'] = 556;
  17800. t['Amacron'] = 722;
  17801. t['rcaron'] = 389;
  17802. t['ccedilla'] = 556;
  17803. t['Zdotaccent'] = 611;
  17804. t['Thorn'] = 667;
  17805. t['Omacron'] = 778;
  17806. t['Racute'] = 722;
  17807. t['Sacute'] = 667;
  17808. t['dcaron'] = 743;
  17809. t['Umacron'] = 722;
  17810. t['uring'] = 611;
  17811. t['threesuperior'] = 333;
  17812. t['Ograve'] = 778;
  17813. t['Agrave'] = 722;
  17814. t['Abreve'] = 722;
  17815. t['multiply'] = 584;
  17816. t['uacute'] = 611;
  17817. t['Tcaron'] = 611;
  17818. t['partialdiff'] = 494;
  17819. t['ydieresis'] = 556;
  17820. t['Nacute'] = 722;
  17821. t['icircumflex'] = 278;
  17822. t['Ecircumflex'] = 667;
  17823. t['adieresis'] = 556;
  17824. t['edieresis'] = 556;
  17825. t['cacute'] = 556;
  17826. t['nacute'] = 611;
  17827. t['umacron'] = 611;
  17828. t['Ncaron'] = 722;
  17829. t['Iacute'] = 278;
  17830. t['plusminus'] = 584;
  17831. t['brokenbar'] = 280;
  17832. t['registered'] = 737;
  17833. t['Gbreve'] = 778;
  17834. t['Idotaccent'] = 278;
  17835. t['summation'] = 600;
  17836. t['Egrave'] = 667;
  17837. t['racute'] = 389;
  17838. t['omacron'] = 611;
  17839. t['Zacute'] = 611;
  17840. t['Zcaron'] = 611;
  17841. t['greaterequal'] = 549;
  17842. t['Eth'] = 722;
  17843. t['Ccedilla'] = 722;
  17844. t['lcommaaccent'] = 278;
  17845. t['tcaron'] = 389;
  17846. t['eogonek'] = 556;
  17847. t['Uogonek'] = 722;
  17848. t['Aacute'] = 722;
  17849. t['Adieresis'] = 722;
  17850. t['egrave'] = 556;
  17851. t['zacute'] = 500;
  17852. t['iogonek'] = 278;
  17853. t['Oacute'] = 778;
  17854. t['oacute'] = 611;
  17855. t['amacron'] = 556;
  17856. t['sacute'] = 556;
  17857. t['idieresis'] = 278;
  17858. t['Ocircumflex'] = 778;
  17859. t['Ugrave'] = 722;
  17860. t['Delta'] = 612;
  17861. t['thorn'] = 611;
  17862. t['twosuperior'] = 333;
  17863. t['Odieresis'] = 778;
  17864. t['mu'] = 611;
  17865. t['igrave'] = 278;
  17866. t['ohungarumlaut'] = 611;
  17867. t['Eogonek'] = 667;
  17868. t['dcroat'] = 611;
  17869. t['threequarters'] = 834;
  17870. t['Scedilla'] = 667;
  17871. t['lcaron'] = 400;
  17872. t['Kcommaaccent'] = 722;
  17873. t['Lacute'] = 611;
  17874. t['trademark'] = 1000;
  17875. t['edotaccent'] = 556;
  17876. t['Igrave'] = 278;
  17877. t['Imacron'] = 278;
  17878. t['Lcaron'] = 611;
  17879. t['onehalf'] = 834;
  17880. t['lessequal'] = 549;
  17881. t['ocircumflex'] = 611;
  17882. t['ntilde'] = 611;
  17883. t['Uhungarumlaut'] = 722;
  17884. t['Eacute'] = 667;
  17885. t['emacron'] = 556;
  17886. t['gbreve'] = 611;
  17887. t['onequarter'] = 834;
  17888. t['Scaron'] = 667;
  17889. t['Scommaaccent'] = 667;
  17890. t['Ohungarumlaut'] = 778;
  17891. t['degree'] = 400;
  17892. t['ograve'] = 611;
  17893. t['Ccaron'] = 722;
  17894. t['ugrave'] = 611;
  17895. t['radical'] = 549;
  17896. t['Dcaron'] = 722;
  17897. t['rcommaaccent'] = 389;
  17898. t['Ntilde'] = 722;
  17899. t['otilde'] = 611;
  17900. t['Rcommaaccent'] = 722;
  17901. t['Lcommaaccent'] = 611;
  17902. t['Atilde'] = 722;
  17903. t['Aogonek'] = 722;
  17904. t['Aring'] = 722;
  17905. t['Otilde'] = 778;
  17906. t['zdotaccent'] = 500;
  17907. t['Ecaron'] = 667;
  17908. t['Iogonek'] = 278;
  17909. t['kcommaaccent'] = 556;
  17910. t['minus'] = 584;
  17911. t['Icircumflex'] = 278;
  17912. t['ncaron'] = 611;
  17913. t['tcommaaccent'] = 333;
  17914. t['logicalnot'] = 584;
  17915. t['odieresis'] = 611;
  17916. t['udieresis'] = 611;
  17917. t['notequal'] = 549;
  17918. t['gcommaaccent'] = 611;
  17919. t['eth'] = 611;
  17920. t['zcaron'] = 500;
  17921. t['ncommaaccent'] = 611;
  17922. t['onesuperior'] = 333;
  17923. t['imacron'] = 278;
  17924. t['Euro'] = 556;
  17925. });
  17926. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17927. t['space'] = 278;
  17928. t['exclam'] = 333;
  17929. t['quotedbl'] = 474;
  17930. t['numbersign'] = 556;
  17931. t['dollar'] = 556;
  17932. t['percent'] = 889;
  17933. t['ampersand'] = 722;
  17934. t['quoteright'] = 278;
  17935. t['parenleft'] = 333;
  17936. t['parenright'] = 333;
  17937. t['asterisk'] = 389;
  17938. t['plus'] = 584;
  17939. t['comma'] = 278;
  17940. t['hyphen'] = 333;
  17941. t['period'] = 278;
  17942. t['slash'] = 278;
  17943. t['zero'] = 556;
  17944. t['one'] = 556;
  17945. t['two'] = 556;
  17946. t['three'] = 556;
  17947. t['four'] = 556;
  17948. t['five'] = 556;
  17949. t['six'] = 556;
  17950. t['seven'] = 556;
  17951. t['eight'] = 556;
  17952. t['nine'] = 556;
  17953. t['colon'] = 333;
  17954. t['semicolon'] = 333;
  17955. t['less'] = 584;
  17956. t['equal'] = 584;
  17957. t['greater'] = 584;
  17958. t['question'] = 611;
  17959. t['at'] = 975;
  17960. t['A'] = 722;
  17961. t['B'] = 722;
  17962. t['C'] = 722;
  17963. t['D'] = 722;
  17964. t['E'] = 667;
  17965. t['F'] = 611;
  17966. t['G'] = 778;
  17967. t['H'] = 722;
  17968. t['I'] = 278;
  17969. t['J'] = 556;
  17970. t['K'] = 722;
  17971. t['L'] = 611;
  17972. t['M'] = 833;
  17973. t['N'] = 722;
  17974. t['O'] = 778;
  17975. t['P'] = 667;
  17976. t['Q'] = 778;
  17977. t['R'] = 722;
  17978. t['S'] = 667;
  17979. t['T'] = 611;
  17980. t['U'] = 722;
  17981. t['V'] = 667;
  17982. t['W'] = 944;
  17983. t['X'] = 667;
  17984. t['Y'] = 667;
  17985. t['Z'] = 611;
  17986. t['bracketleft'] = 333;
  17987. t['backslash'] = 278;
  17988. t['bracketright'] = 333;
  17989. t['asciicircum'] = 584;
  17990. t['underscore'] = 556;
  17991. t['quoteleft'] = 278;
  17992. t['a'] = 556;
  17993. t['b'] = 611;
  17994. t['c'] = 556;
  17995. t['d'] = 611;
  17996. t['e'] = 556;
  17997. t['f'] = 333;
  17998. t['g'] = 611;
  17999. t['h'] = 611;
  18000. t['i'] = 278;
  18001. t['j'] = 278;
  18002. t['k'] = 556;
  18003. t['l'] = 278;
  18004. t['m'] = 889;
  18005. t['n'] = 611;
  18006. t['o'] = 611;
  18007. t['p'] = 611;
  18008. t['q'] = 611;
  18009. t['r'] = 389;
  18010. t['s'] = 556;
  18011. t['t'] = 333;
  18012. t['u'] = 611;
  18013. t['v'] = 556;
  18014. t['w'] = 778;
  18015. t['x'] = 556;
  18016. t['y'] = 556;
  18017. t['z'] = 500;
  18018. t['braceleft'] = 389;
  18019. t['bar'] = 280;
  18020. t['braceright'] = 389;
  18021. t['asciitilde'] = 584;
  18022. t['exclamdown'] = 333;
  18023. t['cent'] = 556;
  18024. t['sterling'] = 556;
  18025. t['fraction'] = 167;
  18026. t['yen'] = 556;
  18027. t['florin'] = 556;
  18028. t['section'] = 556;
  18029. t['currency'] = 556;
  18030. t['quotesingle'] = 238;
  18031. t['quotedblleft'] = 500;
  18032. t['guillemotleft'] = 556;
  18033. t['guilsinglleft'] = 333;
  18034. t['guilsinglright'] = 333;
  18035. t['fi'] = 611;
  18036. t['fl'] = 611;
  18037. t['endash'] = 556;
  18038. t['dagger'] = 556;
  18039. t['daggerdbl'] = 556;
  18040. t['periodcentered'] = 278;
  18041. t['paragraph'] = 556;
  18042. t['bullet'] = 350;
  18043. t['quotesinglbase'] = 278;
  18044. t['quotedblbase'] = 500;
  18045. t['quotedblright'] = 500;
  18046. t['guillemotright'] = 556;
  18047. t['ellipsis'] = 1000;
  18048. t['perthousand'] = 1000;
  18049. t['questiondown'] = 611;
  18050. t['grave'] = 333;
  18051. t['acute'] = 333;
  18052. t['circumflex'] = 333;
  18053. t['tilde'] = 333;
  18054. t['macron'] = 333;
  18055. t['breve'] = 333;
  18056. t['dotaccent'] = 333;
  18057. t['dieresis'] = 333;
  18058. t['ring'] = 333;
  18059. t['cedilla'] = 333;
  18060. t['hungarumlaut'] = 333;
  18061. t['ogonek'] = 333;
  18062. t['caron'] = 333;
  18063. t['emdash'] = 1000;
  18064. t['AE'] = 1000;
  18065. t['ordfeminine'] = 370;
  18066. t['Lslash'] = 611;
  18067. t['Oslash'] = 778;
  18068. t['OE'] = 1000;
  18069. t['ordmasculine'] = 365;
  18070. t['ae'] = 889;
  18071. t['dotlessi'] = 278;
  18072. t['lslash'] = 278;
  18073. t['oslash'] = 611;
  18074. t['oe'] = 944;
  18075. t['germandbls'] = 611;
  18076. t['Idieresis'] = 278;
  18077. t['eacute'] = 556;
  18078. t['abreve'] = 556;
  18079. t['uhungarumlaut'] = 611;
  18080. t['ecaron'] = 556;
  18081. t['Ydieresis'] = 667;
  18082. t['divide'] = 584;
  18083. t['Yacute'] = 667;
  18084. t['Acircumflex'] = 722;
  18085. t['aacute'] = 556;
  18086. t['Ucircumflex'] = 722;
  18087. t['yacute'] = 556;
  18088. t['scommaaccent'] = 556;
  18089. t['ecircumflex'] = 556;
  18090. t['Uring'] = 722;
  18091. t['Udieresis'] = 722;
  18092. t['aogonek'] = 556;
  18093. t['Uacute'] = 722;
  18094. t['uogonek'] = 611;
  18095. t['Edieresis'] = 667;
  18096. t['Dcroat'] = 722;
  18097. t['commaaccent'] = 250;
  18098. t['copyright'] = 737;
  18099. t['Emacron'] = 667;
  18100. t['ccaron'] = 556;
  18101. t['aring'] = 556;
  18102. t['Ncommaaccent'] = 722;
  18103. t['lacute'] = 278;
  18104. t['agrave'] = 556;
  18105. t['Tcommaaccent'] = 611;
  18106. t['Cacute'] = 722;
  18107. t['atilde'] = 556;
  18108. t['Edotaccent'] = 667;
  18109. t['scaron'] = 556;
  18110. t['scedilla'] = 556;
  18111. t['iacute'] = 278;
  18112. t['lozenge'] = 494;
  18113. t['Rcaron'] = 722;
  18114. t['Gcommaaccent'] = 778;
  18115. t['ucircumflex'] = 611;
  18116. t['acircumflex'] = 556;
  18117. t['Amacron'] = 722;
  18118. t['rcaron'] = 389;
  18119. t['ccedilla'] = 556;
  18120. t['Zdotaccent'] = 611;
  18121. t['Thorn'] = 667;
  18122. t['Omacron'] = 778;
  18123. t['Racute'] = 722;
  18124. t['Sacute'] = 667;
  18125. t['dcaron'] = 743;
  18126. t['Umacron'] = 722;
  18127. t['uring'] = 611;
  18128. t['threesuperior'] = 333;
  18129. t['Ograve'] = 778;
  18130. t['Agrave'] = 722;
  18131. t['Abreve'] = 722;
  18132. t['multiply'] = 584;
  18133. t['uacute'] = 611;
  18134. t['Tcaron'] = 611;
  18135. t['partialdiff'] = 494;
  18136. t['ydieresis'] = 556;
  18137. t['Nacute'] = 722;
  18138. t['icircumflex'] = 278;
  18139. t['Ecircumflex'] = 667;
  18140. t['adieresis'] = 556;
  18141. t['edieresis'] = 556;
  18142. t['cacute'] = 556;
  18143. t['nacute'] = 611;
  18144. t['umacron'] = 611;
  18145. t['Ncaron'] = 722;
  18146. t['Iacute'] = 278;
  18147. t['plusminus'] = 584;
  18148. t['brokenbar'] = 280;
  18149. t['registered'] = 737;
  18150. t['Gbreve'] = 778;
  18151. t['Idotaccent'] = 278;
  18152. t['summation'] = 600;
  18153. t['Egrave'] = 667;
  18154. t['racute'] = 389;
  18155. t['omacron'] = 611;
  18156. t['Zacute'] = 611;
  18157. t['Zcaron'] = 611;
  18158. t['greaterequal'] = 549;
  18159. t['Eth'] = 722;
  18160. t['Ccedilla'] = 722;
  18161. t['lcommaaccent'] = 278;
  18162. t['tcaron'] = 389;
  18163. t['eogonek'] = 556;
  18164. t['Uogonek'] = 722;
  18165. t['Aacute'] = 722;
  18166. t['Adieresis'] = 722;
  18167. t['egrave'] = 556;
  18168. t['zacute'] = 500;
  18169. t['iogonek'] = 278;
  18170. t['Oacute'] = 778;
  18171. t['oacute'] = 611;
  18172. t['amacron'] = 556;
  18173. t['sacute'] = 556;
  18174. t['idieresis'] = 278;
  18175. t['Ocircumflex'] = 778;
  18176. t['Ugrave'] = 722;
  18177. t['Delta'] = 612;
  18178. t['thorn'] = 611;
  18179. t['twosuperior'] = 333;
  18180. t['Odieresis'] = 778;
  18181. t['mu'] = 611;
  18182. t['igrave'] = 278;
  18183. t['ohungarumlaut'] = 611;
  18184. t['Eogonek'] = 667;
  18185. t['dcroat'] = 611;
  18186. t['threequarters'] = 834;
  18187. t['Scedilla'] = 667;
  18188. t['lcaron'] = 400;
  18189. t['Kcommaaccent'] = 722;
  18190. t['Lacute'] = 611;
  18191. t['trademark'] = 1000;
  18192. t['edotaccent'] = 556;
  18193. t['Igrave'] = 278;
  18194. t['Imacron'] = 278;
  18195. t['Lcaron'] = 611;
  18196. t['onehalf'] = 834;
  18197. t['lessequal'] = 549;
  18198. t['ocircumflex'] = 611;
  18199. t['ntilde'] = 611;
  18200. t['Uhungarumlaut'] = 722;
  18201. t['Eacute'] = 667;
  18202. t['emacron'] = 556;
  18203. t['gbreve'] = 611;
  18204. t['onequarter'] = 834;
  18205. t['Scaron'] = 667;
  18206. t['Scommaaccent'] = 667;
  18207. t['Ohungarumlaut'] = 778;
  18208. t['degree'] = 400;
  18209. t['ograve'] = 611;
  18210. t['Ccaron'] = 722;
  18211. t['ugrave'] = 611;
  18212. t['radical'] = 549;
  18213. t['Dcaron'] = 722;
  18214. t['rcommaaccent'] = 389;
  18215. t['Ntilde'] = 722;
  18216. t['otilde'] = 611;
  18217. t['Rcommaaccent'] = 722;
  18218. t['Lcommaaccent'] = 611;
  18219. t['Atilde'] = 722;
  18220. t['Aogonek'] = 722;
  18221. t['Aring'] = 722;
  18222. t['Otilde'] = 778;
  18223. t['zdotaccent'] = 500;
  18224. t['Ecaron'] = 667;
  18225. t['Iogonek'] = 278;
  18226. t['kcommaaccent'] = 556;
  18227. t['minus'] = 584;
  18228. t['Icircumflex'] = 278;
  18229. t['ncaron'] = 611;
  18230. t['tcommaaccent'] = 333;
  18231. t['logicalnot'] = 584;
  18232. t['odieresis'] = 611;
  18233. t['udieresis'] = 611;
  18234. t['notequal'] = 549;
  18235. t['gcommaaccent'] = 611;
  18236. t['eth'] = 611;
  18237. t['zcaron'] = 500;
  18238. t['ncommaaccent'] = 611;
  18239. t['onesuperior'] = 333;
  18240. t['imacron'] = 278;
  18241. t['Euro'] = 556;
  18242. });
  18243. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18244. t['space'] = 278;
  18245. t['exclam'] = 278;
  18246. t['quotedbl'] = 355;
  18247. t['numbersign'] = 556;
  18248. t['dollar'] = 556;
  18249. t['percent'] = 889;
  18250. t['ampersand'] = 667;
  18251. t['quoteright'] = 222;
  18252. t['parenleft'] = 333;
  18253. t['parenright'] = 333;
  18254. t['asterisk'] = 389;
  18255. t['plus'] = 584;
  18256. t['comma'] = 278;
  18257. t['hyphen'] = 333;
  18258. t['period'] = 278;
  18259. t['slash'] = 278;
  18260. t['zero'] = 556;
  18261. t['one'] = 556;
  18262. t['two'] = 556;
  18263. t['three'] = 556;
  18264. t['four'] = 556;
  18265. t['five'] = 556;
  18266. t['six'] = 556;
  18267. t['seven'] = 556;
  18268. t['eight'] = 556;
  18269. t['nine'] = 556;
  18270. t['colon'] = 278;
  18271. t['semicolon'] = 278;
  18272. t['less'] = 584;
  18273. t['equal'] = 584;
  18274. t['greater'] = 584;
  18275. t['question'] = 556;
  18276. t['at'] = 1015;
  18277. t['A'] = 667;
  18278. t['B'] = 667;
  18279. t['C'] = 722;
  18280. t['D'] = 722;
  18281. t['E'] = 667;
  18282. t['F'] = 611;
  18283. t['G'] = 778;
  18284. t['H'] = 722;
  18285. t['I'] = 278;
  18286. t['J'] = 500;
  18287. t['K'] = 667;
  18288. t['L'] = 556;
  18289. t['M'] = 833;
  18290. t['N'] = 722;
  18291. t['O'] = 778;
  18292. t['P'] = 667;
  18293. t['Q'] = 778;
  18294. t['R'] = 722;
  18295. t['S'] = 667;
  18296. t['T'] = 611;
  18297. t['U'] = 722;
  18298. t['V'] = 667;
  18299. t['W'] = 944;
  18300. t['X'] = 667;
  18301. t['Y'] = 667;
  18302. t['Z'] = 611;
  18303. t['bracketleft'] = 278;
  18304. t['backslash'] = 278;
  18305. t['bracketright'] = 278;
  18306. t['asciicircum'] = 469;
  18307. t['underscore'] = 556;
  18308. t['quoteleft'] = 222;
  18309. t['a'] = 556;
  18310. t['b'] = 556;
  18311. t['c'] = 500;
  18312. t['d'] = 556;
  18313. t['e'] = 556;
  18314. t['f'] = 278;
  18315. t['g'] = 556;
  18316. t['h'] = 556;
  18317. t['i'] = 222;
  18318. t['j'] = 222;
  18319. t['k'] = 500;
  18320. t['l'] = 222;
  18321. t['m'] = 833;
  18322. t['n'] = 556;
  18323. t['o'] = 556;
  18324. t['p'] = 556;
  18325. t['q'] = 556;
  18326. t['r'] = 333;
  18327. t['s'] = 500;
  18328. t['t'] = 278;
  18329. t['u'] = 556;
  18330. t['v'] = 500;
  18331. t['w'] = 722;
  18332. t['x'] = 500;
  18333. t['y'] = 500;
  18334. t['z'] = 500;
  18335. t['braceleft'] = 334;
  18336. t['bar'] = 260;
  18337. t['braceright'] = 334;
  18338. t['asciitilde'] = 584;
  18339. t['exclamdown'] = 333;
  18340. t['cent'] = 556;
  18341. t['sterling'] = 556;
  18342. t['fraction'] = 167;
  18343. t['yen'] = 556;
  18344. t['florin'] = 556;
  18345. t['section'] = 556;
  18346. t['currency'] = 556;
  18347. t['quotesingle'] = 191;
  18348. t['quotedblleft'] = 333;
  18349. t['guillemotleft'] = 556;
  18350. t['guilsinglleft'] = 333;
  18351. t['guilsinglright'] = 333;
  18352. t['fi'] = 500;
  18353. t['fl'] = 500;
  18354. t['endash'] = 556;
  18355. t['dagger'] = 556;
  18356. t['daggerdbl'] = 556;
  18357. t['periodcentered'] = 278;
  18358. t['paragraph'] = 537;
  18359. t['bullet'] = 350;
  18360. t['quotesinglbase'] = 222;
  18361. t['quotedblbase'] = 333;
  18362. t['quotedblright'] = 333;
  18363. t['guillemotright'] = 556;
  18364. t['ellipsis'] = 1000;
  18365. t['perthousand'] = 1000;
  18366. t['questiondown'] = 611;
  18367. t['grave'] = 333;
  18368. t['acute'] = 333;
  18369. t['circumflex'] = 333;
  18370. t['tilde'] = 333;
  18371. t['macron'] = 333;
  18372. t['breve'] = 333;
  18373. t['dotaccent'] = 333;
  18374. t['dieresis'] = 333;
  18375. t['ring'] = 333;
  18376. t['cedilla'] = 333;
  18377. t['hungarumlaut'] = 333;
  18378. t['ogonek'] = 333;
  18379. t['caron'] = 333;
  18380. t['emdash'] = 1000;
  18381. t['AE'] = 1000;
  18382. t['ordfeminine'] = 370;
  18383. t['Lslash'] = 556;
  18384. t['Oslash'] = 778;
  18385. t['OE'] = 1000;
  18386. t['ordmasculine'] = 365;
  18387. t['ae'] = 889;
  18388. t['dotlessi'] = 278;
  18389. t['lslash'] = 222;
  18390. t['oslash'] = 611;
  18391. t['oe'] = 944;
  18392. t['germandbls'] = 611;
  18393. t['Idieresis'] = 278;
  18394. t['eacute'] = 556;
  18395. t['abreve'] = 556;
  18396. t['uhungarumlaut'] = 556;
  18397. t['ecaron'] = 556;
  18398. t['Ydieresis'] = 667;
  18399. t['divide'] = 584;
  18400. t['Yacute'] = 667;
  18401. t['Acircumflex'] = 667;
  18402. t['aacute'] = 556;
  18403. t['Ucircumflex'] = 722;
  18404. t['yacute'] = 500;
  18405. t['scommaaccent'] = 500;
  18406. t['ecircumflex'] = 556;
  18407. t['Uring'] = 722;
  18408. t['Udieresis'] = 722;
  18409. t['aogonek'] = 556;
  18410. t['Uacute'] = 722;
  18411. t['uogonek'] = 556;
  18412. t['Edieresis'] = 667;
  18413. t['Dcroat'] = 722;
  18414. t['commaaccent'] = 250;
  18415. t['copyright'] = 737;
  18416. t['Emacron'] = 667;
  18417. t['ccaron'] = 500;
  18418. t['aring'] = 556;
  18419. t['Ncommaaccent'] = 722;
  18420. t['lacute'] = 222;
  18421. t['agrave'] = 556;
  18422. t['Tcommaaccent'] = 611;
  18423. t['Cacute'] = 722;
  18424. t['atilde'] = 556;
  18425. t['Edotaccent'] = 667;
  18426. t['scaron'] = 500;
  18427. t['scedilla'] = 500;
  18428. t['iacute'] = 278;
  18429. t['lozenge'] = 471;
  18430. t['Rcaron'] = 722;
  18431. t['Gcommaaccent'] = 778;
  18432. t['ucircumflex'] = 556;
  18433. t['acircumflex'] = 556;
  18434. t['Amacron'] = 667;
  18435. t['rcaron'] = 333;
  18436. t['ccedilla'] = 500;
  18437. t['Zdotaccent'] = 611;
  18438. t['Thorn'] = 667;
  18439. t['Omacron'] = 778;
  18440. t['Racute'] = 722;
  18441. t['Sacute'] = 667;
  18442. t['dcaron'] = 643;
  18443. t['Umacron'] = 722;
  18444. t['uring'] = 556;
  18445. t['threesuperior'] = 333;
  18446. t['Ograve'] = 778;
  18447. t['Agrave'] = 667;
  18448. t['Abreve'] = 667;
  18449. t['multiply'] = 584;
  18450. t['uacute'] = 556;
  18451. t['Tcaron'] = 611;
  18452. t['partialdiff'] = 476;
  18453. t['ydieresis'] = 500;
  18454. t['Nacute'] = 722;
  18455. t['icircumflex'] = 278;
  18456. t['Ecircumflex'] = 667;
  18457. t['adieresis'] = 556;
  18458. t['edieresis'] = 556;
  18459. t['cacute'] = 500;
  18460. t['nacute'] = 556;
  18461. t['umacron'] = 556;
  18462. t['Ncaron'] = 722;
  18463. t['Iacute'] = 278;
  18464. t['plusminus'] = 584;
  18465. t['brokenbar'] = 260;
  18466. t['registered'] = 737;
  18467. t['Gbreve'] = 778;
  18468. t['Idotaccent'] = 278;
  18469. t['summation'] = 600;
  18470. t['Egrave'] = 667;
  18471. t['racute'] = 333;
  18472. t['omacron'] = 556;
  18473. t['Zacute'] = 611;
  18474. t['Zcaron'] = 611;
  18475. t['greaterequal'] = 549;
  18476. t['Eth'] = 722;
  18477. t['Ccedilla'] = 722;
  18478. t['lcommaaccent'] = 222;
  18479. t['tcaron'] = 317;
  18480. t['eogonek'] = 556;
  18481. t['Uogonek'] = 722;
  18482. t['Aacute'] = 667;
  18483. t['Adieresis'] = 667;
  18484. t['egrave'] = 556;
  18485. t['zacute'] = 500;
  18486. t['iogonek'] = 222;
  18487. t['Oacute'] = 778;
  18488. t['oacute'] = 556;
  18489. t['amacron'] = 556;
  18490. t['sacute'] = 500;
  18491. t['idieresis'] = 278;
  18492. t['Ocircumflex'] = 778;
  18493. t['Ugrave'] = 722;
  18494. t['Delta'] = 612;
  18495. t['thorn'] = 556;
  18496. t['twosuperior'] = 333;
  18497. t['Odieresis'] = 778;
  18498. t['mu'] = 556;
  18499. t['igrave'] = 278;
  18500. t['ohungarumlaut'] = 556;
  18501. t['Eogonek'] = 667;
  18502. t['dcroat'] = 556;
  18503. t['threequarters'] = 834;
  18504. t['Scedilla'] = 667;
  18505. t['lcaron'] = 299;
  18506. t['Kcommaaccent'] = 667;
  18507. t['Lacute'] = 556;
  18508. t['trademark'] = 1000;
  18509. t['edotaccent'] = 556;
  18510. t['Igrave'] = 278;
  18511. t['Imacron'] = 278;
  18512. t['Lcaron'] = 556;
  18513. t['onehalf'] = 834;
  18514. t['lessequal'] = 549;
  18515. t['ocircumflex'] = 556;
  18516. t['ntilde'] = 556;
  18517. t['Uhungarumlaut'] = 722;
  18518. t['Eacute'] = 667;
  18519. t['emacron'] = 556;
  18520. t['gbreve'] = 556;
  18521. t['onequarter'] = 834;
  18522. t['Scaron'] = 667;
  18523. t['Scommaaccent'] = 667;
  18524. t['Ohungarumlaut'] = 778;
  18525. t['degree'] = 400;
  18526. t['ograve'] = 556;
  18527. t['Ccaron'] = 722;
  18528. t['ugrave'] = 556;
  18529. t['radical'] = 453;
  18530. t['Dcaron'] = 722;
  18531. t['rcommaaccent'] = 333;
  18532. t['Ntilde'] = 722;
  18533. t['otilde'] = 556;
  18534. t['Rcommaaccent'] = 722;
  18535. t['Lcommaaccent'] = 556;
  18536. t['Atilde'] = 667;
  18537. t['Aogonek'] = 667;
  18538. t['Aring'] = 667;
  18539. t['Otilde'] = 778;
  18540. t['zdotaccent'] = 500;
  18541. t['Ecaron'] = 667;
  18542. t['Iogonek'] = 278;
  18543. t['kcommaaccent'] = 500;
  18544. t['minus'] = 584;
  18545. t['Icircumflex'] = 278;
  18546. t['ncaron'] = 556;
  18547. t['tcommaaccent'] = 278;
  18548. t['logicalnot'] = 584;
  18549. t['odieresis'] = 556;
  18550. t['udieresis'] = 556;
  18551. t['notequal'] = 549;
  18552. t['gcommaaccent'] = 556;
  18553. t['eth'] = 556;
  18554. t['zcaron'] = 500;
  18555. t['ncommaaccent'] = 556;
  18556. t['onesuperior'] = 333;
  18557. t['imacron'] = 278;
  18558. t['Euro'] = 556;
  18559. });
  18560. t['Symbol'] = getLookupTableFactory(function (t) {
  18561. t['space'] = 250;
  18562. t['exclam'] = 333;
  18563. t['universal'] = 713;
  18564. t['numbersign'] = 500;
  18565. t['existential'] = 549;
  18566. t['percent'] = 833;
  18567. t['ampersand'] = 778;
  18568. t['suchthat'] = 439;
  18569. t['parenleft'] = 333;
  18570. t['parenright'] = 333;
  18571. t['asteriskmath'] = 500;
  18572. t['plus'] = 549;
  18573. t['comma'] = 250;
  18574. t['minus'] = 549;
  18575. t['period'] = 250;
  18576. t['slash'] = 278;
  18577. t['zero'] = 500;
  18578. t['one'] = 500;
  18579. t['two'] = 500;
  18580. t['three'] = 500;
  18581. t['four'] = 500;
  18582. t['five'] = 500;
  18583. t['six'] = 500;
  18584. t['seven'] = 500;
  18585. t['eight'] = 500;
  18586. t['nine'] = 500;
  18587. t['colon'] = 278;
  18588. t['semicolon'] = 278;
  18589. t['less'] = 549;
  18590. t['equal'] = 549;
  18591. t['greater'] = 549;
  18592. t['question'] = 444;
  18593. t['congruent'] = 549;
  18594. t['Alpha'] = 722;
  18595. t['Beta'] = 667;
  18596. t['Chi'] = 722;
  18597. t['Delta'] = 612;
  18598. t['Epsilon'] = 611;
  18599. t['Phi'] = 763;
  18600. t['Gamma'] = 603;
  18601. t['Eta'] = 722;
  18602. t['Iota'] = 333;
  18603. t['theta1'] = 631;
  18604. t['Kappa'] = 722;
  18605. t['Lambda'] = 686;
  18606. t['Mu'] = 889;
  18607. t['Nu'] = 722;
  18608. t['Omicron'] = 722;
  18609. t['Pi'] = 768;
  18610. t['Theta'] = 741;
  18611. t['Rho'] = 556;
  18612. t['Sigma'] = 592;
  18613. t['Tau'] = 611;
  18614. t['Upsilon'] = 690;
  18615. t['sigma1'] = 439;
  18616. t['Omega'] = 768;
  18617. t['Xi'] = 645;
  18618. t['Psi'] = 795;
  18619. t['Zeta'] = 611;
  18620. t['bracketleft'] = 333;
  18621. t['therefore'] = 863;
  18622. t['bracketright'] = 333;
  18623. t['perpendicular'] = 658;
  18624. t['underscore'] = 500;
  18625. t['radicalex'] = 500;
  18626. t['alpha'] = 631;
  18627. t['beta'] = 549;
  18628. t['chi'] = 549;
  18629. t['delta'] = 494;
  18630. t['epsilon'] = 439;
  18631. t['phi'] = 521;
  18632. t['gamma'] = 411;
  18633. t['eta'] = 603;
  18634. t['iota'] = 329;
  18635. t['phi1'] = 603;
  18636. t['kappa'] = 549;
  18637. t['lambda'] = 549;
  18638. t['mu'] = 576;
  18639. t['nu'] = 521;
  18640. t['omicron'] = 549;
  18641. t['pi'] = 549;
  18642. t['theta'] = 521;
  18643. t['rho'] = 549;
  18644. t['sigma'] = 603;
  18645. t['tau'] = 439;
  18646. t['upsilon'] = 576;
  18647. t['omega1'] = 713;
  18648. t['omega'] = 686;
  18649. t['xi'] = 493;
  18650. t['psi'] = 686;
  18651. t['zeta'] = 494;
  18652. t['braceleft'] = 480;
  18653. t['bar'] = 200;
  18654. t['braceright'] = 480;
  18655. t['similar'] = 549;
  18656. t['Euro'] = 750;
  18657. t['Upsilon1'] = 620;
  18658. t['minute'] = 247;
  18659. t['lessequal'] = 549;
  18660. t['fraction'] = 167;
  18661. t['infinity'] = 713;
  18662. t['florin'] = 500;
  18663. t['club'] = 753;
  18664. t['diamond'] = 753;
  18665. t['heart'] = 753;
  18666. t['spade'] = 753;
  18667. t['arrowboth'] = 1042;
  18668. t['arrowleft'] = 987;
  18669. t['arrowup'] = 603;
  18670. t['arrowright'] = 987;
  18671. t['arrowdown'] = 603;
  18672. t['degree'] = 400;
  18673. t['plusminus'] = 549;
  18674. t['second'] = 411;
  18675. t['greaterequal'] = 549;
  18676. t['multiply'] = 549;
  18677. t['proportional'] = 713;
  18678. t['partialdiff'] = 494;
  18679. t['bullet'] = 460;
  18680. t['divide'] = 549;
  18681. t['notequal'] = 549;
  18682. t['equivalence'] = 549;
  18683. t['approxequal'] = 549;
  18684. t['ellipsis'] = 1000;
  18685. t['arrowvertex'] = 603;
  18686. t['arrowhorizex'] = 1000;
  18687. t['carriagereturn'] = 658;
  18688. t['aleph'] = 823;
  18689. t['Ifraktur'] = 686;
  18690. t['Rfraktur'] = 795;
  18691. t['weierstrass'] = 987;
  18692. t['circlemultiply'] = 768;
  18693. t['circleplus'] = 768;
  18694. t['emptyset'] = 823;
  18695. t['intersection'] = 768;
  18696. t['union'] = 768;
  18697. t['propersuperset'] = 713;
  18698. t['reflexsuperset'] = 713;
  18699. t['notsubset'] = 713;
  18700. t['propersubset'] = 713;
  18701. t['reflexsubset'] = 713;
  18702. t['element'] = 713;
  18703. t['notelement'] = 713;
  18704. t['angle'] = 768;
  18705. t['gradient'] = 713;
  18706. t['registerserif'] = 790;
  18707. t['copyrightserif'] = 790;
  18708. t['trademarkserif'] = 890;
  18709. t['product'] = 823;
  18710. t['radical'] = 549;
  18711. t['dotmath'] = 250;
  18712. t['logicalnot'] = 713;
  18713. t['logicaland'] = 603;
  18714. t['logicalor'] = 603;
  18715. t['arrowdblboth'] = 1042;
  18716. t['arrowdblleft'] = 987;
  18717. t['arrowdblup'] = 603;
  18718. t['arrowdblright'] = 987;
  18719. t['arrowdbldown'] = 603;
  18720. t['lozenge'] = 494;
  18721. t['angleleft'] = 329;
  18722. t['registersans'] = 790;
  18723. t['copyrightsans'] = 790;
  18724. t['trademarksans'] = 786;
  18725. t['summation'] = 713;
  18726. t['parenlefttp'] = 384;
  18727. t['parenleftex'] = 384;
  18728. t['parenleftbt'] = 384;
  18729. t['bracketlefttp'] = 384;
  18730. t['bracketleftex'] = 384;
  18731. t['bracketleftbt'] = 384;
  18732. t['bracelefttp'] = 494;
  18733. t['braceleftmid'] = 494;
  18734. t['braceleftbt'] = 494;
  18735. t['braceex'] = 494;
  18736. t['angleright'] = 329;
  18737. t['integral'] = 274;
  18738. t['integraltp'] = 686;
  18739. t['integralex'] = 686;
  18740. t['integralbt'] = 686;
  18741. t['parenrighttp'] = 384;
  18742. t['parenrightex'] = 384;
  18743. t['parenrightbt'] = 384;
  18744. t['bracketrighttp'] = 384;
  18745. t['bracketrightex'] = 384;
  18746. t['bracketrightbt'] = 384;
  18747. t['bracerighttp'] = 494;
  18748. t['bracerightmid'] = 494;
  18749. t['bracerightbt'] = 494;
  18750. t['apple'] = 790;
  18751. });
  18752. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18753. t['space'] = 250;
  18754. t['exclam'] = 333;
  18755. t['quotedbl'] = 408;
  18756. t['numbersign'] = 500;
  18757. t['dollar'] = 500;
  18758. t['percent'] = 833;
  18759. t['ampersand'] = 778;
  18760. t['quoteright'] = 333;
  18761. t['parenleft'] = 333;
  18762. t['parenright'] = 333;
  18763. t['asterisk'] = 500;
  18764. t['plus'] = 564;
  18765. t['comma'] = 250;
  18766. t['hyphen'] = 333;
  18767. t['period'] = 250;
  18768. t['slash'] = 278;
  18769. t['zero'] = 500;
  18770. t['one'] = 500;
  18771. t['two'] = 500;
  18772. t['three'] = 500;
  18773. t['four'] = 500;
  18774. t['five'] = 500;
  18775. t['six'] = 500;
  18776. t['seven'] = 500;
  18777. t['eight'] = 500;
  18778. t['nine'] = 500;
  18779. t['colon'] = 278;
  18780. t['semicolon'] = 278;
  18781. t['less'] = 564;
  18782. t['equal'] = 564;
  18783. t['greater'] = 564;
  18784. t['question'] = 444;
  18785. t['at'] = 921;
  18786. t['A'] = 722;
  18787. t['B'] = 667;
  18788. t['C'] = 667;
  18789. t['D'] = 722;
  18790. t['E'] = 611;
  18791. t['F'] = 556;
  18792. t['G'] = 722;
  18793. t['H'] = 722;
  18794. t['I'] = 333;
  18795. t['J'] = 389;
  18796. t['K'] = 722;
  18797. t['L'] = 611;
  18798. t['M'] = 889;
  18799. t['N'] = 722;
  18800. t['O'] = 722;
  18801. t['P'] = 556;
  18802. t['Q'] = 722;
  18803. t['R'] = 667;
  18804. t['S'] = 556;
  18805. t['T'] = 611;
  18806. t['U'] = 722;
  18807. t['V'] = 722;
  18808. t['W'] = 944;
  18809. t['X'] = 722;
  18810. t['Y'] = 722;
  18811. t['Z'] = 611;
  18812. t['bracketleft'] = 333;
  18813. t['backslash'] = 278;
  18814. t['bracketright'] = 333;
  18815. t['asciicircum'] = 469;
  18816. t['underscore'] = 500;
  18817. t['quoteleft'] = 333;
  18818. t['a'] = 444;
  18819. t['b'] = 500;
  18820. t['c'] = 444;
  18821. t['d'] = 500;
  18822. t['e'] = 444;
  18823. t['f'] = 333;
  18824. t['g'] = 500;
  18825. t['h'] = 500;
  18826. t['i'] = 278;
  18827. t['j'] = 278;
  18828. t['k'] = 500;
  18829. t['l'] = 278;
  18830. t['m'] = 778;
  18831. t['n'] = 500;
  18832. t['o'] = 500;
  18833. t['p'] = 500;
  18834. t['q'] = 500;
  18835. t['r'] = 333;
  18836. t['s'] = 389;
  18837. t['t'] = 278;
  18838. t['u'] = 500;
  18839. t['v'] = 500;
  18840. t['w'] = 722;
  18841. t['x'] = 500;
  18842. t['y'] = 500;
  18843. t['z'] = 444;
  18844. t['braceleft'] = 480;
  18845. t['bar'] = 200;
  18846. t['braceright'] = 480;
  18847. t['asciitilde'] = 541;
  18848. t['exclamdown'] = 333;
  18849. t['cent'] = 500;
  18850. t['sterling'] = 500;
  18851. t['fraction'] = 167;
  18852. t['yen'] = 500;
  18853. t['florin'] = 500;
  18854. t['section'] = 500;
  18855. t['currency'] = 500;
  18856. t['quotesingle'] = 180;
  18857. t['quotedblleft'] = 444;
  18858. t['guillemotleft'] = 500;
  18859. t['guilsinglleft'] = 333;
  18860. t['guilsinglright'] = 333;
  18861. t['fi'] = 556;
  18862. t['fl'] = 556;
  18863. t['endash'] = 500;
  18864. t['dagger'] = 500;
  18865. t['daggerdbl'] = 500;
  18866. t['periodcentered'] = 250;
  18867. t['paragraph'] = 453;
  18868. t['bullet'] = 350;
  18869. t['quotesinglbase'] = 333;
  18870. t['quotedblbase'] = 444;
  18871. t['quotedblright'] = 444;
  18872. t['guillemotright'] = 500;
  18873. t['ellipsis'] = 1000;
  18874. t['perthousand'] = 1000;
  18875. t['questiondown'] = 444;
  18876. t['grave'] = 333;
  18877. t['acute'] = 333;
  18878. t['circumflex'] = 333;
  18879. t['tilde'] = 333;
  18880. t['macron'] = 333;
  18881. t['breve'] = 333;
  18882. t['dotaccent'] = 333;
  18883. t['dieresis'] = 333;
  18884. t['ring'] = 333;
  18885. t['cedilla'] = 333;
  18886. t['hungarumlaut'] = 333;
  18887. t['ogonek'] = 333;
  18888. t['caron'] = 333;
  18889. t['emdash'] = 1000;
  18890. t['AE'] = 889;
  18891. t['ordfeminine'] = 276;
  18892. t['Lslash'] = 611;
  18893. t['Oslash'] = 722;
  18894. t['OE'] = 889;
  18895. t['ordmasculine'] = 310;
  18896. t['ae'] = 667;
  18897. t['dotlessi'] = 278;
  18898. t['lslash'] = 278;
  18899. t['oslash'] = 500;
  18900. t['oe'] = 722;
  18901. t['germandbls'] = 500;
  18902. t['Idieresis'] = 333;
  18903. t['eacute'] = 444;
  18904. t['abreve'] = 444;
  18905. t['uhungarumlaut'] = 500;
  18906. t['ecaron'] = 444;
  18907. t['Ydieresis'] = 722;
  18908. t['divide'] = 564;
  18909. t['Yacute'] = 722;
  18910. t['Acircumflex'] = 722;
  18911. t['aacute'] = 444;
  18912. t['Ucircumflex'] = 722;
  18913. t['yacute'] = 500;
  18914. t['scommaaccent'] = 389;
  18915. t['ecircumflex'] = 444;
  18916. t['Uring'] = 722;
  18917. t['Udieresis'] = 722;
  18918. t['aogonek'] = 444;
  18919. t['Uacute'] = 722;
  18920. t['uogonek'] = 500;
  18921. t['Edieresis'] = 611;
  18922. t['Dcroat'] = 722;
  18923. t['commaaccent'] = 250;
  18924. t['copyright'] = 760;
  18925. t['Emacron'] = 611;
  18926. t['ccaron'] = 444;
  18927. t['aring'] = 444;
  18928. t['Ncommaaccent'] = 722;
  18929. t['lacute'] = 278;
  18930. t['agrave'] = 444;
  18931. t['Tcommaaccent'] = 611;
  18932. t['Cacute'] = 667;
  18933. t['atilde'] = 444;
  18934. t['Edotaccent'] = 611;
  18935. t['scaron'] = 389;
  18936. t['scedilla'] = 389;
  18937. t['iacute'] = 278;
  18938. t['lozenge'] = 471;
  18939. t['Rcaron'] = 667;
  18940. t['Gcommaaccent'] = 722;
  18941. t['ucircumflex'] = 500;
  18942. t['acircumflex'] = 444;
  18943. t['Amacron'] = 722;
  18944. t['rcaron'] = 333;
  18945. t['ccedilla'] = 444;
  18946. t['Zdotaccent'] = 611;
  18947. t['Thorn'] = 556;
  18948. t['Omacron'] = 722;
  18949. t['Racute'] = 667;
  18950. t['Sacute'] = 556;
  18951. t['dcaron'] = 588;
  18952. t['Umacron'] = 722;
  18953. t['uring'] = 500;
  18954. t['threesuperior'] = 300;
  18955. t['Ograve'] = 722;
  18956. t['Agrave'] = 722;
  18957. t['Abreve'] = 722;
  18958. t['multiply'] = 564;
  18959. t['uacute'] = 500;
  18960. t['Tcaron'] = 611;
  18961. t['partialdiff'] = 476;
  18962. t['ydieresis'] = 500;
  18963. t['Nacute'] = 722;
  18964. t['icircumflex'] = 278;
  18965. t['Ecircumflex'] = 611;
  18966. t['adieresis'] = 444;
  18967. t['edieresis'] = 444;
  18968. t['cacute'] = 444;
  18969. t['nacute'] = 500;
  18970. t['umacron'] = 500;
  18971. t['Ncaron'] = 722;
  18972. t['Iacute'] = 333;
  18973. t['plusminus'] = 564;
  18974. t['brokenbar'] = 200;
  18975. t['registered'] = 760;
  18976. t['Gbreve'] = 722;
  18977. t['Idotaccent'] = 333;
  18978. t['summation'] = 600;
  18979. t['Egrave'] = 611;
  18980. t['racute'] = 333;
  18981. t['omacron'] = 500;
  18982. t['Zacute'] = 611;
  18983. t['Zcaron'] = 611;
  18984. t['greaterequal'] = 549;
  18985. t['Eth'] = 722;
  18986. t['Ccedilla'] = 667;
  18987. t['lcommaaccent'] = 278;
  18988. t['tcaron'] = 326;
  18989. t['eogonek'] = 444;
  18990. t['Uogonek'] = 722;
  18991. t['Aacute'] = 722;
  18992. t['Adieresis'] = 722;
  18993. t['egrave'] = 444;
  18994. t['zacute'] = 444;
  18995. t['iogonek'] = 278;
  18996. t['Oacute'] = 722;
  18997. t['oacute'] = 500;
  18998. t['amacron'] = 444;
  18999. t['sacute'] = 389;
  19000. t['idieresis'] = 278;
  19001. t['Ocircumflex'] = 722;
  19002. t['Ugrave'] = 722;
  19003. t['Delta'] = 612;
  19004. t['thorn'] = 500;
  19005. t['twosuperior'] = 300;
  19006. t['Odieresis'] = 722;
  19007. t['mu'] = 500;
  19008. t['igrave'] = 278;
  19009. t['ohungarumlaut'] = 500;
  19010. t['Eogonek'] = 611;
  19011. t['dcroat'] = 500;
  19012. t['threequarters'] = 750;
  19013. t['Scedilla'] = 556;
  19014. t['lcaron'] = 344;
  19015. t['Kcommaaccent'] = 722;
  19016. t['Lacute'] = 611;
  19017. t['trademark'] = 980;
  19018. t['edotaccent'] = 444;
  19019. t['Igrave'] = 333;
  19020. t['Imacron'] = 333;
  19021. t['Lcaron'] = 611;
  19022. t['onehalf'] = 750;
  19023. t['lessequal'] = 549;
  19024. t['ocircumflex'] = 500;
  19025. t['ntilde'] = 500;
  19026. t['Uhungarumlaut'] = 722;
  19027. t['Eacute'] = 611;
  19028. t['emacron'] = 444;
  19029. t['gbreve'] = 500;
  19030. t['onequarter'] = 750;
  19031. t['Scaron'] = 556;
  19032. t['Scommaaccent'] = 556;
  19033. t['Ohungarumlaut'] = 722;
  19034. t['degree'] = 400;
  19035. t['ograve'] = 500;
  19036. t['Ccaron'] = 667;
  19037. t['ugrave'] = 500;
  19038. t['radical'] = 453;
  19039. t['Dcaron'] = 722;
  19040. t['rcommaaccent'] = 333;
  19041. t['Ntilde'] = 722;
  19042. t['otilde'] = 500;
  19043. t['Rcommaaccent'] = 667;
  19044. t['Lcommaaccent'] = 611;
  19045. t['Atilde'] = 722;
  19046. t['Aogonek'] = 722;
  19047. t['Aring'] = 722;
  19048. t['Otilde'] = 722;
  19049. t['zdotaccent'] = 444;
  19050. t['Ecaron'] = 611;
  19051. t['Iogonek'] = 333;
  19052. t['kcommaaccent'] = 500;
  19053. t['minus'] = 564;
  19054. t['Icircumflex'] = 333;
  19055. t['ncaron'] = 500;
  19056. t['tcommaaccent'] = 278;
  19057. t['logicalnot'] = 564;
  19058. t['odieresis'] = 500;
  19059. t['udieresis'] = 500;
  19060. t['notequal'] = 549;
  19061. t['gcommaaccent'] = 500;
  19062. t['eth'] = 500;
  19063. t['zcaron'] = 444;
  19064. t['ncommaaccent'] = 500;
  19065. t['onesuperior'] = 300;
  19066. t['imacron'] = 278;
  19067. t['Euro'] = 500;
  19068. });
  19069. t['Times-Bold'] = getLookupTableFactory(function (t) {
  19070. t['space'] = 250;
  19071. t['exclam'] = 333;
  19072. t['quotedbl'] = 555;
  19073. t['numbersign'] = 500;
  19074. t['dollar'] = 500;
  19075. t['percent'] = 1000;
  19076. t['ampersand'] = 833;
  19077. t['quoteright'] = 333;
  19078. t['parenleft'] = 333;
  19079. t['parenright'] = 333;
  19080. t['asterisk'] = 500;
  19081. t['plus'] = 570;
  19082. t['comma'] = 250;
  19083. t['hyphen'] = 333;
  19084. t['period'] = 250;
  19085. t['slash'] = 278;
  19086. t['zero'] = 500;
  19087. t['one'] = 500;
  19088. t['two'] = 500;
  19089. t['three'] = 500;
  19090. t['four'] = 500;
  19091. t['five'] = 500;
  19092. t['six'] = 500;
  19093. t['seven'] = 500;
  19094. t['eight'] = 500;
  19095. t['nine'] = 500;
  19096. t['colon'] = 333;
  19097. t['semicolon'] = 333;
  19098. t['less'] = 570;
  19099. t['equal'] = 570;
  19100. t['greater'] = 570;
  19101. t['question'] = 500;
  19102. t['at'] = 930;
  19103. t['A'] = 722;
  19104. t['B'] = 667;
  19105. t['C'] = 722;
  19106. t['D'] = 722;
  19107. t['E'] = 667;
  19108. t['F'] = 611;
  19109. t['G'] = 778;
  19110. t['H'] = 778;
  19111. t['I'] = 389;
  19112. t['J'] = 500;
  19113. t['K'] = 778;
  19114. t['L'] = 667;
  19115. t['M'] = 944;
  19116. t['N'] = 722;
  19117. t['O'] = 778;
  19118. t['P'] = 611;
  19119. t['Q'] = 778;
  19120. t['R'] = 722;
  19121. t['S'] = 556;
  19122. t['T'] = 667;
  19123. t['U'] = 722;
  19124. t['V'] = 722;
  19125. t['W'] = 1000;
  19126. t['X'] = 722;
  19127. t['Y'] = 722;
  19128. t['Z'] = 667;
  19129. t['bracketleft'] = 333;
  19130. t['backslash'] = 278;
  19131. t['bracketright'] = 333;
  19132. t['asciicircum'] = 581;
  19133. t['underscore'] = 500;
  19134. t['quoteleft'] = 333;
  19135. t['a'] = 500;
  19136. t['b'] = 556;
  19137. t['c'] = 444;
  19138. t['d'] = 556;
  19139. t['e'] = 444;
  19140. t['f'] = 333;
  19141. t['g'] = 500;
  19142. t['h'] = 556;
  19143. t['i'] = 278;
  19144. t['j'] = 333;
  19145. t['k'] = 556;
  19146. t['l'] = 278;
  19147. t['m'] = 833;
  19148. t['n'] = 556;
  19149. t['o'] = 500;
  19150. t['p'] = 556;
  19151. t['q'] = 556;
  19152. t['r'] = 444;
  19153. t['s'] = 389;
  19154. t['t'] = 333;
  19155. t['u'] = 556;
  19156. t['v'] = 500;
  19157. t['w'] = 722;
  19158. t['x'] = 500;
  19159. t['y'] = 500;
  19160. t['z'] = 444;
  19161. t['braceleft'] = 394;
  19162. t['bar'] = 220;
  19163. t['braceright'] = 394;
  19164. t['asciitilde'] = 520;
  19165. t['exclamdown'] = 333;
  19166. t['cent'] = 500;
  19167. t['sterling'] = 500;
  19168. t['fraction'] = 167;
  19169. t['yen'] = 500;
  19170. t['florin'] = 500;
  19171. t['section'] = 500;
  19172. t['currency'] = 500;
  19173. t['quotesingle'] = 278;
  19174. t['quotedblleft'] = 500;
  19175. t['guillemotleft'] = 500;
  19176. t['guilsinglleft'] = 333;
  19177. t['guilsinglright'] = 333;
  19178. t['fi'] = 556;
  19179. t['fl'] = 556;
  19180. t['endash'] = 500;
  19181. t['dagger'] = 500;
  19182. t['daggerdbl'] = 500;
  19183. t['periodcentered'] = 250;
  19184. t['paragraph'] = 540;
  19185. t['bullet'] = 350;
  19186. t['quotesinglbase'] = 333;
  19187. t['quotedblbase'] = 500;
  19188. t['quotedblright'] = 500;
  19189. t['guillemotright'] = 500;
  19190. t['ellipsis'] = 1000;
  19191. t['perthousand'] = 1000;
  19192. t['questiondown'] = 500;
  19193. t['grave'] = 333;
  19194. t['acute'] = 333;
  19195. t['circumflex'] = 333;
  19196. t['tilde'] = 333;
  19197. t['macron'] = 333;
  19198. t['breve'] = 333;
  19199. t['dotaccent'] = 333;
  19200. t['dieresis'] = 333;
  19201. t['ring'] = 333;
  19202. t['cedilla'] = 333;
  19203. t['hungarumlaut'] = 333;
  19204. t['ogonek'] = 333;
  19205. t['caron'] = 333;
  19206. t['emdash'] = 1000;
  19207. t['AE'] = 1000;
  19208. t['ordfeminine'] = 300;
  19209. t['Lslash'] = 667;
  19210. t['Oslash'] = 778;
  19211. t['OE'] = 1000;
  19212. t['ordmasculine'] = 330;
  19213. t['ae'] = 722;
  19214. t['dotlessi'] = 278;
  19215. t['lslash'] = 278;
  19216. t['oslash'] = 500;
  19217. t['oe'] = 722;
  19218. t['germandbls'] = 556;
  19219. t['Idieresis'] = 389;
  19220. t['eacute'] = 444;
  19221. t['abreve'] = 500;
  19222. t['uhungarumlaut'] = 556;
  19223. t['ecaron'] = 444;
  19224. t['Ydieresis'] = 722;
  19225. t['divide'] = 570;
  19226. t['Yacute'] = 722;
  19227. t['Acircumflex'] = 722;
  19228. t['aacute'] = 500;
  19229. t['Ucircumflex'] = 722;
  19230. t['yacute'] = 500;
  19231. t['scommaaccent'] = 389;
  19232. t['ecircumflex'] = 444;
  19233. t['Uring'] = 722;
  19234. t['Udieresis'] = 722;
  19235. t['aogonek'] = 500;
  19236. t['Uacute'] = 722;
  19237. t['uogonek'] = 556;
  19238. t['Edieresis'] = 667;
  19239. t['Dcroat'] = 722;
  19240. t['commaaccent'] = 250;
  19241. t['copyright'] = 747;
  19242. t['Emacron'] = 667;
  19243. t['ccaron'] = 444;
  19244. t['aring'] = 500;
  19245. t['Ncommaaccent'] = 722;
  19246. t['lacute'] = 278;
  19247. t['agrave'] = 500;
  19248. t['Tcommaaccent'] = 667;
  19249. t['Cacute'] = 722;
  19250. t['atilde'] = 500;
  19251. t['Edotaccent'] = 667;
  19252. t['scaron'] = 389;
  19253. t['scedilla'] = 389;
  19254. t['iacute'] = 278;
  19255. t['lozenge'] = 494;
  19256. t['Rcaron'] = 722;
  19257. t['Gcommaaccent'] = 778;
  19258. t['ucircumflex'] = 556;
  19259. t['acircumflex'] = 500;
  19260. t['Amacron'] = 722;
  19261. t['rcaron'] = 444;
  19262. t['ccedilla'] = 444;
  19263. t['Zdotaccent'] = 667;
  19264. t['Thorn'] = 611;
  19265. t['Omacron'] = 778;
  19266. t['Racute'] = 722;
  19267. t['Sacute'] = 556;
  19268. t['dcaron'] = 672;
  19269. t['Umacron'] = 722;
  19270. t['uring'] = 556;
  19271. t['threesuperior'] = 300;
  19272. t['Ograve'] = 778;
  19273. t['Agrave'] = 722;
  19274. t['Abreve'] = 722;
  19275. t['multiply'] = 570;
  19276. t['uacute'] = 556;
  19277. t['Tcaron'] = 667;
  19278. t['partialdiff'] = 494;
  19279. t['ydieresis'] = 500;
  19280. t['Nacute'] = 722;
  19281. t['icircumflex'] = 278;
  19282. t['Ecircumflex'] = 667;
  19283. t['adieresis'] = 500;
  19284. t['edieresis'] = 444;
  19285. t['cacute'] = 444;
  19286. t['nacute'] = 556;
  19287. t['umacron'] = 556;
  19288. t['Ncaron'] = 722;
  19289. t['Iacute'] = 389;
  19290. t['plusminus'] = 570;
  19291. t['brokenbar'] = 220;
  19292. t['registered'] = 747;
  19293. t['Gbreve'] = 778;
  19294. t['Idotaccent'] = 389;
  19295. t['summation'] = 600;
  19296. t['Egrave'] = 667;
  19297. t['racute'] = 444;
  19298. t['omacron'] = 500;
  19299. t['Zacute'] = 667;
  19300. t['Zcaron'] = 667;
  19301. t['greaterequal'] = 549;
  19302. t['Eth'] = 722;
  19303. t['Ccedilla'] = 722;
  19304. t['lcommaaccent'] = 278;
  19305. t['tcaron'] = 416;
  19306. t['eogonek'] = 444;
  19307. t['Uogonek'] = 722;
  19308. t['Aacute'] = 722;
  19309. t['Adieresis'] = 722;
  19310. t['egrave'] = 444;
  19311. t['zacute'] = 444;
  19312. t['iogonek'] = 278;
  19313. t['Oacute'] = 778;
  19314. t['oacute'] = 500;
  19315. t['amacron'] = 500;
  19316. t['sacute'] = 389;
  19317. t['idieresis'] = 278;
  19318. t['Ocircumflex'] = 778;
  19319. t['Ugrave'] = 722;
  19320. t['Delta'] = 612;
  19321. t['thorn'] = 556;
  19322. t['twosuperior'] = 300;
  19323. t['Odieresis'] = 778;
  19324. t['mu'] = 556;
  19325. t['igrave'] = 278;
  19326. t['ohungarumlaut'] = 500;
  19327. t['Eogonek'] = 667;
  19328. t['dcroat'] = 556;
  19329. t['threequarters'] = 750;
  19330. t['Scedilla'] = 556;
  19331. t['lcaron'] = 394;
  19332. t['Kcommaaccent'] = 778;
  19333. t['Lacute'] = 667;
  19334. t['trademark'] = 1000;
  19335. t['edotaccent'] = 444;
  19336. t['Igrave'] = 389;
  19337. t['Imacron'] = 389;
  19338. t['Lcaron'] = 667;
  19339. t['onehalf'] = 750;
  19340. t['lessequal'] = 549;
  19341. t['ocircumflex'] = 500;
  19342. t['ntilde'] = 556;
  19343. t['Uhungarumlaut'] = 722;
  19344. t['Eacute'] = 667;
  19345. t['emacron'] = 444;
  19346. t['gbreve'] = 500;
  19347. t['onequarter'] = 750;
  19348. t['Scaron'] = 556;
  19349. t['Scommaaccent'] = 556;
  19350. t['Ohungarumlaut'] = 778;
  19351. t['degree'] = 400;
  19352. t['ograve'] = 500;
  19353. t['Ccaron'] = 722;
  19354. t['ugrave'] = 556;
  19355. t['radical'] = 549;
  19356. t['Dcaron'] = 722;
  19357. t['rcommaaccent'] = 444;
  19358. t['Ntilde'] = 722;
  19359. t['otilde'] = 500;
  19360. t['Rcommaaccent'] = 722;
  19361. t['Lcommaaccent'] = 667;
  19362. t['Atilde'] = 722;
  19363. t['Aogonek'] = 722;
  19364. t['Aring'] = 722;
  19365. t['Otilde'] = 778;
  19366. t['zdotaccent'] = 444;
  19367. t['Ecaron'] = 667;
  19368. t['Iogonek'] = 389;
  19369. t['kcommaaccent'] = 556;
  19370. t['minus'] = 570;
  19371. t['Icircumflex'] = 389;
  19372. t['ncaron'] = 556;
  19373. t['tcommaaccent'] = 333;
  19374. t['logicalnot'] = 570;
  19375. t['odieresis'] = 500;
  19376. t['udieresis'] = 556;
  19377. t['notequal'] = 549;
  19378. t['gcommaaccent'] = 500;
  19379. t['eth'] = 500;
  19380. t['zcaron'] = 444;
  19381. t['ncommaaccent'] = 556;
  19382. t['onesuperior'] = 300;
  19383. t['imacron'] = 278;
  19384. t['Euro'] = 500;
  19385. });
  19386. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19387. t['space'] = 250;
  19388. t['exclam'] = 389;
  19389. t['quotedbl'] = 555;
  19390. t['numbersign'] = 500;
  19391. t['dollar'] = 500;
  19392. t['percent'] = 833;
  19393. t['ampersand'] = 778;
  19394. t['quoteright'] = 333;
  19395. t['parenleft'] = 333;
  19396. t['parenright'] = 333;
  19397. t['asterisk'] = 500;
  19398. t['plus'] = 570;
  19399. t['comma'] = 250;
  19400. t['hyphen'] = 333;
  19401. t['period'] = 250;
  19402. t['slash'] = 278;
  19403. t['zero'] = 500;
  19404. t['one'] = 500;
  19405. t['two'] = 500;
  19406. t['three'] = 500;
  19407. t['four'] = 500;
  19408. t['five'] = 500;
  19409. t['six'] = 500;
  19410. t['seven'] = 500;
  19411. t['eight'] = 500;
  19412. t['nine'] = 500;
  19413. t['colon'] = 333;
  19414. t['semicolon'] = 333;
  19415. t['less'] = 570;
  19416. t['equal'] = 570;
  19417. t['greater'] = 570;
  19418. t['question'] = 500;
  19419. t['at'] = 832;
  19420. t['A'] = 667;
  19421. t['B'] = 667;
  19422. t['C'] = 667;
  19423. t['D'] = 722;
  19424. t['E'] = 667;
  19425. t['F'] = 667;
  19426. t['G'] = 722;
  19427. t['H'] = 778;
  19428. t['I'] = 389;
  19429. t['J'] = 500;
  19430. t['K'] = 667;
  19431. t['L'] = 611;
  19432. t['M'] = 889;
  19433. t['N'] = 722;
  19434. t['O'] = 722;
  19435. t['P'] = 611;
  19436. t['Q'] = 722;
  19437. t['R'] = 667;
  19438. t['S'] = 556;
  19439. t['T'] = 611;
  19440. t['U'] = 722;
  19441. t['V'] = 667;
  19442. t['W'] = 889;
  19443. t['X'] = 667;
  19444. t['Y'] = 611;
  19445. t['Z'] = 611;
  19446. t['bracketleft'] = 333;
  19447. t['backslash'] = 278;
  19448. t['bracketright'] = 333;
  19449. t['asciicircum'] = 570;
  19450. t['underscore'] = 500;
  19451. t['quoteleft'] = 333;
  19452. t['a'] = 500;
  19453. t['b'] = 500;
  19454. t['c'] = 444;
  19455. t['d'] = 500;
  19456. t['e'] = 444;
  19457. t['f'] = 333;
  19458. t['g'] = 500;
  19459. t['h'] = 556;
  19460. t['i'] = 278;
  19461. t['j'] = 278;
  19462. t['k'] = 500;
  19463. t['l'] = 278;
  19464. t['m'] = 778;
  19465. t['n'] = 556;
  19466. t['o'] = 500;
  19467. t['p'] = 500;
  19468. t['q'] = 500;
  19469. t['r'] = 389;
  19470. t['s'] = 389;
  19471. t['t'] = 278;
  19472. t['u'] = 556;
  19473. t['v'] = 444;
  19474. t['w'] = 667;
  19475. t['x'] = 500;
  19476. t['y'] = 444;
  19477. t['z'] = 389;
  19478. t['braceleft'] = 348;
  19479. t['bar'] = 220;
  19480. t['braceright'] = 348;
  19481. t['asciitilde'] = 570;
  19482. t['exclamdown'] = 389;
  19483. t['cent'] = 500;
  19484. t['sterling'] = 500;
  19485. t['fraction'] = 167;
  19486. t['yen'] = 500;
  19487. t['florin'] = 500;
  19488. t['section'] = 500;
  19489. t['currency'] = 500;
  19490. t['quotesingle'] = 278;
  19491. t['quotedblleft'] = 500;
  19492. t['guillemotleft'] = 500;
  19493. t['guilsinglleft'] = 333;
  19494. t['guilsinglright'] = 333;
  19495. t['fi'] = 556;
  19496. t['fl'] = 556;
  19497. t['endash'] = 500;
  19498. t['dagger'] = 500;
  19499. t['daggerdbl'] = 500;
  19500. t['periodcentered'] = 250;
  19501. t['paragraph'] = 500;
  19502. t['bullet'] = 350;
  19503. t['quotesinglbase'] = 333;
  19504. t['quotedblbase'] = 500;
  19505. t['quotedblright'] = 500;
  19506. t['guillemotright'] = 500;
  19507. t['ellipsis'] = 1000;
  19508. t['perthousand'] = 1000;
  19509. t['questiondown'] = 500;
  19510. t['grave'] = 333;
  19511. t['acute'] = 333;
  19512. t['circumflex'] = 333;
  19513. t['tilde'] = 333;
  19514. t['macron'] = 333;
  19515. t['breve'] = 333;
  19516. t['dotaccent'] = 333;
  19517. t['dieresis'] = 333;
  19518. t['ring'] = 333;
  19519. t['cedilla'] = 333;
  19520. t['hungarumlaut'] = 333;
  19521. t['ogonek'] = 333;
  19522. t['caron'] = 333;
  19523. t['emdash'] = 1000;
  19524. t['AE'] = 944;
  19525. t['ordfeminine'] = 266;
  19526. t['Lslash'] = 611;
  19527. t['Oslash'] = 722;
  19528. t['OE'] = 944;
  19529. t['ordmasculine'] = 300;
  19530. t['ae'] = 722;
  19531. t['dotlessi'] = 278;
  19532. t['lslash'] = 278;
  19533. t['oslash'] = 500;
  19534. t['oe'] = 722;
  19535. t['germandbls'] = 500;
  19536. t['Idieresis'] = 389;
  19537. t['eacute'] = 444;
  19538. t['abreve'] = 500;
  19539. t['uhungarumlaut'] = 556;
  19540. t['ecaron'] = 444;
  19541. t['Ydieresis'] = 611;
  19542. t['divide'] = 570;
  19543. t['Yacute'] = 611;
  19544. t['Acircumflex'] = 667;
  19545. t['aacute'] = 500;
  19546. t['Ucircumflex'] = 722;
  19547. t['yacute'] = 444;
  19548. t['scommaaccent'] = 389;
  19549. t['ecircumflex'] = 444;
  19550. t['Uring'] = 722;
  19551. t['Udieresis'] = 722;
  19552. t['aogonek'] = 500;
  19553. t['Uacute'] = 722;
  19554. t['uogonek'] = 556;
  19555. t['Edieresis'] = 667;
  19556. t['Dcroat'] = 722;
  19557. t['commaaccent'] = 250;
  19558. t['copyright'] = 747;
  19559. t['Emacron'] = 667;
  19560. t['ccaron'] = 444;
  19561. t['aring'] = 500;
  19562. t['Ncommaaccent'] = 722;
  19563. t['lacute'] = 278;
  19564. t['agrave'] = 500;
  19565. t['Tcommaaccent'] = 611;
  19566. t['Cacute'] = 667;
  19567. t['atilde'] = 500;
  19568. t['Edotaccent'] = 667;
  19569. t['scaron'] = 389;
  19570. t['scedilla'] = 389;
  19571. t['iacute'] = 278;
  19572. t['lozenge'] = 494;
  19573. t['Rcaron'] = 667;
  19574. t['Gcommaaccent'] = 722;
  19575. t['ucircumflex'] = 556;
  19576. t['acircumflex'] = 500;
  19577. t['Amacron'] = 667;
  19578. t['rcaron'] = 389;
  19579. t['ccedilla'] = 444;
  19580. t['Zdotaccent'] = 611;
  19581. t['Thorn'] = 611;
  19582. t['Omacron'] = 722;
  19583. t['Racute'] = 667;
  19584. t['Sacute'] = 556;
  19585. t['dcaron'] = 608;
  19586. t['Umacron'] = 722;
  19587. t['uring'] = 556;
  19588. t['threesuperior'] = 300;
  19589. t['Ograve'] = 722;
  19590. t['Agrave'] = 667;
  19591. t['Abreve'] = 667;
  19592. t['multiply'] = 570;
  19593. t['uacute'] = 556;
  19594. t['Tcaron'] = 611;
  19595. t['partialdiff'] = 494;
  19596. t['ydieresis'] = 444;
  19597. t['Nacute'] = 722;
  19598. t['icircumflex'] = 278;
  19599. t['Ecircumflex'] = 667;
  19600. t['adieresis'] = 500;
  19601. t['edieresis'] = 444;
  19602. t['cacute'] = 444;
  19603. t['nacute'] = 556;
  19604. t['umacron'] = 556;
  19605. t['Ncaron'] = 722;
  19606. t['Iacute'] = 389;
  19607. t['plusminus'] = 570;
  19608. t['brokenbar'] = 220;
  19609. t['registered'] = 747;
  19610. t['Gbreve'] = 722;
  19611. t['Idotaccent'] = 389;
  19612. t['summation'] = 600;
  19613. t['Egrave'] = 667;
  19614. t['racute'] = 389;
  19615. t['omacron'] = 500;
  19616. t['Zacute'] = 611;
  19617. t['Zcaron'] = 611;
  19618. t['greaterequal'] = 549;
  19619. t['Eth'] = 722;
  19620. t['Ccedilla'] = 667;
  19621. t['lcommaaccent'] = 278;
  19622. t['tcaron'] = 366;
  19623. t['eogonek'] = 444;
  19624. t['Uogonek'] = 722;
  19625. t['Aacute'] = 667;
  19626. t['Adieresis'] = 667;
  19627. t['egrave'] = 444;
  19628. t['zacute'] = 389;
  19629. t['iogonek'] = 278;
  19630. t['Oacute'] = 722;
  19631. t['oacute'] = 500;
  19632. t['amacron'] = 500;
  19633. t['sacute'] = 389;
  19634. t['idieresis'] = 278;
  19635. t['Ocircumflex'] = 722;
  19636. t['Ugrave'] = 722;
  19637. t['Delta'] = 612;
  19638. t['thorn'] = 500;
  19639. t['twosuperior'] = 300;
  19640. t['Odieresis'] = 722;
  19641. t['mu'] = 576;
  19642. t['igrave'] = 278;
  19643. t['ohungarumlaut'] = 500;
  19644. t['Eogonek'] = 667;
  19645. t['dcroat'] = 500;
  19646. t['threequarters'] = 750;
  19647. t['Scedilla'] = 556;
  19648. t['lcaron'] = 382;
  19649. t['Kcommaaccent'] = 667;
  19650. t['Lacute'] = 611;
  19651. t['trademark'] = 1000;
  19652. t['edotaccent'] = 444;
  19653. t['Igrave'] = 389;
  19654. t['Imacron'] = 389;
  19655. t['Lcaron'] = 611;
  19656. t['onehalf'] = 750;
  19657. t['lessequal'] = 549;
  19658. t['ocircumflex'] = 500;
  19659. t['ntilde'] = 556;
  19660. t['Uhungarumlaut'] = 722;
  19661. t['Eacute'] = 667;
  19662. t['emacron'] = 444;
  19663. t['gbreve'] = 500;
  19664. t['onequarter'] = 750;
  19665. t['Scaron'] = 556;
  19666. t['Scommaaccent'] = 556;
  19667. t['Ohungarumlaut'] = 722;
  19668. t['degree'] = 400;
  19669. t['ograve'] = 500;
  19670. t['Ccaron'] = 667;
  19671. t['ugrave'] = 556;
  19672. t['radical'] = 549;
  19673. t['Dcaron'] = 722;
  19674. t['rcommaaccent'] = 389;
  19675. t['Ntilde'] = 722;
  19676. t['otilde'] = 500;
  19677. t['Rcommaaccent'] = 667;
  19678. t['Lcommaaccent'] = 611;
  19679. t['Atilde'] = 667;
  19680. t['Aogonek'] = 667;
  19681. t['Aring'] = 667;
  19682. t['Otilde'] = 722;
  19683. t['zdotaccent'] = 389;
  19684. t['Ecaron'] = 667;
  19685. t['Iogonek'] = 389;
  19686. t['kcommaaccent'] = 500;
  19687. t['minus'] = 606;
  19688. t['Icircumflex'] = 389;
  19689. t['ncaron'] = 556;
  19690. t['tcommaaccent'] = 278;
  19691. t['logicalnot'] = 606;
  19692. t['odieresis'] = 500;
  19693. t['udieresis'] = 556;
  19694. t['notequal'] = 549;
  19695. t['gcommaaccent'] = 500;
  19696. t['eth'] = 500;
  19697. t['zcaron'] = 389;
  19698. t['ncommaaccent'] = 556;
  19699. t['onesuperior'] = 300;
  19700. t['imacron'] = 278;
  19701. t['Euro'] = 500;
  19702. });
  19703. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19704. t['space'] = 250;
  19705. t['exclam'] = 333;
  19706. t['quotedbl'] = 420;
  19707. t['numbersign'] = 500;
  19708. t['dollar'] = 500;
  19709. t['percent'] = 833;
  19710. t['ampersand'] = 778;
  19711. t['quoteright'] = 333;
  19712. t['parenleft'] = 333;
  19713. t['parenright'] = 333;
  19714. t['asterisk'] = 500;
  19715. t['plus'] = 675;
  19716. t['comma'] = 250;
  19717. t['hyphen'] = 333;
  19718. t['period'] = 250;
  19719. t['slash'] = 278;
  19720. t['zero'] = 500;
  19721. t['one'] = 500;
  19722. t['two'] = 500;
  19723. t['three'] = 500;
  19724. t['four'] = 500;
  19725. t['five'] = 500;
  19726. t['six'] = 500;
  19727. t['seven'] = 500;
  19728. t['eight'] = 500;
  19729. t['nine'] = 500;
  19730. t['colon'] = 333;
  19731. t['semicolon'] = 333;
  19732. t['less'] = 675;
  19733. t['equal'] = 675;
  19734. t['greater'] = 675;
  19735. t['question'] = 500;
  19736. t['at'] = 920;
  19737. t['A'] = 611;
  19738. t['B'] = 611;
  19739. t['C'] = 667;
  19740. t['D'] = 722;
  19741. t['E'] = 611;
  19742. t['F'] = 611;
  19743. t['G'] = 722;
  19744. t['H'] = 722;
  19745. t['I'] = 333;
  19746. t['J'] = 444;
  19747. t['K'] = 667;
  19748. t['L'] = 556;
  19749. t['M'] = 833;
  19750. t['N'] = 667;
  19751. t['O'] = 722;
  19752. t['P'] = 611;
  19753. t['Q'] = 722;
  19754. t['R'] = 611;
  19755. t['S'] = 500;
  19756. t['T'] = 556;
  19757. t['U'] = 722;
  19758. t['V'] = 611;
  19759. t['W'] = 833;
  19760. t['X'] = 611;
  19761. t['Y'] = 556;
  19762. t['Z'] = 556;
  19763. t['bracketleft'] = 389;
  19764. t['backslash'] = 278;
  19765. t['bracketright'] = 389;
  19766. t['asciicircum'] = 422;
  19767. t['underscore'] = 500;
  19768. t['quoteleft'] = 333;
  19769. t['a'] = 500;
  19770. t['b'] = 500;
  19771. t['c'] = 444;
  19772. t['d'] = 500;
  19773. t['e'] = 444;
  19774. t['f'] = 278;
  19775. t['g'] = 500;
  19776. t['h'] = 500;
  19777. t['i'] = 278;
  19778. t['j'] = 278;
  19779. t['k'] = 444;
  19780. t['l'] = 278;
  19781. t['m'] = 722;
  19782. t['n'] = 500;
  19783. t['o'] = 500;
  19784. t['p'] = 500;
  19785. t['q'] = 500;
  19786. t['r'] = 389;
  19787. t['s'] = 389;
  19788. t['t'] = 278;
  19789. t['u'] = 500;
  19790. t['v'] = 444;
  19791. t['w'] = 667;
  19792. t['x'] = 444;
  19793. t['y'] = 444;
  19794. t['z'] = 389;
  19795. t['braceleft'] = 400;
  19796. t['bar'] = 275;
  19797. t['braceright'] = 400;
  19798. t['asciitilde'] = 541;
  19799. t['exclamdown'] = 389;
  19800. t['cent'] = 500;
  19801. t['sterling'] = 500;
  19802. t['fraction'] = 167;
  19803. t['yen'] = 500;
  19804. t['florin'] = 500;
  19805. t['section'] = 500;
  19806. t['currency'] = 500;
  19807. t['quotesingle'] = 214;
  19808. t['quotedblleft'] = 556;
  19809. t['guillemotleft'] = 500;
  19810. t['guilsinglleft'] = 333;
  19811. t['guilsinglright'] = 333;
  19812. t['fi'] = 500;
  19813. t['fl'] = 500;
  19814. t['endash'] = 500;
  19815. t['dagger'] = 500;
  19816. t['daggerdbl'] = 500;
  19817. t['periodcentered'] = 250;
  19818. t['paragraph'] = 523;
  19819. t['bullet'] = 350;
  19820. t['quotesinglbase'] = 333;
  19821. t['quotedblbase'] = 556;
  19822. t['quotedblright'] = 556;
  19823. t['guillemotright'] = 500;
  19824. t['ellipsis'] = 889;
  19825. t['perthousand'] = 1000;
  19826. t['questiondown'] = 500;
  19827. t['grave'] = 333;
  19828. t['acute'] = 333;
  19829. t['circumflex'] = 333;
  19830. t['tilde'] = 333;
  19831. t['macron'] = 333;
  19832. t['breve'] = 333;
  19833. t['dotaccent'] = 333;
  19834. t['dieresis'] = 333;
  19835. t['ring'] = 333;
  19836. t['cedilla'] = 333;
  19837. t['hungarumlaut'] = 333;
  19838. t['ogonek'] = 333;
  19839. t['caron'] = 333;
  19840. t['emdash'] = 889;
  19841. t['AE'] = 889;
  19842. t['ordfeminine'] = 276;
  19843. t['Lslash'] = 556;
  19844. t['Oslash'] = 722;
  19845. t['OE'] = 944;
  19846. t['ordmasculine'] = 310;
  19847. t['ae'] = 667;
  19848. t['dotlessi'] = 278;
  19849. t['lslash'] = 278;
  19850. t['oslash'] = 500;
  19851. t['oe'] = 667;
  19852. t['germandbls'] = 500;
  19853. t['Idieresis'] = 333;
  19854. t['eacute'] = 444;
  19855. t['abreve'] = 500;
  19856. t['uhungarumlaut'] = 500;
  19857. t['ecaron'] = 444;
  19858. t['Ydieresis'] = 556;
  19859. t['divide'] = 675;
  19860. t['Yacute'] = 556;
  19861. t['Acircumflex'] = 611;
  19862. t['aacute'] = 500;
  19863. t['Ucircumflex'] = 722;
  19864. t['yacute'] = 444;
  19865. t['scommaaccent'] = 389;
  19866. t['ecircumflex'] = 444;
  19867. t['Uring'] = 722;
  19868. t['Udieresis'] = 722;
  19869. t['aogonek'] = 500;
  19870. t['Uacute'] = 722;
  19871. t['uogonek'] = 500;
  19872. t['Edieresis'] = 611;
  19873. t['Dcroat'] = 722;
  19874. t['commaaccent'] = 250;
  19875. t['copyright'] = 760;
  19876. t['Emacron'] = 611;
  19877. t['ccaron'] = 444;
  19878. t['aring'] = 500;
  19879. t['Ncommaaccent'] = 667;
  19880. t['lacute'] = 278;
  19881. t['agrave'] = 500;
  19882. t['Tcommaaccent'] = 556;
  19883. t['Cacute'] = 667;
  19884. t['atilde'] = 500;
  19885. t['Edotaccent'] = 611;
  19886. t['scaron'] = 389;
  19887. t['scedilla'] = 389;
  19888. t['iacute'] = 278;
  19889. t['lozenge'] = 471;
  19890. t['Rcaron'] = 611;
  19891. t['Gcommaaccent'] = 722;
  19892. t['ucircumflex'] = 500;
  19893. t['acircumflex'] = 500;
  19894. t['Amacron'] = 611;
  19895. t['rcaron'] = 389;
  19896. t['ccedilla'] = 444;
  19897. t['Zdotaccent'] = 556;
  19898. t['Thorn'] = 611;
  19899. t['Omacron'] = 722;
  19900. t['Racute'] = 611;
  19901. t['Sacute'] = 500;
  19902. t['dcaron'] = 544;
  19903. t['Umacron'] = 722;
  19904. t['uring'] = 500;
  19905. t['threesuperior'] = 300;
  19906. t['Ograve'] = 722;
  19907. t['Agrave'] = 611;
  19908. t['Abreve'] = 611;
  19909. t['multiply'] = 675;
  19910. t['uacute'] = 500;
  19911. t['Tcaron'] = 556;
  19912. t['partialdiff'] = 476;
  19913. t['ydieresis'] = 444;
  19914. t['Nacute'] = 667;
  19915. t['icircumflex'] = 278;
  19916. t['Ecircumflex'] = 611;
  19917. t['adieresis'] = 500;
  19918. t['edieresis'] = 444;
  19919. t['cacute'] = 444;
  19920. t['nacute'] = 500;
  19921. t['umacron'] = 500;
  19922. t['Ncaron'] = 667;
  19923. t['Iacute'] = 333;
  19924. t['plusminus'] = 675;
  19925. t['brokenbar'] = 275;
  19926. t['registered'] = 760;
  19927. t['Gbreve'] = 722;
  19928. t['Idotaccent'] = 333;
  19929. t['summation'] = 600;
  19930. t['Egrave'] = 611;
  19931. t['racute'] = 389;
  19932. t['omacron'] = 500;
  19933. t['Zacute'] = 556;
  19934. t['Zcaron'] = 556;
  19935. t['greaterequal'] = 549;
  19936. t['Eth'] = 722;
  19937. t['Ccedilla'] = 667;
  19938. t['lcommaaccent'] = 278;
  19939. t['tcaron'] = 300;
  19940. t['eogonek'] = 444;
  19941. t['Uogonek'] = 722;
  19942. t['Aacute'] = 611;
  19943. t['Adieresis'] = 611;
  19944. t['egrave'] = 444;
  19945. t['zacute'] = 389;
  19946. t['iogonek'] = 278;
  19947. t['Oacute'] = 722;
  19948. t['oacute'] = 500;
  19949. t['amacron'] = 500;
  19950. t['sacute'] = 389;
  19951. t['idieresis'] = 278;
  19952. t['Ocircumflex'] = 722;
  19953. t['Ugrave'] = 722;
  19954. t['Delta'] = 612;
  19955. t['thorn'] = 500;
  19956. t['twosuperior'] = 300;
  19957. t['Odieresis'] = 722;
  19958. t['mu'] = 500;
  19959. t['igrave'] = 278;
  19960. t['ohungarumlaut'] = 500;
  19961. t['Eogonek'] = 611;
  19962. t['dcroat'] = 500;
  19963. t['threequarters'] = 750;
  19964. t['Scedilla'] = 500;
  19965. t['lcaron'] = 300;
  19966. t['Kcommaaccent'] = 667;
  19967. t['Lacute'] = 556;
  19968. t['trademark'] = 980;
  19969. t['edotaccent'] = 444;
  19970. t['Igrave'] = 333;
  19971. t['Imacron'] = 333;
  19972. t['Lcaron'] = 611;
  19973. t['onehalf'] = 750;
  19974. t['lessequal'] = 549;
  19975. t['ocircumflex'] = 500;
  19976. t['ntilde'] = 500;
  19977. t['Uhungarumlaut'] = 722;
  19978. t['Eacute'] = 611;
  19979. t['emacron'] = 444;
  19980. t['gbreve'] = 500;
  19981. t['onequarter'] = 750;
  19982. t['Scaron'] = 500;
  19983. t['Scommaaccent'] = 500;
  19984. t['Ohungarumlaut'] = 722;
  19985. t['degree'] = 400;
  19986. t['ograve'] = 500;
  19987. t['Ccaron'] = 667;
  19988. t['ugrave'] = 500;
  19989. t['radical'] = 453;
  19990. t['Dcaron'] = 722;
  19991. t['rcommaaccent'] = 389;
  19992. t['Ntilde'] = 667;
  19993. t['otilde'] = 500;
  19994. t['Rcommaaccent'] = 611;
  19995. t['Lcommaaccent'] = 556;
  19996. t['Atilde'] = 611;
  19997. t['Aogonek'] = 611;
  19998. t['Aring'] = 611;
  19999. t['Otilde'] = 722;
  20000. t['zdotaccent'] = 389;
  20001. t['Ecaron'] = 611;
  20002. t['Iogonek'] = 333;
  20003. t['kcommaaccent'] = 444;
  20004. t['minus'] = 675;
  20005. t['Icircumflex'] = 333;
  20006. t['ncaron'] = 500;
  20007. t['tcommaaccent'] = 278;
  20008. t['logicalnot'] = 675;
  20009. t['odieresis'] = 500;
  20010. t['udieresis'] = 500;
  20011. t['notequal'] = 549;
  20012. t['gcommaaccent'] = 500;
  20013. t['eth'] = 500;
  20014. t['zcaron'] = 389;
  20015. t['ncommaaccent'] = 500;
  20016. t['onesuperior'] = 300;
  20017. t['imacron'] = 278;
  20018. t['Euro'] = 500;
  20019. });
  20020. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  20021. t['space'] = 278;
  20022. t['a1'] = 974;
  20023. t['a2'] = 961;
  20024. t['a202'] = 974;
  20025. t['a3'] = 980;
  20026. t['a4'] = 719;
  20027. t['a5'] = 789;
  20028. t['a119'] = 790;
  20029. t['a118'] = 791;
  20030. t['a117'] = 690;
  20031. t['a11'] = 960;
  20032. t['a12'] = 939;
  20033. t['a13'] = 549;
  20034. t['a14'] = 855;
  20035. t['a15'] = 911;
  20036. t['a16'] = 933;
  20037. t['a105'] = 911;
  20038. t['a17'] = 945;
  20039. t['a18'] = 974;
  20040. t['a19'] = 755;
  20041. t['a20'] = 846;
  20042. t['a21'] = 762;
  20043. t['a22'] = 761;
  20044. t['a23'] = 571;
  20045. t['a24'] = 677;
  20046. t['a25'] = 763;
  20047. t['a26'] = 760;
  20048. t['a27'] = 759;
  20049. t['a28'] = 754;
  20050. t['a6'] = 494;
  20051. t['a7'] = 552;
  20052. t['a8'] = 537;
  20053. t['a9'] = 577;
  20054. t['a10'] = 692;
  20055. t['a29'] = 786;
  20056. t['a30'] = 788;
  20057. t['a31'] = 788;
  20058. t['a32'] = 790;
  20059. t['a33'] = 793;
  20060. t['a34'] = 794;
  20061. t['a35'] = 816;
  20062. t['a36'] = 823;
  20063. t['a37'] = 789;
  20064. t['a38'] = 841;
  20065. t['a39'] = 823;
  20066. t['a40'] = 833;
  20067. t['a41'] = 816;
  20068. t['a42'] = 831;
  20069. t['a43'] = 923;
  20070. t['a44'] = 744;
  20071. t['a45'] = 723;
  20072. t['a46'] = 749;
  20073. t['a47'] = 790;
  20074. t['a48'] = 792;
  20075. t['a49'] = 695;
  20076. t['a50'] = 776;
  20077. t['a51'] = 768;
  20078. t['a52'] = 792;
  20079. t['a53'] = 759;
  20080. t['a54'] = 707;
  20081. t['a55'] = 708;
  20082. t['a56'] = 682;
  20083. t['a57'] = 701;
  20084. t['a58'] = 826;
  20085. t['a59'] = 815;
  20086. t['a60'] = 789;
  20087. t['a61'] = 789;
  20088. t['a62'] = 707;
  20089. t['a63'] = 687;
  20090. t['a64'] = 696;
  20091. t['a65'] = 689;
  20092. t['a66'] = 786;
  20093. t['a67'] = 787;
  20094. t['a68'] = 713;
  20095. t['a69'] = 791;
  20096. t['a70'] = 785;
  20097. t['a71'] = 791;
  20098. t['a72'] = 873;
  20099. t['a73'] = 761;
  20100. t['a74'] = 762;
  20101. t['a203'] = 762;
  20102. t['a75'] = 759;
  20103. t['a204'] = 759;
  20104. t['a76'] = 892;
  20105. t['a77'] = 892;
  20106. t['a78'] = 788;
  20107. t['a79'] = 784;
  20108. t['a81'] = 438;
  20109. t['a82'] = 138;
  20110. t['a83'] = 277;
  20111. t['a84'] = 415;
  20112. t['a97'] = 392;
  20113. t['a98'] = 392;
  20114. t['a99'] = 668;
  20115. t['a100'] = 668;
  20116. t['a89'] = 390;
  20117. t['a90'] = 390;
  20118. t['a93'] = 317;
  20119. t['a94'] = 317;
  20120. t['a91'] = 276;
  20121. t['a92'] = 276;
  20122. t['a205'] = 509;
  20123. t['a85'] = 509;
  20124. t['a206'] = 410;
  20125. t['a86'] = 410;
  20126. t['a87'] = 234;
  20127. t['a88'] = 234;
  20128. t['a95'] = 334;
  20129. t['a96'] = 334;
  20130. t['a101'] = 732;
  20131. t['a102'] = 544;
  20132. t['a103'] = 544;
  20133. t['a104'] = 910;
  20134. t['a106'] = 667;
  20135. t['a107'] = 760;
  20136. t['a108'] = 760;
  20137. t['a112'] = 776;
  20138. t['a111'] = 595;
  20139. t['a110'] = 694;
  20140. t['a109'] = 626;
  20141. t['a120'] = 788;
  20142. t['a121'] = 788;
  20143. t['a122'] = 788;
  20144. t['a123'] = 788;
  20145. t['a124'] = 788;
  20146. t['a125'] = 788;
  20147. t['a126'] = 788;
  20148. t['a127'] = 788;
  20149. t['a128'] = 788;
  20150. t['a129'] = 788;
  20151. t['a130'] = 788;
  20152. t['a131'] = 788;
  20153. t['a132'] = 788;
  20154. t['a133'] = 788;
  20155. t['a134'] = 788;
  20156. t['a135'] = 788;
  20157. t['a136'] = 788;
  20158. t['a137'] = 788;
  20159. t['a138'] = 788;
  20160. t['a139'] = 788;
  20161. t['a140'] = 788;
  20162. t['a141'] = 788;
  20163. t['a142'] = 788;
  20164. t['a143'] = 788;
  20165. t['a144'] = 788;
  20166. t['a145'] = 788;
  20167. t['a146'] = 788;
  20168. t['a147'] = 788;
  20169. t['a148'] = 788;
  20170. t['a149'] = 788;
  20171. t['a150'] = 788;
  20172. t['a151'] = 788;
  20173. t['a152'] = 788;
  20174. t['a153'] = 788;
  20175. t['a154'] = 788;
  20176. t['a155'] = 788;
  20177. t['a156'] = 788;
  20178. t['a157'] = 788;
  20179. t['a158'] = 788;
  20180. t['a159'] = 788;
  20181. t['a160'] = 894;
  20182. t['a161'] = 838;
  20183. t['a163'] = 1016;
  20184. t['a164'] = 458;
  20185. t['a196'] = 748;
  20186. t['a165'] = 924;
  20187. t['a192'] = 748;
  20188. t['a166'] = 918;
  20189. t['a167'] = 927;
  20190. t['a168'] = 928;
  20191. t['a169'] = 928;
  20192. t['a170'] = 834;
  20193. t['a171'] = 873;
  20194. t['a172'] = 828;
  20195. t['a173'] = 924;
  20196. t['a162'] = 924;
  20197. t['a174'] = 917;
  20198. t['a175'] = 930;
  20199. t['a176'] = 931;
  20200. t['a177'] = 463;
  20201. t['a178'] = 883;
  20202. t['a179'] = 836;
  20203. t['a193'] = 836;
  20204. t['a180'] = 867;
  20205. t['a199'] = 867;
  20206. t['a181'] = 696;
  20207. t['a200'] = 696;
  20208. t['a182'] = 874;
  20209. t['a201'] = 874;
  20210. t['a183'] = 760;
  20211. t['a184'] = 946;
  20212. t['a197'] = 771;
  20213. t['a185'] = 865;
  20214. t['a194'] = 771;
  20215. t['a198'] = 888;
  20216. t['a186'] = 967;
  20217. t['a195'] = 888;
  20218. t['a187'] = 831;
  20219. t['a188'] = 873;
  20220. t['a189'] = 927;
  20221. t['a190'] = 970;
  20222. t['a191'] = 918;
  20223. });
  20224. });
  20225. exports.getMetrics = getMetrics;
  20226. }));
  20227. (function (root, factory) {
  20228. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20229. }(this, function (exports, sharedUtil) {
  20230. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20231. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20232. var MASK_HIGH = 0xffff0000;
  20233. var MASK_LOW = 0xffff;
  20234. function MurmurHash3_64(seed) {
  20235. var SEED = 0xc3d2e1f0;
  20236. this.h1 = seed ? seed & 0xffffffff : SEED;
  20237. this.h2 = seed ? seed & 0xffffffff : SEED;
  20238. }
  20239. var alwaysUseUint32ArrayView = false;
  20240. try {
  20241. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20242. } catch (e) {
  20243. alwaysUseUint32ArrayView = true;
  20244. }
  20245. MurmurHash3_64.prototype = {
  20246. update: function MurmurHash3_64_update(input) {
  20247. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20248. var i;
  20249. if (typeof input === 'string') {
  20250. var data = new Uint8Array(input.length * 2);
  20251. var length = 0;
  20252. for (i = 0; i < input.length; i++) {
  20253. var code = input.charCodeAt(i);
  20254. if (code <= 0xff) {
  20255. data[length++] = code;
  20256. } else {
  20257. data[length++] = code >>> 8;
  20258. data[length++] = code & 0xff;
  20259. }
  20260. }
  20261. } else if (input instanceof Uint8Array) {
  20262. data = input;
  20263. length = data.length;
  20264. } else if (typeof input === 'object' && 'length' in input) {
  20265. data = input;
  20266. length = data.length;
  20267. useUint32ArrayView = true;
  20268. } else {
  20269. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20270. }
  20271. var blockCounts = length >> 2;
  20272. var tailLength = length - blockCounts * 4;
  20273. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20274. var k1 = 0;
  20275. var k2 = 0;
  20276. var h1 = this.h1;
  20277. var h2 = this.h2;
  20278. var C1 = 0xcc9e2d51;
  20279. var C2 = 0x1b873593;
  20280. var C1_LOW = C1 & MASK_LOW;
  20281. var C2_LOW = C2 & MASK_LOW;
  20282. for (i = 0; i < blockCounts; i++) {
  20283. if (i & 1) {
  20284. k1 = dataUint32[i];
  20285. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20286. k1 = k1 << 15 | k1 >>> 17;
  20287. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20288. h1 ^= k1;
  20289. h1 = h1 << 13 | h1 >>> 19;
  20290. h1 = h1 * 5 + 0xe6546b64;
  20291. } else {
  20292. k2 = dataUint32[i];
  20293. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20294. k2 = k2 << 15 | k2 >>> 17;
  20295. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20296. h2 ^= k2;
  20297. h2 = h2 << 13 | h2 >>> 19;
  20298. h2 = h2 * 5 + 0xe6546b64;
  20299. }
  20300. }
  20301. k1 = 0;
  20302. switch (tailLength) {
  20303. case 3:
  20304. k1 ^= data[blockCounts * 4 + 2] << 16;
  20305. case 2:
  20306. k1 ^= data[blockCounts * 4 + 1] << 8;
  20307. case 1:
  20308. k1 ^= data[blockCounts * 4];
  20309. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20310. k1 = k1 << 15 | k1 >>> 17;
  20311. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20312. if (blockCounts & 1) {
  20313. h1 ^= k1;
  20314. } else {
  20315. h2 ^= k1;
  20316. }
  20317. }
  20318. this.h1 = h1;
  20319. this.h2 = h2;
  20320. return this;
  20321. },
  20322. hexdigest: function MurmurHash3_64_hexdigest() {
  20323. var h1 = this.h1;
  20324. var h2 = this.h2;
  20325. h1 ^= h2 >>> 1;
  20326. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20327. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20328. h1 ^= h2 >>> 1;
  20329. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20330. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20331. h1 ^= h2 >>> 1;
  20332. for (var i = 0, arr = [
  20333. h1,
  20334. h2
  20335. ], str = ''; i < arr.length; i++) {
  20336. var hex = (arr[i] >>> 0).toString(16);
  20337. while (hex.length < 8) {
  20338. hex = '0' + hex;
  20339. }
  20340. str += hex;
  20341. }
  20342. return str;
  20343. }
  20344. };
  20345. return MurmurHash3_64;
  20346. }();
  20347. exports.MurmurHash3_64 = MurmurHash3_64;
  20348. }));
  20349. (function (root, factory) {
  20350. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20351. }(this, function (exports, sharedUtil) {
  20352. var isArray = sharedUtil.isArray;
  20353. var Name = function NameClosure() {
  20354. function Name(name) {
  20355. this.name = name;
  20356. }
  20357. Name.prototype = {};
  20358. var nameCache = Object.create(null);
  20359. Name.get = function Name_get(name) {
  20360. var nameValue = nameCache[name];
  20361. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20362. };
  20363. return Name;
  20364. }();
  20365. var Cmd = function CmdClosure() {
  20366. function Cmd(cmd) {
  20367. this.cmd = cmd;
  20368. }
  20369. Cmd.prototype = {};
  20370. var cmdCache = Object.create(null);
  20371. Cmd.get = function Cmd_get(cmd) {
  20372. var cmdValue = cmdCache[cmd];
  20373. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20374. };
  20375. return Cmd;
  20376. }();
  20377. var Dict = function DictClosure() {
  20378. var nonSerializable = function nonSerializableClosure() {
  20379. return nonSerializable;
  20380. };
  20381. function Dict(xref) {
  20382. this.map = Object.create(null);
  20383. this.xref = xref;
  20384. this.objId = null;
  20385. this.suppressEncryption = false;
  20386. this.__nonSerializable__ = nonSerializable;
  20387. }
  20388. Dict.prototype = {
  20389. assignXref: function Dict_assignXref(newXref) {
  20390. this.xref = newXref;
  20391. },
  20392. get: function Dict_get(key1, key2, key3) {
  20393. var value;
  20394. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20395. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20396. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20397. }
  20398. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20399. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20400. }
  20401. value = this.map[key3] || null;
  20402. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20403. },
  20404. getAsync: function Dict_getAsync(key1, key2, key3) {
  20405. var value;
  20406. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20407. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20408. if (xref) {
  20409. return xref.fetchIfRefAsync(value, suppressEncryption);
  20410. }
  20411. return Promise.resolve(value);
  20412. }
  20413. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20414. if (xref) {
  20415. return xref.fetchIfRefAsync(value, suppressEncryption);
  20416. }
  20417. return Promise.resolve(value);
  20418. }
  20419. value = this.map[key3] || null;
  20420. if (xref) {
  20421. return xref.fetchIfRefAsync(value, suppressEncryption);
  20422. }
  20423. return Promise.resolve(value);
  20424. },
  20425. getArray: function Dict_getArray(key1, key2, key3) {
  20426. var value = this.get(key1, key2, key3);
  20427. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20428. if (!isArray(value) || !xref) {
  20429. return value;
  20430. }
  20431. value = value.slice();
  20432. for (var i = 0, ii = value.length; i < ii; i++) {
  20433. if (!isRef(value[i])) {
  20434. continue;
  20435. }
  20436. value[i] = xref.fetch(value[i], suppressEncryption);
  20437. }
  20438. return value;
  20439. },
  20440. getRaw: function Dict_getRaw(key) {
  20441. return this.map[key];
  20442. },
  20443. getKeys: function Dict_getKeys() {
  20444. return Object.keys(this.map);
  20445. },
  20446. set: function Dict_set(key, value) {
  20447. this.map[key] = value;
  20448. },
  20449. has: function Dict_has(key) {
  20450. return key in this.map;
  20451. },
  20452. forEach: function Dict_forEach(callback) {
  20453. for (var key in this.map) {
  20454. callback(key, this.get(key));
  20455. }
  20456. }
  20457. };
  20458. Dict.empty = new Dict(null);
  20459. Dict.merge = function Dict_merge(xref, dictArray) {
  20460. var mergedDict = new Dict(xref);
  20461. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20462. var dict = dictArray[i];
  20463. if (!isDict(dict)) {
  20464. continue;
  20465. }
  20466. for (var keyName in dict.map) {
  20467. if (mergedDict.map[keyName]) {
  20468. continue;
  20469. }
  20470. mergedDict.map[keyName] = dict.map[keyName];
  20471. }
  20472. }
  20473. return mergedDict;
  20474. };
  20475. return Dict;
  20476. }();
  20477. var Ref = function RefClosure() {
  20478. function Ref(num, gen) {
  20479. this.num = num;
  20480. this.gen = gen;
  20481. }
  20482. Ref.prototype = {
  20483. toString: function Ref_toString() {
  20484. var str = this.num + 'R';
  20485. if (this.gen !== 0) {
  20486. str += this.gen;
  20487. }
  20488. return str;
  20489. }
  20490. };
  20491. return Ref;
  20492. }();
  20493. var RefSet = function RefSetClosure() {
  20494. function RefSet() {
  20495. this.dict = Object.create(null);
  20496. }
  20497. RefSet.prototype = {
  20498. has: function RefSet_has(ref) {
  20499. return ref.toString() in this.dict;
  20500. },
  20501. put: function RefSet_put(ref) {
  20502. this.dict[ref.toString()] = true;
  20503. },
  20504. remove: function RefSet_remove(ref) {
  20505. delete this.dict[ref.toString()];
  20506. }
  20507. };
  20508. return RefSet;
  20509. }();
  20510. var RefSetCache = function RefSetCacheClosure() {
  20511. function RefSetCache() {
  20512. this.dict = Object.create(null);
  20513. }
  20514. RefSetCache.prototype = {
  20515. get: function RefSetCache_get(ref) {
  20516. return this.dict[ref.toString()];
  20517. },
  20518. has: function RefSetCache_has(ref) {
  20519. return ref.toString() in this.dict;
  20520. },
  20521. put: function RefSetCache_put(ref, obj) {
  20522. this.dict[ref.toString()] = obj;
  20523. },
  20524. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20525. this.dict[ref.toString()] = this.get(aliasRef);
  20526. },
  20527. forEach: function RefSetCache_forEach(fn, thisArg) {
  20528. for (var i in this.dict) {
  20529. fn.call(thisArg, this.dict[i]);
  20530. }
  20531. },
  20532. clear: function RefSetCache_clear() {
  20533. this.dict = Object.create(null);
  20534. }
  20535. };
  20536. return RefSetCache;
  20537. }();
  20538. function isName(v, name) {
  20539. return v instanceof Name && (name === undefined || v.name === name);
  20540. }
  20541. function isCmd(v, cmd) {
  20542. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20543. }
  20544. function isDict(v, type) {
  20545. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20546. }
  20547. function isRef(v) {
  20548. return v instanceof Ref;
  20549. }
  20550. function isRefsEqual(v1, v2) {
  20551. return v1.num === v2.num && v1.gen === v2.gen;
  20552. }
  20553. function isStream(v) {
  20554. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20555. }
  20556. exports.Cmd = Cmd;
  20557. exports.Dict = Dict;
  20558. exports.Name = Name;
  20559. exports.Ref = Ref;
  20560. exports.RefSet = RefSet;
  20561. exports.RefSetCache = RefSetCache;
  20562. exports.isCmd = isCmd;
  20563. exports.isDict = isDict;
  20564. exports.isName = isName;
  20565. exports.isRef = isRef;
  20566. exports.isRefsEqual = isRefsEqual;
  20567. exports.isStream = isStream;
  20568. }));
  20569. (function (root, factory) {
  20570. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20571. }(this, function (exports, sharedUtil) {
  20572. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20573. var getStdFontMap = getLookupTableFactory(function (t) {
  20574. t['ArialNarrow'] = 'Helvetica';
  20575. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20576. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20577. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20578. t['ArialBlack'] = 'Helvetica';
  20579. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20580. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20581. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20582. t['Arial-Black'] = 'Helvetica';
  20583. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20584. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20585. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20586. t['Arial'] = 'Helvetica';
  20587. t['Arial-Bold'] = 'Helvetica-Bold';
  20588. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20589. t['Arial-Italic'] = 'Helvetica-Oblique';
  20590. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20591. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20592. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20593. t['ArialMT'] = 'Helvetica';
  20594. t['Courier-Bold'] = 'Courier-Bold';
  20595. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20596. t['Courier-Italic'] = 'Courier-Oblique';
  20597. t['CourierNew'] = 'Courier';
  20598. t['CourierNew-Bold'] = 'Courier-Bold';
  20599. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20600. t['CourierNew-Italic'] = 'Courier-Oblique';
  20601. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20602. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20603. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20604. t['CourierNewPSMT'] = 'Courier';
  20605. t['Helvetica'] = 'Helvetica';
  20606. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20607. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20608. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20609. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20610. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20611. t['Symbol-Bold'] = 'Symbol';
  20612. t['Symbol-BoldItalic'] = 'Symbol';
  20613. t['Symbol-Italic'] = 'Symbol';
  20614. t['TimesNewRoman'] = 'Times-Roman';
  20615. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20616. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20617. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20618. t['TimesNewRomanPS'] = 'Times-Roman';
  20619. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20620. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20621. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20622. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20623. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20624. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20625. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20626. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20627. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20628. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20629. });
  20630. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20631. t['CenturyGothic'] = 'Helvetica';
  20632. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20633. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20634. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20635. t['ComicSansMS'] = 'Comic Sans MS';
  20636. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20637. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20638. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20639. t['LucidaConsole'] = 'Courier';
  20640. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20641. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20642. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20643. t['MS-Gothic'] = 'MS Gothic';
  20644. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20645. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20646. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20647. t['MS-Mincho'] = 'MS Mincho';
  20648. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20649. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20650. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20651. t['MS-PGothic'] = 'MS PGothic';
  20652. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20653. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20654. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20655. t['MS-PMincho'] = 'MS PMincho';
  20656. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20657. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20658. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20659. t['NuptialScript'] = 'Times-Italic';
  20660. t['Wingdings'] = 'ZapfDingbats';
  20661. });
  20662. var getSerifFonts = getLookupTableFactory(function (t) {
  20663. t['Adobe Jenson'] = true;
  20664. t['Adobe Text'] = true;
  20665. t['Albertus'] = true;
  20666. t['Aldus'] = true;
  20667. t['Alexandria'] = true;
  20668. t['Algerian'] = true;
  20669. t['American Typewriter'] = true;
  20670. t['Antiqua'] = true;
  20671. t['Apex'] = true;
  20672. t['Arno'] = true;
  20673. t['Aster'] = true;
  20674. t['Aurora'] = true;
  20675. t['Baskerville'] = true;
  20676. t['Bell'] = true;
  20677. t['Bembo'] = true;
  20678. t['Bembo Schoolbook'] = true;
  20679. t['Benguiat'] = true;
  20680. t['Berkeley Old Style'] = true;
  20681. t['Bernhard Modern'] = true;
  20682. t['Berthold City'] = true;
  20683. t['Bodoni'] = true;
  20684. t['Bauer Bodoni'] = true;
  20685. t['Book Antiqua'] = true;
  20686. t['Bookman'] = true;
  20687. t['Bordeaux Roman'] = true;
  20688. t['Californian FB'] = true;
  20689. t['Calisto'] = true;
  20690. t['Calvert'] = true;
  20691. t['Capitals'] = true;
  20692. t['Cambria'] = true;
  20693. t['Cartier'] = true;
  20694. t['Caslon'] = true;
  20695. t['Catull'] = true;
  20696. t['Centaur'] = true;
  20697. t['Century Old Style'] = true;
  20698. t['Century Schoolbook'] = true;
  20699. t['Chaparral'] = true;
  20700. t['Charis SIL'] = true;
  20701. t['Cheltenham'] = true;
  20702. t['Cholla Slab'] = true;
  20703. t['Clarendon'] = true;
  20704. t['Clearface'] = true;
  20705. t['Cochin'] = true;
  20706. t['Colonna'] = true;
  20707. t['Computer Modern'] = true;
  20708. t['Concrete Roman'] = true;
  20709. t['Constantia'] = true;
  20710. t['Cooper Black'] = true;
  20711. t['Corona'] = true;
  20712. t['Ecotype'] = true;
  20713. t['Egyptienne'] = true;
  20714. t['Elephant'] = true;
  20715. t['Excelsior'] = true;
  20716. t['Fairfield'] = true;
  20717. t['FF Scala'] = true;
  20718. t['Folkard'] = true;
  20719. t['Footlight'] = true;
  20720. t['FreeSerif'] = true;
  20721. t['Friz Quadrata'] = true;
  20722. t['Garamond'] = true;
  20723. t['Gentium'] = true;
  20724. t['Georgia'] = true;
  20725. t['Gloucester'] = true;
  20726. t['Goudy Old Style'] = true;
  20727. t['Goudy Schoolbook'] = true;
  20728. t['Goudy Pro Font'] = true;
  20729. t['Granjon'] = true;
  20730. t['Guardian Egyptian'] = true;
  20731. t['Heather'] = true;
  20732. t['Hercules'] = true;
  20733. t['High Tower Text'] = true;
  20734. t['Hiroshige'] = true;
  20735. t['Hoefler Text'] = true;
  20736. t['Humana Serif'] = true;
  20737. t['Imprint'] = true;
  20738. t['Ionic No. 5'] = true;
  20739. t['Janson'] = true;
  20740. t['Joanna'] = true;
  20741. t['Korinna'] = true;
  20742. t['Lexicon'] = true;
  20743. t['Liberation Serif'] = true;
  20744. t['Linux Libertine'] = true;
  20745. t['Literaturnaya'] = true;
  20746. t['Lucida'] = true;
  20747. t['Lucida Bright'] = true;
  20748. t['Melior'] = true;
  20749. t['Memphis'] = true;
  20750. t['Miller'] = true;
  20751. t['Minion'] = true;
  20752. t['Modern'] = true;
  20753. t['Mona Lisa'] = true;
  20754. t['Mrs Eaves'] = true;
  20755. t['MS Serif'] = true;
  20756. t['Museo Slab'] = true;
  20757. t['New York'] = true;
  20758. t['Nimbus Roman'] = true;
  20759. t['NPS Rawlinson Roadway'] = true;
  20760. t['NuptialScript'] = true;
  20761. t['Palatino'] = true;
  20762. t['Perpetua'] = true;
  20763. t['Plantin'] = true;
  20764. t['Plantin Schoolbook'] = true;
  20765. t['Playbill'] = true;
  20766. t['Poor Richard'] = true;
  20767. t['Rawlinson Roadway'] = true;
  20768. t['Renault'] = true;
  20769. t['Requiem'] = true;
  20770. t['Rockwell'] = true;
  20771. t['Roman'] = true;
  20772. t['Rotis Serif'] = true;
  20773. t['Sabon'] = true;
  20774. t['Scala'] = true;
  20775. t['Seagull'] = true;
  20776. t['Sistina'] = true;
  20777. t['Souvenir'] = true;
  20778. t['STIX'] = true;
  20779. t['Stone Informal'] = true;
  20780. t['Stone Serif'] = true;
  20781. t['Sylfaen'] = true;
  20782. t['Times'] = true;
  20783. t['Trajan'] = true;
  20784. t['Trinité'] = true;
  20785. t['Trump Mediaeval'] = true;
  20786. t['Utopia'] = true;
  20787. t['Vale Type'] = true;
  20788. t['Bitstream Vera'] = true;
  20789. t['Vera Serif'] = true;
  20790. t['Versailles'] = true;
  20791. t['Wanted'] = true;
  20792. t['Weiss'] = true;
  20793. t['Wide Latin'] = true;
  20794. t['Windsor'] = true;
  20795. t['XITS'] = true;
  20796. });
  20797. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20798. t['Dingbats'] = true;
  20799. t['Symbol'] = true;
  20800. t['ZapfDingbats'] = true;
  20801. });
  20802. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20803. t[2] = 10;
  20804. t[3] = 32;
  20805. t[4] = 33;
  20806. t[5] = 34;
  20807. t[6] = 35;
  20808. t[7] = 36;
  20809. t[8] = 37;
  20810. t[9] = 38;
  20811. t[10] = 39;
  20812. t[11] = 40;
  20813. t[12] = 41;
  20814. t[13] = 42;
  20815. t[14] = 43;
  20816. t[15] = 44;
  20817. t[16] = 45;
  20818. t[17] = 46;
  20819. t[18] = 47;
  20820. t[19] = 48;
  20821. t[20] = 49;
  20822. t[21] = 50;
  20823. t[22] = 51;
  20824. t[23] = 52;
  20825. t[24] = 53;
  20826. t[25] = 54;
  20827. t[26] = 55;
  20828. t[27] = 56;
  20829. t[28] = 57;
  20830. t[29] = 58;
  20831. t[30] = 894;
  20832. t[31] = 60;
  20833. t[32] = 61;
  20834. t[33] = 62;
  20835. t[34] = 63;
  20836. t[35] = 64;
  20837. t[36] = 65;
  20838. t[37] = 66;
  20839. t[38] = 67;
  20840. t[39] = 68;
  20841. t[40] = 69;
  20842. t[41] = 70;
  20843. t[42] = 71;
  20844. t[43] = 72;
  20845. t[44] = 73;
  20846. t[45] = 74;
  20847. t[46] = 75;
  20848. t[47] = 76;
  20849. t[48] = 77;
  20850. t[49] = 78;
  20851. t[50] = 79;
  20852. t[51] = 80;
  20853. t[52] = 81;
  20854. t[53] = 82;
  20855. t[54] = 83;
  20856. t[55] = 84;
  20857. t[56] = 85;
  20858. t[57] = 86;
  20859. t[58] = 87;
  20860. t[59] = 88;
  20861. t[60] = 89;
  20862. t[61] = 90;
  20863. t[62] = 91;
  20864. t[63] = 92;
  20865. t[64] = 93;
  20866. t[65] = 94;
  20867. t[66] = 95;
  20868. t[67] = 96;
  20869. t[68] = 97;
  20870. t[69] = 98;
  20871. t[70] = 99;
  20872. t[71] = 100;
  20873. t[72] = 101;
  20874. t[73] = 102;
  20875. t[74] = 103;
  20876. t[75] = 104;
  20877. t[76] = 105;
  20878. t[77] = 106;
  20879. t[78] = 107;
  20880. t[79] = 108;
  20881. t[80] = 109;
  20882. t[81] = 110;
  20883. t[82] = 111;
  20884. t[83] = 112;
  20885. t[84] = 113;
  20886. t[85] = 114;
  20887. t[86] = 115;
  20888. t[87] = 116;
  20889. t[88] = 117;
  20890. t[89] = 118;
  20891. t[90] = 119;
  20892. t[91] = 120;
  20893. t[92] = 121;
  20894. t[93] = 122;
  20895. t[94] = 123;
  20896. t[95] = 124;
  20897. t[96] = 125;
  20898. t[97] = 126;
  20899. t[98] = 196;
  20900. t[99] = 197;
  20901. t[100] = 199;
  20902. t[101] = 201;
  20903. t[102] = 209;
  20904. t[103] = 214;
  20905. t[104] = 220;
  20906. t[105] = 225;
  20907. t[106] = 224;
  20908. t[107] = 226;
  20909. t[108] = 228;
  20910. t[109] = 227;
  20911. t[110] = 229;
  20912. t[111] = 231;
  20913. t[112] = 233;
  20914. t[113] = 232;
  20915. t[114] = 234;
  20916. t[115] = 235;
  20917. t[116] = 237;
  20918. t[117] = 236;
  20919. t[118] = 238;
  20920. t[119] = 239;
  20921. t[120] = 241;
  20922. t[121] = 243;
  20923. t[122] = 242;
  20924. t[123] = 244;
  20925. t[124] = 246;
  20926. t[125] = 245;
  20927. t[126] = 250;
  20928. t[127] = 249;
  20929. t[128] = 251;
  20930. t[129] = 252;
  20931. t[130] = 8224;
  20932. t[131] = 176;
  20933. t[132] = 162;
  20934. t[133] = 163;
  20935. t[134] = 167;
  20936. t[135] = 8226;
  20937. t[136] = 182;
  20938. t[137] = 223;
  20939. t[138] = 174;
  20940. t[139] = 169;
  20941. t[140] = 8482;
  20942. t[141] = 180;
  20943. t[142] = 168;
  20944. t[143] = 8800;
  20945. t[144] = 198;
  20946. t[145] = 216;
  20947. t[146] = 8734;
  20948. t[147] = 177;
  20949. t[148] = 8804;
  20950. t[149] = 8805;
  20951. t[150] = 165;
  20952. t[151] = 181;
  20953. t[152] = 8706;
  20954. t[153] = 8721;
  20955. t[154] = 8719;
  20956. t[156] = 8747;
  20957. t[157] = 170;
  20958. t[158] = 186;
  20959. t[159] = 8486;
  20960. t[160] = 230;
  20961. t[161] = 248;
  20962. t[162] = 191;
  20963. t[163] = 161;
  20964. t[164] = 172;
  20965. t[165] = 8730;
  20966. t[166] = 402;
  20967. t[167] = 8776;
  20968. t[168] = 8710;
  20969. t[169] = 171;
  20970. t[170] = 187;
  20971. t[171] = 8230;
  20972. t[210] = 218;
  20973. t[223] = 711;
  20974. t[224] = 321;
  20975. t[225] = 322;
  20976. t[227] = 353;
  20977. t[229] = 382;
  20978. t[234] = 253;
  20979. t[252] = 263;
  20980. t[253] = 268;
  20981. t[254] = 269;
  20982. t[258] = 258;
  20983. t[260] = 260;
  20984. t[261] = 261;
  20985. t[265] = 280;
  20986. t[266] = 281;
  20987. t[268] = 283;
  20988. t[269] = 313;
  20989. t[275] = 323;
  20990. t[276] = 324;
  20991. t[278] = 328;
  20992. t[284] = 345;
  20993. t[285] = 346;
  20994. t[286] = 347;
  20995. t[292] = 367;
  20996. t[295] = 377;
  20997. t[296] = 378;
  20998. t[298] = 380;
  20999. t[305] = 963;
  21000. t[306] = 964;
  21001. t[307] = 966;
  21002. t[308] = 8215;
  21003. t[309] = 8252;
  21004. t[310] = 8319;
  21005. t[311] = 8359;
  21006. t[312] = 8592;
  21007. t[313] = 8593;
  21008. t[337] = 9552;
  21009. t[493] = 1039;
  21010. t[494] = 1040;
  21011. t[705] = 1524;
  21012. t[706] = 8362;
  21013. t[710] = 64288;
  21014. t[711] = 64298;
  21015. t[759] = 1617;
  21016. t[761] = 1776;
  21017. t[763] = 1778;
  21018. t[775] = 1652;
  21019. t[777] = 1764;
  21020. t[778] = 1780;
  21021. t[779] = 1781;
  21022. t[780] = 1782;
  21023. t[782] = 771;
  21024. t[783] = 64726;
  21025. t[786] = 8363;
  21026. t[788] = 8532;
  21027. t[790] = 768;
  21028. t[791] = 769;
  21029. t[792] = 768;
  21030. t[795] = 803;
  21031. t[797] = 64336;
  21032. t[798] = 64337;
  21033. t[799] = 64342;
  21034. t[800] = 64343;
  21035. t[801] = 64344;
  21036. t[802] = 64345;
  21037. t[803] = 64362;
  21038. t[804] = 64363;
  21039. t[805] = 64364;
  21040. t[2424] = 7821;
  21041. t[2425] = 7822;
  21042. t[2426] = 7823;
  21043. t[2427] = 7824;
  21044. t[2428] = 7825;
  21045. t[2429] = 7826;
  21046. t[2430] = 7827;
  21047. t[2433] = 7682;
  21048. t[2678] = 8045;
  21049. t[2679] = 8046;
  21050. t[2830] = 1552;
  21051. t[2838] = 686;
  21052. t[2840] = 751;
  21053. t[2842] = 753;
  21054. t[2843] = 754;
  21055. t[2844] = 755;
  21056. t[2846] = 757;
  21057. t[2856] = 767;
  21058. t[2857] = 848;
  21059. t[2858] = 849;
  21060. t[2862] = 853;
  21061. t[2863] = 854;
  21062. t[2864] = 855;
  21063. t[2865] = 861;
  21064. t[2866] = 862;
  21065. t[2906] = 7460;
  21066. t[2908] = 7462;
  21067. t[2909] = 7463;
  21068. t[2910] = 7464;
  21069. t[2912] = 7466;
  21070. t[2913] = 7467;
  21071. t[2914] = 7468;
  21072. t[2916] = 7470;
  21073. t[2917] = 7471;
  21074. t[2918] = 7472;
  21075. t[2920] = 7474;
  21076. t[2921] = 7475;
  21077. t[2922] = 7476;
  21078. t[2924] = 7478;
  21079. t[2925] = 7479;
  21080. t[2926] = 7480;
  21081. t[2928] = 7482;
  21082. t[2929] = 7483;
  21083. t[2930] = 7484;
  21084. t[2932] = 7486;
  21085. t[2933] = 7487;
  21086. t[2934] = 7488;
  21087. t[2936] = 7490;
  21088. t[2937] = 7491;
  21089. t[2938] = 7492;
  21090. t[2940] = 7494;
  21091. t[2941] = 7495;
  21092. t[2942] = 7496;
  21093. t[2944] = 7498;
  21094. t[2946] = 7500;
  21095. t[2948] = 7502;
  21096. t[2950] = 7504;
  21097. t[2951] = 7505;
  21098. t[2952] = 7506;
  21099. t[2954] = 7508;
  21100. t[2955] = 7509;
  21101. t[2956] = 7510;
  21102. t[2958] = 7512;
  21103. t[2959] = 7513;
  21104. t[2960] = 7514;
  21105. t[2962] = 7516;
  21106. t[2963] = 7517;
  21107. t[2964] = 7518;
  21108. t[2966] = 7520;
  21109. t[2967] = 7521;
  21110. t[2968] = 7522;
  21111. t[2970] = 7524;
  21112. t[2971] = 7525;
  21113. t[2972] = 7526;
  21114. t[2974] = 7528;
  21115. t[2975] = 7529;
  21116. t[2976] = 7530;
  21117. t[2978] = 1537;
  21118. t[2979] = 1538;
  21119. t[2980] = 1539;
  21120. t[2982] = 1549;
  21121. t[2983] = 1551;
  21122. t[2984] = 1552;
  21123. t[2986] = 1554;
  21124. t[2987] = 1555;
  21125. t[2988] = 1556;
  21126. t[2990] = 1623;
  21127. t[2991] = 1624;
  21128. t[2995] = 1775;
  21129. t[2999] = 1791;
  21130. t[3002] = 64290;
  21131. t[3003] = 64291;
  21132. t[3004] = 64292;
  21133. t[3006] = 64294;
  21134. t[3007] = 64295;
  21135. t[3008] = 64296;
  21136. t[3011] = 1900;
  21137. t[3014] = 8223;
  21138. t[3015] = 8244;
  21139. t[3017] = 7532;
  21140. t[3018] = 7533;
  21141. t[3019] = 7534;
  21142. t[3075] = 7590;
  21143. t[3076] = 7591;
  21144. t[3079] = 7594;
  21145. t[3080] = 7595;
  21146. t[3083] = 7598;
  21147. t[3084] = 7599;
  21148. t[3087] = 7602;
  21149. t[3088] = 7603;
  21150. t[3091] = 7606;
  21151. t[3092] = 7607;
  21152. t[3095] = 7610;
  21153. t[3096] = 7611;
  21154. t[3099] = 7614;
  21155. t[3100] = 7615;
  21156. t[3103] = 7618;
  21157. t[3104] = 7619;
  21158. t[3107] = 8337;
  21159. t[3108] = 8338;
  21160. t[3116] = 1884;
  21161. t[3119] = 1885;
  21162. t[3120] = 1885;
  21163. t[3123] = 1886;
  21164. t[3124] = 1886;
  21165. t[3127] = 1887;
  21166. t[3128] = 1887;
  21167. t[3131] = 1888;
  21168. t[3132] = 1888;
  21169. t[3135] = 1889;
  21170. t[3136] = 1889;
  21171. t[3139] = 1890;
  21172. t[3140] = 1890;
  21173. t[3143] = 1891;
  21174. t[3144] = 1891;
  21175. t[3147] = 1892;
  21176. t[3148] = 1892;
  21177. t[3153] = 580;
  21178. t[3154] = 581;
  21179. t[3157] = 584;
  21180. t[3158] = 585;
  21181. t[3161] = 588;
  21182. t[3162] = 589;
  21183. t[3165] = 891;
  21184. t[3166] = 892;
  21185. t[3169] = 1274;
  21186. t[3170] = 1275;
  21187. t[3173] = 1278;
  21188. t[3174] = 1279;
  21189. t[3181] = 7622;
  21190. t[3182] = 7623;
  21191. t[3282] = 11799;
  21192. t[3316] = 578;
  21193. t[3379] = 42785;
  21194. t[3393] = 1159;
  21195. t[3416] = 8377;
  21196. });
  21197. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21198. t[227] = 322;
  21199. t[264] = 261;
  21200. t[291] = 346;
  21201. });
  21202. exports.getStdFontMap = getStdFontMap;
  21203. exports.getNonStdFontMap = getNonStdFontMap;
  21204. exports.getSerifFonts = getSerifFonts;
  21205. exports.getSymbolsFonts = getSymbolsFonts;
  21206. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21207. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21208. }));
  21209. (function (root, factory) {
  21210. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21211. }(this, function (exports, sharedUtil) {
  21212. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21213. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21214. t[63721] = 0x00A9;
  21215. t[63193] = 0x00A9;
  21216. t[63720] = 0x00AE;
  21217. t[63194] = 0x00AE;
  21218. t[63722] = 0x2122;
  21219. t[63195] = 0x2122;
  21220. t[63729] = 0x23A7;
  21221. t[63730] = 0x23A8;
  21222. t[63731] = 0x23A9;
  21223. t[63740] = 0x23AB;
  21224. t[63741] = 0x23AC;
  21225. t[63742] = 0x23AD;
  21226. t[63726] = 0x23A1;
  21227. t[63727] = 0x23A2;
  21228. t[63728] = 0x23A3;
  21229. t[63737] = 0x23A4;
  21230. t[63738] = 0x23A5;
  21231. t[63739] = 0x23A6;
  21232. t[63723] = 0x239B;
  21233. t[63724] = 0x239C;
  21234. t[63725] = 0x239D;
  21235. t[63734] = 0x239E;
  21236. t[63735] = 0x239F;
  21237. t[63736] = 0x23A0;
  21238. });
  21239. function mapSpecialUnicodeValues(code) {
  21240. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21241. return 0;
  21242. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21243. return getSpecialPUASymbols()[code] || code;
  21244. }
  21245. return code;
  21246. }
  21247. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21248. var unicode = glyphsUnicodeMap[name];
  21249. if (unicode !== undefined) {
  21250. return unicode;
  21251. }
  21252. if (!name) {
  21253. return -1;
  21254. }
  21255. if (name[0] === 'u') {
  21256. var nameLen = name.length, hexStr;
  21257. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21258. hexStr = name.substr(3);
  21259. } else if (nameLen >= 5 && nameLen <= 7) {
  21260. hexStr = name.substr(1);
  21261. } else {
  21262. return -1;
  21263. }
  21264. if (hexStr === hexStr.toUpperCase()) {
  21265. unicode = parseInt(hexStr, 16);
  21266. if (unicode >= 0) {
  21267. return unicode;
  21268. }
  21269. }
  21270. }
  21271. return -1;
  21272. }
  21273. var UnicodeRanges = [
  21274. {
  21275. 'begin': 0x0000,
  21276. 'end': 0x007F
  21277. },
  21278. {
  21279. 'begin': 0x0080,
  21280. 'end': 0x00FF
  21281. },
  21282. {
  21283. 'begin': 0x0100,
  21284. 'end': 0x017F
  21285. },
  21286. {
  21287. 'begin': 0x0180,
  21288. 'end': 0x024F
  21289. },
  21290. {
  21291. 'begin': 0x0250,
  21292. 'end': 0x02AF
  21293. },
  21294. {
  21295. 'begin': 0x02B0,
  21296. 'end': 0x02FF
  21297. },
  21298. {
  21299. 'begin': 0x0300,
  21300. 'end': 0x036F
  21301. },
  21302. {
  21303. 'begin': 0x0370,
  21304. 'end': 0x03FF
  21305. },
  21306. {
  21307. 'begin': 0x2C80,
  21308. 'end': 0x2CFF
  21309. },
  21310. {
  21311. 'begin': 0x0400,
  21312. 'end': 0x04FF
  21313. },
  21314. {
  21315. 'begin': 0x0530,
  21316. 'end': 0x058F
  21317. },
  21318. {
  21319. 'begin': 0x0590,
  21320. 'end': 0x05FF
  21321. },
  21322. {
  21323. 'begin': 0xA500,
  21324. 'end': 0xA63F
  21325. },
  21326. {
  21327. 'begin': 0x0600,
  21328. 'end': 0x06FF
  21329. },
  21330. {
  21331. 'begin': 0x07C0,
  21332. 'end': 0x07FF
  21333. },
  21334. {
  21335. 'begin': 0x0900,
  21336. 'end': 0x097F
  21337. },
  21338. {
  21339. 'begin': 0x0980,
  21340. 'end': 0x09FF
  21341. },
  21342. {
  21343. 'begin': 0x0A00,
  21344. 'end': 0x0A7F
  21345. },
  21346. {
  21347. 'begin': 0x0A80,
  21348. 'end': 0x0AFF
  21349. },
  21350. {
  21351. 'begin': 0x0B00,
  21352. 'end': 0x0B7F
  21353. },
  21354. {
  21355. 'begin': 0x0B80,
  21356. 'end': 0x0BFF
  21357. },
  21358. {
  21359. 'begin': 0x0C00,
  21360. 'end': 0x0C7F
  21361. },
  21362. {
  21363. 'begin': 0x0C80,
  21364. 'end': 0x0CFF
  21365. },
  21366. {
  21367. 'begin': 0x0D00,
  21368. 'end': 0x0D7F
  21369. },
  21370. {
  21371. 'begin': 0x0E00,
  21372. 'end': 0x0E7F
  21373. },
  21374. {
  21375. 'begin': 0x0E80,
  21376. 'end': 0x0EFF
  21377. },
  21378. {
  21379. 'begin': 0x10A0,
  21380. 'end': 0x10FF
  21381. },
  21382. {
  21383. 'begin': 0x1B00,
  21384. 'end': 0x1B7F
  21385. },
  21386. {
  21387. 'begin': 0x1100,
  21388. 'end': 0x11FF
  21389. },
  21390. {
  21391. 'begin': 0x1E00,
  21392. 'end': 0x1EFF
  21393. },
  21394. {
  21395. 'begin': 0x1F00,
  21396. 'end': 0x1FFF
  21397. },
  21398. {
  21399. 'begin': 0x2000,
  21400. 'end': 0x206F
  21401. },
  21402. {
  21403. 'begin': 0x2070,
  21404. 'end': 0x209F
  21405. },
  21406. {
  21407. 'begin': 0x20A0,
  21408. 'end': 0x20CF
  21409. },
  21410. {
  21411. 'begin': 0x20D0,
  21412. 'end': 0x20FF
  21413. },
  21414. {
  21415. 'begin': 0x2100,
  21416. 'end': 0x214F
  21417. },
  21418. {
  21419. 'begin': 0x2150,
  21420. 'end': 0x218F
  21421. },
  21422. {
  21423. 'begin': 0x2190,
  21424. 'end': 0x21FF
  21425. },
  21426. {
  21427. 'begin': 0x2200,
  21428. 'end': 0x22FF
  21429. },
  21430. {
  21431. 'begin': 0x2300,
  21432. 'end': 0x23FF
  21433. },
  21434. {
  21435. 'begin': 0x2400,
  21436. 'end': 0x243F
  21437. },
  21438. {
  21439. 'begin': 0x2440,
  21440. 'end': 0x245F
  21441. },
  21442. {
  21443. 'begin': 0x2460,
  21444. 'end': 0x24FF
  21445. },
  21446. {
  21447. 'begin': 0x2500,
  21448. 'end': 0x257F
  21449. },
  21450. {
  21451. 'begin': 0x2580,
  21452. 'end': 0x259F
  21453. },
  21454. {
  21455. 'begin': 0x25A0,
  21456. 'end': 0x25FF
  21457. },
  21458. {
  21459. 'begin': 0x2600,
  21460. 'end': 0x26FF
  21461. },
  21462. {
  21463. 'begin': 0x2700,
  21464. 'end': 0x27BF
  21465. },
  21466. {
  21467. 'begin': 0x3000,
  21468. 'end': 0x303F
  21469. },
  21470. {
  21471. 'begin': 0x3040,
  21472. 'end': 0x309F
  21473. },
  21474. {
  21475. 'begin': 0x30A0,
  21476. 'end': 0x30FF
  21477. },
  21478. {
  21479. 'begin': 0x3100,
  21480. 'end': 0x312F
  21481. },
  21482. {
  21483. 'begin': 0x3130,
  21484. 'end': 0x318F
  21485. },
  21486. {
  21487. 'begin': 0xA840,
  21488. 'end': 0xA87F
  21489. },
  21490. {
  21491. 'begin': 0x3200,
  21492. 'end': 0x32FF
  21493. },
  21494. {
  21495. 'begin': 0x3300,
  21496. 'end': 0x33FF
  21497. },
  21498. {
  21499. 'begin': 0xAC00,
  21500. 'end': 0xD7AF
  21501. },
  21502. {
  21503. 'begin': 0xD800,
  21504. 'end': 0xDFFF
  21505. },
  21506. {
  21507. 'begin': 0x10900,
  21508. 'end': 0x1091F
  21509. },
  21510. {
  21511. 'begin': 0x4E00,
  21512. 'end': 0x9FFF
  21513. },
  21514. {
  21515. 'begin': 0xE000,
  21516. 'end': 0xF8FF
  21517. },
  21518. {
  21519. 'begin': 0x31C0,
  21520. 'end': 0x31EF
  21521. },
  21522. {
  21523. 'begin': 0xFB00,
  21524. 'end': 0xFB4F
  21525. },
  21526. {
  21527. 'begin': 0xFB50,
  21528. 'end': 0xFDFF
  21529. },
  21530. {
  21531. 'begin': 0xFE20,
  21532. 'end': 0xFE2F
  21533. },
  21534. {
  21535. 'begin': 0xFE10,
  21536. 'end': 0xFE1F
  21537. },
  21538. {
  21539. 'begin': 0xFE50,
  21540. 'end': 0xFE6F
  21541. },
  21542. {
  21543. 'begin': 0xFE70,
  21544. 'end': 0xFEFF
  21545. },
  21546. {
  21547. 'begin': 0xFF00,
  21548. 'end': 0xFFEF
  21549. },
  21550. {
  21551. 'begin': 0xFFF0,
  21552. 'end': 0xFFFF
  21553. },
  21554. {
  21555. 'begin': 0x0F00,
  21556. 'end': 0x0FFF
  21557. },
  21558. {
  21559. 'begin': 0x0700,
  21560. 'end': 0x074F
  21561. },
  21562. {
  21563. 'begin': 0x0780,
  21564. 'end': 0x07BF
  21565. },
  21566. {
  21567. 'begin': 0x0D80,
  21568. 'end': 0x0DFF
  21569. },
  21570. {
  21571. 'begin': 0x1000,
  21572. 'end': 0x109F
  21573. },
  21574. {
  21575. 'begin': 0x1200,
  21576. 'end': 0x137F
  21577. },
  21578. {
  21579. 'begin': 0x13A0,
  21580. 'end': 0x13FF
  21581. },
  21582. {
  21583. 'begin': 0x1400,
  21584. 'end': 0x167F
  21585. },
  21586. {
  21587. 'begin': 0x1680,
  21588. 'end': 0x169F
  21589. },
  21590. {
  21591. 'begin': 0x16A0,
  21592. 'end': 0x16FF
  21593. },
  21594. {
  21595. 'begin': 0x1780,
  21596. 'end': 0x17FF
  21597. },
  21598. {
  21599. 'begin': 0x1800,
  21600. 'end': 0x18AF
  21601. },
  21602. {
  21603. 'begin': 0x2800,
  21604. 'end': 0x28FF
  21605. },
  21606. {
  21607. 'begin': 0xA000,
  21608. 'end': 0xA48F
  21609. },
  21610. {
  21611. 'begin': 0x1700,
  21612. 'end': 0x171F
  21613. },
  21614. {
  21615. 'begin': 0x10300,
  21616. 'end': 0x1032F
  21617. },
  21618. {
  21619. 'begin': 0x10330,
  21620. 'end': 0x1034F
  21621. },
  21622. {
  21623. 'begin': 0x10400,
  21624. 'end': 0x1044F
  21625. },
  21626. {
  21627. 'begin': 0x1D000,
  21628. 'end': 0x1D0FF
  21629. },
  21630. {
  21631. 'begin': 0x1D400,
  21632. 'end': 0x1D7FF
  21633. },
  21634. {
  21635. 'begin': 0xFF000,
  21636. 'end': 0xFFFFD
  21637. },
  21638. {
  21639. 'begin': 0xFE00,
  21640. 'end': 0xFE0F
  21641. },
  21642. {
  21643. 'begin': 0xE0000,
  21644. 'end': 0xE007F
  21645. },
  21646. {
  21647. 'begin': 0x1900,
  21648. 'end': 0x194F
  21649. },
  21650. {
  21651. 'begin': 0x1950,
  21652. 'end': 0x197F
  21653. },
  21654. {
  21655. 'begin': 0x1980,
  21656. 'end': 0x19DF
  21657. },
  21658. {
  21659. 'begin': 0x1A00,
  21660. 'end': 0x1A1F
  21661. },
  21662. {
  21663. 'begin': 0x2C00,
  21664. 'end': 0x2C5F
  21665. },
  21666. {
  21667. 'begin': 0x2D30,
  21668. 'end': 0x2D7F
  21669. },
  21670. {
  21671. 'begin': 0x4DC0,
  21672. 'end': 0x4DFF
  21673. },
  21674. {
  21675. 'begin': 0xA800,
  21676. 'end': 0xA82F
  21677. },
  21678. {
  21679. 'begin': 0x10000,
  21680. 'end': 0x1007F
  21681. },
  21682. {
  21683. 'begin': 0x10140,
  21684. 'end': 0x1018F
  21685. },
  21686. {
  21687. 'begin': 0x10380,
  21688. 'end': 0x1039F
  21689. },
  21690. {
  21691. 'begin': 0x103A0,
  21692. 'end': 0x103DF
  21693. },
  21694. {
  21695. 'begin': 0x10450,
  21696. 'end': 0x1047F
  21697. },
  21698. {
  21699. 'begin': 0x10480,
  21700. 'end': 0x104AF
  21701. },
  21702. {
  21703. 'begin': 0x10800,
  21704. 'end': 0x1083F
  21705. },
  21706. {
  21707. 'begin': 0x10A00,
  21708. 'end': 0x10A5F
  21709. },
  21710. {
  21711. 'begin': 0x1D300,
  21712. 'end': 0x1D35F
  21713. },
  21714. {
  21715. 'begin': 0x12000,
  21716. 'end': 0x123FF
  21717. },
  21718. {
  21719. 'begin': 0x1D360,
  21720. 'end': 0x1D37F
  21721. },
  21722. {
  21723. 'begin': 0x1B80,
  21724. 'end': 0x1BBF
  21725. },
  21726. {
  21727. 'begin': 0x1C00,
  21728. 'end': 0x1C4F
  21729. },
  21730. {
  21731. 'begin': 0x1C50,
  21732. 'end': 0x1C7F
  21733. },
  21734. {
  21735. 'begin': 0xA880,
  21736. 'end': 0xA8DF
  21737. },
  21738. {
  21739. 'begin': 0xA900,
  21740. 'end': 0xA92F
  21741. },
  21742. {
  21743. 'begin': 0xA930,
  21744. 'end': 0xA95F
  21745. },
  21746. {
  21747. 'begin': 0xAA00,
  21748. 'end': 0xAA5F
  21749. },
  21750. {
  21751. 'begin': 0x10190,
  21752. 'end': 0x101CF
  21753. },
  21754. {
  21755. 'begin': 0x101D0,
  21756. 'end': 0x101FF
  21757. },
  21758. {
  21759. 'begin': 0x102A0,
  21760. 'end': 0x102DF
  21761. },
  21762. {
  21763. 'begin': 0x1F030,
  21764. 'end': 0x1F09F
  21765. }
  21766. ];
  21767. function getUnicodeRangeFor(value) {
  21768. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21769. var range = UnicodeRanges[i];
  21770. if (value >= range.begin && value < range.end) {
  21771. return i;
  21772. }
  21773. }
  21774. return -1;
  21775. }
  21776. function isRTLRangeFor(value) {
  21777. var range = UnicodeRanges[13];
  21778. if (value >= range.begin && value < range.end) {
  21779. return true;
  21780. }
  21781. range = UnicodeRanges[11];
  21782. if (value >= range.begin && value < range.end) {
  21783. return true;
  21784. }
  21785. return false;
  21786. }
  21787. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21788. t['\u00A8'] = '\u0020\u0308';
  21789. t['\u00AF'] = '\u0020\u0304';
  21790. t['\u00B4'] = '\u0020\u0301';
  21791. t['\u00B5'] = '\u03BC';
  21792. t['\u00B8'] = '\u0020\u0327';
  21793. t['\u0132'] = '\u0049\u004A';
  21794. t['\u0133'] = '\u0069\u006A';
  21795. t['\u013F'] = '\u004C\u00B7';
  21796. t['\u0140'] = '\u006C\u00B7';
  21797. t['\u0149'] = '\u02BC\u006E';
  21798. t['\u017F'] = '\u0073';
  21799. t['\u01C4'] = '\u0044\u017D';
  21800. t['\u01C5'] = '\u0044\u017E';
  21801. t['\u01C6'] = '\u0064\u017E';
  21802. t['\u01C7'] = '\u004C\u004A';
  21803. t['\u01C8'] = '\u004C\u006A';
  21804. t['\u01C9'] = '\u006C\u006A';
  21805. t['\u01CA'] = '\u004E\u004A';
  21806. t['\u01CB'] = '\u004E\u006A';
  21807. t['\u01CC'] = '\u006E\u006A';
  21808. t['\u01F1'] = '\u0044\u005A';
  21809. t['\u01F2'] = '\u0044\u007A';
  21810. t['\u01F3'] = '\u0064\u007A';
  21811. t['\u02D8'] = '\u0020\u0306';
  21812. t['\u02D9'] = '\u0020\u0307';
  21813. t['\u02DA'] = '\u0020\u030A';
  21814. t['\u02DB'] = '\u0020\u0328';
  21815. t['\u02DC'] = '\u0020\u0303';
  21816. t['\u02DD'] = '\u0020\u030B';
  21817. t['\u037A'] = '\u0020\u0345';
  21818. t['\u0384'] = '\u0020\u0301';
  21819. t['\u03D0'] = '\u03B2';
  21820. t['\u03D1'] = '\u03B8';
  21821. t['\u03D2'] = '\u03A5';
  21822. t['\u03D5'] = '\u03C6';
  21823. t['\u03D6'] = '\u03C0';
  21824. t['\u03F0'] = '\u03BA';
  21825. t['\u03F1'] = '\u03C1';
  21826. t['\u03F2'] = '\u03C2';
  21827. t['\u03F4'] = '\u0398';
  21828. t['\u03F5'] = '\u03B5';
  21829. t['\u03F9'] = '\u03A3';
  21830. t['\u0587'] = '\u0565\u0582';
  21831. t['\u0675'] = '\u0627\u0674';
  21832. t['\u0676'] = '\u0648\u0674';
  21833. t['\u0677'] = '\u06C7\u0674';
  21834. t['\u0678'] = '\u064A\u0674';
  21835. t['\u0E33'] = '\u0E4D\u0E32';
  21836. t['\u0EB3'] = '\u0ECD\u0EB2';
  21837. t['\u0EDC'] = '\u0EAB\u0E99';
  21838. t['\u0EDD'] = '\u0EAB\u0EA1';
  21839. t['\u0F77'] = '\u0FB2\u0F81';
  21840. t['\u0F79'] = '\u0FB3\u0F81';
  21841. t['\u1E9A'] = '\u0061\u02BE';
  21842. t['\u1FBD'] = '\u0020\u0313';
  21843. t['\u1FBF'] = '\u0020\u0313';
  21844. t['\u1FC0'] = '\u0020\u0342';
  21845. t['\u1FFE'] = '\u0020\u0314';
  21846. t['\u2002'] = '\u0020';
  21847. t['\u2003'] = '\u0020';
  21848. t['\u2004'] = '\u0020';
  21849. t['\u2005'] = '\u0020';
  21850. t['\u2006'] = '\u0020';
  21851. t['\u2008'] = '\u0020';
  21852. t['\u2009'] = '\u0020';
  21853. t['\u200A'] = '\u0020';
  21854. t['\u2017'] = '\u0020\u0333';
  21855. t['\u2024'] = '\u002E';
  21856. t['\u2025'] = '\u002E\u002E';
  21857. t['\u2026'] = '\u002E\u002E\u002E';
  21858. t['\u2033'] = '\u2032\u2032';
  21859. t['\u2034'] = '\u2032\u2032\u2032';
  21860. t['\u2036'] = '\u2035\u2035';
  21861. t['\u2037'] = '\u2035\u2035\u2035';
  21862. t['\u203C'] = '\u0021\u0021';
  21863. t['\u203E'] = '\u0020\u0305';
  21864. t['\u2047'] = '\u003F\u003F';
  21865. t['\u2048'] = '\u003F\u0021';
  21866. t['\u2049'] = '\u0021\u003F';
  21867. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21868. t['\u205F'] = '\u0020';
  21869. t['\u20A8'] = '\u0052\u0073';
  21870. t['\u2100'] = '\u0061\u002F\u0063';
  21871. t['\u2101'] = '\u0061\u002F\u0073';
  21872. t['\u2103'] = '\u00B0\u0043';
  21873. t['\u2105'] = '\u0063\u002F\u006F';
  21874. t['\u2106'] = '\u0063\u002F\u0075';
  21875. t['\u2107'] = '\u0190';
  21876. t['\u2109'] = '\u00B0\u0046';
  21877. t['\u2116'] = '\u004E\u006F';
  21878. t['\u2121'] = '\u0054\u0045\u004C';
  21879. t['\u2135'] = '\u05D0';
  21880. t['\u2136'] = '\u05D1';
  21881. t['\u2137'] = '\u05D2';
  21882. t['\u2138'] = '\u05D3';
  21883. t['\u213B'] = '\u0046\u0041\u0058';
  21884. t['\u2160'] = '\u0049';
  21885. t['\u2161'] = '\u0049\u0049';
  21886. t['\u2162'] = '\u0049\u0049\u0049';
  21887. t['\u2163'] = '\u0049\u0056';
  21888. t['\u2164'] = '\u0056';
  21889. t['\u2165'] = '\u0056\u0049';
  21890. t['\u2166'] = '\u0056\u0049\u0049';
  21891. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21892. t['\u2168'] = '\u0049\u0058';
  21893. t['\u2169'] = '\u0058';
  21894. t['\u216A'] = '\u0058\u0049';
  21895. t['\u216B'] = '\u0058\u0049\u0049';
  21896. t['\u216C'] = '\u004C';
  21897. t['\u216D'] = '\u0043';
  21898. t['\u216E'] = '\u0044';
  21899. t['\u216F'] = '\u004D';
  21900. t['\u2170'] = '\u0069';
  21901. t['\u2171'] = '\u0069\u0069';
  21902. t['\u2172'] = '\u0069\u0069\u0069';
  21903. t['\u2173'] = '\u0069\u0076';
  21904. t['\u2174'] = '\u0076';
  21905. t['\u2175'] = '\u0076\u0069';
  21906. t['\u2176'] = '\u0076\u0069\u0069';
  21907. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21908. t['\u2178'] = '\u0069\u0078';
  21909. t['\u2179'] = '\u0078';
  21910. t['\u217A'] = '\u0078\u0069';
  21911. t['\u217B'] = '\u0078\u0069\u0069';
  21912. t['\u217C'] = '\u006C';
  21913. t['\u217D'] = '\u0063';
  21914. t['\u217E'] = '\u0064';
  21915. t['\u217F'] = '\u006D';
  21916. t['\u222C'] = '\u222B\u222B';
  21917. t['\u222D'] = '\u222B\u222B\u222B';
  21918. t['\u222F'] = '\u222E\u222E';
  21919. t['\u2230'] = '\u222E\u222E\u222E';
  21920. t['\u2474'] = '\u0028\u0031\u0029';
  21921. t['\u2475'] = '\u0028\u0032\u0029';
  21922. t['\u2476'] = '\u0028\u0033\u0029';
  21923. t['\u2477'] = '\u0028\u0034\u0029';
  21924. t['\u2478'] = '\u0028\u0035\u0029';
  21925. t['\u2479'] = '\u0028\u0036\u0029';
  21926. t['\u247A'] = '\u0028\u0037\u0029';
  21927. t['\u247B'] = '\u0028\u0038\u0029';
  21928. t['\u247C'] = '\u0028\u0039\u0029';
  21929. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21930. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21931. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21932. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21933. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21934. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21935. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21936. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21937. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21938. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21939. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21940. t['\u2488'] = '\u0031\u002E';
  21941. t['\u2489'] = '\u0032\u002E';
  21942. t['\u248A'] = '\u0033\u002E';
  21943. t['\u248B'] = '\u0034\u002E';
  21944. t['\u248C'] = '\u0035\u002E';
  21945. t['\u248D'] = '\u0036\u002E';
  21946. t['\u248E'] = '\u0037\u002E';
  21947. t['\u248F'] = '\u0038\u002E';
  21948. t['\u2490'] = '\u0039\u002E';
  21949. t['\u2491'] = '\u0031\u0030\u002E';
  21950. t['\u2492'] = '\u0031\u0031\u002E';
  21951. t['\u2493'] = '\u0031\u0032\u002E';
  21952. t['\u2494'] = '\u0031\u0033\u002E';
  21953. t['\u2495'] = '\u0031\u0034\u002E';
  21954. t['\u2496'] = '\u0031\u0035\u002E';
  21955. t['\u2497'] = '\u0031\u0036\u002E';
  21956. t['\u2498'] = '\u0031\u0037\u002E';
  21957. t['\u2499'] = '\u0031\u0038\u002E';
  21958. t['\u249A'] = '\u0031\u0039\u002E';
  21959. t['\u249B'] = '\u0032\u0030\u002E';
  21960. t['\u249C'] = '\u0028\u0061\u0029';
  21961. t['\u249D'] = '\u0028\u0062\u0029';
  21962. t['\u249E'] = '\u0028\u0063\u0029';
  21963. t['\u249F'] = '\u0028\u0064\u0029';
  21964. t['\u24A0'] = '\u0028\u0065\u0029';
  21965. t['\u24A1'] = '\u0028\u0066\u0029';
  21966. t['\u24A2'] = '\u0028\u0067\u0029';
  21967. t['\u24A3'] = '\u0028\u0068\u0029';
  21968. t['\u24A4'] = '\u0028\u0069\u0029';
  21969. t['\u24A5'] = '\u0028\u006A\u0029';
  21970. t['\u24A6'] = '\u0028\u006B\u0029';
  21971. t['\u24A7'] = '\u0028\u006C\u0029';
  21972. t['\u24A8'] = '\u0028\u006D\u0029';
  21973. t['\u24A9'] = '\u0028\u006E\u0029';
  21974. t['\u24AA'] = '\u0028\u006F\u0029';
  21975. t['\u24AB'] = '\u0028\u0070\u0029';
  21976. t['\u24AC'] = '\u0028\u0071\u0029';
  21977. t['\u24AD'] = '\u0028\u0072\u0029';
  21978. t['\u24AE'] = '\u0028\u0073\u0029';
  21979. t['\u24AF'] = '\u0028\u0074\u0029';
  21980. t['\u24B0'] = '\u0028\u0075\u0029';
  21981. t['\u24B1'] = '\u0028\u0076\u0029';
  21982. t['\u24B2'] = '\u0028\u0077\u0029';
  21983. t['\u24B3'] = '\u0028\u0078\u0029';
  21984. t['\u24B4'] = '\u0028\u0079\u0029';
  21985. t['\u24B5'] = '\u0028\u007A\u0029';
  21986. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21987. t['\u2A74'] = '\u003A\u003A\u003D';
  21988. t['\u2A75'] = '\u003D\u003D';
  21989. t['\u2A76'] = '\u003D\u003D\u003D';
  21990. t['\u2E9F'] = '\u6BCD';
  21991. t['\u2EF3'] = '\u9F9F';
  21992. t['\u2F00'] = '\u4E00';
  21993. t['\u2F01'] = '\u4E28';
  21994. t['\u2F02'] = '\u4E36';
  21995. t['\u2F03'] = '\u4E3F';
  21996. t['\u2F04'] = '\u4E59';
  21997. t['\u2F05'] = '\u4E85';
  21998. t['\u2F06'] = '\u4E8C';
  21999. t['\u2F07'] = '\u4EA0';
  22000. t['\u2F08'] = '\u4EBA';
  22001. t['\u2F09'] = '\u513F';
  22002. t['\u2F0A'] = '\u5165';
  22003. t['\u2F0B'] = '\u516B';
  22004. t['\u2F0C'] = '\u5182';
  22005. t['\u2F0D'] = '\u5196';
  22006. t['\u2F0E'] = '\u51AB';
  22007. t['\u2F0F'] = '\u51E0';
  22008. t['\u2F10'] = '\u51F5';
  22009. t['\u2F11'] = '\u5200';
  22010. t['\u2F12'] = '\u529B';
  22011. t['\u2F13'] = '\u52F9';
  22012. t['\u2F14'] = '\u5315';
  22013. t['\u2F15'] = '\u531A';
  22014. t['\u2F16'] = '\u5338';
  22015. t['\u2F17'] = '\u5341';
  22016. t['\u2F18'] = '\u535C';
  22017. t['\u2F19'] = '\u5369';
  22018. t['\u2F1A'] = '\u5382';
  22019. t['\u2F1B'] = '\u53B6';
  22020. t['\u2F1C'] = '\u53C8';
  22021. t['\u2F1D'] = '\u53E3';
  22022. t['\u2F1E'] = '\u56D7';
  22023. t['\u2F1F'] = '\u571F';
  22024. t['\u2F20'] = '\u58EB';
  22025. t['\u2F21'] = '\u5902';
  22026. t['\u2F22'] = '\u590A';
  22027. t['\u2F23'] = '\u5915';
  22028. t['\u2F24'] = '\u5927';
  22029. t['\u2F25'] = '\u5973';
  22030. t['\u2F26'] = '\u5B50';
  22031. t['\u2F27'] = '\u5B80';
  22032. t['\u2F28'] = '\u5BF8';
  22033. t['\u2F29'] = '\u5C0F';
  22034. t['\u2F2A'] = '\u5C22';
  22035. t['\u2F2B'] = '\u5C38';
  22036. t['\u2F2C'] = '\u5C6E';
  22037. t['\u2F2D'] = '\u5C71';
  22038. t['\u2F2E'] = '\u5DDB';
  22039. t['\u2F2F'] = '\u5DE5';
  22040. t['\u2F30'] = '\u5DF1';
  22041. t['\u2F31'] = '\u5DFE';
  22042. t['\u2F32'] = '\u5E72';
  22043. t['\u2F33'] = '\u5E7A';
  22044. t['\u2F34'] = '\u5E7F';
  22045. t['\u2F35'] = '\u5EF4';
  22046. t['\u2F36'] = '\u5EFE';
  22047. t['\u2F37'] = '\u5F0B';
  22048. t['\u2F38'] = '\u5F13';
  22049. t['\u2F39'] = '\u5F50';
  22050. t['\u2F3A'] = '\u5F61';
  22051. t['\u2F3B'] = '\u5F73';
  22052. t['\u2F3C'] = '\u5FC3';
  22053. t['\u2F3D'] = '\u6208';
  22054. t['\u2F3E'] = '\u6236';
  22055. t['\u2F3F'] = '\u624B';
  22056. t['\u2F40'] = '\u652F';
  22057. t['\u2F41'] = '\u6534';
  22058. t['\u2F42'] = '\u6587';
  22059. t['\u2F43'] = '\u6597';
  22060. t['\u2F44'] = '\u65A4';
  22061. t['\u2F45'] = '\u65B9';
  22062. t['\u2F46'] = '\u65E0';
  22063. t['\u2F47'] = '\u65E5';
  22064. t['\u2F48'] = '\u66F0';
  22065. t['\u2F49'] = '\u6708';
  22066. t['\u2F4A'] = '\u6728';
  22067. t['\u2F4B'] = '\u6B20';
  22068. t['\u2F4C'] = '\u6B62';
  22069. t['\u2F4D'] = '\u6B79';
  22070. t['\u2F4E'] = '\u6BB3';
  22071. t['\u2F4F'] = '\u6BCB';
  22072. t['\u2F50'] = '\u6BD4';
  22073. t['\u2F51'] = '\u6BDB';
  22074. t['\u2F52'] = '\u6C0F';
  22075. t['\u2F53'] = '\u6C14';
  22076. t['\u2F54'] = '\u6C34';
  22077. t['\u2F55'] = '\u706B';
  22078. t['\u2F56'] = '\u722A';
  22079. t['\u2F57'] = '\u7236';
  22080. t['\u2F58'] = '\u723B';
  22081. t['\u2F59'] = '\u723F';
  22082. t['\u2F5A'] = '\u7247';
  22083. t['\u2F5B'] = '\u7259';
  22084. t['\u2F5C'] = '\u725B';
  22085. t['\u2F5D'] = '\u72AC';
  22086. t['\u2F5E'] = '\u7384';
  22087. t['\u2F5F'] = '\u7389';
  22088. t['\u2F60'] = '\u74DC';
  22089. t['\u2F61'] = '\u74E6';
  22090. t['\u2F62'] = '\u7518';
  22091. t['\u2F63'] = '\u751F';
  22092. t['\u2F64'] = '\u7528';
  22093. t['\u2F65'] = '\u7530';
  22094. t['\u2F66'] = '\u758B';
  22095. t['\u2F67'] = '\u7592';
  22096. t['\u2F68'] = '\u7676';
  22097. t['\u2F69'] = '\u767D';
  22098. t['\u2F6A'] = '\u76AE';
  22099. t['\u2F6B'] = '\u76BF';
  22100. t['\u2F6C'] = '\u76EE';
  22101. t['\u2F6D'] = '\u77DB';
  22102. t['\u2F6E'] = '\u77E2';
  22103. t['\u2F6F'] = '\u77F3';
  22104. t['\u2F70'] = '\u793A';
  22105. t['\u2F71'] = '\u79B8';
  22106. t['\u2F72'] = '\u79BE';
  22107. t['\u2F73'] = '\u7A74';
  22108. t['\u2F74'] = '\u7ACB';
  22109. t['\u2F75'] = '\u7AF9';
  22110. t['\u2F76'] = '\u7C73';
  22111. t['\u2F77'] = '\u7CF8';
  22112. t['\u2F78'] = '\u7F36';
  22113. t['\u2F79'] = '\u7F51';
  22114. t['\u2F7A'] = '\u7F8A';
  22115. t['\u2F7B'] = '\u7FBD';
  22116. t['\u2F7C'] = '\u8001';
  22117. t['\u2F7D'] = '\u800C';
  22118. t['\u2F7E'] = '\u8012';
  22119. t['\u2F7F'] = '\u8033';
  22120. t['\u2F80'] = '\u807F';
  22121. t['\u2F81'] = '\u8089';
  22122. t['\u2F82'] = '\u81E3';
  22123. t['\u2F83'] = '\u81EA';
  22124. t['\u2F84'] = '\u81F3';
  22125. t['\u2F85'] = '\u81FC';
  22126. t['\u2F86'] = '\u820C';
  22127. t['\u2F87'] = '\u821B';
  22128. t['\u2F88'] = '\u821F';
  22129. t['\u2F89'] = '\u826E';
  22130. t['\u2F8A'] = '\u8272';
  22131. t['\u2F8B'] = '\u8278';
  22132. t['\u2F8C'] = '\u864D';
  22133. t['\u2F8D'] = '\u866B';
  22134. t['\u2F8E'] = '\u8840';
  22135. t['\u2F8F'] = '\u884C';
  22136. t['\u2F90'] = '\u8863';
  22137. t['\u2F91'] = '\u897E';
  22138. t['\u2F92'] = '\u898B';
  22139. t['\u2F93'] = '\u89D2';
  22140. t['\u2F94'] = '\u8A00';
  22141. t['\u2F95'] = '\u8C37';
  22142. t['\u2F96'] = '\u8C46';
  22143. t['\u2F97'] = '\u8C55';
  22144. t['\u2F98'] = '\u8C78';
  22145. t['\u2F99'] = '\u8C9D';
  22146. t['\u2F9A'] = '\u8D64';
  22147. t['\u2F9B'] = '\u8D70';
  22148. t['\u2F9C'] = '\u8DB3';
  22149. t['\u2F9D'] = '\u8EAB';
  22150. t['\u2F9E'] = '\u8ECA';
  22151. t['\u2F9F'] = '\u8F9B';
  22152. t['\u2FA0'] = '\u8FB0';
  22153. t['\u2FA1'] = '\u8FB5';
  22154. t['\u2FA2'] = '\u9091';
  22155. t['\u2FA3'] = '\u9149';
  22156. t['\u2FA4'] = '\u91C6';
  22157. t['\u2FA5'] = '\u91CC';
  22158. t['\u2FA6'] = '\u91D1';
  22159. t['\u2FA7'] = '\u9577';
  22160. t['\u2FA8'] = '\u9580';
  22161. t['\u2FA9'] = '\u961C';
  22162. t['\u2FAA'] = '\u96B6';
  22163. t['\u2FAB'] = '\u96B9';
  22164. t['\u2FAC'] = '\u96E8';
  22165. t['\u2FAD'] = '\u9751';
  22166. t['\u2FAE'] = '\u975E';
  22167. t['\u2FAF'] = '\u9762';
  22168. t['\u2FB0'] = '\u9769';
  22169. t['\u2FB1'] = '\u97CB';
  22170. t['\u2FB2'] = '\u97ED';
  22171. t['\u2FB3'] = '\u97F3';
  22172. t['\u2FB4'] = '\u9801';
  22173. t['\u2FB5'] = '\u98A8';
  22174. t['\u2FB6'] = '\u98DB';
  22175. t['\u2FB7'] = '\u98DF';
  22176. t['\u2FB8'] = '\u9996';
  22177. t['\u2FB9'] = '\u9999';
  22178. t['\u2FBA'] = '\u99AC';
  22179. t['\u2FBB'] = '\u9AA8';
  22180. t['\u2FBC'] = '\u9AD8';
  22181. t['\u2FBD'] = '\u9ADF';
  22182. t['\u2FBE'] = '\u9B25';
  22183. t['\u2FBF'] = '\u9B2F';
  22184. t['\u2FC0'] = '\u9B32';
  22185. t['\u2FC1'] = '\u9B3C';
  22186. t['\u2FC2'] = '\u9B5A';
  22187. t['\u2FC3'] = '\u9CE5';
  22188. t['\u2FC4'] = '\u9E75';
  22189. t['\u2FC5'] = '\u9E7F';
  22190. t['\u2FC6'] = '\u9EA5';
  22191. t['\u2FC7'] = '\u9EBB';
  22192. t['\u2FC8'] = '\u9EC3';
  22193. t['\u2FC9'] = '\u9ECD';
  22194. t['\u2FCA'] = '\u9ED1';
  22195. t['\u2FCB'] = '\u9EF9';
  22196. t['\u2FCC'] = '\u9EFD';
  22197. t['\u2FCD'] = '\u9F0E';
  22198. t['\u2FCE'] = '\u9F13';
  22199. t['\u2FCF'] = '\u9F20';
  22200. t['\u2FD0'] = '\u9F3B';
  22201. t['\u2FD1'] = '\u9F4A';
  22202. t['\u2FD2'] = '\u9F52';
  22203. t['\u2FD3'] = '\u9F8D';
  22204. t['\u2FD4'] = '\u9F9C';
  22205. t['\u2FD5'] = '\u9FA0';
  22206. t['\u3036'] = '\u3012';
  22207. t['\u3038'] = '\u5341';
  22208. t['\u3039'] = '\u5344';
  22209. t['\u303A'] = '\u5345';
  22210. t['\u309B'] = '\u0020\u3099';
  22211. t['\u309C'] = '\u0020\u309A';
  22212. t['\u3131'] = '\u1100';
  22213. t['\u3132'] = '\u1101';
  22214. t['\u3133'] = '\u11AA';
  22215. t['\u3134'] = '\u1102';
  22216. t['\u3135'] = '\u11AC';
  22217. t['\u3136'] = '\u11AD';
  22218. t['\u3137'] = '\u1103';
  22219. t['\u3138'] = '\u1104';
  22220. t['\u3139'] = '\u1105';
  22221. t['\u313A'] = '\u11B0';
  22222. t['\u313B'] = '\u11B1';
  22223. t['\u313C'] = '\u11B2';
  22224. t['\u313D'] = '\u11B3';
  22225. t['\u313E'] = '\u11B4';
  22226. t['\u313F'] = '\u11B5';
  22227. t['\u3140'] = '\u111A';
  22228. t['\u3141'] = '\u1106';
  22229. t['\u3142'] = '\u1107';
  22230. t['\u3143'] = '\u1108';
  22231. t['\u3144'] = '\u1121';
  22232. t['\u3145'] = '\u1109';
  22233. t['\u3146'] = '\u110A';
  22234. t['\u3147'] = '\u110B';
  22235. t['\u3148'] = '\u110C';
  22236. t['\u3149'] = '\u110D';
  22237. t['\u314A'] = '\u110E';
  22238. t['\u314B'] = '\u110F';
  22239. t['\u314C'] = '\u1110';
  22240. t['\u314D'] = '\u1111';
  22241. t['\u314E'] = '\u1112';
  22242. t['\u314F'] = '\u1161';
  22243. t['\u3150'] = '\u1162';
  22244. t['\u3151'] = '\u1163';
  22245. t['\u3152'] = '\u1164';
  22246. t['\u3153'] = '\u1165';
  22247. t['\u3154'] = '\u1166';
  22248. t['\u3155'] = '\u1167';
  22249. t['\u3156'] = '\u1168';
  22250. t['\u3157'] = '\u1169';
  22251. t['\u3158'] = '\u116A';
  22252. t['\u3159'] = '\u116B';
  22253. t['\u315A'] = '\u116C';
  22254. t['\u315B'] = '\u116D';
  22255. t['\u315C'] = '\u116E';
  22256. t['\u315D'] = '\u116F';
  22257. t['\u315E'] = '\u1170';
  22258. t['\u315F'] = '\u1171';
  22259. t['\u3160'] = '\u1172';
  22260. t['\u3161'] = '\u1173';
  22261. t['\u3162'] = '\u1174';
  22262. t['\u3163'] = '\u1175';
  22263. t['\u3164'] = '\u1160';
  22264. t['\u3165'] = '\u1114';
  22265. t['\u3166'] = '\u1115';
  22266. t['\u3167'] = '\u11C7';
  22267. t['\u3168'] = '\u11C8';
  22268. t['\u3169'] = '\u11CC';
  22269. t['\u316A'] = '\u11CE';
  22270. t['\u316B'] = '\u11D3';
  22271. t['\u316C'] = '\u11D7';
  22272. t['\u316D'] = '\u11D9';
  22273. t['\u316E'] = '\u111C';
  22274. t['\u316F'] = '\u11DD';
  22275. t['\u3170'] = '\u11DF';
  22276. t['\u3171'] = '\u111D';
  22277. t['\u3172'] = '\u111E';
  22278. t['\u3173'] = '\u1120';
  22279. t['\u3174'] = '\u1122';
  22280. t['\u3175'] = '\u1123';
  22281. t['\u3176'] = '\u1127';
  22282. t['\u3177'] = '\u1129';
  22283. t['\u3178'] = '\u112B';
  22284. t['\u3179'] = '\u112C';
  22285. t['\u317A'] = '\u112D';
  22286. t['\u317B'] = '\u112E';
  22287. t['\u317C'] = '\u112F';
  22288. t['\u317D'] = '\u1132';
  22289. t['\u317E'] = '\u1136';
  22290. t['\u317F'] = '\u1140';
  22291. t['\u3180'] = '\u1147';
  22292. t['\u3181'] = '\u114C';
  22293. t['\u3182'] = '\u11F1';
  22294. t['\u3183'] = '\u11F2';
  22295. t['\u3184'] = '\u1157';
  22296. t['\u3185'] = '\u1158';
  22297. t['\u3186'] = '\u1159';
  22298. t['\u3187'] = '\u1184';
  22299. t['\u3188'] = '\u1185';
  22300. t['\u3189'] = '\u1188';
  22301. t['\u318A'] = '\u1191';
  22302. t['\u318B'] = '\u1192';
  22303. t['\u318C'] = '\u1194';
  22304. t['\u318D'] = '\u119E';
  22305. t['\u318E'] = '\u11A1';
  22306. t['\u3200'] = '\u0028\u1100\u0029';
  22307. t['\u3201'] = '\u0028\u1102\u0029';
  22308. t['\u3202'] = '\u0028\u1103\u0029';
  22309. t['\u3203'] = '\u0028\u1105\u0029';
  22310. t['\u3204'] = '\u0028\u1106\u0029';
  22311. t['\u3205'] = '\u0028\u1107\u0029';
  22312. t['\u3206'] = '\u0028\u1109\u0029';
  22313. t['\u3207'] = '\u0028\u110B\u0029';
  22314. t['\u3208'] = '\u0028\u110C\u0029';
  22315. t['\u3209'] = '\u0028\u110E\u0029';
  22316. t['\u320A'] = '\u0028\u110F\u0029';
  22317. t['\u320B'] = '\u0028\u1110\u0029';
  22318. t['\u320C'] = '\u0028\u1111\u0029';
  22319. t['\u320D'] = '\u0028\u1112\u0029';
  22320. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22321. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22322. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22323. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22324. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22325. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22326. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22327. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22328. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22329. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22330. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22331. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22332. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22333. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22334. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22335. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22336. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22337. t['\u3220'] = '\u0028\u4E00\u0029';
  22338. t['\u3221'] = '\u0028\u4E8C\u0029';
  22339. t['\u3222'] = '\u0028\u4E09\u0029';
  22340. t['\u3223'] = '\u0028\u56DB\u0029';
  22341. t['\u3224'] = '\u0028\u4E94\u0029';
  22342. t['\u3225'] = '\u0028\u516D\u0029';
  22343. t['\u3226'] = '\u0028\u4E03\u0029';
  22344. t['\u3227'] = '\u0028\u516B\u0029';
  22345. t['\u3228'] = '\u0028\u4E5D\u0029';
  22346. t['\u3229'] = '\u0028\u5341\u0029';
  22347. t['\u322A'] = '\u0028\u6708\u0029';
  22348. t['\u322B'] = '\u0028\u706B\u0029';
  22349. t['\u322C'] = '\u0028\u6C34\u0029';
  22350. t['\u322D'] = '\u0028\u6728\u0029';
  22351. t['\u322E'] = '\u0028\u91D1\u0029';
  22352. t['\u322F'] = '\u0028\u571F\u0029';
  22353. t['\u3230'] = '\u0028\u65E5\u0029';
  22354. t['\u3231'] = '\u0028\u682A\u0029';
  22355. t['\u3232'] = '\u0028\u6709\u0029';
  22356. t['\u3233'] = '\u0028\u793E\u0029';
  22357. t['\u3234'] = '\u0028\u540D\u0029';
  22358. t['\u3235'] = '\u0028\u7279\u0029';
  22359. t['\u3236'] = '\u0028\u8CA1\u0029';
  22360. t['\u3237'] = '\u0028\u795D\u0029';
  22361. t['\u3238'] = '\u0028\u52B4\u0029';
  22362. t['\u3239'] = '\u0028\u4EE3\u0029';
  22363. t['\u323A'] = '\u0028\u547C\u0029';
  22364. t['\u323B'] = '\u0028\u5B66\u0029';
  22365. t['\u323C'] = '\u0028\u76E3\u0029';
  22366. t['\u323D'] = '\u0028\u4F01\u0029';
  22367. t['\u323E'] = '\u0028\u8CC7\u0029';
  22368. t['\u323F'] = '\u0028\u5354\u0029';
  22369. t['\u3240'] = '\u0028\u796D\u0029';
  22370. t['\u3241'] = '\u0028\u4F11\u0029';
  22371. t['\u3242'] = '\u0028\u81EA\u0029';
  22372. t['\u3243'] = '\u0028\u81F3\u0029';
  22373. t['\u32C0'] = '\u0031\u6708';
  22374. t['\u32C1'] = '\u0032\u6708';
  22375. t['\u32C2'] = '\u0033\u6708';
  22376. t['\u32C3'] = '\u0034\u6708';
  22377. t['\u32C4'] = '\u0035\u6708';
  22378. t['\u32C5'] = '\u0036\u6708';
  22379. t['\u32C6'] = '\u0037\u6708';
  22380. t['\u32C7'] = '\u0038\u6708';
  22381. t['\u32C8'] = '\u0039\u6708';
  22382. t['\u32C9'] = '\u0031\u0030\u6708';
  22383. t['\u32CA'] = '\u0031\u0031\u6708';
  22384. t['\u32CB'] = '\u0031\u0032\u6708';
  22385. t['\u3358'] = '\u0030\u70B9';
  22386. t['\u3359'] = '\u0031\u70B9';
  22387. t['\u335A'] = '\u0032\u70B9';
  22388. t['\u335B'] = '\u0033\u70B9';
  22389. t['\u335C'] = '\u0034\u70B9';
  22390. t['\u335D'] = '\u0035\u70B9';
  22391. t['\u335E'] = '\u0036\u70B9';
  22392. t['\u335F'] = '\u0037\u70B9';
  22393. t['\u3360'] = '\u0038\u70B9';
  22394. t['\u3361'] = '\u0039\u70B9';
  22395. t['\u3362'] = '\u0031\u0030\u70B9';
  22396. t['\u3363'] = '\u0031\u0031\u70B9';
  22397. t['\u3364'] = '\u0031\u0032\u70B9';
  22398. t['\u3365'] = '\u0031\u0033\u70B9';
  22399. t['\u3366'] = '\u0031\u0034\u70B9';
  22400. t['\u3367'] = '\u0031\u0035\u70B9';
  22401. t['\u3368'] = '\u0031\u0036\u70B9';
  22402. t['\u3369'] = '\u0031\u0037\u70B9';
  22403. t['\u336A'] = '\u0031\u0038\u70B9';
  22404. t['\u336B'] = '\u0031\u0039\u70B9';
  22405. t['\u336C'] = '\u0032\u0030\u70B9';
  22406. t['\u336D'] = '\u0032\u0031\u70B9';
  22407. t['\u336E'] = '\u0032\u0032\u70B9';
  22408. t['\u336F'] = '\u0032\u0033\u70B9';
  22409. t['\u3370'] = '\u0032\u0034\u70B9';
  22410. t['\u33E0'] = '\u0031\u65E5';
  22411. t['\u33E1'] = '\u0032\u65E5';
  22412. t['\u33E2'] = '\u0033\u65E5';
  22413. t['\u33E3'] = '\u0034\u65E5';
  22414. t['\u33E4'] = '\u0035\u65E5';
  22415. t['\u33E5'] = '\u0036\u65E5';
  22416. t['\u33E6'] = '\u0037\u65E5';
  22417. t['\u33E7'] = '\u0038\u65E5';
  22418. t['\u33E8'] = '\u0039\u65E5';
  22419. t['\u33E9'] = '\u0031\u0030\u65E5';
  22420. t['\u33EA'] = '\u0031\u0031\u65E5';
  22421. t['\u33EB'] = '\u0031\u0032\u65E5';
  22422. t['\u33EC'] = '\u0031\u0033\u65E5';
  22423. t['\u33ED'] = '\u0031\u0034\u65E5';
  22424. t['\u33EE'] = '\u0031\u0035\u65E5';
  22425. t['\u33EF'] = '\u0031\u0036\u65E5';
  22426. t['\u33F0'] = '\u0031\u0037\u65E5';
  22427. t['\u33F1'] = '\u0031\u0038\u65E5';
  22428. t['\u33F2'] = '\u0031\u0039\u65E5';
  22429. t['\u33F3'] = '\u0032\u0030\u65E5';
  22430. t['\u33F4'] = '\u0032\u0031\u65E5';
  22431. t['\u33F5'] = '\u0032\u0032\u65E5';
  22432. t['\u33F6'] = '\u0032\u0033\u65E5';
  22433. t['\u33F7'] = '\u0032\u0034\u65E5';
  22434. t['\u33F8'] = '\u0032\u0035\u65E5';
  22435. t['\u33F9'] = '\u0032\u0036\u65E5';
  22436. t['\u33FA'] = '\u0032\u0037\u65E5';
  22437. t['\u33FB'] = '\u0032\u0038\u65E5';
  22438. t['\u33FC'] = '\u0032\u0039\u65E5';
  22439. t['\u33FD'] = '\u0033\u0030\u65E5';
  22440. t['\u33FE'] = '\u0033\u0031\u65E5';
  22441. t['\uFB00'] = '\u0066\u0066';
  22442. t['\uFB01'] = '\u0066\u0069';
  22443. t['\uFB02'] = '\u0066\u006C';
  22444. t['\uFB03'] = '\u0066\u0066\u0069';
  22445. t['\uFB04'] = '\u0066\u0066\u006C';
  22446. t['\uFB05'] = '\u017F\u0074';
  22447. t['\uFB06'] = '\u0073\u0074';
  22448. t['\uFB13'] = '\u0574\u0576';
  22449. t['\uFB14'] = '\u0574\u0565';
  22450. t['\uFB15'] = '\u0574\u056B';
  22451. t['\uFB16'] = '\u057E\u0576';
  22452. t['\uFB17'] = '\u0574\u056D';
  22453. t['\uFB4F'] = '\u05D0\u05DC';
  22454. t['\uFB50'] = '\u0671';
  22455. t['\uFB51'] = '\u0671';
  22456. t['\uFB52'] = '\u067B';
  22457. t['\uFB53'] = '\u067B';
  22458. t['\uFB54'] = '\u067B';
  22459. t['\uFB55'] = '\u067B';
  22460. t['\uFB56'] = '\u067E';
  22461. t['\uFB57'] = '\u067E';
  22462. t['\uFB58'] = '\u067E';
  22463. t['\uFB59'] = '\u067E';
  22464. t['\uFB5A'] = '\u0680';
  22465. t['\uFB5B'] = '\u0680';
  22466. t['\uFB5C'] = '\u0680';
  22467. t['\uFB5D'] = '\u0680';
  22468. t['\uFB5E'] = '\u067A';
  22469. t['\uFB5F'] = '\u067A';
  22470. t['\uFB60'] = '\u067A';
  22471. t['\uFB61'] = '\u067A';
  22472. t['\uFB62'] = '\u067F';
  22473. t['\uFB63'] = '\u067F';
  22474. t['\uFB64'] = '\u067F';
  22475. t['\uFB65'] = '\u067F';
  22476. t['\uFB66'] = '\u0679';
  22477. t['\uFB67'] = '\u0679';
  22478. t['\uFB68'] = '\u0679';
  22479. t['\uFB69'] = '\u0679';
  22480. t['\uFB6A'] = '\u06A4';
  22481. t['\uFB6B'] = '\u06A4';
  22482. t['\uFB6C'] = '\u06A4';
  22483. t['\uFB6D'] = '\u06A4';
  22484. t['\uFB6E'] = '\u06A6';
  22485. t['\uFB6F'] = '\u06A6';
  22486. t['\uFB70'] = '\u06A6';
  22487. t['\uFB71'] = '\u06A6';
  22488. t['\uFB72'] = '\u0684';
  22489. t['\uFB73'] = '\u0684';
  22490. t['\uFB74'] = '\u0684';
  22491. t['\uFB75'] = '\u0684';
  22492. t['\uFB76'] = '\u0683';
  22493. t['\uFB77'] = '\u0683';
  22494. t['\uFB78'] = '\u0683';
  22495. t['\uFB79'] = '\u0683';
  22496. t['\uFB7A'] = '\u0686';
  22497. t['\uFB7B'] = '\u0686';
  22498. t['\uFB7C'] = '\u0686';
  22499. t['\uFB7D'] = '\u0686';
  22500. t['\uFB7E'] = '\u0687';
  22501. t['\uFB7F'] = '\u0687';
  22502. t['\uFB80'] = '\u0687';
  22503. t['\uFB81'] = '\u0687';
  22504. t['\uFB82'] = '\u068D';
  22505. t['\uFB83'] = '\u068D';
  22506. t['\uFB84'] = '\u068C';
  22507. t['\uFB85'] = '\u068C';
  22508. t['\uFB86'] = '\u068E';
  22509. t['\uFB87'] = '\u068E';
  22510. t['\uFB88'] = '\u0688';
  22511. t['\uFB89'] = '\u0688';
  22512. t['\uFB8A'] = '\u0698';
  22513. t['\uFB8B'] = '\u0698';
  22514. t['\uFB8C'] = '\u0691';
  22515. t['\uFB8D'] = '\u0691';
  22516. t['\uFB8E'] = '\u06A9';
  22517. t['\uFB8F'] = '\u06A9';
  22518. t['\uFB90'] = '\u06A9';
  22519. t['\uFB91'] = '\u06A9';
  22520. t['\uFB92'] = '\u06AF';
  22521. t['\uFB93'] = '\u06AF';
  22522. t['\uFB94'] = '\u06AF';
  22523. t['\uFB95'] = '\u06AF';
  22524. t['\uFB96'] = '\u06B3';
  22525. t['\uFB97'] = '\u06B3';
  22526. t['\uFB98'] = '\u06B3';
  22527. t['\uFB99'] = '\u06B3';
  22528. t['\uFB9A'] = '\u06B1';
  22529. t['\uFB9B'] = '\u06B1';
  22530. t['\uFB9C'] = '\u06B1';
  22531. t['\uFB9D'] = '\u06B1';
  22532. t['\uFB9E'] = '\u06BA';
  22533. t['\uFB9F'] = '\u06BA';
  22534. t['\uFBA0'] = '\u06BB';
  22535. t['\uFBA1'] = '\u06BB';
  22536. t['\uFBA2'] = '\u06BB';
  22537. t['\uFBA3'] = '\u06BB';
  22538. t['\uFBA4'] = '\u06C0';
  22539. t['\uFBA5'] = '\u06C0';
  22540. t['\uFBA6'] = '\u06C1';
  22541. t['\uFBA7'] = '\u06C1';
  22542. t['\uFBA8'] = '\u06C1';
  22543. t['\uFBA9'] = '\u06C1';
  22544. t['\uFBAA'] = '\u06BE';
  22545. t['\uFBAB'] = '\u06BE';
  22546. t['\uFBAC'] = '\u06BE';
  22547. t['\uFBAD'] = '\u06BE';
  22548. t['\uFBAE'] = '\u06D2';
  22549. t['\uFBAF'] = '\u06D2';
  22550. t['\uFBB0'] = '\u06D3';
  22551. t['\uFBB1'] = '\u06D3';
  22552. t['\uFBD3'] = '\u06AD';
  22553. t['\uFBD4'] = '\u06AD';
  22554. t['\uFBD5'] = '\u06AD';
  22555. t['\uFBD6'] = '\u06AD';
  22556. t['\uFBD7'] = '\u06C7';
  22557. t['\uFBD8'] = '\u06C7';
  22558. t['\uFBD9'] = '\u06C6';
  22559. t['\uFBDA'] = '\u06C6';
  22560. t['\uFBDB'] = '\u06C8';
  22561. t['\uFBDC'] = '\u06C8';
  22562. t['\uFBDD'] = '\u0677';
  22563. t['\uFBDE'] = '\u06CB';
  22564. t['\uFBDF'] = '\u06CB';
  22565. t['\uFBE0'] = '\u06C5';
  22566. t['\uFBE1'] = '\u06C5';
  22567. t['\uFBE2'] = '\u06C9';
  22568. t['\uFBE3'] = '\u06C9';
  22569. t['\uFBE4'] = '\u06D0';
  22570. t['\uFBE5'] = '\u06D0';
  22571. t['\uFBE6'] = '\u06D0';
  22572. t['\uFBE7'] = '\u06D0';
  22573. t['\uFBE8'] = '\u0649';
  22574. t['\uFBE9'] = '\u0649';
  22575. t['\uFBEA'] = '\u0626\u0627';
  22576. t['\uFBEB'] = '\u0626\u0627';
  22577. t['\uFBEC'] = '\u0626\u06D5';
  22578. t['\uFBED'] = '\u0626\u06D5';
  22579. t['\uFBEE'] = '\u0626\u0648';
  22580. t['\uFBEF'] = '\u0626\u0648';
  22581. t['\uFBF0'] = '\u0626\u06C7';
  22582. t['\uFBF1'] = '\u0626\u06C7';
  22583. t['\uFBF2'] = '\u0626\u06C6';
  22584. t['\uFBF3'] = '\u0626\u06C6';
  22585. t['\uFBF4'] = '\u0626\u06C8';
  22586. t['\uFBF5'] = '\u0626\u06C8';
  22587. t['\uFBF6'] = '\u0626\u06D0';
  22588. t['\uFBF7'] = '\u0626\u06D0';
  22589. t['\uFBF8'] = '\u0626\u06D0';
  22590. t['\uFBF9'] = '\u0626\u0649';
  22591. t['\uFBFA'] = '\u0626\u0649';
  22592. t['\uFBFB'] = '\u0626\u0649';
  22593. t['\uFBFC'] = '\u06CC';
  22594. t['\uFBFD'] = '\u06CC';
  22595. t['\uFBFE'] = '\u06CC';
  22596. t['\uFBFF'] = '\u06CC';
  22597. t['\uFC00'] = '\u0626\u062C';
  22598. t['\uFC01'] = '\u0626\u062D';
  22599. t['\uFC02'] = '\u0626\u0645';
  22600. t['\uFC03'] = '\u0626\u0649';
  22601. t['\uFC04'] = '\u0626\u064A';
  22602. t['\uFC05'] = '\u0628\u062C';
  22603. t['\uFC06'] = '\u0628\u062D';
  22604. t['\uFC07'] = '\u0628\u062E';
  22605. t['\uFC08'] = '\u0628\u0645';
  22606. t['\uFC09'] = '\u0628\u0649';
  22607. t['\uFC0A'] = '\u0628\u064A';
  22608. t['\uFC0B'] = '\u062A\u062C';
  22609. t['\uFC0C'] = '\u062A\u062D';
  22610. t['\uFC0D'] = '\u062A\u062E';
  22611. t['\uFC0E'] = '\u062A\u0645';
  22612. t['\uFC0F'] = '\u062A\u0649';
  22613. t['\uFC10'] = '\u062A\u064A';
  22614. t['\uFC11'] = '\u062B\u062C';
  22615. t['\uFC12'] = '\u062B\u0645';
  22616. t['\uFC13'] = '\u062B\u0649';
  22617. t['\uFC14'] = '\u062B\u064A';
  22618. t['\uFC15'] = '\u062C\u062D';
  22619. t['\uFC16'] = '\u062C\u0645';
  22620. t['\uFC17'] = '\u062D\u062C';
  22621. t['\uFC18'] = '\u062D\u0645';
  22622. t['\uFC19'] = '\u062E\u062C';
  22623. t['\uFC1A'] = '\u062E\u062D';
  22624. t['\uFC1B'] = '\u062E\u0645';
  22625. t['\uFC1C'] = '\u0633\u062C';
  22626. t['\uFC1D'] = '\u0633\u062D';
  22627. t['\uFC1E'] = '\u0633\u062E';
  22628. t['\uFC1F'] = '\u0633\u0645';
  22629. t['\uFC20'] = '\u0635\u062D';
  22630. t['\uFC21'] = '\u0635\u0645';
  22631. t['\uFC22'] = '\u0636\u062C';
  22632. t['\uFC23'] = '\u0636\u062D';
  22633. t['\uFC24'] = '\u0636\u062E';
  22634. t['\uFC25'] = '\u0636\u0645';
  22635. t['\uFC26'] = '\u0637\u062D';
  22636. t['\uFC27'] = '\u0637\u0645';
  22637. t['\uFC28'] = '\u0638\u0645';
  22638. t['\uFC29'] = '\u0639\u062C';
  22639. t['\uFC2A'] = '\u0639\u0645';
  22640. t['\uFC2B'] = '\u063A\u062C';
  22641. t['\uFC2C'] = '\u063A\u0645';
  22642. t['\uFC2D'] = '\u0641\u062C';
  22643. t['\uFC2E'] = '\u0641\u062D';
  22644. t['\uFC2F'] = '\u0641\u062E';
  22645. t['\uFC30'] = '\u0641\u0645';
  22646. t['\uFC31'] = '\u0641\u0649';
  22647. t['\uFC32'] = '\u0641\u064A';
  22648. t['\uFC33'] = '\u0642\u062D';
  22649. t['\uFC34'] = '\u0642\u0645';
  22650. t['\uFC35'] = '\u0642\u0649';
  22651. t['\uFC36'] = '\u0642\u064A';
  22652. t['\uFC37'] = '\u0643\u0627';
  22653. t['\uFC38'] = '\u0643\u062C';
  22654. t['\uFC39'] = '\u0643\u062D';
  22655. t['\uFC3A'] = '\u0643\u062E';
  22656. t['\uFC3B'] = '\u0643\u0644';
  22657. t['\uFC3C'] = '\u0643\u0645';
  22658. t['\uFC3D'] = '\u0643\u0649';
  22659. t['\uFC3E'] = '\u0643\u064A';
  22660. t['\uFC3F'] = '\u0644\u062C';
  22661. t['\uFC40'] = '\u0644\u062D';
  22662. t['\uFC41'] = '\u0644\u062E';
  22663. t['\uFC42'] = '\u0644\u0645';
  22664. t['\uFC43'] = '\u0644\u0649';
  22665. t['\uFC44'] = '\u0644\u064A';
  22666. t['\uFC45'] = '\u0645\u062C';
  22667. t['\uFC46'] = '\u0645\u062D';
  22668. t['\uFC47'] = '\u0645\u062E';
  22669. t['\uFC48'] = '\u0645\u0645';
  22670. t['\uFC49'] = '\u0645\u0649';
  22671. t['\uFC4A'] = '\u0645\u064A';
  22672. t['\uFC4B'] = '\u0646\u062C';
  22673. t['\uFC4C'] = '\u0646\u062D';
  22674. t['\uFC4D'] = '\u0646\u062E';
  22675. t['\uFC4E'] = '\u0646\u0645';
  22676. t['\uFC4F'] = '\u0646\u0649';
  22677. t['\uFC50'] = '\u0646\u064A';
  22678. t['\uFC51'] = '\u0647\u062C';
  22679. t['\uFC52'] = '\u0647\u0645';
  22680. t['\uFC53'] = '\u0647\u0649';
  22681. t['\uFC54'] = '\u0647\u064A';
  22682. t['\uFC55'] = '\u064A\u062C';
  22683. t['\uFC56'] = '\u064A\u062D';
  22684. t['\uFC57'] = '\u064A\u062E';
  22685. t['\uFC58'] = '\u064A\u0645';
  22686. t['\uFC59'] = '\u064A\u0649';
  22687. t['\uFC5A'] = '\u064A\u064A';
  22688. t['\uFC5B'] = '\u0630\u0670';
  22689. t['\uFC5C'] = '\u0631\u0670';
  22690. t['\uFC5D'] = '\u0649\u0670';
  22691. t['\uFC5E'] = '\u0020\u064C\u0651';
  22692. t['\uFC5F'] = '\u0020\u064D\u0651';
  22693. t['\uFC60'] = '\u0020\u064E\u0651';
  22694. t['\uFC61'] = '\u0020\u064F\u0651';
  22695. t['\uFC62'] = '\u0020\u0650\u0651';
  22696. t['\uFC63'] = '\u0020\u0651\u0670';
  22697. t['\uFC64'] = '\u0626\u0631';
  22698. t['\uFC65'] = '\u0626\u0632';
  22699. t['\uFC66'] = '\u0626\u0645';
  22700. t['\uFC67'] = '\u0626\u0646';
  22701. t['\uFC68'] = '\u0626\u0649';
  22702. t['\uFC69'] = '\u0626\u064A';
  22703. t['\uFC6A'] = '\u0628\u0631';
  22704. t['\uFC6B'] = '\u0628\u0632';
  22705. t['\uFC6C'] = '\u0628\u0645';
  22706. t['\uFC6D'] = '\u0628\u0646';
  22707. t['\uFC6E'] = '\u0628\u0649';
  22708. t['\uFC6F'] = '\u0628\u064A';
  22709. t['\uFC70'] = '\u062A\u0631';
  22710. t['\uFC71'] = '\u062A\u0632';
  22711. t['\uFC72'] = '\u062A\u0645';
  22712. t['\uFC73'] = '\u062A\u0646';
  22713. t['\uFC74'] = '\u062A\u0649';
  22714. t['\uFC75'] = '\u062A\u064A';
  22715. t['\uFC76'] = '\u062B\u0631';
  22716. t['\uFC77'] = '\u062B\u0632';
  22717. t['\uFC78'] = '\u062B\u0645';
  22718. t['\uFC79'] = '\u062B\u0646';
  22719. t['\uFC7A'] = '\u062B\u0649';
  22720. t['\uFC7B'] = '\u062B\u064A';
  22721. t['\uFC7C'] = '\u0641\u0649';
  22722. t['\uFC7D'] = '\u0641\u064A';
  22723. t['\uFC7E'] = '\u0642\u0649';
  22724. t['\uFC7F'] = '\u0642\u064A';
  22725. t['\uFC80'] = '\u0643\u0627';
  22726. t['\uFC81'] = '\u0643\u0644';
  22727. t['\uFC82'] = '\u0643\u0645';
  22728. t['\uFC83'] = '\u0643\u0649';
  22729. t['\uFC84'] = '\u0643\u064A';
  22730. t['\uFC85'] = '\u0644\u0645';
  22731. t['\uFC86'] = '\u0644\u0649';
  22732. t['\uFC87'] = '\u0644\u064A';
  22733. t['\uFC88'] = '\u0645\u0627';
  22734. t['\uFC89'] = '\u0645\u0645';
  22735. t['\uFC8A'] = '\u0646\u0631';
  22736. t['\uFC8B'] = '\u0646\u0632';
  22737. t['\uFC8C'] = '\u0646\u0645';
  22738. t['\uFC8D'] = '\u0646\u0646';
  22739. t['\uFC8E'] = '\u0646\u0649';
  22740. t['\uFC8F'] = '\u0646\u064A';
  22741. t['\uFC90'] = '\u0649\u0670';
  22742. t['\uFC91'] = '\u064A\u0631';
  22743. t['\uFC92'] = '\u064A\u0632';
  22744. t['\uFC93'] = '\u064A\u0645';
  22745. t['\uFC94'] = '\u064A\u0646';
  22746. t['\uFC95'] = '\u064A\u0649';
  22747. t['\uFC96'] = '\u064A\u064A';
  22748. t['\uFC97'] = '\u0626\u062C';
  22749. t['\uFC98'] = '\u0626\u062D';
  22750. t['\uFC99'] = '\u0626\u062E';
  22751. t['\uFC9A'] = '\u0626\u0645';
  22752. t['\uFC9B'] = '\u0626\u0647';
  22753. t['\uFC9C'] = '\u0628\u062C';
  22754. t['\uFC9D'] = '\u0628\u062D';
  22755. t['\uFC9E'] = '\u0628\u062E';
  22756. t['\uFC9F'] = '\u0628\u0645';
  22757. t['\uFCA0'] = '\u0628\u0647';
  22758. t['\uFCA1'] = '\u062A\u062C';
  22759. t['\uFCA2'] = '\u062A\u062D';
  22760. t['\uFCA3'] = '\u062A\u062E';
  22761. t['\uFCA4'] = '\u062A\u0645';
  22762. t['\uFCA5'] = '\u062A\u0647';
  22763. t['\uFCA6'] = '\u062B\u0645';
  22764. t['\uFCA7'] = '\u062C\u062D';
  22765. t['\uFCA8'] = '\u062C\u0645';
  22766. t['\uFCA9'] = '\u062D\u062C';
  22767. t['\uFCAA'] = '\u062D\u0645';
  22768. t['\uFCAB'] = '\u062E\u062C';
  22769. t['\uFCAC'] = '\u062E\u0645';
  22770. t['\uFCAD'] = '\u0633\u062C';
  22771. t['\uFCAE'] = '\u0633\u062D';
  22772. t['\uFCAF'] = '\u0633\u062E';
  22773. t['\uFCB0'] = '\u0633\u0645';
  22774. t['\uFCB1'] = '\u0635\u062D';
  22775. t['\uFCB2'] = '\u0635\u062E';
  22776. t['\uFCB3'] = '\u0635\u0645';
  22777. t['\uFCB4'] = '\u0636\u062C';
  22778. t['\uFCB5'] = '\u0636\u062D';
  22779. t['\uFCB6'] = '\u0636\u062E';
  22780. t['\uFCB7'] = '\u0636\u0645';
  22781. t['\uFCB8'] = '\u0637\u062D';
  22782. t['\uFCB9'] = '\u0638\u0645';
  22783. t['\uFCBA'] = '\u0639\u062C';
  22784. t['\uFCBB'] = '\u0639\u0645';
  22785. t['\uFCBC'] = '\u063A\u062C';
  22786. t['\uFCBD'] = '\u063A\u0645';
  22787. t['\uFCBE'] = '\u0641\u062C';
  22788. t['\uFCBF'] = '\u0641\u062D';
  22789. t['\uFCC0'] = '\u0641\u062E';
  22790. t['\uFCC1'] = '\u0641\u0645';
  22791. t['\uFCC2'] = '\u0642\u062D';
  22792. t['\uFCC3'] = '\u0642\u0645';
  22793. t['\uFCC4'] = '\u0643\u062C';
  22794. t['\uFCC5'] = '\u0643\u062D';
  22795. t['\uFCC6'] = '\u0643\u062E';
  22796. t['\uFCC7'] = '\u0643\u0644';
  22797. t['\uFCC8'] = '\u0643\u0645';
  22798. t['\uFCC9'] = '\u0644\u062C';
  22799. t['\uFCCA'] = '\u0644\u062D';
  22800. t['\uFCCB'] = '\u0644\u062E';
  22801. t['\uFCCC'] = '\u0644\u0645';
  22802. t['\uFCCD'] = '\u0644\u0647';
  22803. t['\uFCCE'] = '\u0645\u062C';
  22804. t['\uFCCF'] = '\u0645\u062D';
  22805. t['\uFCD0'] = '\u0645\u062E';
  22806. t['\uFCD1'] = '\u0645\u0645';
  22807. t['\uFCD2'] = '\u0646\u062C';
  22808. t['\uFCD3'] = '\u0646\u062D';
  22809. t['\uFCD4'] = '\u0646\u062E';
  22810. t['\uFCD5'] = '\u0646\u0645';
  22811. t['\uFCD6'] = '\u0646\u0647';
  22812. t['\uFCD7'] = '\u0647\u062C';
  22813. t['\uFCD8'] = '\u0647\u0645';
  22814. t['\uFCD9'] = '\u0647\u0670';
  22815. t['\uFCDA'] = '\u064A\u062C';
  22816. t['\uFCDB'] = '\u064A\u062D';
  22817. t['\uFCDC'] = '\u064A\u062E';
  22818. t['\uFCDD'] = '\u064A\u0645';
  22819. t['\uFCDE'] = '\u064A\u0647';
  22820. t['\uFCDF'] = '\u0626\u0645';
  22821. t['\uFCE0'] = '\u0626\u0647';
  22822. t['\uFCE1'] = '\u0628\u0645';
  22823. t['\uFCE2'] = '\u0628\u0647';
  22824. t['\uFCE3'] = '\u062A\u0645';
  22825. t['\uFCE4'] = '\u062A\u0647';
  22826. t['\uFCE5'] = '\u062B\u0645';
  22827. t['\uFCE6'] = '\u062B\u0647';
  22828. t['\uFCE7'] = '\u0633\u0645';
  22829. t['\uFCE8'] = '\u0633\u0647';
  22830. t['\uFCE9'] = '\u0634\u0645';
  22831. t['\uFCEA'] = '\u0634\u0647';
  22832. t['\uFCEB'] = '\u0643\u0644';
  22833. t['\uFCEC'] = '\u0643\u0645';
  22834. t['\uFCED'] = '\u0644\u0645';
  22835. t['\uFCEE'] = '\u0646\u0645';
  22836. t['\uFCEF'] = '\u0646\u0647';
  22837. t['\uFCF0'] = '\u064A\u0645';
  22838. t['\uFCF1'] = '\u064A\u0647';
  22839. t['\uFCF2'] = '\u0640\u064E\u0651';
  22840. t['\uFCF3'] = '\u0640\u064F\u0651';
  22841. t['\uFCF4'] = '\u0640\u0650\u0651';
  22842. t['\uFCF5'] = '\u0637\u0649';
  22843. t['\uFCF6'] = '\u0637\u064A';
  22844. t['\uFCF7'] = '\u0639\u0649';
  22845. t['\uFCF8'] = '\u0639\u064A';
  22846. t['\uFCF9'] = '\u063A\u0649';
  22847. t['\uFCFA'] = '\u063A\u064A';
  22848. t['\uFCFB'] = '\u0633\u0649';
  22849. t['\uFCFC'] = '\u0633\u064A';
  22850. t['\uFCFD'] = '\u0634\u0649';
  22851. t['\uFCFE'] = '\u0634\u064A';
  22852. t['\uFCFF'] = '\u062D\u0649';
  22853. t['\uFD00'] = '\u062D\u064A';
  22854. t['\uFD01'] = '\u062C\u0649';
  22855. t['\uFD02'] = '\u062C\u064A';
  22856. t['\uFD03'] = '\u062E\u0649';
  22857. t['\uFD04'] = '\u062E\u064A';
  22858. t['\uFD05'] = '\u0635\u0649';
  22859. t['\uFD06'] = '\u0635\u064A';
  22860. t['\uFD07'] = '\u0636\u0649';
  22861. t['\uFD08'] = '\u0636\u064A';
  22862. t['\uFD09'] = '\u0634\u062C';
  22863. t['\uFD0A'] = '\u0634\u062D';
  22864. t['\uFD0B'] = '\u0634\u062E';
  22865. t['\uFD0C'] = '\u0634\u0645';
  22866. t['\uFD0D'] = '\u0634\u0631';
  22867. t['\uFD0E'] = '\u0633\u0631';
  22868. t['\uFD0F'] = '\u0635\u0631';
  22869. t['\uFD10'] = '\u0636\u0631';
  22870. t['\uFD11'] = '\u0637\u0649';
  22871. t['\uFD12'] = '\u0637\u064A';
  22872. t['\uFD13'] = '\u0639\u0649';
  22873. t['\uFD14'] = '\u0639\u064A';
  22874. t['\uFD15'] = '\u063A\u0649';
  22875. t['\uFD16'] = '\u063A\u064A';
  22876. t['\uFD17'] = '\u0633\u0649';
  22877. t['\uFD18'] = '\u0633\u064A';
  22878. t['\uFD19'] = '\u0634\u0649';
  22879. t['\uFD1A'] = '\u0634\u064A';
  22880. t['\uFD1B'] = '\u062D\u0649';
  22881. t['\uFD1C'] = '\u062D\u064A';
  22882. t['\uFD1D'] = '\u062C\u0649';
  22883. t['\uFD1E'] = '\u062C\u064A';
  22884. t['\uFD1F'] = '\u062E\u0649';
  22885. t['\uFD20'] = '\u062E\u064A';
  22886. t['\uFD21'] = '\u0635\u0649';
  22887. t['\uFD22'] = '\u0635\u064A';
  22888. t['\uFD23'] = '\u0636\u0649';
  22889. t['\uFD24'] = '\u0636\u064A';
  22890. t['\uFD25'] = '\u0634\u062C';
  22891. t['\uFD26'] = '\u0634\u062D';
  22892. t['\uFD27'] = '\u0634\u062E';
  22893. t['\uFD28'] = '\u0634\u0645';
  22894. t['\uFD29'] = '\u0634\u0631';
  22895. t['\uFD2A'] = '\u0633\u0631';
  22896. t['\uFD2B'] = '\u0635\u0631';
  22897. t['\uFD2C'] = '\u0636\u0631';
  22898. t['\uFD2D'] = '\u0634\u062C';
  22899. t['\uFD2E'] = '\u0634\u062D';
  22900. t['\uFD2F'] = '\u0634\u062E';
  22901. t['\uFD30'] = '\u0634\u0645';
  22902. t['\uFD31'] = '\u0633\u0647';
  22903. t['\uFD32'] = '\u0634\u0647';
  22904. t['\uFD33'] = '\u0637\u0645';
  22905. t['\uFD34'] = '\u0633\u062C';
  22906. t['\uFD35'] = '\u0633\u062D';
  22907. t['\uFD36'] = '\u0633\u062E';
  22908. t['\uFD37'] = '\u0634\u062C';
  22909. t['\uFD38'] = '\u0634\u062D';
  22910. t['\uFD39'] = '\u0634\u062E';
  22911. t['\uFD3A'] = '\u0637\u0645';
  22912. t['\uFD3B'] = '\u0638\u0645';
  22913. t['\uFD3C'] = '\u0627\u064B';
  22914. t['\uFD3D'] = '\u0627\u064B';
  22915. t['\uFD50'] = '\u062A\u062C\u0645';
  22916. t['\uFD51'] = '\u062A\u062D\u062C';
  22917. t['\uFD52'] = '\u062A\u062D\u062C';
  22918. t['\uFD53'] = '\u062A\u062D\u0645';
  22919. t['\uFD54'] = '\u062A\u062E\u0645';
  22920. t['\uFD55'] = '\u062A\u0645\u062C';
  22921. t['\uFD56'] = '\u062A\u0645\u062D';
  22922. t['\uFD57'] = '\u062A\u0645\u062E';
  22923. t['\uFD58'] = '\u062C\u0645\u062D';
  22924. t['\uFD59'] = '\u062C\u0645\u062D';
  22925. t['\uFD5A'] = '\u062D\u0645\u064A';
  22926. t['\uFD5B'] = '\u062D\u0645\u0649';
  22927. t['\uFD5C'] = '\u0633\u062D\u062C';
  22928. t['\uFD5D'] = '\u0633\u062C\u062D';
  22929. t['\uFD5E'] = '\u0633\u062C\u0649';
  22930. t['\uFD5F'] = '\u0633\u0645\u062D';
  22931. t['\uFD60'] = '\u0633\u0645\u062D';
  22932. t['\uFD61'] = '\u0633\u0645\u062C';
  22933. t['\uFD62'] = '\u0633\u0645\u0645';
  22934. t['\uFD63'] = '\u0633\u0645\u0645';
  22935. t['\uFD64'] = '\u0635\u062D\u062D';
  22936. t['\uFD65'] = '\u0635\u062D\u062D';
  22937. t['\uFD66'] = '\u0635\u0645\u0645';
  22938. t['\uFD67'] = '\u0634\u062D\u0645';
  22939. t['\uFD68'] = '\u0634\u062D\u0645';
  22940. t['\uFD69'] = '\u0634\u062C\u064A';
  22941. t['\uFD6A'] = '\u0634\u0645\u062E';
  22942. t['\uFD6B'] = '\u0634\u0645\u062E';
  22943. t['\uFD6C'] = '\u0634\u0645\u0645';
  22944. t['\uFD6D'] = '\u0634\u0645\u0645';
  22945. t['\uFD6E'] = '\u0636\u062D\u0649';
  22946. t['\uFD6F'] = '\u0636\u062E\u0645';
  22947. t['\uFD70'] = '\u0636\u062E\u0645';
  22948. t['\uFD71'] = '\u0637\u0645\u062D';
  22949. t['\uFD72'] = '\u0637\u0645\u062D';
  22950. t['\uFD73'] = '\u0637\u0645\u0645';
  22951. t['\uFD74'] = '\u0637\u0645\u064A';
  22952. t['\uFD75'] = '\u0639\u062C\u0645';
  22953. t['\uFD76'] = '\u0639\u0645\u0645';
  22954. t['\uFD77'] = '\u0639\u0645\u0645';
  22955. t['\uFD78'] = '\u0639\u0645\u0649';
  22956. t['\uFD79'] = '\u063A\u0645\u0645';
  22957. t['\uFD7A'] = '\u063A\u0645\u064A';
  22958. t['\uFD7B'] = '\u063A\u0645\u0649';
  22959. t['\uFD7C'] = '\u0641\u062E\u0645';
  22960. t['\uFD7D'] = '\u0641\u062E\u0645';
  22961. t['\uFD7E'] = '\u0642\u0645\u062D';
  22962. t['\uFD7F'] = '\u0642\u0645\u0645';
  22963. t['\uFD80'] = '\u0644\u062D\u0645';
  22964. t['\uFD81'] = '\u0644\u062D\u064A';
  22965. t['\uFD82'] = '\u0644\u062D\u0649';
  22966. t['\uFD83'] = '\u0644\u062C\u062C';
  22967. t['\uFD84'] = '\u0644\u062C\u062C';
  22968. t['\uFD85'] = '\u0644\u062E\u0645';
  22969. t['\uFD86'] = '\u0644\u062E\u0645';
  22970. t['\uFD87'] = '\u0644\u0645\u062D';
  22971. t['\uFD88'] = '\u0644\u0645\u062D';
  22972. t['\uFD89'] = '\u0645\u062D\u062C';
  22973. t['\uFD8A'] = '\u0645\u062D\u0645';
  22974. t['\uFD8B'] = '\u0645\u062D\u064A';
  22975. t['\uFD8C'] = '\u0645\u062C\u062D';
  22976. t['\uFD8D'] = '\u0645\u062C\u0645';
  22977. t['\uFD8E'] = '\u0645\u062E\u062C';
  22978. t['\uFD8F'] = '\u0645\u062E\u0645';
  22979. t['\uFD92'] = '\u0645\u062C\u062E';
  22980. t['\uFD93'] = '\u0647\u0645\u062C';
  22981. t['\uFD94'] = '\u0647\u0645\u0645';
  22982. t['\uFD95'] = '\u0646\u062D\u0645';
  22983. t['\uFD96'] = '\u0646\u062D\u0649';
  22984. t['\uFD97'] = '\u0646\u062C\u0645';
  22985. t['\uFD98'] = '\u0646\u062C\u0645';
  22986. t['\uFD99'] = '\u0646\u062C\u0649';
  22987. t['\uFD9A'] = '\u0646\u0645\u064A';
  22988. t['\uFD9B'] = '\u0646\u0645\u0649';
  22989. t['\uFD9C'] = '\u064A\u0645\u0645';
  22990. t['\uFD9D'] = '\u064A\u0645\u0645';
  22991. t['\uFD9E'] = '\u0628\u062E\u064A';
  22992. t['\uFD9F'] = '\u062A\u062C\u064A';
  22993. t['\uFDA0'] = '\u062A\u062C\u0649';
  22994. t['\uFDA1'] = '\u062A\u062E\u064A';
  22995. t['\uFDA2'] = '\u062A\u062E\u0649';
  22996. t['\uFDA3'] = '\u062A\u0645\u064A';
  22997. t['\uFDA4'] = '\u062A\u0645\u0649';
  22998. t['\uFDA5'] = '\u062C\u0645\u064A';
  22999. t['\uFDA6'] = '\u062C\u062D\u0649';
  23000. t['\uFDA7'] = '\u062C\u0645\u0649';
  23001. t['\uFDA8'] = '\u0633\u062E\u0649';
  23002. t['\uFDA9'] = '\u0635\u062D\u064A';
  23003. t['\uFDAA'] = '\u0634\u062D\u064A';
  23004. t['\uFDAB'] = '\u0636\u062D\u064A';
  23005. t['\uFDAC'] = '\u0644\u062C\u064A';
  23006. t['\uFDAD'] = '\u0644\u0645\u064A';
  23007. t['\uFDAE'] = '\u064A\u062D\u064A';
  23008. t['\uFDAF'] = '\u064A\u062C\u064A';
  23009. t['\uFDB0'] = '\u064A\u0645\u064A';
  23010. t['\uFDB1'] = '\u0645\u0645\u064A';
  23011. t['\uFDB2'] = '\u0642\u0645\u064A';
  23012. t['\uFDB3'] = '\u0646\u062D\u064A';
  23013. t['\uFDB4'] = '\u0642\u0645\u062D';
  23014. t['\uFDB5'] = '\u0644\u062D\u0645';
  23015. t['\uFDB6'] = '\u0639\u0645\u064A';
  23016. t['\uFDB7'] = '\u0643\u0645\u064A';
  23017. t['\uFDB8'] = '\u0646\u062C\u062D';
  23018. t['\uFDB9'] = '\u0645\u062E\u064A';
  23019. t['\uFDBA'] = '\u0644\u062C\u0645';
  23020. t['\uFDBB'] = '\u0643\u0645\u0645';
  23021. t['\uFDBC'] = '\u0644\u062C\u0645';
  23022. t['\uFDBD'] = '\u0646\u062C\u062D';
  23023. t['\uFDBE'] = '\u062C\u062D\u064A';
  23024. t['\uFDBF'] = '\u062D\u062C\u064A';
  23025. t['\uFDC0'] = '\u0645\u062C\u064A';
  23026. t['\uFDC1'] = '\u0641\u0645\u064A';
  23027. t['\uFDC2'] = '\u0628\u062D\u064A';
  23028. t['\uFDC3'] = '\u0643\u0645\u0645';
  23029. t['\uFDC4'] = '\u0639\u062C\u0645';
  23030. t['\uFDC5'] = '\u0635\u0645\u0645';
  23031. t['\uFDC6'] = '\u0633\u062E\u064A';
  23032. t['\uFDC7'] = '\u0646\u062C\u064A';
  23033. t['\uFE49'] = '\u203E';
  23034. t['\uFE4A'] = '\u203E';
  23035. t['\uFE4B'] = '\u203E';
  23036. t['\uFE4C'] = '\u203E';
  23037. t['\uFE4D'] = '\u005F';
  23038. t['\uFE4E'] = '\u005F';
  23039. t['\uFE4F'] = '\u005F';
  23040. t['\uFE80'] = '\u0621';
  23041. t['\uFE81'] = '\u0622';
  23042. t['\uFE82'] = '\u0622';
  23043. t['\uFE83'] = '\u0623';
  23044. t['\uFE84'] = '\u0623';
  23045. t['\uFE85'] = '\u0624';
  23046. t['\uFE86'] = '\u0624';
  23047. t['\uFE87'] = '\u0625';
  23048. t['\uFE88'] = '\u0625';
  23049. t['\uFE89'] = '\u0626';
  23050. t['\uFE8A'] = '\u0626';
  23051. t['\uFE8B'] = '\u0626';
  23052. t['\uFE8C'] = '\u0626';
  23053. t['\uFE8D'] = '\u0627';
  23054. t['\uFE8E'] = '\u0627';
  23055. t['\uFE8F'] = '\u0628';
  23056. t['\uFE90'] = '\u0628';
  23057. t['\uFE91'] = '\u0628';
  23058. t['\uFE92'] = '\u0628';
  23059. t['\uFE93'] = '\u0629';
  23060. t['\uFE94'] = '\u0629';
  23061. t['\uFE95'] = '\u062A';
  23062. t['\uFE96'] = '\u062A';
  23063. t['\uFE97'] = '\u062A';
  23064. t['\uFE98'] = '\u062A';
  23065. t['\uFE99'] = '\u062B';
  23066. t['\uFE9A'] = '\u062B';
  23067. t['\uFE9B'] = '\u062B';
  23068. t['\uFE9C'] = '\u062B';
  23069. t['\uFE9D'] = '\u062C';
  23070. t['\uFE9E'] = '\u062C';
  23071. t['\uFE9F'] = '\u062C';
  23072. t['\uFEA0'] = '\u062C';
  23073. t['\uFEA1'] = '\u062D';
  23074. t['\uFEA2'] = '\u062D';
  23075. t['\uFEA3'] = '\u062D';
  23076. t['\uFEA4'] = '\u062D';
  23077. t['\uFEA5'] = '\u062E';
  23078. t['\uFEA6'] = '\u062E';
  23079. t['\uFEA7'] = '\u062E';
  23080. t['\uFEA8'] = '\u062E';
  23081. t['\uFEA9'] = '\u062F';
  23082. t['\uFEAA'] = '\u062F';
  23083. t['\uFEAB'] = '\u0630';
  23084. t['\uFEAC'] = '\u0630';
  23085. t['\uFEAD'] = '\u0631';
  23086. t['\uFEAE'] = '\u0631';
  23087. t['\uFEAF'] = '\u0632';
  23088. t['\uFEB0'] = '\u0632';
  23089. t['\uFEB1'] = '\u0633';
  23090. t['\uFEB2'] = '\u0633';
  23091. t['\uFEB3'] = '\u0633';
  23092. t['\uFEB4'] = '\u0633';
  23093. t['\uFEB5'] = '\u0634';
  23094. t['\uFEB6'] = '\u0634';
  23095. t['\uFEB7'] = '\u0634';
  23096. t['\uFEB8'] = '\u0634';
  23097. t['\uFEB9'] = '\u0635';
  23098. t['\uFEBA'] = '\u0635';
  23099. t['\uFEBB'] = '\u0635';
  23100. t['\uFEBC'] = '\u0635';
  23101. t['\uFEBD'] = '\u0636';
  23102. t['\uFEBE'] = '\u0636';
  23103. t['\uFEBF'] = '\u0636';
  23104. t['\uFEC0'] = '\u0636';
  23105. t['\uFEC1'] = '\u0637';
  23106. t['\uFEC2'] = '\u0637';
  23107. t['\uFEC3'] = '\u0637';
  23108. t['\uFEC4'] = '\u0637';
  23109. t['\uFEC5'] = '\u0638';
  23110. t['\uFEC6'] = '\u0638';
  23111. t['\uFEC7'] = '\u0638';
  23112. t['\uFEC8'] = '\u0638';
  23113. t['\uFEC9'] = '\u0639';
  23114. t['\uFECA'] = '\u0639';
  23115. t['\uFECB'] = '\u0639';
  23116. t['\uFECC'] = '\u0639';
  23117. t['\uFECD'] = '\u063A';
  23118. t['\uFECE'] = '\u063A';
  23119. t['\uFECF'] = '\u063A';
  23120. t['\uFED0'] = '\u063A';
  23121. t['\uFED1'] = '\u0641';
  23122. t['\uFED2'] = '\u0641';
  23123. t['\uFED3'] = '\u0641';
  23124. t['\uFED4'] = '\u0641';
  23125. t['\uFED5'] = '\u0642';
  23126. t['\uFED6'] = '\u0642';
  23127. t['\uFED7'] = '\u0642';
  23128. t['\uFED8'] = '\u0642';
  23129. t['\uFED9'] = '\u0643';
  23130. t['\uFEDA'] = '\u0643';
  23131. t['\uFEDB'] = '\u0643';
  23132. t['\uFEDC'] = '\u0643';
  23133. t['\uFEDD'] = '\u0644';
  23134. t['\uFEDE'] = '\u0644';
  23135. t['\uFEDF'] = '\u0644';
  23136. t['\uFEE0'] = '\u0644';
  23137. t['\uFEE1'] = '\u0645';
  23138. t['\uFEE2'] = '\u0645';
  23139. t['\uFEE3'] = '\u0645';
  23140. t['\uFEE4'] = '\u0645';
  23141. t['\uFEE5'] = '\u0646';
  23142. t['\uFEE6'] = '\u0646';
  23143. t['\uFEE7'] = '\u0646';
  23144. t['\uFEE8'] = '\u0646';
  23145. t['\uFEE9'] = '\u0647';
  23146. t['\uFEEA'] = '\u0647';
  23147. t['\uFEEB'] = '\u0647';
  23148. t['\uFEEC'] = '\u0647';
  23149. t['\uFEED'] = '\u0648';
  23150. t['\uFEEE'] = '\u0648';
  23151. t['\uFEEF'] = '\u0649';
  23152. t['\uFEF0'] = '\u0649';
  23153. t['\uFEF1'] = '\u064A';
  23154. t['\uFEF2'] = '\u064A';
  23155. t['\uFEF3'] = '\u064A';
  23156. t['\uFEF4'] = '\u064A';
  23157. t['\uFEF5'] = '\u0644\u0622';
  23158. t['\uFEF6'] = '\u0644\u0622';
  23159. t['\uFEF7'] = '\u0644\u0623';
  23160. t['\uFEF8'] = '\u0644\u0623';
  23161. t['\uFEF9'] = '\u0644\u0625';
  23162. t['\uFEFA'] = '\u0644\u0625';
  23163. t['\uFEFB'] = '\u0644\u0627';
  23164. t['\uFEFC'] = '\u0644\u0627';
  23165. });
  23166. function reverseIfRtl(chars) {
  23167. var charsLength = chars.length;
  23168. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23169. return chars;
  23170. }
  23171. var s = '';
  23172. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23173. s += chars[ii];
  23174. }
  23175. return s;
  23176. }
  23177. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23178. exports.reverseIfRtl = reverseIfRtl;
  23179. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23180. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23181. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23182. }));
  23183. (function (root, factory) {
  23184. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  23185. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  23186. var Util = sharedUtil.Util;
  23187. var error = sharedUtil.error;
  23188. var info = sharedUtil.info;
  23189. var isInt = sharedUtil.isInt;
  23190. var isArray = sharedUtil.isArray;
  23191. var createObjectURL = sharedUtil.createObjectURL;
  23192. var shadow = sharedUtil.shadow;
  23193. var warn = sharedUtil.warn;
  23194. var isSpace = sharedUtil.isSpace;
  23195. var Dict = corePrimitives.Dict;
  23196. var isDict = corePrimitives.isDict;
  23197. var isStream = corePrimitives.isStream;
  23198. var Jbig2Image = coreJbig2.Jbig2Image;
  23199. var JpegImage = coreJpg.JpegImage;
  23200. var JpxImage = coreJpx.JpxImage;
  23201. var Stream = function StreamClosure() {
  23202. function Stream(arrayBuffer, start, length, dict) {
  23203. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  23204. this.start = start || 0;
  23205. this.pos = this.start;
  23206. this.end = start + length || this.bytes.length;
  23207. this.dict = dict;
  23208. }
  23209. Stream.prototype = {
  23210. get length() {
  23211. return this.end - this.start;
  23212. },
  23213. get isEmpty() {
  23214. return this.length === 0;
  23215. },
  23216. getByte: function Stream_getByte() {
  23217. if (this.pos >= this.end) {
  23218. return -1;
  23219. }
  23220. return this.bytes[this.pos++];
  23221. },
  23222. getUint16: function Stream_getUint16() {
  23223. var b0 = this.getByte();
  23224. var b1 = this.getByte();
  23225. if (b0 === -1 || b1 === -1) {
  23226. return -1;
  23227. }
  23228. return (b0 << 8) + b1;
  23229. },
  23230. getInt32: function Stream_getInt32() {
  23231. var b0 = this.getByte();
  23232. var b1 = this.getByte();
  23233. var b2 = this.getByte();
  23234. var b3 = this.getByte();
  23235. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  23236. },
  23237. getBytes: function Stream_getBytes(length) {
  23238. var bytes = this.bytes;
  23239. var pos = this.pos;
  23240. var strEnd = this.end;
  23241. if (!length) {
  23242. return bytes.subarray(pos, strEnd);
  23243. }
  23244. var end = pos + length;
  23245. if (end > strEnd) {
  23246. end = strEnd;
  23247. }
  23248. this.pos = end;
  23249. return bytes.subarray(pos, end);
  23250. },
  23251. peekByte: function Stream_peekByte() {
  23252. var peekedByte = this.getByte();
  23253. this.pos--;
  23254. return peekedByte;
  23255. },
  23256. peekBytes: function Stream_peekBytes(length) {
  23257. var bytes = this.getBytes(length);
  23258. this.pos -= bytes.length;
  23259. return bytes;
  23260. },
  23261. skip: function Stream_skip(n) {
  23262. if (!n) {
  23263. n = 1;
  23264. }
  23265. this.pos += n;
  23266. },
  23267. reset: function Stream_reset() {
  23268. this.pos = this.start;
  23269. },
  23270. moveStart: function Stream_moveStart() {
  23271. this.start = this.pos;
  23272. },
  23273. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  23274. return new Stream(this.bytes.buffer, start, length, dict);
  23275. },
  23276. isStream: true
  23277. };
  23278. return Stream;
  23279. }();
  23280. var StringStream = function StringStreamClosure() {
  23281. function StringStream(str) {
  23282. var length = str.length;
  23283. var bytes = new Uint8Array(length);
  23284. for (var n = 0; n < length; ++n) {
  23285. bytes[n] = str.charCodeAt(n);
  23286. }
  23287. Stream.call(this, bytes);
  23288. }
  23289. StringStream.prototype = Stream.prototype;
  23290. return StringStream;
  23291. }();
  23292. var DecodeStream = function DecodeStreamClosure() {
  23293. var emptyBuffer = new Uint8Array(0);
  23294. function DecodeStream(maybeMinBufferLength) {
  23295. this.pos = 0;
  23296. this.bufferLength = 0;
  23297. this.eof = false;
  23298. this.buffer = emptyBuffer;
  23299. this.minBufferLength = 512;
  23300. if (maybeMinBufferLength) {
  23301. while (this.minBufferLength < maybeMinBufferLength) {
  23302. this.minBufferLength *= 2;
  23303. }
  23304. }
  23305. }
  23306. DecodeStream.prototype = {
  23307. get isEmpty() {
  23308. while (!this.eof && this.bufferLength === 0) {
  23309. this.readBlock();
  23310. }
  23311. return this.bufferLength === 0;
  23312. },
  23313. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  23314. var buffer = this.buffer;
  23315. if (requested <= buffer.byteLength) {
  23316. return buffer;
  23317. }
  23318. var size = this.minBufferLength;
  23319. while (size < requested) {
  23320. size *= 2;
  23321. }
  23322. var buffer2 = new Uint8Array(size);
  23323. buffer2.set(buffer);
  23324. return this.buffer = buffer2;
  23325. },
  23326. getByte: function DecodeStream_getByte() {
  23327. var pos = this.pos;
  23328. while (this.bufferLength <= pos) {
  23329. if (this.eof) {
  23330. return -1;
  23331. }
  23332. this.readBlock();
  23333. }
  23334. return this.buffer[this.pos++];
  23335. },
  23336. getUint16: function DecodeStream_getUint16() {
  23337. var b0 = this.getByte();
  23338. var b1 = this.getByte();
  23339. if (b0 === -1 || b1 === -1) {
  23340. return -1;
  23341. }
  23342. return (b0 << 8) + b1;
  23343. },
  23344. getInt32: function DecodeStream_getInt32() {
  23345. var b0 = this.getByte();
  23346. var b1 = this.getByte();
  23347. var b2 = this.getByte();
  23348. var b3 = this.getByte();
  23349. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  23350. },
  23351. getBytes: function DecodeStream_getBytes(length) {
  23352. var end, pos = this.pos;
  23353. if (length) {
  23354. this.ensureBuffer(pos + length);
  23355. end = pos + length;
  23356. while (!this.eof && this.bufferLength < end) {
  23357. this.readBlock();
  23358. }
  23359. var bufEnd = this.bufferLength;
  23360. if (end > bufEnd) {
  23361. end = bufEnd;
  23362. }
  23363. } else {
  23364. while (!this.eof) {
  23365. this.readBlock();
  23366. }
  23367. end = this.bufferLength;
  23368. }
  23369. this.pos = end;
  23370. return this.buffer.subarray(pos, end);
  23371. },
  23372. peekByte: function DecodeStream_peekByte() {
  23373. var peekedByte = this.getByte();
  23374. this.pos--;
  23375. return peekedByte;
  23376. },
  23377. peekBytes: function DecodeStream_peekBytes(length) {
  23378. var bytes = this.getBytes(length);
  23379. this.pos -= bytes.length;
  23380. return bytes;
  23381. },
  23382. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  23383. var end = start + length;
  23384. while (this.bufferLength <= end && !this.eof) {
  23385. this.readBlock();
  23386. }
  23387. return new Stream(this.buffer, start, length, dict);
  23388. },
  23389. skip: function DecodeStream_skip(n) {
  23390. if (!n) {
  23391. n = 1;
  23392. }
  23393. this.pos += n;
  23394. },
  23395. reset: function DecodeStream_reset() {
  23396. this.pos = 0;
  23397. },
  23398. getBaseStreams: function DecodeStream_getBaseStreams() {
  23399. if (this.str && this.str.getBaseStreams) {
  23400. return this.str.getBaseStreams();
  23401. }
  23402. return [];
  23403. }
  23404. };
  23405. return DecodeStream;
  23406. }();
  23407. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  23408. function StreamsSequenceStream(streams) {
  23409. this.streams = streams;
  23410. DecodeStream.call(this, null);
  23411. }
  23412. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  23413. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  23414. var streams = this.streams;
  23415. if (streams.length === 0) {
  23416. this.eof = true;
  23417. return;
  23418. }
  23419. var stream = streams.shift();
  23420. var chunk = stream.getBytes();
  23421. var bufferLength = this.bufferLength;
  23422. var newLength = bufferLength + chunk.length;
  23423. var buffer = this.ensureBuffer(newLength);
  23424. buffer.set(chunk, bufferLength);
  23425. this.bufferLength = newLength;
  23426. };
  23427. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  23428. var baseStreams = [];
  23429. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  23430. var stream = this.streams[i];
  23431. if (stream.getBaseStreams) {
  23432. Util.appendToArray(baseStreams, stream.getBaseStreams());
  23433. }
  23434. }
  23435. return baseStreams;
  23436. };
  23437. return StreamsSequenceStream;
  23438. }();
  23439. var FlateStream = function FlateStreamClosure() {
  23440. var codeLenCodeMap = new Int32Array([
  23441. 16,
  23442. 17,
  23443. 18,
  23444. 0,
  23445. 8,
  23446. 7,
  23447. 9,
  23448. 6,
  23449. 10,
  23450. 5,
  23451. 11,
  23452. 4,
  23453. 12,
  23454. 3,
  23455. 13,
  23456. 2,
  23457. 14,
  23458. 1,
  23459. 15
  23460. ]);
  23461. var lengthDecode = new Int32Array([
  23462. 0x00003,
  23463. 0x00004,
  23464. 0x00005,
  23465. 0x00006,
  23466. 0x00007,
  23467. 0x00008,
  23468. 0x00009,
  23469. 0x0000a,
  23470. 0x1000b,
  23471. 0x1000d,
  23472. 0x1000f,
  23473. 0x10011,
  23474. 0x20013,
  23475. 0x20017,
  23476. 0x2001b,
  23477. 0x2001f,
  23478. 0x30023,
  23479. 0x3002b,
  23480. 0x30033,
  23481. 0x3003b,
  23482. 0x40043,
  23483. 0x40053,
  23484. 0x40063,
  23485. 0x40073,
  23486. 0x50083,
  23487. 0x500a3,
  23488. 0x500c3,
  23489. 0x500e3,
  23490. 0x00102,
  23491. 0x00102,
  23492. 0x00102
  23493. ]);
  23494. var distDecode = new Int32Array([
  23495. 0x00001,
  23496. 0x00002,
  23497. 0x00003,
  23498. 0x00004,
  23499. 0x10005,
  23500. 0x10007,
  23501. 0x20009,
  23502. 0x2000d,
  23503. 0x30011,
  23504. 0x30019,
  23505. 0x40021,
  23506. 0x40031,
  23507. 0x50041,
  23508. 0x50061,
  23509. 0x60081,
  23510. 0x600c1,
  23511. 0x70101,
  23512. 0x70181,
  23513. 0x80201,
  23514. 0x80301,
  23515. 0x90401,
  23516. 0x90601,
  23517. 0xa0801,
  23518. 0xa0c01,
  23519. 0xb1001,
  23520. 0xb1801,
  23521. 0xc2001,
  23522. 0xc3001,
  23523. 0xd4001,
  23524. 0xd6001
  23525. ]);
  23526. var fixedLitCodeTab = [
  23527. new Int32Array([
  23528. 0x70100,
  23529. 0x80050,
  23530. 0x80010,
  23531. 0x80118,
  23532. 0x70110,
  23533. 0x80070,
  23534. 0x80030,
  23535. 0x900c0,
  23536. 0x70108,
  23537. 0x80060,
  23538. 0x80020,
  23539. 0x900a0,
  23540. 0x80000,
  23541. 0x80080,
  23542. 0x80040,
  23543. 0x900e0,
  23544. 0x70104,
  23545. 0x80058,
  23546. 0x80018,
  23547. 0x90090,
  23548. 0x70114,
  23549. 0x80078,
  23550. 0x80038,
  23551. 0x900d0,
  23552. 0x7010c,
  23553. 0x80068,
  23554. 0x80028,
  23555. 0x900b0,
  23556. 0x80008,
  23557. 0x80088,
  23558. 0x80048,
  23559. 0x900f0,
  23560. 0x70102,
  23561. 0x80054,
  23562. 0x80014,
  23563. 0x8011c,
  23564. 0x70112,
  23565. 0x80074,
  23566. 0x80034,
  23567. 0x900c8,
  23568. 0x7010a,
  23569. 0x80064,
  23570. 0x80024,
  23571. 0x900a8,
  23572. 0x80004,
  23573. 0x80084,
  23574. 0x80044,
  23575. 0x900e8,
  23576. 0x70106,
  23577. 0x8005c,
  23578. 0x8001c,
  23579. 0x90098,
  23580. 0x70116,
  23581. 0x8007c,
  23582. 0x8003c,
  23583. 0x900d8,
  23584. 0x7010e,
  23585. 0x8006c,
  23586. 0x8002c,
  23587. 0x900b8,
  23588. 0x8000c,
  23589. 0x8008c,
  23590. 0x8004c,
  23591. 0x900f8,
  23592. 0x70101,
  23593. 0x80052,
  23594. 0x80012,
  23595. 0x8011a,
  23596. 0x70111,
  23597. 0x80072,
  23598. 0x80032,
  23599. 0x900c4,
  23600. 0x70109,
  23601. 0x80062,
  23602. 0x80022,
  23603. 0x900a4,
  23604. 0x80002,
  23605. 0x80082,
  23606. 0x80042,
  23607. 0x900e4,
  23608. 0x70105,
  23609. 0x8005a,
  23610. 0x8001a,
  23611. 0x90094,
  23612. 0x70115,
  23613. 0x8007a,
  23614. 0x8003a,
  23615. 0x900d4,
  23616. 0x7010d,
  23617. 0x8006a,
  23618. 0x8002a,
  23619. 0x900b4,
  23620. 0x8000a,
  23621. 0x8008a,
  23622. 0x8004a,
  23623. 0x900f4,
  23624. 0x70103,
  23625. 0x80056,
  23626. 0x80016,
  23627. 0x8011e,
  23628. 0x70113,
  23629. 0x80076,
  23630. 0x80036,
  23631. 0x900cc,
  23632. 0x7010b,
  23633. 0x80066,
  23634. 0x80026,
  23635. 0x900ac,
  23636. 0x80006,
  23637. 0x80086,
  23638. 0x80046,
  23639. 0x900ec,
  23640. 0x70107,
  23641. 0x8005e,
  23642. 0x8001e,
  23643. 0x9009c,
  23644. 0x70117,
  23645. 0x8007e,
  23646. 0x8003e,
  23647. 0x900dc,
  23648. 0x7010f,
  23649. 0x8006e,
  23650. 0x8002e,
  23651. 0x900bc,
  23652. 0x8000e,
  23653. 0x8008e,
  23654. 0x8004e,
  23655. 0x900fc,
  23656. 0x70100,
  23657. 0x80051,
  23658. 0x80011,
  23659. 0x80119,
  23660. 0x70110,
  23661. 0x80071,
  23662. 0x80031,
  23663. 0x900c2,
  23664. 0x70108,
  23665. 0x80061,
  23666. 0x80021,
  23667. 0x900a2,
  23668. 0x80001,
  23669. 0x80081,
  23670. 0x80041,
  23671. 0x900e2,
  23672. 0x70104,
  23673. 0x80059,
  23674. 0x80019,
  23675. 0x90092,
  23676. 0x70114,
  23677. 0x80079,
  23678. 0x80039,
  23679. 0x900d2,
  23680. 0x7010c,
  23681. 0x80069,
  23682. 0x80029,
  23683. 0x900b2,
  23684. 0x80009,
  23685. 0x80089,
  23686. 0x80049,
  23687. 0x900f2,
  23688. 0x70102,
  23689. 0x80055,
  23690. 0x80015,
  23691. 0x8011d,
  23692. 0x70112,
  23693. 0x80075,
  23694. 0x80035,
  23695. 0x900ca,
  23696. 0x7010a,
  23697. 0x80065,
  23698. 0x80025,
  23699. 0x900aa,
  23700. 0x80005,
  23701. 0x80085,
  23702. 0x80045,
  23703. 0x900ea,
  23704. 0x70106,
  23705. 0x8005d,
  23706. 0x8001d,
  23707. 0x9009a,
  23708. 0x70116,
  23709. 0x8007d,
  23710. 0x8003d,
  23711. 0x900da,
  23712. 0x7010e,
  23713. 0x8006d,
  23714. 0x8002d,
  23715. 0x900ba,
  23716. 0x8000d,
  23717. 0x8008d,
  23718. 0x8004d,
  23719. 0x900fa,
  23720. 0x70101,
  23721. 0x80053,
  23722. 0x80013,
  23723. 0x8011b,
  23724. 0x70111,
  23725. 0x80073,
  23726. 0x80033,
  23727. 0x900c6,
  23728. 0x70109,
  23729. 0x80063,
  23730. 0x80023,
  23731. 0x900a6,
  23732. 0x80003,
  23733. 0x80083,
  23734. 0x80043,
  23735. 0x900e6,
  23736. 0x70105,
  23737. 0x8005b,
  23738. 0x8001b,
  23739. 0x90096,
  23740. 0x70115,
  23741. 0x8007b,
  23742. 0x8003b,
  23743. 0x900d6,
  23744. 0x7010d,
  23745. 0x8006b,
  23746. 0x8002b,
  23747. 0x900b6,
  23748. 0x8000b,
  23749. 0x8008b,
  23750. 0x8004b,
  23751. 0x900f6,
  23752. 0x70103,
  23753. 0x80057,
  23754. 0x80017,
  23755. 0x8011f,
  23756. 0x70113,
  23757. 0x80077,
  23758. 0x80037,
  23759. 0x900ce,
  23760. 0x7010b,
  23761. 0x80067,
  23762. 0x80027,
  23763. 0x900ae,
  23764. 0x80007,
  23765. 0x80087,
  23766. 0x80047,
  23767. 0x900ee,
  23768. 0x70107,
  23769. 0x8005f,
  23770. 0x8001f,
  23771. 0x9009e,
  23772. 0x70117,
  23773. 0x8007f,
  23774. 0x8003f,
  23775. 0x900de,
  23776. 0x7010f,
  23777. 0x8006f,
  23778. 0x8002f,
  23779. 0x900be,
  23780. 0x8000f,
  23781. 0x8008f,
  23782. 0x8004f,
  23783. 0x900fe,
  23784. 0x70100,
  23785. 0x80050,
  23786. 0x80010,
  23787. 0x80118,
  23788. 0x70110,
  23789. 0x80070,
  23790. 0x80030,
  23791. 0x900c1,
  23792. 0x70108,
  23793. 0x80060,
  23794. 0x80020,
  23795. 0x900a1,
  23796. 0x80000,
  23797. 0x80080,
  23798. 0x80040,
  23799. 0x900e1,
  23800. 0x70104,
  23801. 0x80058,
  23802. 0x80018,
  23803. 0x90091,
  23804. 0x70114,
  23805. 0x80078,
  23806. 0x80038,
  23807. 0x900d1,
  23808. 0x7010c,
  23809. 0x80068,
  23810. 0x80028,
  23811. 0x900b1,
  23812. 0x80008,
  23813. 0x80088,
  23814. 0x80048,
  23815. 0x900f1,
  23816. 0x70102,
  23817. 0x80054,
  23818. 0x80014,
  23819. 0x8011c,
  23820. 0x70112,
  23821. 0x80074,
  23822. 0x80034,
  23823. 0x900c9,
  23824. 0x7010a,
  23825. 0x80064,
  23826. 0x80024,
  23827. 0x900a9,
  23828. 0x80004,
  23829. 0x80084,
  23830. 0x80044,
  23831. 0x900e9,
  23832. 0x70106,
  23833. 0x8005c,
  23834. 0x8001c,
  23835. 0x90099,
  23836. 0x70116,
  23837. 0x8007c,
  23838. 0x8003c,
  23839. 0x900d9,
  23840. 0x7010e,
  23841. 0x8006c,
  23842. 0x8002c,
  23843. 0x900b9,
  23844. 0x8000c,
  23845. 0x8008c,
  23846. 0x8004c,
  23847. 0x900f9,
  23848. 0x70101,
  23849. 0x80052,
  23850. 0x80012,
  23851. 0x8011a,
  23852. 0x70111,
  23853. 0x80072,
  23854. 0x80032,
  23855. 0x900c5,
  23856. 0x70109,
  23857. 0x80062,
  23858. 0x80022,
  23859. 0x900a5,
  23860. 0x80002,
  23861. 0x80082,
  23862. 0x80042,
  23863. 0x900e5,
  23864. 0x70105,
  23865. 0x8005a,
  23866. 0x8001a,
  23867. 0x90095,
  23868. 0x70115,
  23869. 0x8007a,
  23870. 0x8003a,
  23871. 0x900d5,
  23872. 0x7010d,
  23873. 0x8006a,
  23874. 0x8002a,
  23875. 0x900b5,
  23876. 0x8000a,
  23877. 0x8008a,
  23878. 0x8004a,
  23879. 0x900f5,
  23880. 0x70103,
  23881. 0x80056,
  23882. 0x80016,
  23883. 0x8011e,
  23884. 0x70113,
  23885. 0x80076,
  23886. 0x80036,
  23887. 0x900cd,
  23888. 0x7010b,
  23889. 0x80066,
  23890. 0x80026,
  23891. 0x900ad,
  23892. 0x80006,
  23893. 0x80086,
  23894. 0x80046,
  23895. 0x900ed,
  23896. 0x70107,
  23897. 0x8005e,
  23898. 0x8001e,
  23899. 0x9009d,
  23900. 0x70117,
  23901. 0x8007e,
  23902. 0x8003e,
  23903. 0x900dd,
  23904. 0x7010f,
  23905. 0x8006e,
  23906. 0x8002e,
  23907. 0x900bd,
  23908. 0x8000e,
  23909. 0x8008e,
  23910. 0x8004e,
  23911. 0x900fd,
  23912. 0x70100,
  23913. 0x80051,
  23914. 0x80011,
  23915. 0x80119,
  23916. 0x70110,
  23917. 0x80071,
  23918. 0x80031,
  23919. 0x900c3,
  23920. 0x70108,
  23921. 0x80061,
  23922. 0x80021,
  23923. 0x900a3,
  23924. 0x80001,
  23925. 0x80081,
  23926. 0x80041,
  23927. 0x900e3,
  23928. 0x70104,
  23929. 0x80059,
  23930. 0x80019,
  23931. 0x90093,
  23932. 0x70114,
  23933. 0x80079,
  23934. 0x80039,
  23935. 0x900d3,
  23936. 0x7010c,
  23937. 0x80069,
  23938. 0x80029,
  23939. 0x900b3,
  23940. 0x80009,
  23941. 0x80089,
  23942. 0x80049,
  23943. 0x900f3,
  23944. 0x70102,
  23945. 0x80055,
  23946. 0x80015,
  23947. 0x8011d,
  23948. 0x70112,
  23949. 0x80075,
  23950. 0x80035,
  23951. 0x900cb,
  23952. 0x7010a,
  23953. 0x80065,
  23954. 0x80025,
  23955. 0x900ab,
  23956. 0x80005,
  23957. 0x80085,
  23958. 0x80045,
  23959. 0x900eb,
  23960. 0x70106,
  23961. 0x8005d,
  23962. 0x8001d,
  23963. 0x9009b,
  23964. 0x70116,
  23965. 0x8007d,
  23966. 0x8003d,
  23967. 0x900db,
  23968. 0x7010e,
  23969. 0x8006d,
  23970. 0x8002d,
  23971. 0x900bb,
  23972. 0x8000d,
  23973. 0x8008d,
  23974. 0x8004d,
  23975. 0x900fb,
  23976. 0x70101,
  23977. 0x80053,
  23978. 0x80013,
  23979. 0x8011b,
  23980. 0x70111,
  23981. 0x80073,
  23982. 0x80033,
  23983. 0x900c7,
  23984. 0x70109,
  23985. 0x80063,
  23986. 0x80023,
  23987. 0x900a7,
  23988. 0x80003,
  23989. 0x80083,
  23990. 0x80043,
  23991. 0x900e7,
  23992. 0x70105,
  23993. 0x8005b,
  23994. 0x8001b,
  23995. 0x90097,
  23996. 0x70115,
  23997. 0x8007b,
  23998. 0x8003b,
  23999. 0x900d7,
  24000. 0x7010d,
  24001. 0x8006b,
  24002. 0x8002b,
  24003. 0x900b7,
  24004. 0x8000b,
  24005. 0x8008b,
  24006. 0x8004b,
  24007. 0x900f7,
  24008. 0x70103,
  24009. 0x80057,
  24010. 0x80017,
  24011. 0x8011f,
  24012. 0x70113,
  24013. 0x80077,
  24014. 0x80037,
  24015. 0x900cf,
  24016. 0x7010b,
  24017. 0x80067,
  24018. 0x80027,
  24019. 0x900af,
  24020. 0x80007,
  24021. 0x80087,
  24022. 0x80047,
  24023. 0x900ef,
  24024. 0x70107,
  24025. 0x8005f,
  24026. 0x8001f,
  24027. 0x9009f,
  24028. 0x70117,
  24029. 0x8007f,
  24030. 0x8003f,
  24031. 0x900df,
  24032. 0x7010f,
  24033. 0x8006f,
  24034. 0x8002f,
  24035. 0x900bf,
  24036. 0x8000f,
  24037. 0x8008f,
  24038. 0x8004f,
  24039. 0x900ff
  24040. ]),
  24041. 9
  24042. ];
  24043. var fixedDistCodeTab = [
  24044. new Int32Array([
  24045. 0x50000,
  24046. 0x50010,
  24047. 0x50008,
  24048. 0x50018,
  24049. 0x50004,
  24050. 0x50014,
  24051. 0x5000c,
  24052. 0x5001c,
  24053. 0x50002,
  24054. 0x50012,
  24055. 0x5000a,
  24056. 0x5001a,
  24057. 0x50006,
  24058. 0x50016,
  24059. 0x5000e,
  24060. 0x00000,
  24061. 0x50001,
  24062. 0x50011,
  24063. 0x50009,
  24064. 0x50019,
  24065. 0x50005,
  24066. 0x50015,
  24067. 0x5000d,
  24068. 0x5001d,
  24069. 0x50003,
  24070. 0x50013,
  24071. 0x5000b,
  24072. 0x5001b,
  24073. 0x50007,
  24074. 0x50017,
  24075. 0x5000f,
  24076. 0x00000
  24077. ]),
  24078. 5
  24079. ];
  24080. function FlateStream(str, maybeLength) {
  24081. this.str = str;
  24082. this.dict = str.dict;
  24083. var cmf = str.getByte();
  24084. var flg = str.getByte();
  24085. if (cmf === -1 || flg === -1) {
  24086. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  24087. }
  24088. if ((cmf & 0x0f) !== 0x08) {
  24089. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  24090. }
  24091. if (((cmf << 8) + flg) % 31 !== 0) {
  24092. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  24093. }
  24094. if (flg & 0x20) {
  24095. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  24096. }
  24097. this.codeSize = 0;
  24098. this.codeBuf = 0;
  24099. DecodeStream.call(this, maybeLength);
  24100. }
  24101. FlateStream.prototype = Object.create(DecodeStream.prototype);
  24102. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  24103. var str = this.str;
  24104. var codeSize = this.codeSize;
  24105. var codeBuf = this.codeBuf;
  24106. var b;
  24107. while (codeSize < bits) {
  24108. if ((b = str.getByte()) === -1) {
  24109. error('Bad encoding in flate stream');
  24110. }
  24111. codeBuf |= b << codeSize;
  24112. codeSize += 8;
  24113. }
  24114. b = codeBuf & (1 << bits) - 1;
  24115. this.codeBuf = codeBuf >> bits;
  24116. this.codeSize = codeSize -= bits;
  24117. return b;
  24118. };
  24119. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  24120. var str = this.str;
  24121. var codes = table[0];
  24122. var maxLen = table[1];
  24123. var codeSize = this.codeSize;
  24124. var codeBuf = this.codeBuf;
  24125. var b;
  24126. while (codeSize < maxLen) {
  24127. if ((b = str.getByte()) === -1) {
  24128. break;
  24129. }
  24130. codeBuf |= b << codeSize;
  24131. codeSize += 8;
  24132. }
  24133. var code = codes[codeBuf & (1 << maxLen) - 1];
  24134. var codeLen = code >> 16;
  24135. var codeVal = code & 0xffff;
  24136. if (codeLen < 1 || codeSize < codeLen) {
  24137. error('Bad encoding in flate stream');
  24138. }
  24139. this.codeBuf = codeBuf >> codeLen;
  24140. this.codeSize = codeSize - codeLen;
  24141. return codeVal;
  24142. };
  24143. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  24144. var n = lengths.length;
  24145. var maxLen = 0;
  24146. var i;
  24147. for (i = 0; i < n; ++i) {
  24148. if (lengths[i] > maxLen) {
  24149. maxLen = lengths[i];
  24150. }
  24151. }
  24152. var size = 1 << maxLen;
  24153. var codes = new Int32Array(size);
  24154. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  24155. for (var val = 0; val < n; ++val) {
  24156. if (lengths[val] === len) {
  24157. var code2 = 0;
  24158. var t = code;
  24159. for (i = 0; i < len; ++i) {
  24160. code2 = code2 << 1 | t & 1;
  24161. t >>= 1;
  24162. }
  24163. for (i = code2; i < size; i += skip) {
  24164. codes[i] = len << 16 | val;
  24165. }
  24166. ++code;
  24167. }
  24168. }
  24169. }
  24170. return [
  24171. codes,
  24172. maxLen
  24173. ];
  24174. };
  24175. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  24176. var buffer, len;
  24177. var str = this.str;
  24178. var hdr = this.getBits(3);
  24179. if (hdr & 1) {
  24180. this.eof = true;
  24181. }
  24182. hdr >>= 1;
  24183. if (hdr === 0) {
  24184. var b;
  24185. if ((b = str.getByte()) === -1) {
  24186. error('Bad block header in flate stream');
  24187. }
  24188. var blockLen = b;
  24189. if ((b = str.getByte()) === -1) {
  24190. error('Bad block header in flate stream');
  24191. }
  24192. blockLen |= b << 8;
  24193. if ((b = str.getByte()) === -1) {
  24194. error('Bad block header in flate stream');
  24195. }
  24196. var check = b;
  24197. if ((b = str.getByte()) === -1) {
  24198. error('Bad block header in flate stream');
  24199. }
  24200. check |= b << 8;
  24201. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  24202. error('Bad uncompressed block length in flate stream');
  24203. }
  24204. this.codeBuf = 0;
  24205. this.codeSize = 0;
  24206. var bufferLength = this.bufferLength;
  24207. buffer = this.ensureBuffer(bufferLength + blockLen);
  24208. var end = bufferLength + blockLen;
  24209. this.bufferLength = end;
  24210. if (blockLen === 0) {
  24211. if (str.peekByte() === -1) {
  24212. this.eof = true;
  24213. }
  24214. } else {
  24215. for (var n = bufferLength; n < end; ++n) {
  24216. if ((b = str.getByte()) === -1) {
  24217. this.eof = true;
  24218. break;
  24219. }
  24220. buffer[n] = b;
  24221. }
  24222. }
  24223. return;
  24224. }
  24225. var litCodeTable;
  24226. var distCodeTable;
  24227. if (hdr === 1) {
  24228. litCodeTable = fixedLitCodeTab;
  24229. distCodeTable = fixedDistCodeTab;
  24230. } else if (hdr === 2) {
  24231. var numLitCodes = this.getBits(5) + 257;
  24232. var numDistCodes = this.getBits(5) + 1;
  24233. var numCodeLenCodes = this.getBits(4) + 4;
  24234. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  24235. var i;
  24236. for (i = 0; i < numCodeLenCodes; ++i) {
  24237. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  24238. }
  24239. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  24240. len = 0;
  24241. i = 0;
  24242. var codes = numLitCodes + numDistCodes;
  24243. var codeLengths = new Uint8Array(codes);
  24244. var bitsLength, bitsOffset, what;
  24245. while (i < codes) {
  24246. var code = this.getCode(codeLenCodeTab);
  24247. if (code === 16) {
  24248. bitsLength = 2;
  24249. bitsOffset = 3;
  24250. what = len;
  24251. } else if (code === 17) {
  24252. bitsLength = 3;
  24253. bitsOffset = 3;
  24254. what = len = 0;
  24255. } else if (code === 18) {
  24256. bitsLength = 7;
  24257. bitsOffset = 11;
  24258. what = len = 0;
  24259. } else {
  24260. codeLengths[i++] = len = code;
  24261. continue;
  24262. }
  24263. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  24264. while (repeatLength-- > 0) {
  24265. codeLengths[i++] = what;
  24266. }
  24267. }
  24268. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  24269. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  24270. } else {
  24271. error('Unknown block type in flate stream');
  24272. }
  24273. buffer = this.buffer;
  24274. var limit = buffer ? buffer.length : 0;
  24275. var pos = this.bufferLength;
  24276. while (true) {
  24277. var code1 = this.getCode(litCodeTable);
  24278. if (code1 < 256) {
  24279. if (pos + 1 >= limit) {
  24280. buffer = this.ensureBuffer(pos + 1);
  24281. limit = buffer.length;
  24282. }
  24283. buffer[pos++] = code1;
  24284. continue;
  24285. }
  24286. if (code1 === 256) {
  24287. this.bufferLength = pos;
  24288. return;
  24289. }
  24290. code1 -= 257;
  24291. code1 = lengthDecode[code1];
  24292. var code2 = code1 >> 16;
  24293. if (code2 > 0) {
  24294. code2 = this.getBits(code2);
  24295. }
  24296. len = (code1 & 0xffff) + code2;
  24297. code1 = this.getCode(distCodeTable);
  24298. code1 = distDecode[code1];
  24299. code2 = code1 >> 16;
  24300. if (code2 > 0) {
  24301. code2 = this.getBits(code2);
  24302. }
  24303. var dist = (code1 & 0xffff) + code2;
  24304. if (pos + len >= limit) {
  24305. buffer = this.ensureBuffer(pos + len);
  24306. limit = buffer.length;
  24307. }
  24308. for (var k = 0; k < len; ++k, ++pos) {
  24309. buffer[pos] = buffer[pos - dist];
  24310. }
  24311. }
  24312. };
  24313. return FlateStream;
  24314. }();
  24315. var PredictorStream = function PredictorStreamClosure() {
  24316. function PredictorStream(str, maybeLength, params) {
  24317. if (!isDict(params)) {
  24318. return str;
  24319. }
  24320. var predictor = this.predictor = params.get('Predictor') || 1;
  24321. if (predictor <= 1) {
  24322. return str;
  24323. }
  24324. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  24325. error('Unsupported predictor: ' + predictor);
  24326. }
  24327. if (predictor === 2) {
  24328. this.readBlock = this.readBlockTiff;
  24329. } else {
  24330. this.readBlock = this.readBlockPng;
  24331. }
  24332. this.str = str;
  24333. this.dict = str.dict;
  24334. var colors = this.colors = params.get('Colors') || 1;
  24335. var bits = this.bits = params.get('BitsPerComponent') || 8;
  24336. var columns = this.columns = params.get('Columns') || 1;
  24337. this.pixBytes = colors * bits + 7 >> 3;
  24338. this.rowBytes = columns * colors * bits + 7 >> 3;
  24339. DecodeStream.call(this, maybeLength);
  24340. return this;
  24341. }
  24342. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  24343. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  24344. var rowBytes = this.rowBytes;
  24345. var bufferLength = this.bufferLength;
  24346. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  24347. var bits = this.bits;
  24348. var colors = this.colors;
  24349. var rawBytes = this.str.getBytes(rowBytes);
  24350. this.eof = !rawBytes.length;
  24351. if (this.eof) {
  24352. return;
  24353. }
  24354. var inbuf = 0, outbuf = 0;
  24355. var inbits = 0, outbits = 0;
  24356. var pos = bufferLength;
  24357. var i;
  24358. if (bits === 1) {
  24359. for (i = 0; i < rowBytes; ++i) {
  24360. var c = rawBytes[i];
  24361. inbuf = inbuf << 8 | c;
  24362. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  24363. inbuf &= 0xFFFF;
  24364. }
  24365. } else if (bits === 8) {
  24366. for (i = 0; i < colors; ++i) {
  24367. buffer[pos++] = rawBytes[i];
  24368. }
  24369. for (; i < rowBytes; ++i) {
  24370. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  24371. pos++;
  24372. }
  24373. } else {
  24374. var compArray = new Uint8Array(colors + 1);
  24375. var bitMask = (1 << bits) - 1;
  24376. var j = 0, k = bufferLength;
  24377. var columns = this.columns;
  24378. for (i = 0; i < columns; ++i) {
  24379. for (var kk = 0; kk < colors; ++kk) {
  24380. if (inbits < bits) {
  24381. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  24382. inbits += 8;
  24383. }
  24384. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  24385. inbits -= bits;
  24386. outbuf = outbuf << bits | compArray[kk];
  24387. outbits += bits;
  24388. if (outbits >= 8) {
  24389. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  24390. outbits -= 8;
  24391. }
  24392. }
  24393. }
  24394. if (outbits > 0) {
  24395. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  24396. }
  24397. }
  24398. this.bufferLength += rowBytes;
  24399. };
  24400. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  24401. var rowBytes = this.rowBytes;
  24402. var pixBytes = this.pixBytes;
  24403. var predictor = this.str.getByte();
  24404. var rawBytes = this.str.getBytes(rowBytes);
  24405. this.eof = !rawBytes.length;
  24406. if (this.eof) {
  24407. return;
  24408. }
  24409. var bufferLength = this.bufferLength;
  24410. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  24411. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  24412. if (prevRow.length === 0) {
  24413. prevRow = new Uint8Array(rowBytes);
  24414. }
  24415. var i, j = bufferLength, up, c;
  24416. switch (predictor) {
  24417. case 0:
  24418. for (i = 0; i < rowBytes; ++i) {
  24419. buffer[j++] = rawBytes[i];
  24420. }
  24421. break;
  24422. case 1:
  24423. for (i = 0; i < pixBytes; ++i) {
  24424. buffer[j++] = rawBytes[i];
  24425. }
  24426. for (; i < rowBytes; ++i) {
  24427. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  24428. j++;
  24429. }
  24430. break;
  24431. case 2:
  24432. for (i = 0; i < rowBytes; ++i) {
  24433. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  24434. }
  24435. break;
  24436. case 3:
  24437. for (i = 0; i < pixBytes; ++i) {
  24438. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  24439. }
  24440. for (; i < rowBytes; ++i) {
  24441. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  24442. j++;
  24443. }
  24444. break;
  24445. case 4:
  24446. for (i = 0; i < pixBytes; ++i) {
  24447. up = prevRow[i];
  24448. c = rawBytes[i];
  24449. buffer[j++] = up + c;
  24450. }
  24451. for (; i < rowBytes; ++i) {
  24452. up = prevRow[i];
  24453. var upLeft = prevRow[i - pixBytes];
  24454. var left = buffer[j - pixBytes];
  24455. var p = left + up - upLeft;
  24456. var pa = p - left;
  24457. if (pa < 0) {
  24458. pa = -pa;
  24459. }
  24460. var pb = p - up;
  24461. if (pb < 0) {
  24462. pb = -pb;
  24463. }
  24464. var pc = p - upLeft;
  24465. if (pc < 0) {
  24466. pc = -pc;
  24467. }
  24468. c = rawBytes[i];
  24469. if (pa <= pb && pa <= pc) {
  24470. buffer[j++] = left + c;
  24471. } else if (pb <= pc) {
  24472. buffer[j++] = up + c;
  24473. } else {
  24474. buffer[j++] = upLeft + c;
  24475. }
  24476. }
  24477. break;
  24478. default:
  24479. error('Unsupported predictor: ' + predictor);
  24480. }
  24481. this.bufferLength += rowBytes;
  24482. };
  24483. return PredictorStream;
  24484. }();
  24485. var JpegStream = function JpegStreamClosure() {
  24486. function JpegStream(stream, maybeLength, dict, params) {
  24487. var ch;
  24488. while ((ch = stream.getByte()) !== -1) {
  24489. if (ch === 0xFF) {
  24490. stream.skip(-1);
  24491. break;
  24492. }
  24493. }
  24494. this.stream = stream;
  24495. this.maybeLength = maybeLength;
  24496. this.dict = dict;
  24497. this.params = params;
  24498. DecodeStream.call(this, maybeLength);
  24499. }
  24500. JpegStream.prototype = Object.create(DecodeStream.prototype);
  24501. Object.defineProperty(JpegStream.prototype, 'bytes', {
  24502. get: function JpegStream_bytes() {
  24503. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24504. },
  24505. configurable: true
  24506. });
  24507. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  24508. if (this.bufferLength) {
  24509. return;
  24510. }
  24511. var jpegImage = new JpegImage();
  24512. var decodeArr = this.dict.getArray('Decode', 'D');
  24513. if (this.forceRGB && isArray(decodeArr)) {
  24514. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  24515. var decodeArrLength = decodeArr.length;
  24516. var transform = new Int32Array(decodeArrLength);
  24517. var transformNeeded = false;
  24518. var maxValue = (1 << bitsPerComponent) - 1;
  24519. for (var i = 0; i < decodeArrLength; i += 2) {
  24520. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  24521. transform[i + 1] = decodeArr[i] * maxValue | 0;
  24522. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  24523. transformNeeded = true;
  24524. }
  24525. }
  24526. if (transformNeeded) {
  24527. jpegImage.decodeTransform = transform;
  24528. }
  24529. }
  24530. if (isDict(this.params)) {
  24531. var colorTransform = this.params.get('ColorTransform');
  24532. if (isInt(colorTransform)) {
  24533. jpegImage.colorTransform = colorTransform;
  24534. }
  24535. }
  24536. jpegImage.parse(this.bytes);
  24537. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  24538. this.buffer = data;
  24539. this.bufferLength = data.length;
  24540. this.eof = true;
  24541. };
  24542. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  24543. this.ensureBuffer();
  24544. return this.buffer;
  24545. };
  24546. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  24547. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  24548. };
  24549. return JpegStream;
  24550. }();
  24551. var JpxStream = function JpxStreamClosure() {
  24552. function JpxStream(stream, maybeLength, dict, params) {
  24553. this.stream = stream;
  24554. this.maybeLength = maybeLength;
  24555. this.dict = dict;
  24556. this.params = params;
  24557. DecodeStream.call(this, maybeLength);
  24558. }
  24559. JpxStream.prototype = Object.create(DecodeStream.prototype);
  24560. Object.defineProperty(JpxStream.prototype, 'bytes', {
  24561. get: function JpxStream_bytes() {
  24562. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24563. },
  24564. configurable: true
  24565. });
  24566. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  24567. if (this.bufferLength) {
  24568. return;
  24569. }
  24570. var jpxImage = new JpxImage();
  24571. jpxImage.parse(this.bytes);
  24572. var width = jpxImage.width;
  24573. var height = jpxImage.height;
  24574. var componentsCount = jpxImage.componentsCount;
  24575. var tileCount = jpxImage.tiles.length;
  24576. if (tileCount === 1) {
  24577. this.buffer = jpxImage.tiles[0].items;
  24578. } else {
  24579. var data = new Uint8Array(width * height * componentsCount);
  24580. for (var k = 0; k < tileCount; k++) {
  24581. var tileComponents = jpxImage.tiles[k];
  24582. var tileWidth = tileComponents.width;
  24583. var tileHeight = tileComponents.height;
  24584. var tileLeft = tileComponents.left;
  24585. var tileTop = tileComponents.top;
  24586. var src = tileComponents.items;
  24587. var srcPosition = 0;
  24588. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  24589. var imgRowSize = width * componentsCount;
  24590. var tileRowSize = tileWidth * componentsCount;
  24591. for (var j = 0; j < tileHeight; j++) {
  24592. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  24593. data.set(rowBytes, dataPosition);
  24594. srcPosition += tileRowSize;
  24595. dataPosition += imgRowSize;
  24596. }
  24597. }
  24598. this.buffer = data;
  24599. }
  24600. this.bufferLength = this.buffer.length;
  24601. this.eof = true;
  24602. };
  24603. return JpxStream;
  24604. }();
  24605. var Jbig2Stream = function Jbig2StreamClosure() {
  24606. function Jbig2Stream(stream, maybeLength, dict, params) {
  24607. this.stream = stream;
  24608. this.maybeLength = maybeLength;
  24609. this.dict = dict;
  24610. this.params = params;
  24611. DecodeStream.call(this, maybeLength);
  24612. }
  24613. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  24614. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  24615. get: function Jbig2Stream_bytes() {
  24616. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24617. },
  24618. configurable: true
  24619. });
  24620. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  24621. if (this.bufferLength) {
  24622. return;
  24623. }
  24624. var jbig2Image = new Jbig2Image();
  24625. var chunks = [];
  24626. if (isDict(this.params)) {
  24627. var globalsStream = this.params.get('JBIG2Globals');
  24628. if (isStream(globalsStream)) {
  24629. var globals = globalsStream.getBytes();
  24630. chunks.push({
  24631. data: globals,
  24632. start: 0,
  24633. end: globals.length
  24634. });
  24635. }
  24636. }
  24637. chunks.push({
  24638. data: this.bytes,
  24639. start: 0,
  24640. end: this.bytes.length
  24641. });
  24642. var data = jbig2Image.parseChunks(chunks);
  24643. var dataLength = data.length;
  24644. for (var i = 0; i < dataLength; i++) {
  24645. data[i] ^= 0xFF;
  24646. }
  24647. this.buffer = data;
  24648. this.bufferLength = dataLength;
  24649. this.eof = true;
  24650. };
  24651. return Jbig2Stream;
  24652. }();
  24653. var DecryptStream = function DecryptStreamClosure() {
  24654. function DecryptStream(str, maybeLength, decrypt) {
  24655. this.str = str;
  24656. this.dict = str.dict;
  24657. this.decrypt = decrypt;
  24658. this.nextChunk = null;
  24659. this.initialized = false;
  24660. DecodeStream.call(this, maybeLength);
  24661. }
  24662. var chunkSize = 512;
  24663. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  24664. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  24665. var chunk;
  24666. if (this.initialized) {
  24667. chunk = this.nextChunk;
  24668. } else {
  24669. chunk = this.str.getBytes(chunkSize);
  24670. this.initialized = true;
  24671. }
  24672. if (!chunk || chunk.length === 0) {
  24673. this.eof = true;
  24674. return;
  24675. }
  24676. this.nextChunk = this.str.getBytes(chunkSize);
  24677. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  24678. var decrypt = this.decrypt;
  24679. chunk = decrypt(chunk, !hasMoreData);
  24680. var bufferLength = this.bufferLength;
  24681. var i, n = chunk.length;
  24682. var buffer = this.ensureBuffer(bufferLength + n);
  24683. for (i = 0; i < n; i++) {
  24684. buffer[bufferLength++] = chunk[i];
  24685. }
  24686. this.bufferLength = bufferLength;
  24687. };
  24688. return DecryptStream;
  24689. }();
  24690. var Ascii85Stream = function Ascii85StreamClosure() {
  24691. function Ascii85Stream(str, maybeLength) {
  24692. this.str = str;
  24693. this.dict = str.dict;
  24694. this.input = new Uint8Array(5);
  24695. if (maybeLength) {
  24696. maybeLength = 0.8 * maybeLength;
  24697. }
  24698. DecodeStream.call(this, maybeLength);
  24699. }
  24700. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  24701. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  24702. var TILDA_CHAR = 0x7E;
  24703. var Z_LOWER_CHAR = 0x7A;
  24704. var EOF = -1;
  24705. var str = this.str;
  24706. var c = str.getByte();
  24707. while (isSpace(c)) {
  24708. c = str.getByte();
  24709. }
  24710. if (c === EOF || c === TILDA_CHAR) {
  24711. this.eof = true;
  24712. return;
  24713. }
  24714. var bufferLength = this.bufferLength, buffer;
  24715. var i;
  24716. if (c === Z_LOWER_CHAR) {
  24717. buffer = this.ensureBuffer(bufferLength + 4);
  24718. for (i = 0; i < 4; ++i) {
  24719. buffer[bufferLength + i] = 0;
  24720. }
  24721. this.bufferLength += 4;
  24722. } else {
  24723. var input = this.input;
  24724. input[0] = c;
  24725. for (i = 1; i < 5; ++i) {
  24726. c = str.getByte();
  24727. while (isSpace(c)) {
  24728. c = str.getByte();
  24729. }
  24730. input[i] = c;
  24731. if (c === EOF || c === TILDA_CHAR) {
  24732. break;
  24733. }
  24734. }
  24735. buffer = this.ensureBuffer(bufferLength + i - 1);
  24736. this.bufferLength += i - 1;
  24737. if (i < 5) {
  24738. for (; i < 5; ++i) {
  24739. input[i] = 0x21 + 84;
  24740. }
  24741. this.eof = true;
  24742. }
  24743. var t = 0;
  24744. for (i = 0; i < 5; ++i) {
  24745. t = t * 85 + (input[i] - 0x21);
  24746. }
  24747. for (i = 3; i >= 0; --i) {
  24748. buffer[bufferLength + i] = t & 0xFF;
  24749. t >>= 8;
  24750. }
  24751. }
  24752. };
  24753. return Ascii85Stream;
  24754. }();
  24755. var AsciiHexStream = function AsciiHexStreamClosure() {
  24756. function AsciiHexStream(str, maybeLength) {
  24757. this.str = str;
  24758. this.dict = str.dict;
  24759. this.firstDigit = -1;
  24760. if (maybeLength) {
  24761. maybeLength = 0.5 * maybeLength;
  24762. }
  24763. DecodeStream.call(this, maybeLength);
  24764. }
  24765. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  24766. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  24767. var UPSTREAM_BLOCK_SIZE = 8000;
  24768. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  24769. if (!bytes.length) {
  24770. this.eof = true;
  24771. return;
  24772. }
  24773. var maxDecodeLength = bytes.length + 1 >> 1;
  24774. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  24775. var bufferLength = this.bufferLength;
  24776. var firstDigit = this.firstDigit;
  24777. for (var i = 0, ii = bytes.length; i < ii; i++) {
  24778. var ch = bytes[i], digit;
  24779. if (ch >= 0x30 && ch <= 0x39) {
  24780. digit = ch & 0x0F;
  24781. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  24782. digit = (ch & 0x0F) + 9;
  24783. } else if (ch === 0x3E) {
  24784. this.eof = true;
  24785. break;
  24786. } else {
  24787. continue;
  24788. }
  24789. if (firstDigit < 0) {
  24790. firstDigit = digit;
  24791. } else {
  24792. buffer[bufferLength++] = firstDigit << 4 | digit;
  24793. firstDigit = -1;
  24794. }
  24795. }
  24796. if (firstDigit >= 0 && this.eof) {
  24797. buffer[bufferLength++] = firstDigit << 4;
  24798. firstDigit = -1;
  24799. }
  24800. this.firstDigit = firstDigit;
  24801. this.bufferLength = bufferLength;
  24802. };
  24803. return AsciiHexStream;
  24804. }();
  24805. var RunLengthStream = function RunLengthStreamClosure() {
  24806. function RunLengthStream(str, maybeLength) {
  24807. this.str = str;
  24808. this.dict = str.dict;
  24809. DecodeStream.call(this, maybeLength);
  24810. }
  24811. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  24812. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  24813. var repeatHeader = this.str.getBytes(2);
  24814. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  24815. this.eof = true;
  24816. return;
  24817. }
  24818. var buffer;
  24819. var bufferLength = this.bufferLength;
  24820. var n = repeatHeader[0];
  24821. if (n < 128) {
  24822. buffer = this.ensureBuffer(bufferLength + n + 1);
  24823. buffer[bufferLength++] = repeatHeader[1];
  24824. if (n > 0) {
  24825. var source = this.str.getBytes(n);
  24826. buffer.set(source, bufferLength);
  24827. bufferLength += n;
  24828. }
  24829. } else {
  24830. n = 257 - n;
  24831. var b = repeatHeader[1];
  24832. buffer = this.ensureBuffer(bufferLength + n + 1);
  24833. for (var i = 0; i < n; i++) {
  24834. buffer[bufferLength++] = b;
  24835. }
  24836. }
  24837. this.bufferLength = bufferLength;
  24838. };
  24839. return RunLengthStream;
  24840. }();
  24841. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  24842. var ccittEOL = -2;
  24843. var ccittEOF = -1;
  24844. var twoDimPass = 0;
  24845. var twoDimHoriz = 1;
  24846. var twoDimVert0 = 2;
  24847. var twoDimVertR1 = 3;
  24848. var twoDimVertL1 = 4;
  24849. var twoDimVertR2 = 5;
  24850. var twoDimVertL2 = 6;
  24851. var twoDimVertR3 = 7;
  24852. var twoDimVertL3 = 8;
  24853. var twoDimTable = [
  24854. [
  24855. -1,
  24856. -1
  24857. ],
  24858. [
  24859. -1,
  24860. -1
  24861. ],
  24862. [
  24863. 7,
  24864. twoDimVertL3
  24865. ],
  24866. [
  24867. 7,
  24868. twoDimVertR3
  24869. ],
  24870. [
  24871. 6,
  24872. twoDimVertL2
  24873. ],
  24874. [
  24875. 6,
  24876. twoDimVertL2
  24877. ],
  24878. [
  24879. 6,
  24880. twoDimVertR2
  24881. ],
  24882. [
  24883. 6,
  24884. twoDimVertR2
  24885. ],
  24886. [
  24887. 4,
  24888. twoDimPass
  24889. ],
  24890. [
  24891. 4,
  24892. twoDimPass
  24893. ],
  24894. [
  24895. 4,
  24896. twoDimPass
  24897. ],
  24898. [
  24899. 4,
  24900. twoDimPass
  24901. ],
  24902. [
  24903. 4,
  24904. twoDimPass
  24905. ],
  24906. [
  24907. 4,
  24908. twoDimPass
  24909. ],
  24910. [
  24911. 4,
  24912. twoDimPass
  24913. ],
  24914. [
  24915. 4,
  24916. twoDimPass
  24917. ],
  24918. [
  24919. 3,
  24920. twoDimHoriz
  24921. ],
  24922. [
  24923. 3,
  24924. twoDimHoriz
  24925. ],
  24926. [
  24927. 3,
  24928. twoDimHoriz
  24929. ],
  24930. [
  24931. 3,
  24932. twoDimHoriz
  24933. ],
  24934. [
  24935. 3,
  24936. twoDimHoriz
  24937. ],
  24938. [
  24939. 3,
  24940. twoDimHoriz
  24941. ],
  24942. [
  24943. 3,
  24944. twoDimHoriz
  24945. ],
  24946. [
  24947. 3,
  24948. twoDimHoriz
  24949. ],
  24950. [
  24951. 3,
  24952. twoDimHoriz
  24953. ],
  24954. [
  24955. 3,
  24956. twoDimHoriz
  24957. ],
  24958. [
  24959. 3,
  24960. twoDimHoriz
  24961. ],
  24962. [
  24963. 3,
  24964. twoDimHoriz
  24965. ],
  24966. [
  24967. 3,
  24968. twoDimHoriz
  24969. ],
  24970. [
  24971. 3,
  24972. twoDimHoriz
  24973. ],
  24974. [
  24975. 3,
  24976. twoDimHoriz
  24977. ],
  24978. [
  24979. 3,
  24980. twoDimHoriz
  24981. ],
  24982. [
  24983. 3,
  24984. twoDimVertL1
  24985. ],
  24986. [
  24987. 3,
  24988. twoDimVertL1
  24989. ],
  24990. [
  24991. 3,
  24992. twoDimVertL1
  24993. ],
  24994. [
  24995. 3,
  24996. twoDimVertL1
  24997. ],
  24998. [
  24999. 3,
  25000. twoDimVertL1
  25001. ],
  25002. [
  25003. 3,
  25004. twoDimVertL1
  25005. ],
  25006. [
  25007. 3,
  25008. twoDimVertL1
  25009. ],
  25010. [
  25011. 3,
  25012. twoDimVertL1
  25013. ],
  25014. [
  25015. 3,
  25016. twoDimVertL1
  25017. ],
  25018. [
  25019. 3,
  25020. twoDimVertL1
  25021. ],
  25022. [
  25023. 3,
  25024. twoDimVertL1
  25025. ],
  25026. [
  25027. 3,
  25028. twoDimVertL1
  25029. ],
  25030. [
  25031. 3,
  25032. twoDimVertL1
  25033. ],
  25034. [
  25035. 3,
  25036. twoDimVertL1
  25037. ],
  25038. [
  25039. 3,
  25040. twoDimVertL1
  25041. ],
  25042. [
  25043. 3,
  25044. twoDimVertL1
  25045. ],
  25046. [
  25047. 3,
  25048. twoDimVertR1
  25049. ],
  25050. [
  25051. 3,
  25052. twoDimVertR1
  25053. ],
  25054. [
  25055. 3,
  25056. twoDimVertR1
  25057. ],
  25058. [
  25059. 3,
  25060. twoDimVertR1
  25061. ],
  25062. [
  25063. 3,
  25064. twoDimVertR1
  25065. ],
  25066. [
  25067. 3,
  25068. twoDimVertR1
  25069. ],
  25070. [
  25071. 3,
  25072. twoDimVertR1
  25073. ],
  25074. [
  25075. 3,
  25076. twoDimVertR1
  25077. ],
  25078. [
  25079. 3,
  25080. twoDimVertR1
  25081. ],
  25082. [
  25083. 3,
  25084. twoDimVertR1
  25085. ],
  25086. [
  25087. 3,
  25088. twoDimVertR1
  25089. ],
  25090. [
  25091. 3,
  25092. twoDimVertR1
  25093. ],
  25094. [
  25095. 3,
  25096. twoDimVertR1
  25097. ],
  25098. [
  25099. 3,
  25100. twoDimVertR1
  25101. ],
  25102. [
  25103. 3,
  25104. twoDimVertR1
  25105. ],
  25106. [
  25107. 3,
  25108. twoDimVertR1
  25109. ],
  25110. [
  25111. 1,
  25112. twoDimVert0
  25113. ],
  25114. [
  25115. 1,
  25116. twoDimVert0
  25117. ],
  25118. [
  25119. 1,
  25120. twoDimVert0
  25121. ],
  25122. [
  25123. 1,
  25124. twoDimVert0
  25125. ],
  25126. [
  25127. 1,
  25128. twoDimVert0
  25129. ],
  25130. [
  25131. 1,
  25132. twoDimVert0
  25133. ],
  25134. [
  25135. 1,
  25136. twoDimVert0
  25137. ],
  25138. [
  25139. 1,
  25140. twoDimVert0
  25141. ],
  25142. [
  25143. 1,
  25144. twoDimVert0
  25145. ],
  25146. [
  25147. 1,
  25148. twoDimVert0
  25149. ],
  25150. [
  25151. 1,
  25152. twoDimVert0
  25153. ],
  25154. [
  25155. 1,
  25156. twoDimVert0
  25157. ],
  25158. [
  25159. 1,
  25160. twoDimVert0
  25161. ],
  25162. [
  25163. 1,
  25164. twoDimVert0
  25165. ],
  25166. [
  25167. 1,
  25168. twoDimVert0
  25169. ],
  25170. [
  25171. 1,
  25172. twoDimVert0
  25173. ],
  25174. [
  25175. 1,
  25176. twoDimVert0
  25177. ],
  25178. [
  25179. 1,
  25180. twoDimVert0
  25181. ],
  25182. [
  25183. 1,
  25184. twoDimVert0
  25185. ],
  25186. [
  25187. 1,
  25188. twoDimVert0
  25189. ],
  25190. [
  25191. 1,
  25192. twoDimVert0
  25193. ],
  25194. [
  25195. 1,
  25196. twoDimVert0
  25197. ],
  25198. [
  25199. 1,
  25200. twoDimVert0
  25201. ],
  25202. [
  25203. 1,
  25204. twoDimVert0
  25205. ],
  25206. [
  25207. 1,
  25208. twoDimVert0
  25209. ],
  25210. [
  25211. 1,
  25212. twoDimVert0
  25213. ],
  25214. [
  25215. 1,
  25216. twoDimVert0
  25217. ],
  25218. [
  25219. 1,
  25220. twoDimVert0
  25221. ],
  25222. [
  25223. 1,
  25224. twoDimVert0
  25225. ],
  25226. [
  25227. 1,
  25228. twoDimVert0
  25229. ],
  25230. [
  25231. 1,
  25232. twoDimVert0
  25233. ],
  25234. [
  25235. 1,
  25236. twoDimVert0
  25237. ],
  25238. [
  25239. 1,
  25240. twoDimVert0
  25241. ],
  25242. [
  25243. 1,
  25244. twoDimVert0
  25245. ],
  25246. [
  25247. 1,
  25248. twoDimVert0
  25249. ],
  25250. [
  25251. 1,
  25252. twoDimVert0
  25253. ],
  25254. [
  25255. 1,
  25256. twoDimVert0
  25257. ],
  25258. [
  25259. 1,
  25260. twoDimVert0
  25261. ],
  25262. [
  25263. 1,
  25264. twoDimVert0
  25265. ],
  25266. [
  25267. 1,
  25268. twoDimVert0
  25269. ],
  25270. [
  25271. 1,
  25272. twoDimVert0
  25273. ],
  25274. [
  25275. 1,
  25276. twoDimVert0
  25277. ],
  25278. [
  25279. 1,
  25280. twoDimVert0
  25281. ],
  25282. [
  25283. 1,
  25284. twoDimVert0
  25285. ],
  25286. [
  25287. 1,
  25288. twoDimVert0
  25289. ],
  25290. [
  25291. 1,
  25292. twoDimVert0
  25293. ],
  25294. [
  25295. 1,
  25296. twoDimVert0
  25297. ],
  25298. [
  25299. 1,
  25300. twoDimVert0
  25301. ],
  25302. [
  25303. 1,
  25304. twoDimVert0
  25305. ],
  25306. [
  25307. 1,
  25308. twoDimVert0
  25309. ],
  25310. [
  25311. 1,
  25312. twoDimVert0
  25313. ],
  25314. [
  25315. 1,
  25316. twoDimVert0
  25317. ],
  25318. [
  25319. 1,
  25320. twoDimVert0
  25321. ],
  25322. [
  25323. 1,
  25324. twoDimVert0
  25325. ],
  25326. [
  25327. 1,
  25328. twoDimVert0
  25329. ],
  25330. [
  25331. 1,
  25332. twoDimVert0
  25333. ],
  25334. [
  25335. 1,
  25336. twoDimVert0
  25337. ],
  25338. [
  25339. 1,
  25340. twoDimVert0
  25341. ],
  25342. [
  25343. 1,
  25344. twoDimVert0
  25345. ],
  25346. [
  25347. 1,
  25348. twoDimVert0
  25349. ],
  25350. [
  25351. 1,
  25352. twoDimVert0
  25353. ],
  25354. [
  25355. 1,
  25356. twoDimVert0
  25357. ],
  25358. [
  25359. 1,
  25360. twoDimVert0
  25361. ],
  25362. [
  25363. 1,
  25364. twoDimVert0
  25365. ]
  25366. ];
  25367. var whiteTable1 = [
  25368. [
  25369. -1,
  25370. -1
  25371. ],
  25372. [
  25373. 12,
  25374. ccittEOL
  25375. ],
  25376. [
  25377. -1,
  25378. -1
  25379. ],
  25380. [
  25381. -1,
  25382. -1
  25383. ],
  25384. [
  25385. -1,
  25386. -1
  25387. ],
  25388. [
  25389. -1,
  25390. -1
  25391. ],
  25392. [
  25393. -1,
  25394. -1
  25395. ],
  25396. [
  25397. -1,
  25398. -1
  25399. ],
  25400. [
  25401. -1,
  25402. -1
  25403. ],
  25404. [
  25405. -1,
  25406. -1
  25407. ],
  25408. [
  25409. -1,
  25410. -1
  25411. ],
  25412. [
  25413. -1,
  25414. -1
  25415. ],
  25416. [
  25417. -1,
  25418. -1
  25419. ],
  25420. [
  25421. -1,
  25422. -1
  25423. ],
  25424. [
  25425. -1,
  25426. -1
  25427. ],
  25428. [
  25429. -1,
  25430. -1
  25431. ],
  25432. [
  25433. 11,
  25434. 1792
  25435. ],
  25436. [
  25437. 11,
  25438. 1792
  25439. ],
  25440. [
  25441. 12,
  25442. 1984
  25443. ],
  25444. [
  25445. 12,
  25446. 2048
  25447. ],
  25448. [
  25449. 12,
  25450. 2112
  25451. ],
  25452. [
  25453. 12,
  25454. 2176
  25455. ],
  25456. [
  25457. 12,
  25458. 2240
  25459. ],
  25460. [
  25461. 12,
  25462. 2304
  25463. ],
  25464. [
  25465. 11,
  25466. 1856
  25467. ],
  25468. [
  25469. 11,
  25470. 1856
  25471. ],
  25472. [
  25473. 11,
  25474. 1920
  25475. ],
  25476. [
  25477. 11,
  25478. 1920
  25479. ],
  25480. [
  25481. 12,
  25482. 2368
  25483. ],
  25484. [
  25485. 12,
  25486. 2432
  25487. ],
  25488. [
  25489. 12,
  25490. 2496
  25491. ],
  25492. [
  25493. 12,
  25494. 2560
  25495. ]
  25496. ];
  25497. var whiteTable2 = [
  25498. [
  25499. -1,
  25500. -1
  25501. ],
  25502. [
  25503. -1,
  25504. -1
  25505. ],
  25506. [
  25507. -1,
  25508. -1
  25509. ],
  25510. [
  25511. -1,
  25512. -1
  25513. ],
  25514. [
  25515. 8,
  25516. 29
  25517. ],
  25518. [
  25519. 8,
  25520. 29
  25521. ],
  25522. [
  25523. 8,
  25524. 30
  25525. ],
  25526. [
  25527. 8,
  25528. 30
  25529. ],
  25530. [
  25531. 8,
  25532. 45
  25533. ],
  25534. [
  25535. 8,
  25536. 45
  25537. ],
  25538. [
  25539. 8,
  25540. 46
  25541. ],
  25542. [
  25543. 8,
  25544. 46
  25545. ],
  25546. [
  25547. 7,
  25548. 22
  25549. ],
  25550. [
  25551. 7,
  25552. 22
  25553. ],
  25554. [
  25555. 7,
  25556. 22
  25557. ],
  25558. [
  25559. 7,
  25560. 22
  25561. ],
  25562. [
  25563. 7,
  25564. 23
  25565. ],
  25566. [
  25567. 7,
  25568. 23
  25569. ],
  25570. [
  25571. 7,
  25572. 23
  25573. ],
  25574. [
  25575. 7,
  25576. 23
  25577. ],
  25578. [
  25579. 8,
  25580. 47
  25581. ],
  25582. [
  25583. 8,
  25584. 47
  25585. ],
  25586. [
  25587. 8,
  25588. 48
  25589. ],
  25590. [
  25591. 8,
  25592. 48
  25593. ],
  25594. [
  25595. 6,
  25596. 13
  25597. ],
  25598. [
  25599. 6,
  25600. 13
  25601. ],
  25602. [
  25603. 6,
  25604. 13
  25605. ],
  25606. [
  25607. 6,
  25608. 13
  25609. ],
  25610. [
  25611. 6,
  25612. 13
  25613. ],
  25614. [
  25615. 6,
  25616. 13
  25617. ],
  25618. [
  25619. 6,
  25620. 13
  25621. ],
  25622. [
  25623. 6,
  25624. 13
  25625. ],
  25626. [
  25627. 7,
  25628. 20
  25629. ],
  25630. [
  25631. 7,
  25632. 20
  25633. ],
  25634. [
  25635. 7,
  25636. 20
  25637. ],
  25638. [
  25639. 7,
  25640. 20
  25641. ],
  25642. [
  25643. 8,
  25644. 33
  25645. ],
  25646. [
  25647. 8,
  25648. 33
  25649. ],
  25650. [
  25651. 8,
  25652. 34
  25653. ],
  25654. [
  25655. 8,
  25656. 34
  25657. ],
  25658. [
  25659. 8,
  25660. 35
  25661. ],
  25662. [
  25663. 8,
  25664. 35
  25665. ],
  25666. [
  25667. 8,
  25668. 36
  25669. ],
  25670. [
  25671. 8,
  25672. 36
  25673. ],
  25674. [
  25675. 8,
  25676. 37
  25677. ],
  25678. [
  25679. 8,
  25680. 37
  25681. ],
  25682. [
  25683. 8,
  25684. 38
  25685. ],
  25686. [
  25687. 8,
  25688. 38
  25689. ],
  25690. [
  25691. 7,
  25692. 19
  25693. ],
  25694. [
  25695. 7,
  25696. 19
  25697. ],
  25698. [
  25699. 7,
  25700. 19
  25701. ],
  25702. [
  25703. 7,
  25704. 19
  25705. ],
  25706. [
  25707. 8,
  25708. 31
  25709. ],
  25710. [
  25711. 8,
  25712. 31
  25713. ],
  25714. [
  25715. 8,
  25716. 32
  25717. ],
  25718. [
  25719. 8,
  25720. 32
  25721. ],
  25722. [
  25723. 6,
  25724. 1
  25725. ],
  25726. [
  25727. 6,
  25728. 1
  25729. ],
  25730. [
  25731. 6,
  25732. 1
  25733. ],
  25734. [
  25735. 6,
  25736. 1
  25737. ],
  25738. [
  25739. 6,
  25740. 1
  25741. ],
  25742. [
  25743. 6,
  25744. 1
  25745. ],
  25746. [
  25747. 6,
  25748. 1
  25749. ],
  25750. [
  25751. 6,
  25752. 1
  25753. ],
  25754. [
  25755. 6,
  25756. 12
  25757. ],
  25758. [
  25759. 6,
  25760. 12
  25761. ],
  25762. [
  25763. 6,
  25764. 12
  25765. ],
  25766. [
  25767. 6,
  25768. 12
  25769. ],
  25770. [
  25771. 6,
  25772. 12
  25773. ],
  25774. [
  25775. 6,
  25776. 12
  25777. ],
  25778. [
  25779. 6,
  25780. 12
  25781. ],
  25782. [
  25783. 6,
  25784. 12
  25785. ],
  25786. [
  25787. 8,
  25788. 53
  25789. ],
  25790. [
  25791. 8,
  25792. 53
  25793. ],
  25794. [
  25795. 8,
  25796. 54
  25797. ],
  25798. [
  25799. 8,
  25800. 54
  25801. ],
  25802. [
  25803. 7,
  25804. 26
  25805. ],
  25806. [
  25807. 7,
  25808. 26
  25809. ],
  25810. [
  25811. 7,
  25812. 26
  25813. ],
  25814. [
  25815. 7,
  25816. 26
  25817. ],
  25818. [
  25819. 8,
  25820. 39
  25821. ],
  25822. [
  25823. 8,
  25824. 39
  25825. ],
  25826. [
  25827. 8,
  25828. 40
  25829. ],
  25830. [
  25831. 8,
  25832. 40
  25833. ],
  25834. [
  25835. 8,
  25836. 41
  25837. ],
  25838. [
  25839. 8,
  25840. 41
  25841. ],
  25842. [
  25843. 8,
  25844. 42
  25845. ],
  25846. [
  25847. 8,
  25848. 42
  25849. ],
  25850. [
  25851. 8,
  25852. 43
  25853. ],
  25854. [
  25855. 8,
  25856. 43
  25857. ],
  25858. [
  25859. 8,
  25860. 44
  25861. ],
  25862. [
  25863. 8,
  25864. 44
  25865. ],
  25866. [
  25867. 7,
  25868. 21
  25869. ],
  25870. [
  25871. 7,
  25872. 21
  25873. ],
  25874. [
  25875. 7,
  25876. 21
  25877. ],
  25878. [
  25879. 7,
  25880. 21
  25881. ],
  25882. [
  25883. 7,
  25884. 28
  25885. ],
  25886. [
  25887. 7,
  25888. 28
  25889. ],
  25890. [
  25891. 7,
  25892. 28
  25893. ],
  25894. [
  25895. 7,
  25896. 28
  25897. ],
  25898. [
  25899. 8,
  25900. 61
  25901. ],
  25902. [
  25903. 8,
  25904. 61
  25905. ],
  25906. [
  25907. 8,
  25908. 62
  25909. ],
  25910. [
  25911. 8,
  25912. 62
  25913. ],
  25914. [
  25915. 8,
  25916. 63
  25917. ],
  25918. [
  25919. 8,
  25920. 63
  25921. ],
  25922. [
  25923. 8,
  25924. 0
  25925. ],
  25926. [
  25927. 8,
  25928. 0
  25929. ],
  25930. [
  25931. 8,
  25932. 320
  25933. ],
  25934. [
  25935. 8,
  25936. 320
  25937. ],
  25938. [
  25939. 8,
  25940. 384
  25941. ],
  25942. [
  25943. 8,
  25944. 384
  25945. ],
  25946. [
  25947. 5,
  25948. 10
  25949. ],
  25950. [
  25951. 5,
  25952. 10
  25953. ],
  25954. [
  25955. 5,
  25956. 10
  25957. ],
  25958. [
  25959. 5,
  25960. 10
  25961. ],
  25962. [
  25963. 5,
  25964. 10
  25965. ],
  25966. [
  25967. 5,
  25968. 10
  25969. ],
  25970. [
  25971. 5,
  25972. 10
  25973. ],
  25974. [
  25975. 5,
  25976. 10
  25977. ],
  25978. [
  25979. 5,
  25980. 10
  25981. ],
  25982. [
  25983. 5,
  25984. 10
  25985. ],
  25986. [
  25987. 5,
  25988. 10
  25989. ],
  25990. [
  25991. 5,
  25992. 10
  25993. ],
  25994. [
  25995. 5,
  25996. 10
  25997. ],
  25998. [
  25999. 5,
  26000. 10
  26001. ],
  26002. [
  26003. 5,
  26004. 10
  26005. ],
  26006. [
  26007. 5,
  26008. 10
  26009. ],
  26010. [
  26011. 5,
  26012. 11
  26013. ],
  26014. [
  26015. 5,
  26016. 11
  26017. ],
  26018. [
  26019. 5,
  26020. 11
  26021. ],
  26022. [
  26023. 5,
  26024. 11
  26025. ],
  26026. [
  26027. 5,
  26028. 11
  26029. ],
  26030. [
  26031. 5,
  26032. 11
  26033. ],
  26034. [
  26035. 5,
  26036. 11
  26037. ],
  26038. [
  26039. 5,
  26040. 11
  26041. ],
  26042. [
  26043. 5,
  26044. 11
  26045. ],
  26046. [
  26047. 5,
  26048. 11
  26049. ],
  26050. [
  26051. 5,
  26052. 11
  26053. ],
  26054. [
  26055. 5,
  26056. 11
  26057. ],
  26058. [
  26059. 5,
  26060. 11
  26061. ],
  26062. [
  26063. 5,
  26064. 11
  26065. ],
  26066. [
  26067. 5,
  26068. 11
  26069. ],
  26070. [
  26071. 5,
  26072. 11
  26073. ],
  26074. [
  26075. 7,
  26076. 27
  26077. ],
  26078. [
  26079. 7,
  26080. 27
  26081. ],
  26082. [
  26083. 7,
  26084. 27
  26085. ],
  26086. [
  26087. 7,
  26088. 27
  26089. ],
  26090. [
  26091. 8,
  26092. 59
  26093. ],
  26094. [
  26095. 8,
  26096. 59
  26097. ],
  26098. [
  26099. 8,
  26100. 60
  26101. ],
  26102. [
  26103. 8,
  26104. 60
  26105. ],
  26106. [
  26107. 9,
  26108. 1472
  26109. ],
  26110. [
  26111. 9,
  26112. 1536
  26113. ],
  26114. [
  26115. 9,
  26116. 1600
  26117. ],
  26118. [
  26119. 9,
  26120. 1728
  26121. ],
  26122. [
  26123. 7,
  26124. 18
  26125. ],
  26126. [
  26127. 7,
  26128. 18
  26129. ],
  26130. [
  26131. 7,
  26132. 18
  26133. ],
  26134. [
  26135. 7,
  26136. 18
  26137. ],
  26138. [
  26139. 7,
  26140. 24
  26141. ],
  26142. [
  26143. 7,
  26144. 24
  26145. ],
  26146. [
  26147. 7,
  26148. 24
  26149. ],
  26150. [
  26151. 7,
  26152. 24
  26153. ],
  26154. [
  26155. 8,
  26156. 49
  26157. ],
  26158. [
  26159. 8,
  26160. 49
  26161. ],
  26162. [
  26163. 8,
  26164. 50
  26165. ],
  26166. [
  26167. 8,
  26168. 50
  26169. ],
  26170. [
  26171. 8,
  26172. 51
  26173. ],
  26174. [
  26175. 8,
  26176. 51
  26177. ],
  26178. [
  26179. 8,
  26180. 52
  26181. ],
  26182. [
  26183. 8,
  26184. 52
  26185. ],
  26186. [
  26187. 7,
  26188. 25
  26189. ],
  26190. [
  26191. 7,
  26192. 25
  26193. ],
  26194. [
  26195. 7,
  26196. 25
  26197. ],
  26198. [
  26199. 7,
  26200. 25
  26201. ],
  26202. [
  26203. 8,
  26204. 55
  26205. ],
  26206. [
  26207. 8,
  26208. 55
  26209. ],
  26210. [
  26211. 8,
  26212. 56
  26213. ],
  26214. [
  26215. 8,
  26216. 56
  26217. ],
  26218. [
  26219. 8,
  26220. 57
  26221. ],
  26222. [
  26223. 8,
  26224. 57
  26225. ],
  26226. [
  26227. 8,
  26228. 58
  26229. ],
  26230. [
  26231. 8,
  26232. 58
  26233. ],
  26234. [
  26235. 6,
  26236. 192
  26237. ],
  26238. [
  26239. 6,
  26240. 192
  26241. ],
  26242. [
  26243. 6,
  26244. 192
  26245. ],
  26246. [
  26247. 6,
  26248. 192
  26249. ],
  26250. [
  26251. 6,
  26252. 192
  26253. ],
  26254. [
  26255. 6,
  26256. 192
  26257. ],
  26258. [
  26259. 6,
  26260. 192
  26261. ],
  26262. [
  26263. 6,
  26264. 192
  26265. ],
  26266. [
  26267. 6,
  26268. 1664
  26269. ],
  26270. [
  26271. 6,
  26272. 1664
  26273. ],
  26274. [
  26275. 6,
  26276. 1664
  26277. ],
  26278. [
  26279. 6,
  26280. 1664
  26281. ],
  26282. [
  26283. 6,
  26284. 1664
  26285. ],
  26286. [
  26287. 6,
  26288. 1664
  26289. ],
  26290. [
  26291. 6,
  26292. 1664
  26293. ],
  26294. [
  26295. 6,
  26296. 1664
  26297. ],
  26298. [
  26299. 8,
  26300. 448
  26301. ],
  26302. [
  26303. 8,
  26304. 448
  26305. ],
  26306. [
  26307. 8,
  26308. 512
  26309. ],
  26310. [
  26311. 8,
  26312. 512
  26313. ],
  26314. [
  26315. 9,
  26316. 704
  26317. ],
  26318. [
  26319. 9,
  26320. 768
  26321. ],
  26322. [
  26323. 8,
  26324. 640
  26325. ],
  26326. [
  26327. 8,
  26328. 640
  26329. ],
  26330. [
  26331. 8,
  26332. 576
  26333. ],
  26334. [
  26335. 8,
  26336. 576
  26337. ],
  26338. [
  26339. 9,
  26340. 832
  26341. ],
  26342. [
  26343. 9,
  26344. 896
  26345. ],
  26346. [
  26347. 9,
  26348. 960
  26349. ],
  26350. [
  26351. 9,
  26352. 1024
  26353. ],
  26354. [
  26355. 9,
  26356. 1088
  26357. ],
  26358. [
  26359. 9,
  26360. 1152
  26361. ],
  26362. [
  26363. 9,
  26364. 1216
  26365. ],
  26366. [
  26367. 9,
  26368. 1280
  26369. ],
  26370. [
  26371. 9,
  26372. 1344
  26373. ],
  26374. [
  26375. 9,
  26376. 1408
  26377. ],
  26378. [
  26379. 7,
  26380. 256
  26381. ],
  26382. [
  26383. 7,
  26384. 256
  26385. ],
  26386. [
  26387. 7,
  26388. 256
  26389. ],
  26390. [
  26391. 7,
  26392. 256
  26393. ],
  26394. [
  26395. 4,
  26396. 2
  26397. ],
  26398. [
  26399. 4,
  26400. 2
  26401. ],
  26402. [
  26403. 4,
  26404. 2
  26405. ],
  26406. [
  26407. 4,
  26408. 2
  26409. ],
  26410. [
  26411. 4,
  26412. 2
  26413. ],
  26414. [
  26415. 4,
  26416. 2
  26417. ],
  26418. [
  26419. 4,
  26420. 2
  26421. ],
  26422. [
  26423. 4,
  26424. 2
  26425. ],
  26426. [
  26427. 4,
  26428. 2
  26429. ],
  26430. [
  26431. 4,
  26432. 2
  26433. ],
  26434. [
  26435. 4,
  26436. 2
  26437. ],
  26438. [
  26439. 4,
  26440. 2
  26441. ],
  26442. [
  26443. 4,
  26444. 2
  26445. ],
  26446. [
  26447. 4,
  26448. 2
  26449. ],
  26450. [
  26451. 4,
  26452. 2
  26453. ],
  26454. [
  26455. 4,
  26456. 2
  26457. ],
  26458. [
  26459. 4,
  26460. 2
  26461. ],
  26462. [
  26463. 4,
  26464. 2
  26465. ],
  26466. [
  26467. 4,
  26468. 2
  26469. ],
  26470. [
  26471. 4,
  26472. 2
  26473. ],
  26474. [
  26475. 4,
  26476. 2
  26477. ],
  26478. [
  26479. 4,
  26480. 2
  26481. ],
  26482. [
  26483. 4,
  26484. 2
  26485. ],
  26486. [
  26487. 4,
  26488. 2
  26489. ],
  26490. [
  26491. 4,
  26492. 2
  26493. ],
  26494. [
  26495. 4,
  26496. 2
  26497. ],
  26498. [
  26499. 4,
  26500. 2
  26501. ],
  26502. [
  26503. 4,
  26504. 2
  26505. ],
  26506. [
  26507. 4,
  26508. 2
  26509. ],
  26510. [
  26511. 4,
  26512. 2
  26513. ],
  26514. [
  26515. 4,
  26516. 2
  26517. ],
  26518. [
  26519. 4,
  26520. 2
  26521. ],
  26522. [
  26523. 4,
  26524. 3
  26525. ],
  26526. [
  26527. 4,
  26528. 3
  26529. ],
  26530. [
  26531. 4,
  26532. 3
  26533. ],
  26534. [
  26535. 4,
  26536. 3
  26537. ],
  26538. [
  26539. 4,
  26540. 3
  26541. ],
  26542. [
  26543. 4,
  26544. 3
  26545. ],
  26546. [
  26547. 4,
  26548. 3
  26549. ],
  26550. [
  26551. 4,
  26552. 3
  26553. ],
  26554. [
  26555. 4,
  26556. 3
  26557. ],
  26558. [
  26559. 4,
  26560. 3
  26561. ],
  26562. [
  26563. 4,
  26564. 3
  26565. ],
  26566. [
  26567. 4,
  26568. 3
  26569. ],
  26570. [
  26571. 4,
  26572. 3
  26573. ],
  26574. [
  26575. 4,
  26576. 3
  26577. ],
  26578. [
  26579. 4,
  26580. 3
  26581. ],
  26582. [
  26583. 4,
  26584. 3
  26585. ],
  26586. [
  26587. 4,
  26588. 3
  26589. ],
  26590. [
  26591. 4,
  26592. 3
  26593. ],
  26594. [
  26595. 4,
  26596. 3
  26597. ],
  26598. [
  26599. 4,
  26600. 3
  26601. ],
  26602. [
  26603. 4,
  26604. 3
  26605. ],
  26606. [
  26607. 4,
  26608. 3
  26609. ],
  26610. [
  26611. 4,
  26612. 3
  26613. ],
  26614. [
  26615. 4,
  26616. 3
  26617. ],
  26618. [
  26619. 4,
  26620. 3
  26621. ],
  26622. [
  26623. 4,
  26624. 3
  26625. ],
  26626. [
  26627. 4,
  26628. 3
  26629. ],
  26630. [
  26631. 4,
  26632. 3
  26633. ],
  26634. [
  26635. 4,
  26636. 3
  26637. ],
  26638. [
  26639. 4,
  26640. 3
  26641. ],
  26642. [
  26643. 4,
  26644. 3
  26645. ],
  26646. [
  26647. 4,
  26648. 3
  26649. ],
  26650. [
  26651. 5,
  26652. 128
  26653. ],
  26654. [
  26655. 5,
  26656. 128
  26657. ],
  26658. [
  26659. 5,
  26660. 128
  26661. ],
  26662. [
  26663. 5,
  26664. 128
  26665. ],
  26666. [
  26667. 5,
  26668. 128
  26669. ],
  26670. [
  26671. 5,
  26672. 128
  26673. ],
  26674. [
  26675. 5,
  26676. 128
  26677. ],
  26678. [
  26679. 5,
  26680. 128
  26681. ],
  26682. [
  26683. 5,
  26684. 128
  26685. ],
  26686. [
  26687. 5,
  26688. 128
  26689. ],
  26690. [
  26691. 5,
  26692. 128
  26693. ],
  26694. [
  26695. 5,
  26696. 128
  26697. ],
  26698. [
  26699. 5,
  26700. 128
  26701. ],
  26702. [
  26703. 5,
  26704. 128
  26705. ],
  26706. [
  26707. 5,
  26708. 128
  26709. ],
  26710. [
  26711. 5,
  26712. 128
  26713. ],
  26714. [
  26715. 5,
  26716. 8
  26717. ],
  26718. [
  26719. 5,
  26720. 8
  26721. ],
  26722. [
  26723. 5,
  26724. 8
  26725. ],
  26726. [
  26727. 5,
  26728. 8
  26729. ],
  26730. [
  26731. 5,
  26732. 8
  26733. ],
  26734. [
  26735. 5,
  26736. 8
  26737. ],
  26738. [
  26739. 5,
  26740. 8
  26741. ],
  26742. [
  26743. 5,
  26744. 8
  26745. ],
  26746. [
  26747. 5,
  26748. 8
  26749. ],
  26750. [
  26751. 5,
  26752. 8
  26753. ],
  26754. [
  26755. 5,
  26756. 8
  26757. ],
  26758. [
  26759. 5,
  26760. 8
  26761. ],
  26762. [
  26763. 5,
  26764. 8
  26765. ],
  26766. [
  26767. 5,
  26768. 8
  26769. ],
  26770. [
  26771. 5,
  26772. 8
  26773. ],
  26774. [
  26775. 5,
  26776. 8
  26777. ],
  26778. [
  26779. 5,
  26780. 9
  26781. ],
  26782. [
  26783. 5,
  26784. 9
  26785. ],
  26786. [
  26787. 5,
  26788. 9
  26789. ],
  26790. [
  26791. 5,
  26792. 9
  26793. ],
  26794. [
  26795. 5,
  26796. 9
  26797. ],
  26798. [
  26799. 5,
  26800. 9
  26801. ],
  26802. [
  26803. 5,
  26804. 9
  26805. ],
  26806. [
  26807. 5,
  26808. 9
  26809. ],
  26810. [
  26811. 5,
  26812. 9
  26813. ],
  26814. [
  26815. 5,
  26816. 9
  26817. ],
  26818. [
  26819. 5,
  26820. 9
  26821. ],
  26822. [
  26823. 5,
  26824. 9
  26825. ],
  26826. [
  26827. 5,
  26828. 9
  26829. ],
  26830. [
  26831. 5,
  26832. 9
  26833. ],
  26834. [
  26835. 5,
  26836. 9
  26837. ],
  26838. [
  26839. 5,
  26840. 9
  26841. ],
  26842. [
  26843. 6,
  26844. 16
  26845. ],
  26846. [
  26847. 6,
  26848. 16
  26849. ],
  26850. [
  26851. 6,
  26852. 16
  26853. ],
  26854. [
  26855. 6,
  26856. 16
  26857. ],
  26858. [
  26859. 6,
  26860. 16
  26861. ],
  26862. [
  26863. 6,
  26864. 16
  26865. ],
  26866. [
  26867. 6,
  26868. 16
  26869. ],
  26870. [
  26871. 6,
  26872. 16
  26873. ],
  26874. [
  26875. 6,
  26876. 17
  26877. ],
  26878. [
  26879. 6,
  26880. 17
  26881. ],
  26882. [
  26883. 6,
  26884. 17
  26885. ],
  26886. [
  26887. 6,
  26888. 17
  26889. ],
  26890. [
  26891. 6,
  26892. 17
  26893. ],
  26894. [
  26895. 6,
  26896. 17
  26897. ],
  26898. [
  26899. 6,
  26900. 17
  26901. ],
  26902. [
  26903. 6,
  26904. 17
  26905. ],
  26906. [
  26907. 4,
  26908. 4
  26909. ],
  26910. [
  26911. 4,
  26912. 4
  26913. ],
  26914. [
  26915. 4,
  26916. 4
  26917. ],
  26918. [
  26919. 4,
  26920. 4
  26921. ],
  26922. [
  26923. 4,
  26924. 4
  26925. ],
  26926. [
  26927. 4,
  26928. 4
  26929. ],
  26930. [
  26931. 4,
  26932. 4
  26933. ],
  26934. [
  26935. 4,
  26936. 4
  26937. ],
  26938. [
  26939. 4,
  26940. 4
  26941. ],
  26942. [
  26943. 4,
  26944. 4
  26945. ],
  26946. [
  26947. 4,
  26948. 4
  26949. ],
  26950. [
  26951. 4,
  26952. 4
  26953. ],
  26954. [
  26955. 4,
  26956. 4
  26957. ],
  26958. [
  26959. 4,
  26960. 4
  26961. ],
  26962. [
  26963. 4,
  26964. 4
  26965. ],
  26966. [
  26967. 4,
  26968. 4
  26969. ],
  26970. [
  26971. 4,
  26972. 4
  26973. ],
  26974. [
  26975. 4,
  26976. 4
  26977. ],
  26978. [
  26979. 4,
  26980. 4
  26981. ],
  26982. [
  26983. 4,
  26984. 4
  26985. ],
  26986. [
  26987. 4,
  26988. 4
  26989. ],
  26990. [
  26991. 4,
  26992. 4
  26993. ],
  26994. [
  26995. 4,
  26996. 4
  26997. ],
  26998. [
  26999. 4,
  27000. 4
  27001. ],
  27002. [
  27003. 4,
  27004. 4
  27005. ],
  27006. [
  27007. 4,
  27008. 4
  27009. ],
  27010. [
  27011. 4,
  27012. 4
  27013. ],
  27014. [
  27015. 4,
  27016. 4
  27017. ],
  27018. [
  27019. 4,
  27020. 4
  27021. ],
  27022. [
  27023. 4,
  27024. 4
  27025. ],
  27026. [
  27027. 4,
  27028. 4
  27029. ],
  27030. [
  27031. 4,
  27032. 4
  27033. ],
  27034. [
  27035. 4,
  27036. 5
  27037. ],
  27038. [
  27039. 4,
  27040. 5
  27041. ],
  27042. [
  27043. 4,
  27044. 5
  27045. ],
  27046. [
  27047. 4,
  27048. 5
  27049. ],
  27050. [
  27051. 4,
  27052. 5
  27053. ],
  27054. [
  27055. 4,
  27056. 5
  27057. ],
  27058. [
  27059. 4,
  27060. 5
  27061. ],
  27062. [
  27063. 4,
  27064. 5
  27065. ],
  27066. [
  27067. 4,
  27068. 5
  27069. ],
  27070. [
  27071. 4,
  27072. 5
  27073. ],
  27074. [
  27075. 4,
  27076. 5
  27077. ],
  27078. [
  27079. 4,
  27080. 5
  27081. ],
  27082. [
  27083. 4,
  27084. 5
  27085. ],
  27086. [
  27087. 4,
  27088. 5
  27089. ],
  27090. [
  27091. 4,
  27092. 5
  27093. ],
  27094. [
  27095. 4,
  27096. 5
  27097. ],
  27098. [
  27099. 4,
  27100. 5
  27101. ],
  27102. [
  27103. 4,
  27104. 5
  27105. ],
  27106. [
  27107. 4,
  27108. 5
  27109. ],
  27110. [
  27111. 4,
  27112. 5
  27113. ],
  27114. [
  27115. 4,
  27116. 5
  27117. ],
  27118. [
  27119. 4,
  27120. 5
  27121. ],
  27122. [
  27123. 4,
  27124. 5
  27125. ],
  27126. [
  27127. 4,
  27128. 5
  27129. ],
  27130. [
  27131. 4,
  27132. 5
  27133. ],
  27134. [
  27135. 4,
  27136. 5
  27137. ],
  27138. [
  27139. 4,
  27140. 5
  27141. ],
  27142. [
  27143. 4,
  27144. 5
  27145. ],
  27146. [
  27147. 4,
  27148. 5
  27149. ],
  27150. [
  27151. 4,
  27152. 5
  27153. ],
  27154. [
  27155. 4,
  27156. 5
  27157. ],
  27158. [
  27159. 4,
  27160. 5
  27161. ],
  27162. [
  27163. 6,
  27164. 14
  27165. ],
  27166. [
  27167. 6,
  27168. 14
  27169. ],
  27170. [
  27171. 6,
  27172. 14
  27173. ],
  27174. [
  27175. 6,
  27176. 14
  27177. ],
  27178. [
  27179. 6,
  27180. 14
  27181. ],
  27182. [
  27183. 6,
  27184. 14
  27185. ],
  27186. [
  27187. 6,
  27188. 14
  27189. ],
  27190. [
  27191. 6,
  27192. 14
  27193. ],
  27194. [
  27195. 6,
  27196. 15
  27197. ],
  27198. [
  27199. 6,
  27200. 15
  27201. ],
  27202. [
  27203. 6,
  27204. 15
  27205. ],
  27206. [
  27207. 6,
  27208. 15
  27209. ],
  27210. [
  27211. 6,
  27212. 15
  27213. ],
  27214. [
  27215. 6,
  27216. 15
  27217. ],
  27218. [
  27219. 6,
  27220. 15
  27221. ],
  27222. [
  27223. 6,
  27224. 15
  27225. ],
  27226. [
  27227. 5,
  27228. 64
  27229. ],
  27230. [
  27231. 5,
  27232. 64
  27233. ],
  27234. [
  27235. 5,
  27236. 64
  27237. ],
  27238. [
  27239. 5,
  27240. 64
  27241. ],
  27242. [
  27243. 5,
  27244. 64
  27245. ],
  27246. [
  27247. 5,
  27248. 64
  27249. ],
  27250. [
  27251. 5,
  27252. 64
  27253. ],
  27254. [
  27255. 5,
  27256. 64
  27257. ],
  27258. [
  27259. 5,
  27260. 64
  27261. ],
  27262. [
  27263. 5,
  27264. 64
  27265. ],
  27266. [
  27267. 5,
  27268. 64
  27269. ],
  27270. [
  27271. 5,
  27272. 64
  27273. ],
  27274. [
  27275. 5,
  27276. 64
  27277. ],
  27278. [
  27279. 5,
  27280. 64
  27281. ],
  27282. [
  27283. 5,
  27284. 64
  27285. ],
  27286. [
  27287. 5,
  27288. 64
  27289. ],
  27290. [
  27291. 4,
  27292. 6
  27293. ],
  27294. [
  27295. 4,
  27296. 6
  27297. ],
  27298. [
  27299. 4,
  27300. 6
  27301. ],
  27302. [
  27303. 4,
  27304. 6
  27305. ],
  27306. [
  27307. 4,
  27308. 6
  27309. ],
  27310. [
  27311. 4,
  27312. 6
  27313. ],
  27314. [
  27315. 4,
  27316. 6
  27317. ],
  27318. [
  27319. 4,
  27320. 6
  27321. ],
  27322. [
  27323. 4,
  27324. 6
  27325. ],
  27326. [
  27327. 4,
  27328. 6
  27329. ],
  27330. [
  27331. 4,
  27332. 6
  27333. ],
  27334. [
  27335. 4,
  27336. 6
  27337. ],
  27338. [
  27339. 4,
  27340. 6
  27341. ],
  27342. [
  27343. 4,
  27344. 6
  27345. ],
  27346. [
  27347. 4,
  27348. 6
  27349. ],
  27350. [
  27351. 4,
  27352. 6
  27353. ],
  27354. [
  27355. 4,
  27356. 6
  27357. ],
  27358. [
  27359. 4,
  27360. 6
  27361. ],
  27362. [
  27363. 4,
  27364. 6
  27365. ],
  27366. [
  27367. 4,
  27368. 6
  27369. ],
  27370. [
  27371. 4,
  27372. 6
  27373. ],
  27374. [
  27375. 4,
  27376. 6
  27377. ],
  27378. [
  27379. 4,
  27380. 6
  27381. ],
  27382. [
  27383. 4,
  27384. 6
  27385. ],
  27386. [
  27387. 4,
  27388. 6
  27389. ],
  27390. [
  27391. 4,
  27392. 6
  27393. ],
  27394. [
  27395. 4,
  27396. 6
  27397. ],
  27398. [
  27399. 4,
  27400. 6
  27401. ],
  27402. [
  27403. 4,
  27404. 6
  27405. ],
  27406. [
  27407. 4,
  27408. 6
  27409. ],
  27410. [
  27411. 4,
  27412. 6
  27413. ],
  27414. [
  27415. 4,
  27416. 6
  27417. ],
  27418. [
  27419. 4,
  27420. 7
  27421. ],
  27422. [
  27423. 4,
  27424. 7
  27425. ],
  27426. [
  27427. 4,
  27428. 7
  27429. ],
  27430. [
  27431. 4,
  27432. 7
  27433. ],
  27434. [
  27435. 4,
  27436. 7
  27437. ],
  27438. [
  27439. 4,
  27440. 7
  27441. ],
  27442. [
  27443. 4,
  27444. 7
  27445. ],
  27446. [
  27447. 4,
  27448. 7
  27449. ],
  27450. [
  27451. 4,
  27452. 7
  27453. ],
  27454. [
  27455. 4,
  27456. 7
  27457. ],
  27458. [
  27459. 4,
  27460. 7
  27461. ],
  27462. [
  27463. 4,
  27464. 7
  27465. ],
  27466. [
  27467. 4,
  27468. 7
  27469. ],
  27470. [
  27471. 4,
  27472. 7
  27473. ],
  27474. [
  27475. 4,
  27476. 7
  27477. ],
  27478. [
  27479. 4,
  27480. 7
  27481. ],
  27482. [
  27483. 4,
  27484. 7
  27485. ],
  27486. [
  27487. 4,
  27488. 7
  27489. ],
  27490. [
  27491. 4,
  27492. 7
  27493. ],
  27494. [
  27495. 4,
  27496. 7
  27497. ],
  27498. [
  27499. 4,
  27500. 7
  27501. ],
  27502. [
  27503. 4,
  27504. 7
  27505. ],
  27506. [
  27507. 4,
  27508. 7
  27509. ],
  27510. [
  27511. 4,
  27512. 7
  27513. ],
  27514. [
  27515. 4,
  27516. 7
  27517. ],
  27518. [
  27519. 4,
  27520. 7
  27521. ],
  27522. [
  27523. 4,
  27524. 7
  27525. ],
  27526. [
  27527. 4,
  27528. 7
  27529. ],
  27530. [
  27531. 4,
  27532. 7
  27533. ],
  27534. [
  27535. 4,
  27536. 7
  27537. ],
  27538. [
  27539. 4,
  27540. 7
  27541. ],
  27542. [
  27543. 4,
  27544. 7
  27545. ]
  27546. ];
  27547. var blackTable1 = [
  27548. [
  27549. -1,
  27550. -1
  27551. ],
  27552. [
  27553. -1,
  27554. -1
  27555. ],
  27556. [
  27557. 12,
  27558. ccittEOL
  27559. ],
  27560. [
  27561. 12,
  27562. ccittEOL
  27563. ],
  27564. [
  27565. -1,
  27566. -1
  27567. ],
  27568. [
  27569. -1,
  27570. -1
  27571. ],
  27572. [
  27573. -1,
  27574. -1
  27575. ],
  27576. [
  27577. -1,
  27578. -1
  27579. ],
  27580. [
  27581. -1,
  27582. -1
  27583. ],
  27584. [
  27585. -1,
  27586. -1
  27587. ],
  27588. [
  27589. -1,
  27590. -1
  27591. ],
  27592. [
  27593. -1,
  27594. -1
  27595. ],
  27596. [
  27597. -1,
  27598. -1
  27599. ],
  27600. [
  27601. -1,
  27602. -1
  27603. ],
  27604. [
  27605. -1,
  27606. -1
  27607. ],
  27608. [
  27609. -1,
  27610. -1
  27611. ],
  27612. [
  27613. -1,
  27614. -1
  27615. ],
  27616. [
  27617. -1,
  27618. -1
  27619. ],
  27620. [
  27621. -1,
  27622. -1
  27623. ],
  27624. [
  27625. -1,
  27626. -1
  27627. ],
  27628. [
  27629. -1,
  27630. -1
  27631. ],
  27632. [
  27633. -1,
  27634. -1
  27635. ],
  27636. [
  27637. -1,
  27638. -1
  27639. ],
  27640. [
  27641. -1,
  27642. -1
  27643. ],
  27644. [
  27645. -1,
  27646. -1
  27647. ],
  27648. [
  27649. -1,
  27650. -1
  27651. ],
  27652. [
  27653. -1,
  27654. -1
  27655. ],
  27656. [
  27657. -1,
  27658. -1
  27659. ],
  27660. [
  27661. -1,
  27662. -1
  27663. ],
  27664. [
  27665. -1,
  27666. -1
  27667. ],
  27668. [
  27669. -1,
  27670. -1
  27671. ],
  27672. [
  27673. -1,
  27674. -1
  27675. ],
  27676. [
  27677. 11,
  27678. 1792
  27679. ],
  27680. [
  27681. 11,
  27682. 1792
  27683. ],
  27684. [
  27685. 11,
  27686. 1792
  27687. ],
  27688. [
  27689. 11,
  27690. 1792
  27691. ],
  27692. [
  27693. 12,
  27694. 1984
  27695. ],
  27696. [
  27697. 12,
  27698. 1984
  27699. ],
  27700. [
  27701. 12,
  27702. 2048
  27703. ],
  27704. [
  27705. 12,
  27706. 2048
  27707. ],
  27708. [
  27709. 12,
  27710. 2112
  27711. ],
  27712. [
  27713. 12,
  27714. 2112
  27715. ],
  27716. [
  27717. 12,
  27718. 2176
  27719. ],
  27720. [
  27721. 12,
  27722. 2176
  27723. ],
  27724. [
  27725. 12,
  27726. 2240
  27727. ],
  27728. [
  27729. 12,
  27730. 2240
  27731. ],
  27732. [
  27733. 12,
  27734. 2304
  27735. ],
  27736. [
  27737. 12,
  27738. 2304
  27739. ],
  27740. [
  27741. 11,
  27742. 1856
  27743. ],
  27744. [
  27745. 11,
  27746. 1856
  27747. ],
  27748. [
  27749. 11,
  27750. 1856
  27751. ],
  27752. [
  27753. 11,
  27754. 1856
  27755. ],
  27756. [
  27757. 11,
  27758. 1920
  27759. ],
  27760. [
  27761. 11,
  27762. 1920
  27763. ],
  27764. [
  27765. 11,
  27766. 1920
  27767. ],
  27768. [
  27769. 11,
  27770. 1920
  27771. ],
  27772. [
  27773. 12,
  27774. 2368
  27775. ],
  27776. [
  27777. 12,
  27778. 2368
  27779. ],
  27780. [
  27781. 12,
  27782. 2432
  27783. ],
  27784. [
  27785. 12,
  27786. 2432
  27787. ],
  27788. [
  27789. 12,
  27790. 2496
  27791. ],
  27792. [
  27793. 12,
  27794. 2496
  27795. ],
  27796. [
  27797. 12,
  27798. 2560
  27799. ],
  27800. [
  27801. 12,
  27802. 2560
  27803. ],
  27804. [
  27805. 10,
  27806. 18
  27807. ],
  27808. [
  27809. 10,
  27810. 18
  27811. ],
  27812. [
  27813. 10,
  27814. 18
  27815. ],
  27816. [
  27817. 10,
  27818. 18
  27819. ],
  27820. [
  27821. 10,
  27822. 18
  27823. ],
  27824. [
  27825. 10,
  27826. 18
  27827. ],
  27828. [
  27829. 10,
  27830. 18
  27831. ],
  27832. [
  27833. 10,
  27834. 18
  27835. ],
  27836. [
  27837. 12,
  27838. 52
  27839. ],
  27840. [
  27841. 12,
  27842. 52
  27843. ],
  27844. [
  27845. 13,
  27846. 640
  27847. ],
  27848. [
  27849. 13,
  27850. 704
  27851. ],
  27852. [
  27853. 13,
  27854. 768
  27855. ],
  27856. [
  27857. 13,
  27858. 832
  27859. ],
  27860. [
  27861. 12,
  27862. 55
  27863. ],
  27864. [
  27865. 12,
  27866. 55
  27867. ],
  27868. [
  27869. 12,
  27870. 56
  27871. ],
  27872. [
  27873. 12,
  27874. 56
  27875. ],
  27876. [
  27877. 13,
  27878. 1280
  27879. ],
  27880. [
  27881. 13,
  27882. 1344
  27883. ],
  27884. [
  27885. 13,
  27886. 1408
  27887. ],
  27888. [
  27889. 13,
  27890. 1472
  27891. ],
  27892. [
  27893. 12,
  27894. 59
  27895. ],
  27896. [
  27897. 12,
  27898. 59
  27899. ],
  27900. [
  27901. 12,
  27902. 60
  27903. ],
  27904. [
  27905. 12,
  27906. 60
  27907. ],
  27908. [
  27909. 13,
  27910. 1536
  27911. ],
  27912. [
  27913. 13,
  27914. 1600
  27915. ],
  27916. [
  27917. 11,
  27918. 24
  27919. ],
  27920. [
  27921. 11,
  27922. 24
  27923. ],
  27924. [
  27925. 11,
  27926. 24
  27927. ],
  27928. [
  27929. 11,
  27930. 24
  27931. ],
  27932. [
  27933. 11,
  27934. 25
  27935. ],
  27936. [
  27937. 11,
  27938. 25
  27939. ],
  27940. [
  27941. 11,
  27942. 25
  27943. ],
  27944. [
  27945. 11,
  27946. 25
  27947. ],
  27948. [
  27949. 13,
  27950. 1664
  27951. ],
  27952. [
  27953. 13,
  27954. 1728
  27955. ],
  27956. [
  27957. 12,
  27958. 320
  27959. ],
  27960. [
  27961. 12,
  27962. 320
  27963. ],
  27964. [
  27965. 12,
  27966. 384
  27967. ],
  27968. [
  27969. 12,
  27970. 384
  27971. ],
  27972. [
  27973. 12,
  27974. 448
  27975. ],
  27976. [
  27977. 12,
  27978. 448
  27979. ],
  27980. [
  27981. 13,
  27982. 512
  27983. ],
  27984. [
  27985. 13,
  27986. 576
  27987. ],
  27988. [
  27989. 12,
  27990. 53
  27991. ],
  27992. [
  27993. 12,
  27994. 53
  27995. ],
  27996. [
  27997. 12,
  27998. 54
  27999. ],
  28000. [
  28001. 12,
  28002. 54
  28003. ],
  28004. [
  28005. 13,
  28006. 896
  28007. ],
  28008. [
  28009. 13,
  28010. 960
  28011. ],
  28012. [
  28013. 13,
  28014. 1024
  28015. ],
  28016. [
  28017. 13,
  28018. 1088
  28019. ],
  28020. [
  28021. 13,
  28022. 1152
  28023. ],
  28024. [
  28025. 13,
  28026. 1216
  28027. ],
  28028. [
  28029. 10,
  28030. 64
  28031. ],
  28032. [
  28033. 10,
  28034. 64
  28035. ],
  28036. [
  28037. 10,
  28038. 64
  28039. ],
  28040. [
  28041. 10,
  28042. 64
  28043. ],
  28044. [
  28045. 10,
  28046. 64
  28047. ],
  28048. [
  28049. 10,
  28050. 64
  28051. ],
  28052. [
  28053. 10,
  28054. 64
  28055. ],
  28056. [
  28057. 10,
  28058. 64
  28059. ]
  28060. ];
  28061. var blackTable2 = [
  28062. [
  28063. 8,
  28064. 13
  28065. ],
  28066. [
  28067. 8,
  28068. 13
  28069. ],
  28070. [
  28071. 8,
  28072. 13
  28073. ],
  28074. [
  28075. 8,
  28076. 13
  28077. ],
  28078. [
  28079. 8,
  28080. 13
  28081. ],
  28082. [
  28083. 8,
  28084. 13
  28085. ],
  28086. [
  28087. 8,
  28088. 13
  28089. ],
  28090. [
  28091. 8,
  28092. 13
  28093. ],
  28094. [
  28095. 8,
  28096. 13
  28097. ],
  28098. [
  28099. 8,
  28100. 13
  28101. ],
  28102. [
  28103. 8,
  28104. 13
  28105. ],
  28106. [
  28107. 8,
  28108. 13
  28109. ],
  28110. [
  28111. 8,
  28112. 13
  28113. ],
  28114. [
  28115. 8,
  28116. 13
  28117. ],
  28118. [
  28119. 8,
  28120. 13
  28121. ],
  28122. [
  28123. 8,
  28124. 13
  28125. ],
  28126. [
  28127. 11,
  28128. 23
  28129. ],
  28130. [
  28131. 11,
  28132. 23
  28133. ],
  28134. [
  28135. 12,
  28136. 50
  28137. ],
  28138. [
  28139. 12,
  28140. 51
  28141. ],
  28142. [
  28143. 12,
  28144. 44
  28145. ],
  28146. [
  28147. 12,
  28148. 45
  28149. ],
  28150. [
  28151. 12,
  28152. 46
  28153. ],
  28154. [
  28155. 12,
  28156. 47
  28157. ],
  28158. [
  28159. 12,
  28160. 57
  28161. ],
  28162. [
  28163. 12,
  28164. 58
  28165. ],
  28166. [
  28167. 12,
  28168. 61
  28169. ],
  28170. [
  28171. 12,
  28172. 256
  28173. ],
  28174. [
  28175. 10,
  28176. 16
  28177. ],
  28178. [
  28179. 10,
  28180. 16
  28181. ],
  28182. [
  28183. 10,
  28184. 16
  28185. ],
  28186. [
  28187. 10,
  28188. 16
  28189. ],
  28190. [
  28191. 10,
  28192. 17
  28193. ],
  28194. [
  28195. 10,
  28196. 17
  28197. ],
  28198. [
  28199. 10,
  28200. 17
  28201. ],
  28202. [
  28203. 10,
  28204. 17
  28205. ],
  28206. [
  28207. 12,
  28208. 48
  28209. ],
  28210. [
  28211. 12,
  28212. 49
  28213. ],
  28214. [
  28215. 12,
  28216. 62
  28217. ],
  28218. [
  28219. 12,
  28220. 63
  28221. ],
  28222. [
  28223. 12,
  28224. 30
  28225. ],
  28226. [
  28227. 12,
  28228. 31
  28229. ],
  28230. [
  28231. 12,
  28232. 32
  28233. ],
  28234. [
  28235. 12,
  28236. 33
  28237. ],
  28238. [
  28239. 12,
  28240. 40
  28241. ],
  28242. [
  28243. 12,
  28244. 41
  28245. ],
  28246. [
  28247. 11,
  28248. 22
  28249. ],
  28250. [
  28251. 11,
  28252. 22
  28253. ],
  28254. [
  28255. 8,
  28256. 14
  28257. ],
  28258. [
  28259. 8,
  28260. 14
  28261. ],
  28262. [
  28263. 8,
  28264. 14
  28265. ],
  28266. [
  28267. 8,
  28268. 14
  28269. ],
  28270. [
  28271. 8,
  28272. 14
  28273. ],
  28274. [
  28275. 8,
  28276. 14
  28277. ],
  28278. [
  28279. 8,
  28280. 14
  28281. ],
  28282. [
  28283. 8,
  28284. 14
  28285. ],
  28286. [
  28287. 8,
  28288. 14
  28289. ],
  28290. [
  28291. 8,
  28292. 14
  28293. ],
  28294. [
  28295. 8,
  28296. 14
  28297. ],
  28298. [
  28299. 8,
  28300. 14
  28301. ],
  28302. [
  28303. 8,
  28304. 14
  28305. ],
  28306. [
  28307. 8,
  28308. 14
  28309. ],
  28310. [
  28311. 8,
  28312. 14
  28313. ],
  28314. [
  28315. 8,
  28316. 14
  28317. ],
  28318. [
  28319. 7,
  28320. 10
  28321. ],
  28322. [
  28323. 7,
  28324. 10
  28325. ],
  28326. [
  28327. 7,
  28328. 10
  28329. ],
  28330. [
  28331. 7,
  28332. 10
  28333. ],
  28334. [
  28335. 7,
  28336. 10
  28337. ],
  28338. [
  28339. 7,
  28340. 10
  28341. ],
  28342. [
  28343. 7,
  28344. 10
  28345. ],
  28346. [
  28347. 7,
  28348. 10
  28349. ],
  28350. [
  28351. 7,
  28352. 10
  28353. ],
  28354. [
  28355. 7,
  28356. 10
  28357. ],
  28358. [
  28359. 7,
  28360. 10
  28361. ],
  28362. [
  28363. 7,
  28364. 10
  28365. ],
  28366. [
  28367. 7,
  28368. 10
  28369. ],
  28370. [
  28371. 7,
  28372. 10
  28373. ],
  28374. [
  28375. 7,
  28376. 10
  28377. ],
  28378. [
  28379. 7,
  28380. 10
  28381. ],
  28382. [
  28383. 7,
  28384. 10
  28385. ],
  28386. [
  28387. 7,
  28388. 10
  28389. ],
  28390. [
  28391. 7,
  28392. 10
  28393. ],
  28394. [
  28395. 7,
  28396. 10
  28397. ],
  28398. [
  28399. 7,
  28400. 10
  28401. ],
  28402. [
  28403. 7,
  28404. 10
  28405. ],
  28406. [
  28407. 7,
  28408. 10
  28409. ],
  28410. [
  28411. 7,
  28412. 10
  28413. ],
  28414. [
  28415. 7,
  28416. 10
  28417. ],
  28418. [
  28419. 7,
  28420. 10
  28421. ],
  28422. [
  28423. 7,
  28424. 10
  28425. ],
  28426. [
  28427. 7,
  28428. 10
  28429. ],
  28430. [
  28431. 7,
  28432. 10
  28433. ],
  28434. [
  28435. 7,
  28436. 10
  28437. ],
  28438. [
  28439. 7,
  28440. 10
  28441. ],
  28442. [
  28443. 7,
  28444. 10
  28445. ],
  28446. [
  28447. 7,
  28448. 11
  28449. ],
  28450. [
  28451. 7,
  28452. 11
  28453. ],
  28454. [
  28455. 7,
  28456. 11
  28457. ],
  28458. [
  28459. 7,
  28460. 11
  28461. ],
  28462. [
  28463. 7,
  28464. 11
  28465. ],
  28466. [
  28467. 7,
  28468. 11
  28469. ],
  28470. [
  28471. 7,
  28472. 11
  28473. ],
  28474. [
  28475. 7,
  28476. 11
  28477. ],
  28478. [
  28479. 7,
  28480. 11
  28481. ],
  28482. [
  28483. 7,
  28484. 11
  28485. ],
  28486. [
  28487. 7,
  28488. 11
  28489. ],
  28490. [
  28491. 7,
  28492. 11
  28493. ],
  28494. [
  28495. 7,
  28496. 11
  28497. ],
  28498. [
  28499. 7,
  28500. 11
  28501. ],
  28502. [
  28503. 7,
  28504. 11
  28505. ],
  28506. [
  28507. 7,
  28508. 11
  28509. ],
  28510. [
  28511. 7,
  28512. 11
  28513. ],
  28514. [
  28515. 7,
  28516. 11
  28517. ],
  28518. [
  28519. 7,
  28520. 11
  28521. ],
  28522. [
  28523. 7,
  28524. 11
  28525. ],
  28526. [
  28527. 7,
  28528. 11
  28529. ],
  28530. [
  28531. 7,
  28532. 11
  28533. ],
  28534. [
  28535. 7,
  28536. 11
  28537. ],
  28538. [
  28539. 7,
  28540. 11
  28541. ],
  28542. [
  28543. 7,
  28544. 11
  28545. ],
  28546. [
  28547. 7,
  28548. 11
  28549. ],
  28550. [
  28551. 7,
  28552. 11
  28553. ],
  28554. [
  28555. 7,
  28556. 11
  28557. ],
  28558. [
  28559. 7,
  28560. 11
  28561. ],
  28562. [
  28563. 7,
  28564. 11
  28565. ],
  28566. [
  28567. 7,
  28568. 11
  28569. ],
  28570. [
  28571. 7,
  28572. 11
  28573. ],
  28574. [
  28575. 9,
  28576. 15
  28577. ],
  28578. [
  28579. 9,
  28580. 15
  28581. ],
  28582. [
  28583. 9,
  28584. 15
  28585. ],
  28586. [
  28587. 9,
  28588. 15
  28589. ],
  28590. [
  28591. 9,
  28592. 15
  28593. ],
  28594. [
  28595. 9,
  28596. 15
  28597. ],
  28598. [
  28599. 9,
  28600. 15
  28601. ],
  28602. [
  28603. 9,
  28604. 15
  28605. ],
  28606. [
  28607. 12,
  28608. 128
  28609. ],
  28610. [
  28611. 12,
  28612. 192
  28613. ],
  28614. [
  28615. 12,
  28616. 26
  28617. ],
  28618. [
  28619. 12,
  28620. 27
  28621. ],
  28622. [
  28623. 12,
  28624. 28
  28625. ],
  28626. [
  28627. 12,
  28628. 29
  28629. ],
  28630. [
  28631. 11,
  28632. 19
  28633. ],
  28634. [
  28635. 11,
  28636. 19
  28637. ],
  28638. [
  28639. 11,
  28640. 20
  28641. ],
  28642. [
  28643. 11,
  28644. 20
  28645. ],
  28646. [
  28647. 12,
  28648. 34
  28649. ],
  28650. [
  28651. 12,
  28652. 35
  28653. ],
  28654. [
  28655. 12,
  28656. 36
  28657. ],
  28658. [
  28659. 12,
  28660. 37
  28661. ],
  28662. [
  28663. 12,
  28664. 38
  28665. ],
  28666. [
  28667. 12,
  28668. 39
  28669. ],
  28670. [
  28671. 11,
  28672. 21
  28673. ],
  28674. [
  28675. 11,
  28676. 21
  28677. ],
  28678. [
  28679. 12,
  28680. 42
  28681. ],
  28682. [
  28683. 12,
  28684. 43
  28685. ],
  28686. [
  28687. 10,
  28688. 0
  28689. ],
  28690. [
  28691. 10,
  28692. 0
  28693. ],
  28694. [
  28695. 10,
  28696. 0
  28697. ],
  28698. [
  28699. 10,
  28700. 0
  28701. ],
  28702. [
  28703. 7,
  28704. 12
  28705. ],
  28706. [
  28707. 7,
  28708. 12
  28709. ],
  28710. [
  28711. 7,
  28712. 12
  28713. ],
  28714. [
  28715. 7,
  28716. 12
  28717. ],
  28718. [
  28719. 7,
  28720. 12
  28721. ],
  28722. [
  28723. 7,
  28724. 12
  28725. ],
  28726. [
  28727. 7,
  28728. 12
  28729. ],
  28730. [
  28731. 7,
  28732. 12
  28733. ],
  28734. [
  28735. 7,
  28736. 12
  28737. ],
  28738. [
  28739. 7,
  28740. 12
  28741. ],
  28742. [
  28743. 7,
  28744. 12
  28745. ],
  28746. [
  28747. 7,
  28748. 12
  28749. ],
  28750. [
  28751. 7,
  28752. 12
  28753. ],
  28754. [
  28755. 7,
  28756. 12
  28757. ],
  28758. [
  28759. 7,
  28760. 12
  28761. ],
  28762. [
  28763. 7,
  28764. 12
  28765. ],
  28766. [
  28767. 7,
  28768. 12
  28769. ],
  28770. [
  28771. 7,
  28772. 12
  28773. ],
  28774. [
  28775. 7,
  28776. 12
  28777. ],
  28778. [
  28779. 7,
  28780. 12
  28781. ],
  28782. [
  28783. 7,
  28784. 12
  28785. ],
  28786. [
  28787. 7,
  28788. 12
  28789. ],
  28790. [
  28791. 7,
  28792. 12
  28793. ],
  28794. [
  28795. 7,
  28796. 12
  28797. ],
  28798. [
  28799. 7,
  28800. 12
  28801. ],
  28802. [
  28803. 7,
  28804. 12
  28805. ],
  28806. [
  28807. 7,
  28808. 12
  28809. ],
  28810. [
  28811. 7,
  28812. 12
  28813. ],
  28814. [
  28815. 7,
  28816. 12
  28817. ],
  28818. [
  28819. 7,
  28820. 12
  28821. ],
  28822. [
  28823. 7,
  28824. 12
  28825. ],
  28826. [
  28827. 7,
  28828. 12
  28829. ]
  28830. ];
  28831. var blackTable3 = [
  28832. [
  28833. -1,
  28834. -1
  28835. ],
  28836. [
  28837. -1,
  28838. -1
  28839. ],
  28840. [
  28841. -1,
  28842. -1
  28843. ],
  28844. [
  28845. -1,
  28846. -1
  28847. ],
  28848. [
  28849. 6,
  28850. 9
  28851. ],
  28852. [
  28853. 6,
  28854. 8
  28855. ],
  28856. [
  28857. 5,
  28858. 7
  28859. ],
  28860. [
  28861. 5,
  28862. 7
  28863. ],
  28864. [
  28865. 4,
  28866. 6
  28867. ],
  28868. [
  28869. 4,
  28870. 6
  28871. ],
  28872. [
  28873. 4,
  28874. 6
  28875. ],
  28876. [
  28877. 4,
  28878. 6
  28879. ],
  28880. [
  28881. 4,
  28882. 5
  28883. ],
  28884. [
  28885. 4,
  28886. 5
  28887. ],
  28888. [
  28889. 4,
  28890. 5
  28891. ],
  28892. [
  28893. 4,
  28894. 5
  28895. ],
  28896. [
  28897. 3,
  28898. 1
  28899. ],
  28900. [
  28901. 3,
  28902. 1
  28903. ],
  28904. [
  28905. 3,
  28906. 1
  28907. ],
  28908. [
  28909. 3,
  28910. 1
  28911. ],
  28912. [
  28913. 3,
  28914. 1
  28915. ],
  28916. [
  28917. 3,
  28918. 1
  28919. ],
  28920. [
  28921. 3,
  28922. 1
  28923. ],
  28924. [
  28925. 3,
  28926. 1
  28927. ],
  28928. [
  28929. 3,
  28930. 4
  28931. ],
  28932. [
  28933. 3,
  28934. 4
  28935. ],
  28936. [
  28937. 3,
  28938. 4
  28939. ],
  28940. [
  28941. 3,
  28942. 4
  28943. ],
  28944. [
  28945. 3,
  28946. 4
  28947. ],
  28948. [
  28949. 3,
  28950. 4
  28951. ],
  28952. [
  28953. 3,
  28954. 4
  28955. ],
  28956. [
  28957. 3,
  28958. 4
  28959. ],
  28960. [
  28961. 2,
  28962. 3
  28963. ],
  28964. [
  28965. 2,
  28966. 3
  28967. ],
  28968. [
  28969. 2,
  28970. 3
  28971. ],
  28972. [
  28973. 2,
  28974. 3
  28975. ],
  28976. [
  28977. 2,
  28978. 3
  28979. ],
  28980. [
  28981. 2,
  28982. 3
  28983. ],
  28984. [
  28985. 2,
  28986. 3
  28987. ],
  28988. [
  28989. 2,
  28990. 3
  28991. ],
  28992. [
  28993. 2,
  28994. 3
  28995. ],
  28996. [
  28997. 2,
  28998. 3
  28999. ],
  29000. [
  29001. 2,
  29002. 3
  29003. ],
  29004. [
  29005. 2,
  29006. 3
  29007. ],
  29008. [
  29009. 2,
  29010. 3
  29011. ],
  29012. [
  29013. 2,
  29014. 3
  29015. ],
  29016. [
  29017. 2,
  29018. 3
  29019. ],
  29020. [
  29021. 2,
  29022. 3
  29023. ],
  29024. [
  29025. 2,
  29026. 2
  29027. ],
  29028. [
  29029. 2,
  29030. 2
  29031. ],
  29032. [
  29033. 2,
  29034. 2
  29035. ],
  29036. [
  29037. 2,
  29038. 2
  29039. ],
  29040. [
  29041. 2,
  29042. 2
  29043. ],
  29044. [
  29045. 2,
  29046. 2
  29047. ],
  29048. [
  29049. 2,
  29050. 2
  29051. ],
  29052. [
  29053. 2,
  29054. 2
  29055. ],
  29056. [
  29057. 2,
  29058. 2
  29059. ],
  29060. [
  29061. 2,
  29062. 2
  29063. ],
  29064. [
  29065. 2,
  29066. 2
  29067. ],
  29068. [
  29069. 2,
  29070. 2
  29071. ],
  29072. [
  29073. 2,
  29074. 2
  29075. ],
  29076. [
  29077. 2,
  29078. 2
  29079. ],
  29080. [
  29081. 2,
  29082. 2
  29083. ],
  29084. [
  29085. 2,
  29086. 2
  29087. ]
  29088. ];
  29089. function CCITTFaxStream(str, maybeLength, params) {
  29090. this.str = str;
  29091. this.dict = str.dict;
  29092. params = params || Dict.empty;
  29093. this.encoding = params.get('K') || 0;
  29094. this.eoline = params.get('EndOfLine') || false;
  29095. this.byteAlign = params.get('EncodedByteAlign') || false;
  29096. this.columns = params.get('Columns') || 1728;
  29097. this.rows = params.get('Rows') || 0;
  29098. var eoblock = params.get('EndOfBlock');
  29099. if (eoblock === null || eoblock === undefined) {
  29100. eoblock = true;
  29101. }
  29102. this.eoblock = eoblock;
  29103. this.black = params.get('BlackIs1') || false;
  29104. this.codingLine = new Uint32Array(this.columns + 1);
  29105. this.refLine = new Uint32Array(this.columns + 2);
  29106. this.codingLine[0] = this.columns;
  29107. this.codingPos = 0;
  29108. this.row = 0;
  29109. this.nextLine2D = this.encoding < 0;
  29110. this.inputBits = 0;
  29111. this.inputBuf = 0;
  29112. this.outputBits = 0;
  29113. var code1;
  29114. while ((code1 = this.lookBits(12)) === 0) {
  29115. this.eatBits(1);
  29116. }
  29117. if (code1 === 1) {
  29118. this.eatBits(12);
  29119. }
  29120. if (this.encoding > 0) {
  29121. this.nextLine2D = !this.lookBits(1);
  29122. this.eatBits(1);
  29123. }
  29124. DecodeStream.call(this, maybeLength);
  29125. }
  29126. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  29127. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  29128. while (!this.eof) {
  29129. var c = this.lookChar();
  29130. this.ensureBuffer(this.bufferLength + 1);
  29131. this.buffer[this.bufferLength++] = c;
  29132. }
  29133. };
  29134. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  29135. var codingLine = this.codingLine;
  29136. var codingPos = this.codingPos;
  29137. if (a1 > codingLine[codingPos]) {
  29138. if (a1 > this.columns) {
  29139. info('row is wrong length');
  29140. this.err = true;
  29141. a1 = this.columns;
  29142. }
  29143. if (codingPos & 1 ^ blackPixels) {
  29144. ++codingPos;
  29145. }
  29146. codingLine[codingPos] = a1;
  29147. }
  29148. this.codingPos = codingPos;
  29149. };
  29150. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  29151. var codingLine = this.codingLine;
  29152. var codingPos = this.codingPos;
  29153. if (a1 > codingLine[codingPos]) {
  29154. if (a1 > this.columns) {
  29155. info('row is wrong length');
  29156. this.err = true;
  29157. a1 = this.columns;
  29158. }
  29159. if (codingPos & 1 ^ blackPixels) {
  29160. ++codingPos;
  29161. }
  29162. codingLine[codingPos] = a1;
  29163. } else if (a1 < codingLine[codingPos]) {
  29164. if (a1 < 0) {
  29165. info('invalid code');
  29166. this.err = true;
  29167. a1 = 0;
  29168. }
  29169. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  29170. --codingPos;
  29171. }
  29172. codingLine[codingPos] = a1;
  29173. }
  29174. this.codingPos = codingPos;
  29175. };
  29176. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  29177. var refLine = this.refLine;
  29178. var codingLine = this.codingLine;
  29179. var columns = this.columns;
  29180. var refPos, blackPixels, bits, i;
  29181. if (this.outputBits === 0) {
  29182. if (this.eof) {
  29183. return null;
  29184. }
  29185. this.err = false;
  29186. var code1, code2, code3;
  29187. if (this.nextLine2D) {
  29188. for (i = 0; codingLine[i] < columns; ++i) {
  29189. refLine[i] = codingLine[i];
  29190. }
  29191. refLine[i++] = columns;
  29192. refLine[i] = columns;
  29193. codingLine[0] = 0;
  29194. this.codingPos = 0;
  29195. refPos = 0;
  29196. blackPixels = 0;
  29197. while (codingLine[this.codingPos] < columns) {
  29198. code1 = this.getTwoDimCode();
  29199. switch (code1) {
  29200. case twoDimPass:
  29201. this.addPixels(refLine[refPos + 1], blackPixels);
  29202. if (refLine[refPos + 1] < columns) {
  29203. refPos += 2;
  29204. }
  29205. break;
  29206. case twoDimHoriz:
  29207. code1 = code2 = 0;
  29208. if (blackPixels) {
  29209. do {
  29210. code1 += code3 = this.getBlackCode();
  29211. } while (code3 >= 64);
  29212. do {
  29213. code2 += code3 = this.getWhiteCode();
  29214. } while (code3 >= 64);
  29215. } else {
  29216. do {
  29217. code1 += code3 = this.getWhiteCode();
  29218. } while (code3 >= 64);
  29219. do {
  29220. code2 += code3 = this.getBlackCode();
  29221. } while (code3 >= 64);
  29222. }
  29223. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29224. if (codingLine[this.codingPos] < columns) {
  29225. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  29226. }
  29227. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29228. refPos += 2;
  29229. }
  29230. break;
  29231. case twoDimVertR3:
  29232. this.addPixels(refLine[refPos] + 3, blackPixels);
  29233. blackPixels ^= 1;
  29234. if (codingLine[this.codingPos] < columns) {
  29235. ++refPos;
  29236. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29237. refPos += 2;
  29238. }
  29239. }
  29240. break;
  29241. case twoDimVertR2:
  29242. this.addPixels(refLine[refPos] + 2, blackPixels);
  29243. blackPixels ^= 1;
  29244. if (codingLine[this.codingPos] < columns) {
  29245. ++refPos;
  29246. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29247. refPos += 2;
  29248. }
  29249. }
  29250. break;
  29251. case twoDimVertR1:
  29252. this.addPixels(refLine[refPos] + 1, blackPixels);
  29253. blackPixels ^= 1;
  29254. if (codingLine[this.codingPos] < columns) {
  29255. ++refPos;
  29256. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29257. refPos += 2;
  29258. }
  29259. }
  29260. break;
  29261. case twoDimVert0:
  29262. this.addPixels(refLine[refPos], blackPixels);
  29263. blackPixels ^= 1;
  29264. if (codingLine[this.codingPos] < columns) {
  29265. ++refPos;
  29266. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29267. refPos += 2;
  29268. }
  29269. }
  29270. break;
  29271. case twoDimVertL3:
  29272. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  29273. blackPixels ^= 1;
  29274. if (codingLine[this.codingPos] < columns) {
  29275. if (refPos > 0) {
  29276. --refPos;
  29277. } else {
  29278. ++refPos;
  29279. }
  29280. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29281. refPos += 2;
  29282. }
  29283. }
  29284. break;
  29285. case twoDimVertL2:
  29286. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  29287. blackPixels ^= 1;
  29288. if (codingLine[this.codingPos] < columns) {
  29289. if (refPos > 0) {
  29290. --refPos;
  29291. } else {
  29292. ++refPos;
  29293. }
  29294. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29295. refPos += 2;
  29296. }
  29297. }
  29298. break;
  29299. case twoDimVertL1:
  29300. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  29301. blackPixels ^= 1;
  29302. if (codingLine[this.codingPos] < columns) {
  29303. if (refPos > 0) {
  29304. --refPos;
  29305. } else {
  29306. ++refPos;
  29307. }
  29308. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29309. refPos += 2;
  29310. }
  29311. }
  29312. break;
  29313. case ccittEOF:
  29314. this.addPixels(columns, 0);
  29315. this.eof = true;
  29316. break;
  29317. default:
  29318. info('bad 2d code');
  29319. this.addPixels(columns, 0);
  29320. this.err = true;
  29321. }
  29322. }
  29323. } else {
  29324. codingLine[0] = 0;
  29325. this.codingPos = 0;
  29326. blackPixels = 0;
  29327. while (codingLine[this.codingPos] < columns) {
  29328. code1 = 0;
  29329. if (blackPixels) {
  29330. do {
  29331. code1 += code3 = this.getBlackCode();
  29332. } while (code3 >= 64);
  29333. } else {
  29334. do {
  29335. code1 += code3 = this.getWhiteCode();
  29336. } while (code3 >= 64);
  29337. }
  29338. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29339. blackPixels ^= 1;
  29340. }
  29341. }
  29342. var gotEOL = false;
  29343. if (this.byteAlign) {
  29344. this.inputBits &= ~7;
  29345. }
  29346. if (!this.eoblock && this.row === this.rows - 1) {
  29347. this.eof = true;
  29348. } else {
  29349. code1 = this.lookBits(12);
  29350. if (this.eoline) {
  29351. while (code1 !== ccittEOF && code1 !== 1) {
  29352. this.eatBits(1);
  29353. code1 = this.lookBits(12);
  29354. }
  29355. } else {
  29356. while (code1 === 0) {
  29357. this.eatBits(1);
  29358. code1 = this.lookBits(12);
  29359. }
  29360. }
  29361. if (code1 === 1) {
  29362. this.eatBits(12);
  29363. gotEOL = true;
  29364. } else if (code1 === ccittEOF) {
  29365. this.eof = true;
  29366. }
  29367. }
  29368. if (!this.eof && this.encoding > 0) {
  29369. this.nextLine2D = !this.lookBits(1);
  29370. this.eatBits(1);
  29371. }
  29372. if (this.eoblock && gotEOL && this.byteAlign) {
  29373. code1 = this.lookBits(12);
  29374. if (code1 === 1) {
  29375. this.eatBits(12);
  29376. if (this.encoding > 0) {
  29377. this.lookBits(1);
  29378. this.eatBits(1);
  29379. }
  29380. if (this.encoding >= 0) {
  29381. for (i = 0; i < 4; ++i) {
  29382. code1 = this.lookBits(12);
  29383. if (code1 !== 1) {
  29384. info('bad rtc code: ' + code1);
  29385. }
  29386. this.eatBits(12);
  29387. if (this.encoding > 0) {
  29388. this.lookBits(1);
  29389. this.eatBits(1);
  29390. }
  29391. }
  29392. }
  29393. this.eof = true;
  29394. }
  29395. } else if (this.err && this.eoline) {
  29396. while (true) {
  29397. code1 = this.lookBits(13);
  29398. if (code1 === ccittEOF) {
  29399. this.eof = true;
  29400. return null;
  29401. }
  29402. if (code1 >> 1 === 1) {
  29403. break;
  29404. }
  29405. this.eatBits(1);
  29406. }
  29407. this.eatBits(12);
  29408. if (this.encoding > 0) {
  29409. this.eatBits(1);
  29410. this.nextLine2D = !(code1 & 1);
  29411. }
  29412. }
  29413. if (codingLine[0] > 0) {
  29414. this.outputBits = codingLine[this.codingPos = 0];
  29415. } else {
  29416. this.outputBits = codingLine[this.codingPos = 1];
  29417. }
  29418. this.row++;
  29419. }
  29420. var c;
  29421. if (this.outputBits >= 8) {
  29422. c = this.codingPos & 1 ? 0 : 0xFF;
  29423. this.outputBits -= 8;
  29424. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  29425. this.codingPos++;
  29426. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29427. }
  29428. } else {
  29429. bits = 8;
  29430. c = 0;
  29431. do {
  29432. if (this.outputBits > bits) {
  29433. c <<= bits;
  29434. if (!(this.codingPos & 1)) {
  29435. c |= 0xFF >> 8 - bits;
  29436. }
  29437. this.outputBits -= bits;
  29438. bits = 0;
  29439. } else {
  29440. c <<= this.outputBits;
  29441. if (!(this.codingPos & 1)) {
  29442. c |= 0xFF >> 8 - this.outputBits;
  29443. }
  29444. bits -= this.outputBits;
  29445. this.outputBits = 0;
  29446. if (codingLine[this.codingPos] < columns) {
  29447. this.codingPos++;
  29448. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29449. } else if (bits > 0) {
  29450. c <<= bits;
  29451. bits = 0;
  29452. }
  29453. }
  29454. } while (bits);
  29455. }
  29456. if (this.black) {
  29457. c ^= 0xFF;
  29458. }
  29459. return c;
  29460. };
  29461. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  29462. var limitValue = limit || 0;
  29463. for (var i = start; i <= end; ++i) {
  29464. var code = this.lookBits(i);
  29465. if (code === ccittEOF) {
  29466. return [
  29467. true,
  29468. 1,
  29469. false
  29470. ];
  29471. }
  29472. if (i < end) {
  29473. code <<= end - i;
  29474. }
  29475. if (!limitValue || code >= limitValue) {
  29476. var p = table[code - limitValue];
  29477. if (p[0] === i) {
  29478. this.eatBits(i);
  29479. return [
  29480. true,
  29481. p[1],
  29482. true
  29483. ];
  29484. }
  29485. }
  29486. }
  29487. return [
  29488. false,
  29489. 0,
  29490. false
  29491. ];
  29492. };
  29493. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  29494. var code = 0;
  29495. var p;
  29496. if (this.eoblock) {
  29497. code = this.lookBits(7);
  29498. p = twoDimTable[code];
  29499. if (p && p[0] > 0) {
  29500. this.eatBits(p[0]);
  29501. return p[1];
  29502. }
  29503. } else {
  29504. var result = this.findTableCode(1, 7, twoDimTable);
  29505. if (result[0] && result[2]) {
  29506. return result[1];
  29507. }
  29508. }
  29509. info('Bad two dim code');
  29510. return ccittEOF;
  29511. };
  29512. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  29513. var code = 0;
  29514. var p;
  29515. if (this.eoblock) {
  29516. code = this.lookBits(12);
  29517. if (code === ccittEOF) {
  29518. return 1;
  29519. }
  29520. if (code >> 5 === 0) {
  29521. p = whiteTable1[code];
  29522. } else {
  29523. p = whiteTable2[code >> 3];
  29524. }
  29525. if (p[0] > 0) {
  29526. this.eatBits(p[0]);
  29527. return p[1];
  29528. }
  29529. } else {
  29530. var result = this.findTableCode(1, 9, whiteTable2);
  29531. if (result[0]) {
  29532. return result[1];
  29533. }
  29534. result = this.findTableCode(11, 12, whiteTable1);
  29535. if (result[0]) {
  29536. return result[1];
  29537. }
  29538. }
  29539. info('bad white code');
  29540. this.eatBits(1);
  29541. return 1;
  29542. };
  29543. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  29544. var code, p;
  29545. if (this.eoblock) {
  29546. code = this.lookBits(13);
  29547. if (code === ccittEOF) {
  29548. return 1;
  29549. }
  29550. if (code >> 7 === 0) {
  29551. p = blackTable1[code];
  29552. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  29553. p = blackTable2[(code >> 1) - 64];
  29554. } else {
  29555. p = blackTable3[code >> 7];
  29556. }
  29557. if (p[0] > 0) {
  29558. this.eatBits(p[0]);
  29559. return p[1];
  29560. }
  29561. } else {
  29562. var result = this.findTableCode(2, 6, blackTable3);
  29563. if (result[0]) {
  29564. return result[1];
  29565. }
  29566. result = this.findTableCode(7, 12, blackTable2, 64);
  29567. if (result[0]) {
  29568. return result[1];
  29569. }
  29570. result = this.findTableCode(10, 13, blackTable1);
  29571. if (result[0]) {
  29572. return result[1];
  29573. }
  29574. }
  29575. info('bad black code');
  29576. this.eatBits(1);
  29577. return 1;
  29578. };
  29579. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  29580. var c;
  29581. while (this.inputBits < n) {
  29582. if ((c = this.str.getByte()) === -1) {
  29583. if (this.inputBits === 0) {
  29584. return ccittEOF;
  29585. }
  29586. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  29587. }
  29588. this.inputBuf = this.inputBuf << 8 | c;
  29589. this.inputBits += 8;
  29590. }
  29591. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  29592. };
  29593. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  29594. if ((this.inputBits -= n) < 0) {
  29595. this.inputBits = 0;
  29596. }
  29597. };
  29598. return CCITTFaxStream;
  29599. }();
  29600. var LZWStream = function LZWStreamClosure() {
  29601. function LZWStream(str, maybeLength, earlyChange) {
  29602. this.str = str;
  29603. this.dict = str.dict;
  29604. this.cachedData = 0;
  29605. this.bitsCached = 0;
  29606. var maxLzwDictionarySize = 4096;
  29607. var lzwState = {
  29608. earlyChange: earlyChange,
  29609. codeLength: 9,
  29610. nextCode: 258,
  29611. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  29612. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  29613. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  29614. currentSequence: new Uint8Array(maxLzwDictionarySize),
  29615. currentSequenceLength: 0
  29616. };
  29617. for (var i = 0; i < 256; ++i) {
  29618. lzwState.dictionaryValues[i] = i;
  29619. lzwState.dictionaryLengths[i] = 1;
  29620. }
  29621. this.lzwState = lzwState;
  29622. DecodeStream.call(this, maybeLength);
  29623. }
  29624. LZWStream.prototype = Object.create(DecodeStream.prototype);
  29625. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  29626. var bitsCached = this.bitsCached;
  29627. var cachedData = this.cachedData;
  29628. while (bitsCached < n) {
  29629. var c = this.str.getByte();
  29630. if (c === -1) {
  29631. this.eof = true;
  29632. return null;
  29633. }
  29634. cachedData = cachedData << 8 | c;
  29635. bitsCached += 8;
  29636. }
  29637. this.bitsCached = bitsCached -= n;
  29638. this.cachedData = cachedData;
  29639. this.lastCode = null;
  29640. return cachedData >>> bitsCached & (1 << n) - 1;
  29641. };
  29642. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  29643. var blockSize = 512;
  29644. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  29645. var i, j, q;
  29646. var lzwState = this.lzwState;
  29647. if (!lzwState) {
  29648. return;
  29649. }
  29650. var earlyChange = lzwState.earlyChange;
  29651. var nextCode = lzwState.nextCode;
  29652. var dictionaryValues = lzwState.dictionaryValues;
  29653. var dictionaryLengths = lzwState.dictionaryLengths;
  29654. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  29655. var codeLength = lzwState.codeLength;
  29656. var prevCode = lzwState.prevCode;
  29657. var currentSequence = lzwState.currentSequence;
  29658. var currentSequenceLength = lzwState.currentSequenceLength;
  29659. var decodedLength = 0;
  29660. var currentBufferLength = this.bufferLength;
  29661. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  29662. for (i = 0; i < blockSize; i++) {
  29663. var code = this.readBits(codeLength);
  29664. var hasPrev = currentSequenceLength > 0;
  29665. if (code < 256) {
  29666. currentSequence[0] = code;
  29667. currentSequenceLength = 1;
  29668. } else if (code >= 258) {
  29669. if (code < nextCode) {
  29670. currentSequenceLength = dictionaryLengths[code];
  29671. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  29672. currentSequence[j] = dictionaryValues[q];
  29673. q = dictionaryPrevCodes[q];
  29674. }
  29675. } else {
  29676. currentSequence[currentSequenceLength++] = currentSequence[0];
  29677. }
  29678. } else if (code === 256) {
  29679. codeLength = 9;
  29680. nextCode = 258;
  29681. currentSequenceLength = 0;
  29682. continue;
  29683. } else {
  29684. this.eof = true;
  29685. delete this.lzwState;
  29686. break;
  29687. }
  29688. if (hasPrev) {
  29689. dictionaryPrevCodes[nextCode] = prevCode;
  29690. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  29691. dictionaryValues[nextCode] = currentSequence[0];
  29692. nextCode++;
  29693. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  29694. }
  29695. prevCode = code;
  29696. decodedLength += currentSequenceLength;
  29697. if (estimatedDecodedSize < decodedLength) {
  29698. do {
  29699. estimatedDecodedSize += decodedSizeDelta;
  29700. } while (estimatedDecodedSize < decodedLength);
  29701. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  29702. }
  29703. for (j = 0; j < currentSequenceLength; j++) {
  29704. buffer[currentBufferLength++] = currentSequence[j];
  29705. }
  29706. }
  29707. lzwState.nextCode = nextCode;
  29708. lzwState.codeLength = codeLength;
  29709. lzwState.prevCode = prevCode;
  29710. lzwState.currentSequenceLength = currentSequenceLength;
  29711. this.bufferLength = currentBufferLength;
  29712. };
  29713. return LZWStream;
  29714. }();
  29715. var NullStream = function NullStreamClosure() {
  29716. function NullStream() {
  29717. Stream.call(this, new Uint8Array(0));
  29718. }
  29719. NullStream.prototype = Stream.prototype;
  29720. return NullStream;
  29721. }();
  29722. exports.Ascii85Stream = Ascii85Stream;
  29723. exports.AsciiHexStream = AsciiHexStream;
  29724. exports.CCITTFaxStream = CCITTFaxStream;
  29725. exports.DecryptStream = DecryptStream;
  29726. exports.DecodeStream = DecodeStream;
  29727. exports.FlateStream = FlateStream;
  29728. exports.Jbig2Stream = Jbig2Stream;
  29729. exports.JpegStream = JpegStream;
  29730. exports.JpxStream = JpxStream;
  29731. exports.NullStream = NullStream;
  29732. exports.PredictorStream = PredictorStream;
  29733. exports.RunLengthStream = RunLengthStream;
  29734. exports.Stream = Stream;
  29735. exports.StreamsSequenceStream = StreamsSequenceStream;
  29736. exports.StringStream = StringStream;
  29737. exports.LZWStream = LZWStream;
  29738. }));
  29739. (function (root, factory) {
  29740. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  29741. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  29742. var PasswordException = sharedUtil.PasswordException;
  29743. var PasswordResponses = sharedUtil.PasswordResponses;
  29744. var bytesToString = sharedUtil.bytesToString;
  29745. var warn = sharedUtil.warn;
  29746. var error = sharedUtil.error;
  29747. var assert = sharedUtil.assert;
  29748. var isInt = sharedUtil.isInt;
  29749. var stringToBytes = sharedUtil.stringToBytes;
  29750. var utf8StringToString = sharedUtil.utf8StringToString;
  29751. var Name = corePrimitives.Name;
  29752. var isName = corePrimitives.isName;
  29753. var isDict = corePrimitives.isDict;
  29754. var DecryptStream = coreStream.DecryptStream;
  29755. var ARCFourCipher = function ARCFourCipherClosure() {
  29756. function ARCFourCipher(key) {
  29757. this.a = 0;
  29758. this.b = 0;
  29759. var s = new Uint8Array(256);
  29760. var i, j = 0, tmp, keyLength = key.length;
  29761. for (i = 0; i < 256; ++i) {
  29762. s[i] = i;
  29763. }
  29764. for (i = 0; i < 256; ++i) {
  29765. tmp = s[i];
  29766. j = j + tmp + key[i % keyLength] & 0xFF;
  29767. s[i] = s[j];
  29768. s[j] = tmp;
  29769. }
  29770. this.s = s;
  29771. }
  29772. ARCFourCipher.prototype = {
  29773. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  29774. var i, n = data.length, tmp, tmp2;
  29775. var a = this.a, b = this.b, s = this.s;
  29776. var output = new Uint8Array(n);
  29777. for (i = 0; i < n; ++i) {
  29778. a = a + 1 & 0xFF;
  29779. tmp = s[a];
  29780. b = b + tmp & 0xFF;
  29781. tmp2 = s[b];
  29782. s[a] = tmp2;
  29783. s[b] = tmp;
  29784. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  29785. }
  29786. this.a = a;
  29787. this.b = b;
  29788. return output;
  29789. }
  29790. };
  29791. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  29792. return ARCFourCipher;
  29793. }();
  29794. var calculateMD5 = function calculateMD5Closure() {
  29795. var r = new Uint8Array([
  29796. 7,
  29797. 12,
  29798. 17,
  29799. 22,
  29800. 7,
  29801. 12,
  29802. 17,
  29803. 22,
  29804. 7,
  29805. 12,
  29806. 17,
  29807. 22,
  29808. 7,
  29809. 12,
  29810. 17,
  29811. 22,
  29812. 5,
  29813. 9,
  29814. 14,
  29815. 20,
  29816. 5,
  29817. 9,
  29818. 14,
  29819. 20,
  29820. 5,
  29821. 9,
  29822. 14,
  29823. 20,
  29824. 5,
  29825. 9,
  29826. 14,
  29827. 20,
  29828. 4,
  29829. 11,
  29830. 16,
  29831. 23,
  29832. 4,
  29833. 11,
  29834. 16,
  29835. 23,
  29836. 4,
  29837. 11,
  29838. 16,
  29839. 23,
  29840. 4,
  29841. 11,
  29842. 16,
  29843. 23,
  29844. 6,
  29845. 10,
  29846. 15,
  29847. 21,
  29848. 6,
  29849. 10,
  29850. 15,
  29851. 21,
  29852. 6,
  29853. 10,
  29854. 15,
  29855. 21,
  29856. 6,
  29857. 10,
  29858. 15,
  29859. 21
  29860. ]);
  29861. var k = new Int32Array([
  29862. -680876936,
  29863. -389564586,
  29864. 606105819,
  29865. -1044525330,
  29866. -176418897,
  29867. 1200080426,
  29868. -1473231341,
  29869. -45705983,
  29870. 1770035416,
  29871. -1958414417,
  29872. -42063,
  29873. -1990404162,
  29874. 1804603682,
  29875. -40341101,
  29876. -1502002290,
  29877. 1236535329,
  29878. -165796510,
  29879. -1069501632,
  29880. 643717713,
  29881. -373897302,
  29882. -701558691,
  29883. 38016083,
  29884. -660478335,
  29885. -405537848,
  29886. 568446438,
  29887. -1019803690,
  29888. -187363961,
  29889. 1163531501,
  29890. -1444681467,
  29891. -51403784,
  29892. 1735328473,
  29893. -1926607734,
  29894. -378558,
  29895. -2022574463,
  29896. 1839030562,
  29897. -35309556,
  29898. -1530992060,
  29899. 1272893353,
  29900. -155497632,
  29901. -1094730640,
  29902. 681279174,
  29903. -358537222,
  29904. -722521979,
  29905. 76029189,
  29906. -640364487,
  29907. -421815835,
  29908. 530742520,
  29909. -995338651,
  29910. -198630844,
  29911. 1126891415,
  29912. -1416354905,
  29913. -57434055,
  29914. 1700485571,
  29915. -1894986606,
  29916. -1051523,
  29917. -2054922799,
  29918. 1873313359,
  29919. -30611744,
  29920. -1560198380,
  29921. 1309151649,
  29922. -145523070,
  29923. -1120210379,
  29924. 718787259,
  29925. -343485551
  29926. ]);
  29927. function hash(data, offset, length) {
  29928. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  29929. var paddedLength = length + 72 & ~63;
  29930. var padded = new Uint8Array(paddedLength);
  29931. var i, j, n;
  29932. for (i = 0; i < length; ++i) {
  29933. padded[i] = data[offset++];
  29934. }
  29935. padded[i++] = 0x80;
  29936. n = paddedLength - 8;
  29937. while (i < n) {
  29938. padded[i++] = 0;
  29939. }
  29940. padded[i++] = length << 3 & 0xFF;
  29941. padded[i++] = length >> 5 & 0xFF;
  29942. padded[i++] = length >> 13 & 0xFF;
  29943. padded[i++] = length >> 21 & 0xFF;
  29944. padded[i++] = length >>> 29 & 0xFF;
  29945. padded[i++] = 0;
  29946. padded[i++] = 0;
  29947. padded[i++] = 0;
  29948. var w = new Int32Array(16);
  29949. for (i = 0; i < paddedLength;) {
  29950. for (j = 0; j < 16; ++j, i += 4) {
  29951. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  29952. }
  29953. var a = h0, b = h1, c = h2, d = h3, f, g;
  29954. for (j = 0; j < 64; ++j) {
  29955. if (j < 16) {
  29956. f = b & c | ~b & d;
  29957. g = j;
  29958. } else if (j < 32) {
  29959. f = d & b | ~d & c;
  29960. g = 5 * j + 1 & 15;
  29961. } else if (j < 48) {
  29962. f = b ^ c ^ d;
  29963. g = 3 * j + 5 & 15;
  29964. } else {
  29965. f = c ^ (b | ~d);
  29966. g = 7 * j & 15;
  29967. }
  29968. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  29969. d = c;
  29970. c = b;
  29971. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  29972. a = tmp;
  29973. }
  29974. h0 = h0 + a | 0;
  29975. h1 = h1 + b | 0;
  29976. h2 = h2 + c | 0;
  29977. h3 = h3 + d | 0;
  29978. }
  29979. return new Uint8Array([
  29980. h0 & 0xFF,
  29981. h0 >> 8 & 0xFF,
  29982. h0 >> 16 & 0xFF,
  29983. h0 >>> 24 & 0xFF,
  29984. h1 & 0xFF,
  29985. h1 >> 8 & 0xFF,
  29986. h1 >> 16 & 0xFF,
  29987. h1 >>> 24 & 0xFF,
  29988. h2 & 0xFF,
  29989. h2 >> 8 & 0xFF,
  29990. h2 >> 16 & 0xFF,
  29991. h2 >>> 24 & 0xFF,
  29992. h3 & 0xFF,
  29993. h3 >> 8 & 0xFF,
  29994. h3 >> 16 & 0xFF,
  29995. h3 >>> 24 & 0xFF
  29996. ]);
  29997. }
  29998. return hash;
  29999. }();
  30000. var Word64 = function Word64Closure() {
  30001. function Word64(highInteger, lowInteger) {
  30002. this.high = highInteger | 0;
  30003. this.low = lowInteger | 0;
  30004. }
  30005. Word64.prototype = {
  30006. and: function Word64_and(word) {
  30007. this.high &= word.high;
  30008. this.low &= word.low;
  30009. },
  30010. xor: function Word64_xor(word) {
  30011. this.high ^= word.high;
  30012. this.low ^= word.low;
  30013. },
  30014. or: function Word64_or(word) {
  30015. this.high |= word.high;
  30016. this.low |= word.low;
  30017. },
  30018. shiftRight: function Word64_shiftRight(places) {
  30019. if (places >= 32) {
  30020. this.low = this.high >>> places - 32 | 0;
  30021. this.high = 0;
  30022. } else {
  30023. this.low = this.low >>> places | this.high << 32 - places;
  30024. this.high = this.high >>> places | 0;
  30025. }
  30026. },
  30027. shiftLeft: function Word64_shiftLeft(places) {
  30028. if (places >= 32) {
  30029. this.high = this.low << places - 32;
  30030. this.low = 0;
  30031. } else {
  30032. this.high = this.high << places | this.low >>> 32 - places;
  30033. this.low = this.low << places;
  30034. }
  30035. },
  30036. rotateRight: function Word64_rotateRight(places) {
  30037. var low, high;
  30038. if (places & 32) {
  30039. high = this.low;
  30040. low = this.high;
  30041. } else {
  30042. low = this.low;
  30043. high = this.high;
  30044. }
  30045. places &= 31;
  30046. this.low = low >>> places | high << 32 - places;
  30047. this.high = high >>> places | low << 32 - places;
  30048. },
  30049. not: function Word64_not() {
  30050. this.high = ~this.high;
  30051. this.low = ~this.low;
  30052. },
  30053. add: function Word64_add(word) {
  30054. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  30055. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  30056. if (lowAdd > 0xFFFFFFFF) {
  30057. highAdd += 1;
  30058. }
  30059. this.low = lowAdd | 0;
  30060. this.high = highAdd | 0;
  30061. },
  30062. copyTo: function Word64_copyTo(bytes, offset) {
  30063. bytes[offset] = this.high >>> 24 & 0xFF;
  30064. bytes[offset + 1] = this.high >> 16 & 0xFF;
  30065. bytes[offset + 2] = this.high >> 8 & 0xFF;
  30066. bytes[offset + 3] = this.high & 0xFF;
  30067. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  30068. bytes[offset + 5] = this.low >> 16 & 0xFF;
  30069. bytes[offset + 6] = this.low >> 8 & 0xFF;
  30070. bytes[offset + 7] = this.low & 0xFF;
  30071. },
  30072. assign: function Word64_assign(word) {
  30073. this.high = word.high;
  30074. this.low = word.low;
  30075. }
  30076. };
  30077. return Word64;
  30078. }();
  30079. var calculateSHA256 = function calculateSHA256Closure() {
  30080. function rotr(x, n) {
  30081. return x >>> n | x << 32 - n;
  30082. }
  30083. function ch(x, y, z) {
  30084. return x & y ^ ~x & z;
  30085. }
  30086. function maj(x, y, z) {
  30087. return x & y ^ x & z ^ y & z;
  30088. }
  30089. function sigma(x) {
  30090. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  30091. }
  30092. function sigmaPrime(x) {
  30093. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  30094. }
  30095. function littleSigma(x) {
  30096. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  30097. }
  30098. function littleSigmaPrime(x) {
  30099. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  30100. }
  30101. var k = [
  30102. 0x428a2f98,
  30103. 0x71374491,
  30104. 0xb5c0fbcf,
  30105. 0xe9b5dba5,
  30106. 0x3956c25b,
  30107. 0x59f111f1,
  30108. 0x923f82a4,
  30109. 0xab1c5ed5,
  30110. 0xd807aa98,
  30111. 0x12835b01,
  30112. 0x243185be,
  30113. 0x550c7dc3,
  30114. 0x72be5d74,
  30115. 0x80deb1fe,
  30116. 0x9bdc06a7,
  30117. 0xc19bf174,
  30118. 0xe49b69c1,
  30119. 0xefbe4786,
  30120. 0x0fc19dc6,
  30121. 0x240ca1cc,
  30122. 0x2de92c6f,
  30123. 0x4a7484aa,
  30124. 0x5cb0a9dc,
  30125. 0x76f988da,
  30126. 0x983e5152,
  30127. 0xa831c66d,
  30128. 0xb00327c8,
  30129. 0xbf597fc7,
  30130. 0xc6e00bf3,
  30131. 0xd5a79147,
  30132. 0x06ca6351,
  30133. 0x14292967,
  30134. 0x27b70a85,
  30135. 0x2e1b2138,
  30136. 0x4d2c6dfc,
  30137. 0x53380d13,
  30138. 0x650a7354,
  30139. 0x766a0abb,
  30140. 0x81c2c92e,
  30141. 0x92722c85,
  30142. 0xa2bfe8a1,
  30143. 0xa81a664b,
  30144. 0xc24b8b70,
  30145. 0xc76c51a3,
  30146. 0xd192e819,
  30147. 0xd6990624,
  30148. 0xf40e3585,
  30149. 0x106aa070,
  30150. 0x19a4c116,
  30151. 0x1e376c08,
  30152. 0x2748774c,
  30153. 0x34b0bcb5,
  30154. 0x391c0cb3,
  30155. 0x4ed8aa4a,
  30156. 0x5b9cca4f,
  30157. 0x682e6ff3,
  30158. 0x748f82ee,
  30159. 0x78a5636f,
  30160. 0x84c87814,
  30161. 0x8cc70208,
  30162. 0x90befffa,
  30163. 0xa4506ceb,
  30164. 0xbef9a3f7,
  30165. 0xc67178f2
  30166. ];
  30167. function hash(data, offset, length) {
  30168. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  30169. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  30170. var padded = new Uint8Array(paddedLength);
  30171. var i, j, n;
  30172. for (i = 0; i < length; ++i) {
  30173. padded[i] = data[offset++];
  30174. }
  30175. padded[i++] = 0x80;
  30176. n = paddedLength - 8;
  30177. while (i < n) {
  30178. padded[i++] = 0;
  30179. }
  30180. padded[i++] = 0;
  30181. padded[i++] = 0;
  30182. padded[i++] = 0;
  30183. padded[i++] = length >>> 29 & 0xFF;
  30184. padded[i++] = length >> 21 & 0xFF;
  30185. padded[i++] = length >> 13 & 0xFF;
  30186. padded[i++] = length >> 5 & 0xFF;
  30187. padded[i++] = length << 3 & 0xFF;
  30188. var w = new Uint32Array(64);
  30189. for (i = 0; i < paddedLength;) {
  30190. for (j = 0; j < 16; ++j) {
  30191. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  30192. i += 4;
  30193. }
  30194. for (j = 16; j < 64; ++j) {
  30195. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  30196. }
  30197. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  30198. for (j = 0; j < 64; ++j) {
  30199. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  30200. t2 = sigma(a) + maj(a, b, c);
  30201. h = g;
  30202. g = f;
  30203. f = e;
  30204. e = d + t1 | 0;
  30205. d = c;
  30206. c = b;
  30207. b = a;
  30208. a = t1 + t2 | 0;
  30209. }
  30210. h0 = h0 + a | 0;
  30211. h1 = h1 + b | 0;
  30212. h2 = h2 + c | 0;
  30213. h3 = h3 + d | 0;
  30214. h4 = h4 + e | 0;
  30215. h5 = h5 + f | 0;
  30216. h6 = h6 + g | 0;
  30217. h7 = h7 + h | 0;
  30218. }
  30219. return new Uint8Array([
  30220. h0 >> 24 & 0xFF,
  30221. h0 >> 16 & 0xFF,
  30222. h0 >> 8 & 0xFF,
  30223. h0 & 0xFF,
  30224. h1 >> 24 & 0xFF,
  30225. h1 >> 16 & 0xFF,
  30226. h1 >> 8 & 0xFF,
  30227. h1 & 0xFF,
  30228. h2 >> 24 & 0xFF,
  30229. h2 >> 16 & 0xFF,
  30230. h2 >> 8 & 0xFF,
  30231. h2 & 0xFF,
  30232. h3 >> 24 & 0xFF,
  30233. h3 >> 16 & 0xFF,
  30234. h3 >> 8 & 0xFF,
  30235. h3 & 0xFF,
  30236. h4 >> 24 & 0xFF,
  30237. h4 >> 16 & 0xFF,
  30238. h4 >> 8 & 0xFF,
  30239. h4 & 0xFF,
  30240. h5 >> 24 & 0xFF,
  30241. h5 >> 16 & 0xFF,
  30242. h5 >> 8 & 0xFF,
  30243. h5 & 0xFF,
  30244. h6 >> 24 & 0xFF,
  30245. h6 >> 16 & 0xFF,
  30246. h6 >> 8 & 0xFF,
  30247. h6 & 0xFF,
  30248. h7 >> 24 & 0xFF,
  30249. h7 >> 16 & 0xFF,
  30250. h7 >> 8 & 0xFF,
  30251. h7 & 0xFF
  30252. ]);
  30253. }
  30254. return hash;
  30255. }();
  30256. var calculateSHA512 = function calculateSHA512Closure() {
  30257. function ch(result, x, y, z, tmp) {
  30258. result.assign(x);
  30259. result.and(y);
  30260. tmp.assign(x);
  30261. tmp.not();
  30262. tmp.and(z);
  30263. result.xor(tmp);
  30264. }
  30265. function maj(result, x, y, z, tmp) {
  30266. result.assign(x);
  30267. result.and(y);
  30268. tmp.assign(x);
  30269. tmp.and(z);
  30270. result.xor(tmp);
  30271. tmp.assign(y);
  30272. tmp.and(z);
  30273. result.xor(tmp);
  30274. }
  30275. function sigma(result, x, tmp) {
  30276. result.assign(x);
  30277. result.rotateRight(28);
  30278. tmp.assign(x);
  30279. tmp.rotateRight(34);
  30280. result.xor(tmp);
  30281. tmp.assign(x);
  30282. tmp.rotateRight(39);
  30283. result.xor(tmp);
  30284. }
  30285. function sigmaPrime(result, x, tmp) {
  30286. result.assign(x);
  30287. result.rotateRight(14);
  30288. tmp.assign(x);
  30289. tmp.rotateRight(18);
  30290. result.xor(tmp);
  30291. tmp.assign(x);
  30292. tmp.rotateRight(41);
  30293. result.xor(tmp);
  30294. }
  30295. function littleSigma(result, x, tmp) {
  30296. result.assign(x);
  30297. result.rotateRight(1);
  30298. tmp.assign(x);
  30299. tmp.rotateRight(8);
  30300. result.xor(tmp);
  30301. tmp.assign(x);
  30302. tmp.shiftRight(7);
  30303. result.xor(tmp);
  30304. }
  30305. function littleSigmaPrime(result, x, tmp) {
  30306. result.assign(x);
  30307. result.rotateRight(19);
  30308. tmp.assign(x);
  30309. tmp.rotateRight(61);
  30310. result.xor(tmp);
  30311. tmp.assign(x);
  30312. tmp.shiftRight(6);
  30313. result.xor(tmp);
  30314. }
  30315. var k = [
  30316. new Word64(0x428a2f98, 0xd728ae22),
  30317. new Word64(0x71374491, 0x23ef65cd),
  30318. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  30319. new Word64(0xe9b5dba5, 0x8189dbbc),
  30320. new Word64(0x3956c25b, 0xf348b538),
  30321. new Word64(0x59f111f1, 0xb605d019),
  30322. new Word64(0x923f82a4, 0xaf194f9b),
  30323. new Word64(0xab1c5ed5, 0xda6d8118),
  30324. new Word64(0xd807aa98, 0xa3030242),
  30325. new Word64(0x12835b01, 0x45706fbe),
  30326. new Word64(0x243185be, 0x4ee4b28c),
  30327. new Word64(0x550c7dc3, 0xd5ffb4e2),
  30328. new Word64(0x72be5d74, 0xf27b896f),
  30329. new Word64(0x80deb1fe, 0x3b1696b1),
  30330. new Word64(0x9bdc06a7, 0x25c71235),
  30331. new Word64(0xc19bf174, 0xcf692694),
  30332. new Word64(0xe49b69c1, 0x9ef14ad2),
  30333. new Word64(0xefbe4786, 0x384f25e3),
  30334. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  30335. new Word64(0x240ca1cc, 0x77ac9c65),
  30336. new Word64(0x2de92c6f, 0x592b0275),
  30337. new Word64(0x4a7484aa, 0x6ea6e483),
  30338. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  30339. new Word64(0x76f988da, 0x831153b5),
  30340. new Word64(0x983e5152, 0xee66dfab),
  30341. new Word64(0xa831c66d, 0x2db43210),
  30342. new Word64(0xb00327c8, 0x98fb213f),
  30343. new Word64(0xbf597fc7, 0xbeef0ee4),
  30344. new Word64(0xc6e00bf3, 0x3da88fc2),
  30345. new Word64(0xd5a79147, 0x930aa725),
  30346. new Word64(0x06ca6351, 0xe003826f),
  30347. new Word64(0x14292967, 0x0a0e6e70),
  30348. new Word64(0x27b70a85, 0x46d22ffc),
  30349. new Word64(0x2e1b2138, 0x5c26c926),
  30350. new Word64(0x4d2c6dfc, 0x5ac42aed),
  30351. new Word64(0x53380d13, 0x9d95b3df),
  30352. new Word64(0x650a7354, 0x8baf63de),
  30353. new Word64(0x766a0abb, 0x3c77b2a8),
  30354. new Word64(0x81c2c92e, 0x47edaee6),
  30355. new Word64(0x92722c85, 0x1482353b),
  30356. new Word64(0xa2bfe8a1, 0x4cf10364),
  30357. new Word64(0xa81a664b, 0xbc423001),
  30358. new Word64(0xc24b8b70, 0xd0f89791),
  30359. new Word64(0xc76c51a3, 0x0654be30),
  30360. new Word64(0xd192e819, 0xd6ef5218),
  30361. new Word64(0xd6990624, 0x5565a910),
  30362. new Word64(0xf40e3585, 0x5771202a),
  30363. new Word64(0x106aa070, 0x32bbd1b8),
  30364. new Word64(0x19a4c116, 0xb8d2d0c8),
  30365. new Word64(0x1e376c08, 0x5141ab53),
  30366. new Word64(0x2748774c, 0xdf8eeb99),
  30367. new Word64(0x34b0bcb5, 0xe19b48a8),
  30368. new Word64(0x391c0cb3, 0xc5c95a63),
  30369. new Word64(0x4ed8aa4a, 0xe3418acb),
  30370. new Word64(0x5b9cca4f, 0x7763e373),
  30371. new Word64(0x682e6ff3, 0xd6b2b8a3),
  30372. new Word64(0x748f82ee, 0x5defb2fc),
  30373. new Word64(0x78a5636f, 0x43172f60),
  30374. new Word64(0x84c87814, 0xa1f0ab72),
  30375. new Word64(0x8cc70208, 0x1a6439ec),
  30376. new Word64(0x90befffa, 0x23631e28),
  30377. new Word64(0xa4506ceb, 0xde82bde9),
  30378. new Word64(0xbef9a3f7, 0xb2c67915),
  30379. new Word64(0xc67178f2, 0xe372532b),
  30380. new Word64(0xca273ece, 0xea26619c),
  30381. new Word64(0xd186b8c7, 0x21c0c207),
  30382. new Word64(0xeada7dd6, 0xcde0eb1e),
  30383. new Word64(0xf57d4f7f, 0xee6ed178),
  30384. new Word64(0x06f067aa, 0x72176fba),
  30385. new Word64(0x0a637dc5, 0xa2c898a6),
  30386. new Word64(0x113f9804, 0xbef90dae),
  30387. new Word64(0x1b710b35, 0x131c471b),
  30388. new Word64(0x28db77f5, 0x23047d84),
  30389. new Word64(0x32caab7b, 0x40c72493),
  30390. new Word64(0x3c9ebe0a, 0x15c9bebc),
  30391. new Word64(0x431d67c4, 0x9c100d4c),
  30392. new Word64(0x4cc5d4be, 0xcb3e42b6),
  30393. new Word64(0x597f299c, 0xfc657e2a),
  30394. new Word64(0x5fcb6fab, 0x3ad6faec),
  30395. new Word64(0x6c44198c, 0x4a475817)
  30396. ];
  30397. function hash(data, offset, length, mode384) {
  30398. mode384 = !!mode384;
  30399. var h0, h1, h2, h3, h4, h5, h6, h7;
  30400. if (!mode384) {
  30401. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  30402. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  30403. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  30404. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  30405. h4 = new Word64(0x510e527f, 0xade682d1);
  30406. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  30407. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  30408. h7 = new Word64(0x5be0cd19, 0x137e2179);
  30409. } else {
  30410. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  30411. h1 = new Word64(0x629a292a, 0x367cd507);
  30412. h2 = new Word64(0x9159015a, 0x3070dd17);
  30413. h3 = new Word64(0x152fecd8, 0xf70e5939);
  30414. h4 = new Word64(0x67332667, 0xffc00b31);
  30415. h5 = new Word64(0x8eb44a87, 0x68581511);
  30416. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  30417. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  30418. }
  30419. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  30420. var padded = new Uint8Array(paddedLength);
  30421. var i, j, n;
  30422. for (i = 0; i < length; ++i) {
  30423. padded[i] = data[offset++];
  30424. }
  30425. padded[i++] = 0x80;
  30426. n = paddedLength - 16;
  30427. while (i < n) {
  30428. padded[i++] = 0;
  30429. }
  30430. padded[i++] = 0;
  30431. padded[i++] = 0;
  30432. padded[i++] = 0;
  30433. padded[i++] = 0;
  30434. padded[i++] = 0;
  30435. padded[i++] = 0;
  30436. padded[i++] = 0;
  30437. padded[i++] = 0;
  30438. padded[i++] = 0;
  30439. padded[i++] = 0;
  30440. padded[i++] = 0;
  30441. padded[i++] = length >>> 29 & 0xFF;
  30442. padded[i++] = length >> 21 & 0xFF;
  30443. padded[i++] = length >> 13 & 0xFF;
  30444. padded[i++] = length >> 5 & 0xFF;
  30445. padded[i++] = length << 3 & 0xFF;
  30446. var w = new Array(80);
  30447. for (i = 0; i < 80; i++) {
  30448. w[i] = new Word64(0, 0);
  30449. }
  30450. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  30451. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  30452. var g = new Word64(0, 0), h = new Word64(0, 0);
  30453. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  30454. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  30455. for (i = 0; i < paddedLength;) {
  30456. for (j = 0; j < 16; ++j) {
  30457. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  30458. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  30459. i += 8;
  30460. }
  30461. for (j = 16; j < 80; ++j) {
  30462. tmp3 = w[j];
  30463. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  30464. tmp3.add(w[j - 7]);
  30465. littleSigma(tmp1, w[j - 15], tmp2);
  30466. tmp3.add(tmp1);
  30467. tmp3.add(w[j - 16]);
  30468. }
  30469. a.assign(h0);
  30470. b.assign(h1);
  30471. c.assign(h2);
  30472. d.assign(h3);
  30473. e.assign(h4);
  30474. f.assign(h5);
  30475. g.assign(h6);
  30476. h.assign(h7);
  30477. for (j = 0; j < 80; ++j) {
  30478. t1.assign(h);
  30479. sigmaPrime(tmp1, e, tmp2);
  30480. t1.add(tmp1);
  30481. ch(tmp1, e, f, g, tmp2);
  30482. t1.add(tmp1);
  30483. t1.add(k[j]);
  30484. t1.add(w[j]);
  30485. sigma(t2, a, tmp2);
  30486. maj(tmp1, a, b, c, tmp2);
  30487. t2.add(tmp1);
  30488. tmp3 = h;
  30489. h = g;
  30490. g = f;
  30491. f = e;
  30492. d.add(t1);
  30493. e = d;
  30494. d = c;
  30495. c = b;
  30496. b = a;
  30497. tmp3.assign(t1);
  30498. tmp3.add(t2);
  30499. a = tmp3;
  30500. }
  30501. h0.add(a);
  30502. h1.add(b);
  30503. h2.add(c);
  30504. h3.add(d);
  30505. h4.add(e);
  30506. h5.add(f);
  30507. h6.add(g);
  30508. h7.add(h);
  30509. }
  30510. var result;
  30511. if (!mode384) {
  30512. result = new Uint8Array(64);
  30513. h0.copyTo(result, 0);
  30514. h1.copyTo(result, 8);
  30515. h2.copyTo(result, 16);
  30516. h3.copyTo(result, 24);
  30517. h4.copyTo(result, 32);
  30518. h5.copyTo(result, 40);
  30519. h6.copyTo(result, 48);
  30520. h7.copyTo(result, 56);
  30521. } else {
  30522. result = new Uint8Array(48);
  30523. h0.copyTo(result, 0);
  30524. h1.copyTo(result, 8);
  30525. h2.copyTo(result, 16);
  30526. h3.copyTo(result, 24);
  30527. h4.copyTo(result, 32);
  30528. h5.copyTo(result, 40);
  30529. }
  30530. return result;
  30531. }
  30532. return hash;
  30533. }();
  30534. var calculateSHA384 = function calculateSHA384Closure() {
  30535. function hash(data, offset, length) {
  30536. return calculateSHA512(data, offset, length, true);
  30537. }
  30538. return hash;
  30539. }();
  30540. var NullCipher = function NullCipherClosure() {
  30541. function NullCipher() {
  30542. }
  30543. NullCipher.prototype = {
  30544. decryptBlock: function NullCipher_decryptBlock(data) {
  30545. return data;
  30546. }
  30547. };
  30548. return NullCipher;
  30549. }();
  30550. var AES128Cipher = function AES128CipherClosure() {
  30551. var rcon = new Uint8Array([
  30552. 0x8d,
  30553. 0x01,
  30554. 0x02,
  30555. 0x04,
  30556. 0x08,
  30557. 0x10,
  30558. 0x20,
  30559. 0x40,
  30560. 0x80,
  30561. 0x1b,
  30562. 0x36,
  30563. 0x6c,
  30564. 0xd8,
  30565. 0xab,
  30566. 0x4d,
  30567. 0x9a,
  30568. 0x2f,
  30569. 0x5e,
  30570. 0xbc,
  30571. 0x63,
  30572. 0xc6,
  30573. 0x97,
  30574. 0x35,
  30575. 0x6a,
  30576. 0xd4,
  30577. 0xb3,
  30578. 0x7d,
  30579. 0xfa,
  30580. 0xef,
  30581. 0xc5,
  30582. 0x91,
  30583. 0x39,
  30584. 0x72,
  30585. 0xe4,
  30586. 0xd3,
  30587. 0xbd,
  30588. 0x61,
  30589. 0xc2,
  30590. 0x9f,
  30591. 0x25,
  30592. 0x4a,
  30593. 0x94,
  30594. 0x33,
  30595. 0x66,
  30596. 0xcc,
  30597. 0x83,
  30598. 0x1d,
  30599. 0x3a,
  30600. 0x74,
  30601. 0xe8,
  30602. 0xcb,
  30603. 0x8d,
  30604. 0x01,
  30605. 0x02,
  30606. 0x04,
  30607. 0x08,
  30608. 0x10,
  30609. 0x20,
  30610. 0x40,
  30611. 0x80,
  30612. 0x1b,
  30613. 0x36,
  30614. 0x6c,
  30615. 0xd8,
  30616. 0xab,
  30617. 0x4d,
  30618. 0x9a,
  30619. 0x2f,
  30620. 0x5e,
  30621. 0xbc,
  30622. 0x63,
  30623. 0xc6,
  30624. 0x97,
  30625. 0x35,
  30626. 0x6a,
  30627. 0xd4,
  30628. 0xb3,
  30629. 0x7d,
  30630. 0xfa,
  30631. 0xef,
  30632. 0xc5,
  30633. 0x91,
  30634. 0x39,
  30635. 0x72,
  30636. 0xe4,
  30637. 0xd3,
  30638. 0xbd,
  30639. 0x61,
  30640. 0xc2,
  30641. 0x9f,
  30642. 0x25,
  30643. 0x4a,
  30644. 0x94,
  30645. 0x33,
  30646. 0x66,
  30647. 0xcc,
  30648. 0x83,
  30649. 0x1d,
  30650. 0x3a,
  30651. 0x74,
  30652. 0xe8,
  30653. 0xcb,
  30654. 0x8d,
  30655. 0x01,
  30656. 0x02,
  30657. 0x04,
  30658. 0x08,
  30659. 0x10,
  30660. 0x20,
  30661. 0x40,
  30662. 0x80,
  30663. 0x1b,
  30664. 0x36,
  30665. 0x6c,
  30666. 0xd8,
  30667. 0xab,
  30668. 0x4d,
  30669. 0x9a,
  30670. 0x2f,
  30671. 0x5e,
  30672. 0xbc,
  30673. 0x63,
  30674. 0xc6,
  30675. 0x97,
  30676. 0x35,
  30677. 0x6a,
  30678. 0xd4,
  30679. 0xb3,
  30680. 0x7d,
  30681. 0xfa,
  30682. 0xef,
  30683. 0xc5,
  30684. 0x91,
  30685. 0x39,
  30686. 0x72,
  30687. 0xe4,
  30688. 0xd3,
  30689. 0xbd,
  30690. 0x61,
  30691. 0xc2,
  30692. 0x9f,
  30693. 0x25,
  30694. 0x4a,
  30695. 0x94,
  30696. 0x33,
  30697. 0x66,
  30698. 0xcc,
  30699. 0x83,
  30700. 0x1d,
  30701. 0x3a,
  30702. 0x74,
  30703. 0xe8,
  30704. 0xcb,
  30705. 0x8d,
  30706. 0x01,
  30707. 0x02,
  30708. 0x04,
  30709. 0x08,
  30710. 0x10,
  30711. 0x20,
  30712. 0x40,
  30713. 0x80,
  30714. 0x1b,
  30715. 0x36,
  30716. 0x6c,
  30717. 0xd8,
  30718. 0xab,
  30719. 0x4d,
  30720. 0x9a,
  30721. 0x2f,
  30722. 0x5e,
  30723. 0xbc,
  30724. 0x63,
  30725. 0xc6,
  30726. 0x97,
  30727. 0x35,
  30728. 0x6a,
  30729. 0xd4,
  30730. 0xb3,
  30731. 0x7d,
  30732. 0xfa,
  30733. 0xef,
  30734. 0xc5,
  30735. 0x91,
  30736. 0x39,
  30737. 0x72,
  30738. 0xe4,
  30739. 0xd3,
  30740. 0xbd,
  30741. 0x61,
  30742. 0xc2,
  30743. 0x9f,
  30744. 0x25,
  30745. 0x4a,
  30746. 0x94,
  30747. 0x33,
  30748. 0x66,
  30749. 0xcc,
  30750. 0x83,
  30751. 0x1d,
  30752. 0x3a,
  30753. 0x74,
  30754. 0xe8,
  30755. 0xcb,
  30756. 0x8d,
  30757. 0x01,
  30758. 0x02,
  30759. 0x04,
  30760. 0x08,
  30761. 0x10,
  30762. 0x20,
  30763. 0x40,
  30764. 0x80,
  30765. 0x1b,
  30766. 0x36,
  30767. 0x6c,
  30768. 0xd8,
  30769. 0xab,
  30770. 0x4d,
  30771. 0x9a,
  30772. 0x2f,
  30773. 0x5e,
  30774. 0xbc,
  30775. 0x63,
  30776. 0xc6,
  30777. 0x97,
  30778. 0x35,
  30779. 0x6a,
  30780. 0xd4,
  30781. 0xb3,
  30782. 0x7d,
  30783. 0xfa,
  30784. 0xef,
  30785. 0xc5,
  30786. 0x91,
  30787. 0x39,
  30788. 0x72,
  30789. 0xe4,
  30790. 0xd3,
  30791. 0xbd,
  30792. 0x61,
  30793. 0xc2,
  30794. 0x9f,
  30795. 0x25,
  30796. 0x4a,
  30797. 0x94,
  30798. 0x33,
  30799. 0x66,
  30800. 0xcc,
  30801. 0x83,
  30802. 0x1d,
  30803. 0x3a,
  30804. 0x74,
  30805. 0xe8,
  30806. 0xcb,
  30807. 0x8d
  30808. ]);
  30809. var s = new Uint8Array([
  30810. 0x63,
  30811. 0x7c,
  30812. 0x77,
  30813. 0x7b,
  30814. 0xf2,
  30815. 0x6b,
  30816. 0x6f,
  30817. 0xc5,
  30818. 0x30,
  30819. 0x01,
  30820. 0x67,
  30821. 0x2b,
  30822. 0xfe,
  30823. 0xd7,
  30824. 0xab,
  30825. 0x76,
  30826. 0xca,
  30827. 0x82,
  30828. 0xc9,
  30829. 0x7d,
  30830. 0xfa,
  30831. 0x59,
  30832. 0x47,
  30833. 0xf0,
  30834. 0xad,
  30835. 0xd4,
  30836. 0xa2,
  30837. 0xaf,
  30838. 0x9c,
  30839. 0xa4,
  30840. 0x72,
  30841. 0xc0,
  30842. 0xb7,
  30843. 0xfd,
  30844. 0x93,
  30845. 0x26,
  30846. 0x36,
  30847. 0x3f,
  30848. 0xf7,
  30849. 0xcc,
  30850. 0x34,
  30851. 0xa5,
  30852. 0xe5,
  30853. 0xf1,
  30854. 0x71,
  30855. 0xd8,
  30856. 0x31,
  30857. 0x15,
  30858. 0x04,
  30859. 0xc7,
  30860. 0x23,
  30861. 0xc3,
  30862. 0x18,
  30863. 0x96,
  30864. 0x05,
  30865. 0x9a,
  30866. 0x07,
  30867. 0x12,
  30868. 0x80,
  30869. 0xe2,
  30870. 0xeb,
  30871. 0x27,
  30872. 0xb2,
  30873. 0x75,
  30874. 0x09,
  30875. 0x83,
  30876. 0x2c,
  30877. 0x1a,
  30878. 0x1b,
  30879. 0x6e,
  30880. 0x5a,
  30881. 0xa0,
  30882. 0x52,
  30883. 0x3b,
  30884. 0xd6,
  30885. 0xb3,
  30886. 0x29,
  30887. 0xe3,
  30888. 0x2f,
  30889. 0x84,
  30890. 0x53,
  30891. 0xd1,
  30892. 0x00,
  30893. 0xed,
  30894. 0x20,
  30895. 0xfc,
  30896. 0xb1,
  30897. 0x5b,
  30898. 0x6a,
  30899. 0xcb,
  30900. 0xbe,
  30901. 0x39,
  30902. 0x4a,
  30903. 0x4c,
  30904. 0x58,
  30905. 0xcf,
  30906. 0xd0,
  30907. 0xef,
  30908. 0xaa,
  30909. 0xfb,
  30910. 0x43,
  30911. 0x4d,
  30912. 0x33,
  30913. 0x85,
  30914. 0x45,
  30915. 0xf9,
  30916. 0x02,
  30917. 0x7f,
  30918. 0x50,
  30919. 0x3c,
  30920. 0x9f,
  30921. 0xa8,
  30922. 0x51,
  30923. 0xa3,
  30924. 0x40,
  30925. 0x8f,
  30926. 0x92,
  30927. 0x9d,
  30928. 0x38,
  30929. 0xf5,
  30930. 0xbc,
  30931. 0xb6,
  30932. 0xda,
  30933. 0x21,
  30934. 0x10,
  30935. 0xff,
  30936. 0xf3,
  30937. 0xd2,
  30938. 0xcd,
  30939. 0x0c,
  30940. 0x13,
  30941. 0xec,
  30942. 0x5f,
  30943. 0x97,
  30944. 0x44,
  30945. 0x17,
  30946. 0xc4,
  30947. 0xa7,
  30948. 0x7e,
  30949. 0x3d,
  30950. 0x64,
  30951. 0x5d,
  30952. 0x19,
  30953. 0x73,
  30954. 0x60,
  30955. 0x81,
  30956. 0x4f,
  30957. 0xdc,
  30958. 0x22,
  30959. 0x2a,
  30960. 0x90,
  30961. 0x88,
  30962. 0x46,
  30963. 0xee,
  30964. 0xb8,
  30965. 0x14,
  30966. 0xde,
  30967. 0x5e,
  30968. 0x0b,
  30969. 0xdb,
  30970. 0xe0,
  30971. 0x32,
  30972. 0x3a,
  30973. 0x0a,
  30974. 0x49,
  30975. 0x06,
  30976. 0x24,
  30977. 0x5c,
  30978. 0xc2,
  30979. 0xd3,
  30980. 0xac,
  30981. 0x62,
  30982. 0x91,
  30983. 0x95,
  30984. 0xe4,
  30985. 0x79,
  30986. 0xe7,
  30987. 0xc8,
  30988. 0x37,
  30989. 0x6d,
  30990. 0x8d,
  30991. 0xd5,
  30992. 0x4e,
  30993. 0xa9,
  30994. 0x6c,
  30995. 0x56,
  30996. 0xf4,
  30997. 0xea,
  30998. 0x65,
  30999. 0x7a,
  31000. 0xae,
  31001. 0x08,
  31002. 0xba,
  31003. 0x78,
  31004. 0x25,
  31005. 0x2e,
  31006. 0x1c,
  31007. 0xa6,
  31008. 0xb4,
  31009. 0xc6,
  31010. 0xe8,
  31011. 0xdd,
  31012. 0x74,
  31013. 0x1f,
  31014. 0x4b,
  31015. 0xbd,
  31016. 0x8b,
  31017. 0x8a,
  31018. 0x70,
  31019. 0x3e,
  31020. 0xb5,
  31021. 0x66,
  31022. 0x48,
  31023. 0x03,
  31024. 0xf6,
  31025. 0x0e,
  31026. 0x61,
  31027. 0x35,
  31028. 0x57,
  31029. 0xb9,
  31030. 0x86,
  31031. 0xc1,
  31032. 0x1d,
  31033. 0x9e,
  31034. 0xe1,
  31035. 0xf8,
  31036. 0x98,
  31037. 0x11,
  31038. 0x69,
  31039. 0xd9,
  31040. 0x8e,
  31041. 0x94,
  31042. 0x9b,
  31043. 0x1e,
  31044. 0x87,
  31045. 0xe9,
  31046. 0xce,
  31047. 0x55,
  31048. 0x28,
  31049. 0xdf,
  31050. 0x8c,
  31051. 0xa1,
  31052. 0x89,
  31053. 0x0d,
  31054. 0xbf,
  31055. 0xe6,
  31056. 0x42,
  31057. 0x68,
  31058. 0x41,
  31059. 0x99,
  31060. 0x2d,
  31061. 0x0f,
  31062. 0xb0,
  31063. 0x54,
  31064. 0xbb,
  31065. 0x16
  31066. ]);
  31067. var inv_s = new Uint8Array([
  31068. 0x52,
  31069. 0x09,
  31070. 0x6a,
  31071. 0xd5,
  31072. 0x30,
  31073. 0x36,
  31074. 0xa5,
  31075. 0x38,
  31076. 0xbf,
  31077. 0x40,
  31078. 0xa3,
  31079. 0x9e,
  31080. 0x81,
  31081. 0xf3,
  31082. 0xd7,
  31083. 0xfb,
  31084. 0x7c,
  31085. 0xe3,
  31086. 0x39,
  31087. 0x82,
  31088. 0x9b,
  31089. 0x2f,
  31090. 0xff,
  31091. 0x87,
  31092. 0x34,
  31093. 0x8e,
  31094. 0x43,
  31095. 0x44,
  31096. 0xc4,
  31097. 0xde,
  31098. 0xe9,
  31099. 0xcb,
  31100. 0x54,
  31101. 0x7b,
  31102. 0x94,
  31103. 0x32,
  31104. 0xa6,
  31105. 0xc2,
  31106. 0x23,
  31107. 0x3d,
  31108. 0xee,
  31109. 0x4c,
  31110. 0x95,
  31111. 0x0b,
  31112. 0x42,
  31113. 0xfa,
  31114. 0xc3,
  31115. 0x4e,
  31116. 0x08,
  31117. 0x2e,
  31118. 0xa1,
  31119. 0x66,
  31120. 0x28,
  31121. 0xd9,
  31122. 0x24,
  31123. 0xb2,
  31124. 0x76,
  31125. 0x5b,
  31126. 0xa2,
  31127. 0x49,
  31128. 0x6d,
  31129. 0x8b,
  31130. 0xd1,
  31131. 0x25,
  31132. 0x72,
  31133. 0xf8,
  31134. 0xf6,
  31135. 0x64,
  31136. 0x86,
  31137. 0x68,
  31138. 0x98,
  31139. 0x16,
  31140. 0xd4,
  31141. 0xa4,
  31142. 0x5c,
  31143. 0xcc,
  31144. 0x5d,
  31145. 0x65,
  31146. 0xb6,
  31147. 0x92,
  31148. 0x6c,
  31149. 0x70,
  31150. 0x48,
  31151. 0x50,
  31152. 0xfd,
  31153. 0xed,
  31154. 0xb9,
  31155. 0xda,
  31156. 0x5e,
  31157. 0x15,
  31158. 0x46,
  31159. 0x57,
  31160. 0xa7,
  31161. 0x8d,
  31162. 0x9d,
  31163. 0x84,
  31164. 0x90,
  31165. 0xd8,
  31166. 0xab,
  31167. 0x00,
  31168. 0x8c,
  31169. 0xbc,
  31170. 0xd3,
  31171. 0x0a,
  31172. 0xf7,
  31173. 0xe4,
  31174. 0x58,
  31175. 0x05,
  31176. 0xb8,
  31177. 0xb3,
  31178. 0x45,
  31179. 0x06,
  31180. 0xd0,
  31181. 0x2c,
  31182. 0x1e,
  31183. 0x8f,
  31184. 0xca,
  31185. 0x3f,
  31186. 0x0f,
  31187. 0x02,
  31188. 0xc1,
  31189. 0xaf,
  31190. 0xbd,
  31191. 0x03,
  31192. 0x01,
  31193. 0x13,
  31194. 0x8a,
  31195. 0x6b,
  31196. 0x3a,
  31197. 0x91,
  31198. 0x11,
  31199. 0x41,
  31200. 0x4f,
  31201. 0x67,
  31202. 0xdc,
  31203. 0xea,
  31204. 0x97,
  31205. 0xf2,
  31206. 0xcf,
  31207. 0xce,
  31208. 0xf0,
  31209. 0xb4,
  31210. 0xe6,
  31211. 0x73,
  31212. 0x96,
  31213. 0xac,
  31214. 0x74,
  31215. 0x22,
  31216. 0xe7,
  31217. 0xad,
  31218. 0x35,
  31219. 0x85,
  31220. 0xe2,
  31221. 0xf9,
  31222. 0x37,
  31223. 0xe8,
  31224. 0x1c,
  31225. 0x75,
  31226. 0xdf,
  31227. 0x6e,
  31228. 0x47,
  31229. 0xf1,
  31230. 0x1a,
  31231. 0x71,
  31232. 0x1d,
  31233. 0x29,
  31234. 0xc5,
  31235. 0x89,
  31236. 0x6f,
  31237. 0xb7,
  31238. 0x62,
  31239. 0x0e,
  31240. 0xaa,
  31241. 0x18,
  31242. 0xbe,
  31243. 0x1b,
  31244. 0xfc,
  31245. 0x56,
  31246. 0x3e,
  31247. 0x4b,
  31248. 0xc6,
  31249. 0xd2,
  31250. 0x79,
  31251. 0x20,
  31252. 0x9a,
  31253. 0xdb,
  31254. 0xc0,
  31255. 0xfe,
  31256. 0x78,
  31257. 0xcd,
  31258. 0x5a,
  31259. 0xf4,
  31260. 0x1f,
  31261. 0xdd,
  31262. 0xa8,
  31263. 0x33,
  31264. 0x88,
  31265. 0x07,
  31266. 0xc7,
  31267. 0x31,
  31268. 0xb1,
  31269. 0x12,
  31270. 0x10,
  31271. 0x59,
  31272. 0x27,
  31273. 0x80,
  31274. 0xec,
  31275. 0x5f,
  31276. 0x60,
  31277. 0x51,
  31278. 0x7f,
  31279. 0xa9,
  31280. 0x19,
  31281. 0xb5,
  31282. 0x4a,
  31283. 0x0d,
  31284. 0x2d,
  31285. 0xe5,
  31286. 0x7a,
  31287. 0x9f,
  31288. 0x93,
  31289. 0xc9,
  31290. 0x9c,
  31291. 0xef,
  31292. 0xa0,
  31293. 0xe0,
  31294. 0x3b,
  31295. 0x4d,
  31296. 0xae,
  31297. 0x2a,
  31298. 0xf5,
  31299. 0xb0,
  31300. 0xc8,
  31301. 0xeb,
  31302. 0xbb,
  31303. 0x3c,
  31304. 0x83,
  31305. 0x53,
  31306. 0x99,
  31307. 0x61,
  31308. 0x17,
  31309. 0x2b,
  31310. 0x04,
  31311. 0x7e,
  31312. 0xba,
  31313. 0x77,
  31314. 0xd6,
  31315. 0x26,
  31316. 0xe1,
  31317. 0x69,
  31318. 0x14,
  31319. 0x63,
  31320. 0x55,
  31321. 0x21,
  31322. 0x0c,
  31323. 0x7d
  31324. ]);
  31325. var mixCol = new Uint8Array(256);
  31326. for (var i = 0; i < 256; i++) {
  31327. if (i < 128) {
  31328. mixCol[i] = i << 1;
  31329. } else {
  31330. mixCol[i] = i << 1 ^ 0x1b;
  31331. }
  31332. }
  31333. var mix = new Uint32Array([
  31334. 0x00000000,
  31335. 0x0e090d0b,
  31336. 0x1c121a16,
  31337. 0x121b171d,
  31338. 0x3824342c,
  31339. 0x362d3927,
  31340. 0x24362e3a,
  31341. 0x2a3f2331,
  31342. 0x70486858,
  31343. 0x7e416553,
  31344. 0x6c5a724e,
  31345. 0x62537f45,
  31346. 0x486c5c74,
  31347. 0x4665517f,
  31348. 0x547e4662,
  31349. 0x5a774b69,
  31350. 0xe090d0b0,
  31351. 0xee99ddbb,
  31352. 0xfc82caa6,
  31353. 0xf28bc7ad,
  31354. 0xd8b4e49c,
  31355. 0xd6bde997,
  31356. 0xc4a6fe8a,
  31357. 0xcaaff381,
  31358. 0x90d8b8e8,
  31359. 0x9ed1b5e3,
  31360. 0x8ccaa2fe,
  31361. 0x82c3aff5,
  31362. 0xa8fc8cc4,
  31363. 0xa6f581cf,
  31364. 0xb4ee96d2,
  31365. 0xbae79bd9,
  31366. 0xdb3bbb7b,
  31367. 0xd532b670,
  31368. 0xc729a16d,
  31369. 0xc920ac66,
  31370. 0xe31f8f57,
  31371. 0xed16825c,
  31372. 0xff0d9541,
  31373. 0xf104984a,
  31374. 0xab73d323,
  31375. 0xa57ade28,
  31376. 0xb761c935,
  31377. 0xb968c43e,
  31378. 0x9357e70f,
  31379. 0x9d5eea04,
  31380. 0x8f45fd19,
  31381. 0x814cf012,
  31382. 0x3bab6bcb,
  31383. 0x35a266c0,
  31384. 0x27b971dd,
  31385. 0x29b07cd6,
  31386. 0x038f5fe7,
  31387. 0x0d8652ec,
  31388. 0x1f9d45f1,
  31389. 0x119448fa,
  31390. 0x4be30393,
  31391. 0x45ea0e98,
  31392. 0x57f11985,
  31393. 0x59f8148e,
  31394. 0x73c737bf,
  31395. 0x7dce3ab4,
  31396. 0x6fd52da9,
  31397. 0x61dc20a2,
  31398. 0xad766df6,
  31399. 0xa37f60fd,
  31400. 0xb16477e0,
  31401. 0xbf6d7aeb,
  31402. 0x955259da,
  31403. 0x9b5b54d1,
  31404. 0x894043cc,
  31405. 0x87494ec7,
  31406. 0xdd3e05ae,
  31407. 0xd33708a5,
  31408. 0xc12c1fb8,
  31409. 0xcf2512b3,
  31410. 0xe51a3182,
  31411. 0xeb133c89,
  31412. 0xf9082b94,
  31413. 0xf701269f,
  31414. 0x4de6bd46,
  31415. 0x43efb04d,
  31416. 0x51f4a750,
  31417. 0x5ffdaa5b,
  31418. 0x75c2896a,
  31419. 0x7bcb8461,
  31420. 0x69d0937c,
  31421. 0x67d99e77,
  31422. 0x3daed51e,
  31423. 0x33a7d815,
  31424. 0x21bccf08,
  31425. 0x2fb5c203,
  31426. 0x058ae132,
  31427. 0x0b83ec39,
  31428. 0x1998fb24,
  31429. 0x1791f62f,
  31430. 0x764dd68d,
  31431. 0x7844db86,
  31432. 0x6a5fcc9b,
  31433. 0x6456c190,
  31434. 0x4e69e2a1,
  31435. 0x4060efaa,
  31436. 0x527bf8b7,
  31437. 0x5c72f5bc,
  31438. 0x0605bed5,
  31439. 0x080cb3de,
  31440. 0x1a17a4c3,
  31441. 0x141ea9c8,
  31442. 0x3e218af9,
  31443. 0x302887f2,
  31444. 0x223390ef,
  31445. 0x2c3a9de4,
  31446. 0x96dd063d,
  31447. 0x98d40b36,
  31448. 0x8acf1c2b,
  31449. 0x84c61120,
  31450. 0xaef93211,
  31451. 0xa0f03f1a,
  31452. 0xb2eb2807,
  31453. 0xbce2250c,
  31454. 0xe6956e65,
  31455. 0xe89c636e,
  31456. 0xfa877473,
  31457. 0xf48e7978,
  31458. 0xdeb15a49,
  31459. 0xd0b85742,
  31460. 0xc2a3405f,
  31461. 0xccaa4d54,
  31462. 0x41ecdaf7,
  31463. 0x4fe5d7fc,
  31464. 0x5dfec0e1,
  31465. 0x53f7cdea,
  31466. 0x79c8eedb,
  31467. 0x77c1e3d0,
  31468. 0x65daf4cd,
  31469. 0x6bd3f9c6,
  31470. 0x31a4b2af,
  31471. 0x3fadbfa4,
  31472. 0x2db6a8b9,
  31473. 0x23bfa5b2,
  31474. 0x09808683,
  31475. 0x07898b88,
  31476. 0x15929c95,
  31477. 0x1b9b919e,
  31478. 0xa17c0a47,
  31479. 0xaf75074c,
  31480. 0xbd6e1051,
  31481. 0xb3671d5a,
  31482. 0x99583e6b,
  31483. 0x97513360,
  31484. 0x854a247d,
  31485. 0x8b432976,
  31486. 0xd134621f,
  31487. 0xdf3d6f14,
  31488. 0xcd267809,
  31489. 0xc32f7502,
  31490. 0xe9105633,
  31491. 0xe7195b38,
  31492. 0xf5024c25,
  31493. 0xfb0b412e,
  31494. 0x9ad7618c,
  31495. 0x94de6c87,
  31496. 0x86c57b9a,
  31497. 0x88cc7691,
  31498. 0xa2f355a0,
  31499. 0xacfa58ab,
  31500. 0xbee14fb6,
  31501. 0xb0e842bd,
  31502. 0xea9f09d4,
  31503. 0xe49604df,
  31504. 0xf68d13c2,
  31505. 0xf8841ec9,
  31506. 0xd2bb3df8,
  31507. 0xdcb230f3,
  31508. 0xcea927ee,
  31509. 0xc0a02ae5,
  31510. 0x7a47b13c,
  31511. 0x744ebc37,
  31512. 0x6655ab2a,
  31513. 0x685ca621,
  31514. 0x42638510,
  31515. 0x4c6a881b,
  31516. 0x5e719f06,
  31517. 0x5078920d,
  31518. 0x0a0fd964,
  31519. 0x0406d46f,
  31520. 0x161dc372,
  31521. 0x1814ce79,
  31522. 0x322bed48,
  31523. 0x3c22e043,
  31524. 0x2e39f75e,
  31525. 0x2030fa55,
  31526. 0xec9ab701,
  31527. 0xe293ba0a,
  31528. 0xf088ad17,
  31529. 0xfe81a01c,
  31530. 0xd4be832d,
  31531. 0xdab78e26,
  31532. 0xc8ac993b,
  31533. 0xc6a59430,
  31534. 0x9cd2df59,
  31535. 0x92dbd252,
  31536. 0x80c0c54f,
  31537. 0x8ec9c844,
  31538. 0xa4f6eb75,
  31539. 0xaaffe67e,
  31540. 0xb8e4f163,
  31541. 0xb6edfc68,
  31542. 0x0c0a67b1,
  31543. 0x02036aba,
  31544. 0x10187da7,
  31545. 0x1e1170ac,
  31546. 0x342e539d,
  31547. 0x3a275e96,
  31548. 0x283c498b,
  31549. 0x26354480,
  31550. 0x7c420fe9,
  31551. 0x724b02e2,
  31552. 0x605015ff,
  31553. 0x6e5918f4,
  31554. 0x44663bc5,
  31555. 0x4a6f36ce,
  31556. 0x587421d3,
  31557. 0x567d2cd8,
  31558. 0x37a10c7a,
  31559. 0x39a80171,
  31560. 0x2bb3166c,
  31561. 0x25ba1b67,
  31562. 0x0f853856,
  31563. 0x018c355d,
  31564. 0x13972240,
  31565. 0x1d9e2f4b,
  31566. 0x47e96422,
  31567. 0x49e06929,
  31568. 0x5bfb7e34,
  31569. 0x55f2733f,
  31570. 0x7fcd500e,
  31571. 0x71c45d05,
  31572. 0x63df4a18,
  31573. 0x6dd64713,
  31574. 0xd731dcca,
  31575. 0xd938d1c1,
  31576. 0xcb23c6dc,
  31577. 0xc52acbd7,
  31578. 0xef15e8e6,
  31579. 0xe11ce5ed,
  31580. 0xf307f2f0,
  31581. 0xfd0efffb,
  31582. 0xa779b492,
  31583. 0xa970b999,
  31584. 0xbb6bae84,
  31585. 0xb562a38f,
  31586. 0x9f5d80be,
  31587. 0x91548db5,
  31588. 0x834f9aa8,
  31589. 0x8d4697a3
  31590. ]);
  31591. function expandKey128(cipherKey) {
  31592. var b = 176, result = new Uint8Array(b);
  31593. result.set(cipherKey);
  31594. for (var j = 16, i = 1; j < b; ++i) {
  31595. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  31596. t1 = s[t1];
  31597. t2 = s[t2];
  31598. t3 = s[t3];
  31599. t4 = s[t4];
  31600. t1 = t1 ^ rcon[i];
  31601. for (var n = 0; n < 4; ++n) {
  31602. result[j] = t1 ^= result[j - 16];
  31603. j++;
  31604. result[j] = t2 ^= result[j - 16];
  31605. j++;
  31606. result[j] = t3 ^= result[j - 16];
  31607. j++;
  31608. result[j] = t4 ^= result[j - 16];
  31609. j++;
  31610. }
  31611. }
  31612. return result;
  31613. }
  31614. function decrypt128(input, key) {
  31615. var state = new Uint8Array(16);
  31616. state.set(input);
  31617. var i, j, k;
  31618. var t, u, v;
  31619. for (j = 0, k = 160; j < 16; ++j, ++k) {
  31620. state[j] ^= key[k];
  31621. }
  31622. for (i = 9; i >= 1; --i) {
  31623. t = state[13];
  31624. state[13] = state[9];
  31625. state[9] = state[5];
  31626. state[5] = state[1];
  31627. state[1] = t;
  31628. t = state[14];
  31629. u = state[10];
  31630. state[14] = state[6];
  31631. state[10] = state[2];
  31632. state[6] = t;
  31633. state[2] = u;
  31634. t = state[15];
  31635. u = state[11];
  31636. v = state[7];
  31637. state[15] = state[3];
  31638. state[11] = t;
  31639. state[7] = u;
  31640. state[3] = v;
  31641. for (j = 0; j < 16; ++j) {
  31642. state[j] = inv_s[state[j]];
  31643. }
  31644. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  31645. state[j] ^= key[k];
  31646. }
  31647. for (j = 0; j < 16; j += 4) {
  31648. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  31649. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  31650. state[j] = t >>> 24 & 0xFF;
  31651. state[j + 1] = t >> 16 & 0xFF;
  31652. state[j + 2] = t >> 8 & 0xFF;
  31653. state[j + 3] = t & 0xFF;
  31654. }
  31655. }
  31656. t = state[13];
  31657. state[13] = state[9];
  31658. state[9] = state[5];
  31659. state[5] = state[1];
  31660. state[1] = t;
  31661. t = state[14];
  31662. u = state[10];
  31663. state[14] = state[6];
  31664. state[10] = state[2];
  31665. state[6] = t;
  31666. state[2] = u;
  31667. t = state[15];
  31668. u = state[11];
  31669. v = state[7];
  31670. state[15] = state[3];
  31671. state[11] = t;
  31672. state[7] = u;
  31673. state[3] = v;
  31674. for (j = 0; j < 16; ++j) {
  31675. state[j] = inv_s[state[j]];
  31676. state[j] ^= key[j];
  31677. }
  31678. return state;
  31679. }
  31680. function encrypt128(input, key) {
  31681. var t, u, v, k;
  31682. var state = new Uint8Array(16);
  31683. state.set(input);
  31684. for (j = 0; j < 16; ++j) {
  31685. state[j] ^= key[j];
  31686. }
  31687. for (i = 1; i < 10; i++) {
  31688. for (j = 0; j < 16; ++j) {
  31689. state[j] = s[state[j]];
  31690. }
  31691. v = state[1];
  31692. state[1] = state[5];
  31693. state[5] = state[9];
  31694. state[9] = state[13];
  31695. state[13] = v;
  31696. v = state[2];
  31697. u = state[6];
  31698. state[2] = state[10];
  31699. state[6] = state[14];
  31700. state[10] = v;
  31701. state[14] = u;
  31702. v = state[3];
  31703. u = state[7];
  31704. t = state[11];
  31705. state[3] = state[15];
  31706. state[7] = v;
  31707. state[11] = u;
  31708. state[15] = t;
  31709. for (var j = 0; j < 16; j += 4) {
  31710. var s0 = state[j + 0], s1 = state[j + 1];
  31711. var s2 = state[j + 2], s3 = state[j + 3];
  31712. t = s0 ^ s1 ^ s2 ^ s3;
  31713. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  31714. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  31715. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  31716. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  31717. }
  31718. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  31719. state[j] ^= key[k];
  31720. }
  31721. }
  31722. for (j = 0; j < 16; ++j) {
  31723. state[j] = s[state[j]];
  31724. }
  31725. v = state[1];
  31726. state[1] = state[5];
  31727. state[5] = state[9];
  31728. state[9] = state[13];
  31729. state[13] = v;
  31730. v = state[2];
  31731. u = state[6];
  31732. state[2] = state[10];
  31733. state[6] = state[14];
  31734. state[10] = v;
  31735. state[14] = u;
  31736. v = state[3];
  31737. u = state[7];
  31738. t = state[11];
  31739. state[3] = state[15];
  31740. state[7] = v;
  31741. state[11] = u;
  31742. state[15] = t;
  31743. for (j = 0, k = 160; j < 16; ++j, ++k) {
  31744. state[j] ^= key[k];
  31745. }
  31746. return state;
  31747. }
  31748. function AES128Cipher(key) {
  31749. this.key = expandKey128(key);
  31750. this.buffer = new Uint8Array(16);
  31751. this.bufferPosition = 0;
  31752. }
  31753. function decryptBlock2(data, finalize) {
  31754. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  31755. for (i = 0; i < sourceLength; ++i) {
  31756. buffer[bufferLength] = data[i];
  31757. ++bufferLength;
  31758. if (bufferLength < 16) {
  31759. continue;
  31760. }
  31761. var plain = decrypt128(buffer, this.key);
  31762. for (j = 0; j < 16; ++j) {
  31763. plain[j] ^= iv[j];
  31764. }
  31765. iv = buffer;
  31766. result.push(plain);
  31767. buffer = new Uint8Array(16);
  31768. bufferLength = 0;
  31769. }
  31770. this.buffer = buffer;
  31771. this.bufferLength = bufferLength;
  31772. this.iv = iv;
  31773. if (result.length === 0) {
  31774. return new Uint8Array([]);
  31775. }
  31776. var outputLength = 16 * result.length;
  31777. if (finalize) {
  31778. var lastBlock = result[result.length - 1];
  31779. var psLen = lastBlock[15];
  31780. if (psLen <= 16) {
  31781. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  31782. if (lastBlock[i] !== psLen) {
  31783. psLen = 0;
  31784. break;
  31785. }
  31786. }
  31787. outputLength -= psLen;
  31788. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  31789. }
  31790. }
  31791. var output = new Uint8Array(outputLength);
  31792. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  31793. output.set(result[i], j);
  31794. }
  31795. return output;
  31796. }
  31797. AES128Cipher.prototype = {
  31798. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  31799. var i, sourceLength = data.length;
  31800. var buffer = this.buffer, bufferLength = this.bufferPosition;
  31801. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  31802. buffer[bufferLength] = data[i];
  31803. }
  31804. if (bufferLength < 16) {
  31805. this.bufferLength = bufferLength;
  31806. return new Uint8Array([]);
  31807. }
  31808. this.iv = buffer;
  31809. this.buffer = new Uint8Array(16);
  31810. this.bufferLength = 0;
  31811. this.decryptBlock = decryptBlock2;
  31812. return this.decryptBlock(data.subarray(16), finalize);
  31813. },
  31814. encrypt: function AES128Cipher_encrypt(data, iv) {
  31815. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  31816. if (!iv) {
  31817. iv = new Uint8Array(16);
  31818. }
  31819. for (i = 0; i < sourceLength; ++i) {
  31820. buffer[bufferLength] = data[i];
  31821. ++bufferLength;
  31822. if (bufferLength < 16) {
  31823. continue;
  31824. }
  31825. for (j = 0; j < 16; ++j) {
  31826. buffer[j] ^= iv[j];
  31827. }
  31828. var cipher = encrypt128(buffer, this.key);
  31829. iv = cipher;
  31830. result.push(cipher);
  31831. buffer = new Uint8Array(16);
  31832. bufferLength = 0;
  31833. }
  31834. this.buffer = buffer;
  31835. this.bufferLength = bufferLength;
  31836. this.iv = iv;
  31837. if (result.length === 0) {
  31838. return new Uint8Array([]);
  31839. }
  31840. var outputLength = 16 * result.length;
  31841. var output = new Uint8Array(outputLength);
  31842. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  31843. output.set(result[i], j);
  31844. }
  31845. return output;
  31846. }
  31847. };
  31848. return AES128Cipher;
  31849. }();
  31850. var AES256Cipher = function AES256CipherClosure() {
  31851. var rcon = new Uint8Array([
  31852. 0x8d,
  31853. 0x01,
  31854. 0x02,
  31855. 0x04,
  31856. 0x08,
  31857. 0x10,
  31858. 0x20,
  31859. 0x40,
  31860. 0x80,
  31861. 0x1b,
  31862. 0x36,
  31863. 0x6c,
  31864. 0xd8,
  31865. 0xab,
  31866. 0x4d,
  31867. 0x9a,
  31868. 0x2f,
  31869. 0x5e,
  31870. 0xbc,
  31871. 0x63,
  31872. 0xc6,
  31873. 0x97,
  31874. 0x35,
  31875. 0x6a,
  31876. 0xd4,
  31877. 0xb3,
  31878. 0x7d,
  31879. 0xfa,
  31880. 0xef,
  31881. 0xc5,
  31882. 0x91,
  31883. 0x39,
  31884. 0x72,
  31885. 0xe4,
  31886. 0xd3,
  31887. 0xbd,
  31888. 0x61,
  31889. 0xc2,
  31890. 0x9f,
  31891. 0x25,
  31892. 0x4a,
  31893. 0x94,
  31894. 0x33,
  31895. 0x66,
  31896. 0xcc,
  31897. 0x83,
  31898. 0x1d,
  31899. 0x3a,
  31900. 0x74,
  31901. 0xe8,
  31902. 0xcb,
  31903. 0x8d,
  31904. 0x01,
  31905. 0x02,
  31906. 0x04,
  31907. 0x08,
  31908. 0x10,
  31909. 0x20,
  31910. 0x40,
  31911. 0x80,
  31912. 0x1b,
  31913. 0x36,
  31914. 0x6c,
  31915. 0xd8,
  31916. 0xab,
  31917. 0x4d,
  31918. 0x9a,
  31919. 0x2f,
  31920. 0x5e,
  31921. 0xbc,
  31922. 0x63,
  31923. 0xc6,
  31924. 0x97,
  31925. 0x35,
  31926. 0x6a,
  31927. 0xd4,
  31928. 0xb3,
  31929. 0x7d,
  31930. 0xfa,
  31931. 0xef,
  31932. 0xc5,
  31933. 0x91,
  31934. 0x39,
  31935. 0x72,
  31936. 0xe4,
  31937. 0xd3,
  31938. 0xbd,
  31939. 0x61,
  31940. 0xc2,
  31941. 0x9f,
  31942. 0x25,
  31943. 0x4a,
  31944. 0x94,
  31945. 0x33,
  31946. 0x66,
  31947. 0xcc,
  31948. 0x83,
  31949. 0x1d,
  31950. 0x3a,
  31951. 0x74,
  31952. 0xe8,
  31953. 0xcb,
  31954. 0x8d,
  31955. 0x01,
  31956. 0x02,
  31957. 0x04,
  31958. 0x08,
  31959. 0x10,
  31960. 0x20,
  31961. 0x40,
  31962. 0x80,
  31963. 0x1b,
  31964. 0x36,
  31965. 0x6c,
  31966. 0xd8,
  31967. 0xab,
  31968. 0x4d,
  31969. 0x9a,
  31970. 0x2f,
  31971. 0x5e,
  31972. 0xbc,
  31973. 0x63,
  31974. 0xc6,
  31975. 0x97,
  31976. 0x35,
  31977. 0x6a,
  31978. 0xd4,
  31979. 0xb3,
  31980. 0x7d,
  31981. 0xfa,
  31982. 0xef,
  31983. 0xc5,
  31984. 0x91,
  31985. 0x39,
  31986. 0x72,
  31987. 0xe4,
  31988. 0xd3,
  31989. 0xbd,
  31990. 0x61,
  31991. 0xc2,
  31992. 0x9f,
  31993. 0x25,
  31994. 0x4a,
  31995. 0x94,
  31996. 0x33,
  31997. 0x66,
  31998. 0xcc,
  31999. 0x83,
  32000. 0x1d,
  32001. 0x3a,
  32002. 0x74,
  32003. 0xe8,
  32004. 0xcb,
  32005. 0x8d,
  32006. 0x01,
  32007. 0x02,
  32008. 0x04,
  32009. 0x08,
  32010. 0x10,
  32011. 0x20,
  32012. 0x40,
  32013. 0x80,
  32014. 0x1b,
  32015. 0x36,
  32016. 0x6c,
  32017. 0xd8,
  32018. 0xab,
  32019. 0x4d,
  32020. 0x9a,
  32021. 0x2f,
  32022. 0x5e,
  32023. 0xbc,
  32024. 0x63,
  32025. 0xc6,
  32026. 0x97,
  32027. 0x35,
  32028. 0x6a,
  32029. 0xd4,
  32030. 0xb3,
  32031. 0x7d,
  32032. 0xfa,
  32033. 0xef,
  32034. 0xc5,
  32035. 0x91,
  32036. 0x39,
  32037. 0x72,
  32038. 0xe4,
  32039. 0xd3,
  32040. 0xbd,
  32041. 0x61,
  32042. 0xc2,
  32043. 0x9f,
  32044. 0x25,
  32045. 0x4a,
  32046. 0x94,
  32047. 0x33,
  32048. 0x66,
  32049. 0xcc,
  32050. 0x83,
  32051. 0x1d,
  32052. 0x3a,
  32053. 0x74,
  32054. 0xe8,
  32055. 0xcb,
  32056. 0x8d,
  32057. 0x01,
  32058. 0x02,
  32059. 0x04,
  32060. 0x08,
  32061. 0x10,
  32062. 0x20,
  32063. 0x40,
  32064. 0x80,
  32065. 0x1b,
  32066. 0x36,
  32067. 0x6c,
  32068. 0xd8,
  32069. 0xab,
  32070. 0x4d,
  32071. 0x9a,
  32072. 0x2f,
  32073. 0x5e,
  32074. 0xbc,
  32075. 0x63,
  32076. 0xc6,
  32077. 0x97,
  32078. 0x35,
  32079. 0x6a,
  32080. 0xd4,
  32081. 0xb3,
  32082. 0x7d,
  32083. 0xfa,
  32084. 0xef,
  32085. 0xc5,
  32086. 0x91,
  32087. 0x39,
  32088. 0x72,
  32089. 0xe4,
  32090. 0xd3,
  32091. 0xbd,
  32092. 0x61,
  32093. 0xc2,
  32094. 0x9f,
  32095. 0x25,
  32096. 0x4a,
  32097. 0x94,
  32098. 0x33,
  32099. 0x66,
  32100. 0xcc,
  32101. 0x83,
  32102. 0x1d,
  32103. 0x3a,
  32104. 0x74,
  32105. 0xe8,
  32106. 0xcb,
  32107. 0x8d
  32108. ]);
  32109. var s = new Uint8Array([
  32110. 0x63,
  32111. 0x7c,
  32112. 0x77,
  32113. 0x7b,
  32114. 0xf2,
  32115. 0x6b,
  32116. 0x6f,
  32117. 0xc5,
  32118. 0x30,
  32119. 0x01,
  32120. 0x67,
  32121. 0x2b,
  32122. 0xfe,
  32123. 0xd7,
  32124. 0xab,
  32125. 0x76,
  32126. 0xca,
  32127. 0x82,
  32128. 0xc9,
  32129. 0x7d,
  32130. 0xfa,
  32131. 0x59,
  32132. 0x47,
  32133. 0xf0,
  32134. 0xad,
  32135. 0xd4,
  32136. 0xa2,
  32137. 0xaf,
  32138. 0x9c,
  32139. 0xa4,
  32140. 0x72,
  32141. 0xc0,
  32142. 0xb7,
  32143. 0xfd,
  32144. 0x93,
  32145. 0x26,
  32146. 0x36,
  32147. 0x3f,
  32148. 0xf7,
  32149. 0xcc,
  32150. 0x34,
  32151. 0xa5,
  32152. 0xe5,
  32153. 0xf1,
  32154. 0x71,
  32155. 0xd8,
  32156. 0x31,
  32157. 0x15,
  32158. 0x04,
  32159. 0xc7,
  32160. 0x23,
  32161. 0xc3,
  32162. 0x18,
  32163. 0x96,
  32164. 0x05,
  32165. 0x9a,
  32166. 0x07,
  32167. 0x12,
  32168. 0x80,
  32169. 0xe2,
  32170. 0xeb,
  32171. 0x27,
  32172. 0xb2,
  32173. 0x75,
  32174. 0x09,
  32175. 0x83,
  32176. 0x2c,
  32177. 0x1a,
  32178. 0x1b,
  32179. 0x6e,
  32180. 0x5a,
  32181. 0xa0,
  32182. 0x52,
  32183. 0x3b,
  32184. 0xd6,
  32185. 0xb3,
  32186. 0x29,
  32187. 0xe3,
  32188. 0x2f,
  32189. 0x84,
  32190. 0x53,
  32191. 0xd1,
  32192. 0x00,
  32193. 0xed,
  32194. 0x20,
  32195. 0xfc,
  32196. 0xb1,
  32197. 0x5b,
  32198. 0x6a,
  32199. 0xcb,
  32200. 0xbe,
  32201. 0x39,
  32202. 0x4a,
  32203. 0x4c,
  32204. 0x58,
  32205. 0xcf,
  32206. 0xd0,
  32207. 0xef,
  32208. 0xaa,
  32209. 0xfb,
  32210. 0x43,
  32211. 0x4d,
  32212. 0x33,
  32213. 0x85,
  32214. 0x45,
  32215. 0xf9,
  32216. 0x02,
  32217. 0x7f,
  32218. 0x50,
  32219. 0x3c,
  32220. 0x9f,
  32221. 0xa8,
  32222. 0x51,
  32223. 0xa3,
  32224. 0x40,
  32225. 0x8f,
  32226. 0x92,
  32227. 0x9d,
  32228. 0x38,
  32229. 0xf5,
  32230. 0xbc,
  32231. 0xb6,
  32232. 0xda,
  32233. 0x21,
  32234. 0x10,
  32235. 0xff,
  32236. 0xf3,
  32237. 0xd2,
  32238. 0xcd,
  32239. 0x0c,
  32240. 0x13,
  32241. 0xec,
  32242. 0x5f,
  32243. 0x97,
  32244. 0x44,
  32245. 0x17,
  32246. 0xc4,
  32247. 0xa7,
  32248. 0x7e,
  32249. 0x3d,
  32250. 0x64,
  32251. 0x5d,
  32252. 0x19,
  32253. 0x73,
  32254. 0x60,
  32255. 0x81,
  32256. 0x4f,
  32257. 0xdc,
  32258. 0x22,
  32259. 0x2a,
  32260. 0x90,
  32261. 0x88,
  32262. 0x46,
  32263. 0xee,
  32264. 0xb8,
  32265. 0x14,
  32266. 0xde,
  32267. 0x5e,
  32268. 0x0b,
  32269. 0xdb,
  32270. 0xe0,
  32271. 0x32,
  32272. 0x3a,
  32273. 0x0a,
  32274. 0x49,
  32275. 0x06,
  32276. 0x24,
  32277. 0x5c,
  32278. 0xc2,
  32279. 0xd3,
  32280. 0xac,
  32281. 0x62,
  32282. 0x91,
  32283. 0x95,
  32284. 0xe4,
  32285. 0x79,
  32286. 0xe7,
  32287. 0xc8,
  32288. 0x37,
  32289. 0x6d,
  32290. 0x8d,
  32291. 0xd5,
  32292. 0x4e,
  32293. 0xa9,
  32294. 0x6c,
  32295. 0x56,
  32296. 0xf4,
  32297. 0xea,
  32298. 0x65,
  32299. 0x7a,
  32300. 0xae,
  32301. 0x08,
  32302. 0xba,
  32303. 0x78,
  32304. 0x25,
  32305. 0x2e,
  32306. 0x1c,
  32307. 0xa6,
  32308. 0xb4,
  32309. 0xc6,
  32310. 0xe8,
  32311. 0xdd,
  32312. 0x74,
  32313. 0x1f,
  32314. 0x4b,
  32315. 0xbd,
  32316. 0x8b,
  32317. 0x8a,
  32318. 0x70,
  32319. 0x3e,
  32320. 0xb5,
  32321. 0x66,
  32322. 0x48,
  32323. 0x03,
  32324. 0xf6,
  32325. 0x0e,
  32326. 0x61,
  32327. 0x35,
  32328. 0x57,
  32329. 0xb9,
  32330. 0x86,
  32331. 0xc1,
  32332. 0x1d,
  32333. 0x9e,
  32334. 0xe1,
  32335. 0xf8,
  32336. 0x98,
  32337. 0x11,
  32338. 0x69,
  32339. 0xd9,
  32340. 0x8e,
  32341. 0x94,
  32342. 0x9b,
  32343. 0x1e,
  32344. 0x87,
  32345. 0xe9,
  32346. 0xce,
  32347. 0x55,
  32348. 0x28,
  32349. 0xdf,
  32350. 0x8c,
  32351. 0xa1,
  32352. 0x89,
  32353. 0x0d,
  32354. 0xbf,
  32355. 0xe6,
  32356. 0x42,
  32357. 0x68,
  32358. 0x41,
  32359. 0x99,
  32360. 0x2d,
  32361. 0x0f,
  32362. 0xb0,
  32363. 0x54,
  32364. 0xbb,
  32365. 0x16
  32366. ]);
  32367. var inv_s = new Uint8Array([
  32368. 0x52,
  32369. 0x09,
  32370. 0x6a,
  32371. 0xd5,
  32372. 0x30,
  32373. 0x36,
  32374. 0xa5,
  32375. 0x38,
  32376. 0xbf,
  32377. 0x40,
  32378. 0xa3,
  32379. 0x9e,
  32380. 0x81,
  32381. 0xf3,
  32382. 0xd7,
  32383. 0xfb,
  32384. 0x7c,
  32385. 0xe3,
  32386. 0x39,
  32387. 0x82,
  32388. 0x9b,
  32389. 0x2f,
  32390. 0xff,
  32391. 0x87,
  32392. 0x34,
  32393. 0x8e,
  32394. 0x43,
  32395. 0x44,
  32396. 0xc4,
  32397. 0xde,
  32398. 0xe9,
  32399. 0xcb,
  32400. 0x54,
  32401. 0x7b,
  32402. 0x94,
  32403. 0x32,
  32404. 0xa6,
  32405. 0xc2,
  32406. 0x23,
  32407. 0x3d,
  32408. 0xee,
  32409. 0x4c,
  32410. 0x95,
  32411. 0x0b,
  32412. 0x42,
  32413. 0xfa,
  32414. 0xc3,
  32415. 0x4e,
  32416. 0x08,
  32417. 0x2e,
  32418. 0xa1,
  32419. 0x66,
  32420. 0x28,
  32421. 0xd9,
  32422. 0x24,
  32423. 0xb2,
  32424. 0x76,
  32425. 0x5b,
  32426. 0xa2,
  32427. 0x49,
  32428. 0x6d,
  32429. 0x8b,
  32430. 0xd1,
  32431. 0x25,
  32432. 0x72,
  32433. 0xf8,
  32434. 0xf6,
  32435. 0x64,
  32436. 0x86,
  32437. 0x68,
  32438. 0x98,
  32439. 0x16,
  32440. 0xd4,
  32441. 0xa4,
  32442. 0x5c,
  32443. 0xcc,
  32444. 0x5d,
  32445. 0x65,
  32446. 0xb6,
  32447. 0x92,
  32448. 0x6c,
  32449. 0x70,
  32450. 0x48,
  32451. 0x50,
  32452. 0xfd,
  32453. 0xed,
  32454. 0xb9,
  32455. 0xda,
  32456. 0x5e,
  32457. 0x15,
  32458. 0x46,
  32459. 0x57,
  32460. 0xa7,
  32461. 0x8d,
  32462. 0x9d,
  32463. 0x84,
  32464. 0x90,
  32465. 0xd8,
  32466. 0xab,
  32467. 0x00,
  32468. 0x8c,
  32469. 0xbc,
  32470. 0xd3,
  32471. 0x0a,
  32472. 0xf7,
  32473. 0xe4,
  32474. 0x58,
  32475. 0x05,
  32476. 0xb8,
  32477. 0xb3,
  32478. 0x45,
  32479. 0x06,
  32480. 0xd0,
  32481. 0x2c,
  32482. 0x1e,
  32483. 0x8f,
  32484. 0xca,
  32485. 0x3f,
  32486. 0x0f,
  32487. 0x02,
  32488. 0xc1,
  32489. 0xaf,
  32490. 0xbd,
  32491. 0x03,
  32492. 0x01,
  32493. 0x13,
  32494. 0x8a,
  32495. 0x6b,
  32496. 0x3a,
  32497. 0x91,
  32498. 0x11,
  32499. 0x41,
  32500. 0x4f,
  32501. 0x67,
  32502. 0xdc,
  32503. 0xea,
  32504. 0x97,
  32505. 0xf2,
  32506. 0xcf,
  32507. 0xce,
  32508. 0xf0,
  32509. 0xb4,
  32510. 0xe6,
  32511. 0x73,
  32512. 0x96,
  32513. 0xac,
  32514. 0x74,
  32515. 0x22,
  32516. 0xe7,
  32517. 0xad,
  32518. 0x35,
  32519. 0x85,
  32520. 0xe2,
  32521. 0xf9,
  32522. 0x37,
  32523. 0xe8,
  32524. 0x1c,
  32525. 0x75,
  32526. 0xdf,
  32527. 0x6e,
  32528. 0x47,
  32529. 0xf1,
  32530. 0x1a,
  32531. 0x71,
  32532. 0x1d,
  32533. 0x29,
  32534. 0xc5,
  32535. 0x89,
  32536. 0x6f,
  32537. 0xb7,
  32538. 0x62,
  32539. 0x0e,
  32540. 0xaa,
  32541. 0x18,
  32542. 0xbe,
  32543. 0x1b,
  32544. 0xfc,
  32545. 0x56,
  32546. 0x3e,
  32547. 0x4b,
  32548. 0xc6,
  32549. 0xd2,
  32550. 0x79,
  32551. 0x20,
  32552. 0x9a,
  32553. 0xdb,
  32554. 0xc0,
  32555. 0xfe,
  32556. 0x78,
  32557. 0xcd,
  32558. 0x5a,
  32559. 0xf4,
  32560. 0x1f,
  32561. 0xdd,
  32562. 0xa8,
  32563. 0x33,
  32564. 0x88,
  32565. 0x07,
  32566. 0xc7,
  32567. 0x31,
  32568. 0xb1,
  32569. 0x12,
  32570. 0x10,
  32571. 0x59,
  32572. 0x27,
  32573. 0x80,
  32574. 0xec,
  32575. 0x5f,
  32576. 0x60,
  32577. 0x51,
  32578. 0x7f,
  32579. 0xa9,
  32580. 0x19,
  32581. 0xb5,
  32582. 0x4a,
  32583. 0x0d,
  32584. 0x2d,
  32585. 0xe5,
  32586. 0x7a,
  32587. 0x9f,
  32588. 0x93,
  32589. 0xc9,
  32590. 0x9c,
  32591. 0xef,
  32592. 0xa0,
  32593. 0xe0,
  32594. 0x3b,
  32595. 0x4d,
  32596. 0xae,
  32597. 0x2a,
  32598. 0xf5,
  32599. 0xb0,
  32600. 0xc8,
  32601. 0xeb,
  32602. 0xbb,
  32603. 0x3c,
  32604. 0x83,
  32605. 0x53,
  32606. 0x99,
  32607. 0x61,
  32608. 0x17,
  32609. 0x2b,
  32610. 0x04,
  32611. 0x7e,
  32612. 0xba,
  32613. 0x77,
  32614. 0xd6,
  32615. 0x26,
  32616. 0xe1,
  32617. 0x69,
  32618. 0x14,
  32619. 0x63,
  32620. 0x55,
  32621. 0x21,
  32622. 0x0c,
  32623. 0x7d
  32624. ]);
  32625. var mixCol = new Uint8Array(256);
  32626. for (var i = 0; i < 256; i++) {
  32627. if (i < 128) {
  32628. mixCol[i] = i << 1;
  32629. } else {
  32630. mixCol[i] = i << 1 ^ 0x1b;
  32631. }
  32632. }
  32633. var mix = new Uint32Array([
  32634. 0x00000000,
  32635. 0x0e090d0b,
  32636. 0x1c121a16,
  32637. 0x121b171d,
  32638. 0x3824342c,
  32639. 0x362d3927,
  32640. 0x24362e3a,
  32641. 0x2a3f2331,
  32642. 0x70486858,
  32643. 0x7e416553,
  32644. 0x6c5a724e,
  32645. 0x62537f45,
  32646. 0x486c5c74,
  32647. 0x4665517f,
  32648. 0x547e4662,
  32649. 0x5a774b69,
  32650. 0xe090d0b0,
  32651. 0xee99ddbb,
  32652. 0xfc82caa6,
  32653. 0xf28bc7ad,
  32654. 0xd8b4e49c,
  32655. 0xd6bde997,
  32656. 0xc4a6fe8a,
  32657. 0xcaaff381,
  32658. 0x90d8b8e8,
  32659. 0x9ed1b5e3,
  32660. 0x8ccaa2fe,
  32661. 0x82c3aff5,
  32662. 0xa8fc8cc4,
  32663. 0xa6f581cf,
  32664. 0xb4ee96d2,
  32665. 0xbae79bd9,
  32666. 0xdb3bbb7b,
  32667. 0xd532b670,
  32668. 0xc729a16d,
  32669. 0xc920ac66,
  32670. 0xe31f8f57,
  32671. 0xed16825c,
  32672. 0xff0d9541,
  32673. 0xf104984a,
  32674. 0xab73d323,
  32675. 0xa57ade28,
  32676. 0xb761c935,
  32677. 0xb968c43e,
  32678. 0x9357e70f,
  32679. 0x9d5eea04,
  32680. 0x8f45fd19,
  32681. 0x814cf012,
  32682. 0x3bab6bcb,
  32683. 0x35a266c0,
  32684. 0x27b971dd,
  32685. 0x29b07cd6,
  32686. 0x038f5fe7,
  32687. 0x0d8652ec,
  32688. 0x1f9d45f1,
  32689. 0x119448fa,
  32690. 0x4be30393,
  32691. 0x45ea0e98,
  32692. 0x57f11985,
  32693. 0x59f8148e,
  32694. 0x73c737bf,
  32695. 0x7dce3ab4,
  32696. 0x6fd52da9,
  32697. 0x61dc20a2,
  32698. 0xad766df6,
  32699. 0xa37f60fd,
  32700. 0xb16477e0,
  32701. 0xbf6d7aeb,
  32702. 0x955259da,
  32703. 0x9b5b54d1,
  32704. 0x894043cc,
  32705. 0x87494ec7,
  32706. 0xdd3e05ae,
  32707. 0xd33708a5,
  32708. 0xc12c1fb8,
  32709. 0xcf2512b3,
  32710. 0xe51a3182,
  32711. 0xeb133c89,
  32712. 0xf9082b94,
  32713. 0xf701269f,
  32714. 0x4de6bd46,
  32715. 0x43efb04d,
  32716. 0x51f4a750,
  32717. 0x5ffdaa5b,
  32718. 0x75c2896a,
  32719. 0x7bcb8461,
  32720. 0x69d0937c,
  32721. 0x67d99e77,
  32722. 0x3daed51e,
  32723. 0x33a7d815,
  32724. 0x21bccf08,
  32725. 0x2fb5c203,
  32726. 0x058ae132,
  32727. 0x0b83ec39,
  32728. 0x1998fb24,
  32729. 0x1791f62f,
  32730. 0x764dd68d,
  32731. 0x7844db86,
  32732. 0x6a5fcc9b,
  32733. 0x6456c190,
  32734. 0x4e69e2a1,
  32735. 0x4060efaa,
  32736. 0x527bf8b7,
  32737. 0x5c72f5bc,
  32738. 0x0605bed5,
  32739. 0x080cb3de,
  32740. 0x1a17a4c3,
  32741. 0x141ea9c8,
  32742. 0x3e218af9,
  32743. 0x302887f2,
  32744. 0x223390ef,
  32745. 0x2c3a9de4,
  32746. 0x96dd063d,
  32747. 0x98d40b36,
  32748. 0x8acf1c2b,
  32749. 0x84c61120,
  32750. 0xaef93211,
  32751. 0xa0f03f1a,
  32752. 0xb2eb2807,
  32753. 0xbce2250c,
  32754. 0xe6956e65,
  32755. 0xe89c636e,
  32756. 0xfa877473,
  32757. 0xf48e7978,
  32758. 0xdeb15a49,
  32759. 0xd0b85742,
  32760. 0xc2a3405f,
  32761. 0xccaa4d54,
  32762. 0x41ecdaf7,
  32763. 0x4fe5d7fc,
  32764. 0x5dfec0e1,
  32765. 0x53f7cdea,
  32766. 0x79c8eedb,
  32767. 0x77c1e3d0,
  32768. 0x65daf4cd,
  32769. 0x6bd3f9c6,
  32770. 0x31a4b2af,
  32771. 0x3fadbfa4,
  32772. 0x2db6a8b9,
  32773. 0x23bfa5b2,
  32774. 0x09808683,
  32775. 0x07898b88,
  32776. 0x15929c95,
  32777. 0x1b9b919e,
  32778. 0xa17c0a47,
  32779. 0xaf75074c,
  32780. 0xbd6e1051,
  32781. 0xb3671d5a,
  32782. 0x99583e6b,
  32783. 0x97513360,
  32784. 0x854a247d,
  32785. 0x8b432976,
  32786. 0xd134621f,
  32787. 0xdf3d6f14,
  32788. 0xcd267809,
  32789. 0xc32f7502,
  32790. 0xe9105633,
  32791. 0xe7195b38,
  32792. 0xf5024c25,
  32793. 0xfb0b412e,
  32794. 0x9ad7618c,
  32795. 0x94de6c87,
  32796. 0x86c57b9a,
  32797. 0x88cc7691,
  32798. 0xa2f355a0,
  32799. 0xacfa58ab,
  32800. 0xbee14fb6,
  32801. 0xb0e842bd,
  32802. 0xea9f09d4,
  32803. 0xe49604df,
  32804. 0xf68d13c2,
  32805. 0xf8841ec9,
  32806. 0xd2bb3df8,
  32807. 0xdcb230f3,
  32808. 0xcea927ee,
  32809. 0xc0a02ae5,
  32810. 0x7a47b13c,
  32811. 0x744ebc37,
  32812. 0x6655ab2a,
  32813. 0x685ca621,
  32814. 0x42638510,
  32815. 0x4c6a881b,
  32816. 0x5e719f06,
  32817. 0x5078920d,
  32818. 0x0a0fd964,
  32819. 0x0406d46f,
  32820. 0x161dc372,
  32821. 0x1814ce79,
  32822. 0x322bed48,
  32823. 0x3c22e043,
  32824. 0x2e39f75e,
  32825. 0x2030fa55,
  32826. 0xec9ab701,
  32827. 0xe293ba0a,
  32828. 0xf088ad17,
  32829. 0xfe81a01c,
  32830. 0xd4be832d,
  32831. 0xdab78e26,
  32832. 0xc8ac993b,
  32833. 0xc6a59430,
  32834. 0x9cd2df59,
  32835. 0x92dbd252,
  32836. 0x80c0c54f,
  32837. 0x8ec9c844,
  32838. 0xa4f6eb75,
  32839. 0xaaffe67e,
  32840. 0xb8e4f163,
  32841. 0xb6edfc68,
  32842. 0x0c0a67b1,
  32843. 0x02036aba,
  32844. 0x10187da7,
  32845. 0x1e1170ac,
  32846. 0x342e539d,
  32847. 0x3a275e96,
  32848. 0x283c498b,
  32849. 0x26354480,
  32850. 0x7c420fe9,
  32851. 0x724b02e2,
  32852. 0x605015ff,
  32853. 0x6e5918f4,
  32854. 0x44663bc5,
  32855. 0x4a6f36ce,
  32856. 0x587421d3,
  32857. 0x567d2cd8,
  32858. 0x37a10c7a,
  32859. 0x39a80171,
  32860. 0x2bb3166c,
  32861. 0x25ba1b67,
  32862. 0x0f853856,
  32863. 0x018c355d,
  32864. 0x13972240,
  32865. 0x1d9e2f4b,
  32866. 0x47e96422,
  32867. 0x49e06929,
  32868. 0x5bfb7e34,
  32869. 0x55f2733f,
  32870. 0x7fcd500e,
  32871. 0x71c45d05,
  32872. 0x63df4a18,
  32873. 0x6dd64713,
  32874. 0xd731dcca,
  32875. 0xd938d1c1,
  32876. 0xcb23c6dc,
  32877. 0xc52acbd7,
  32878. 0xef15e8e6,
  32879. 0xe11ce5ed,
  32880. 0xf307f2f0,
  32881. 0xfd0efffb,
  32882. 0xa779b492,
  32883. 0xa970b999,
  32884. 0xbb6bae84,
  32885. 0xb562a38f,
  32886. 0x9f5d80be,
  32887. 0x91548db5,
  32888. 0x834f9aa8,
  32889. 0x8d4697a3
  32890. ]);
  32891. function expandKey256(cipherKey) {
  32892. var b = 240, result = new Uint8Array(b);
  32893. var r = 1;
  32894. result.set(cipherKey);
  32895. for (var j = 32, i = 1; j < b; ++i) {
  32896. if (j % 32 === 16) {
  32897. t1 = s[t1];
  32898. t2 = s[t2];
  32899. t3 = s[t3];
  32900. t4 = s[t4];
  32901. } else if (j % 32 === 0) {
  32902. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  32903. t1 = s[t1];
  32904. t2 = s[t2];
  32905. t3 = s[t3];
  32906. t4 = s[t4];
  32907. t1 = t1 ^ r;
  32908. if ((r <<= 1) >= 256) {
  32909. r = (r ^ 0x1b) & 0xFF;
  32910. }
  32911. }
  32912. for (var n = 0; n < 4; ++n) {
  32913. result[j] = t1 ^= result[j - 32];
  32914. j++;
  32915. result[j] = t2 ^= result[j - 32];
  32916. j++;
  32917. result[j] = t3 ^= result[j - 32];
  32918. j++;
  32919. result[j] = t4 ^= result[j - 32];
  32920. j++;
  32921. }
  32922. }
  32923. return result;
  32924. }
  32925. function decrypt256(input, key) {
  32926. var state = new Uint8Array(16);
  32927. state.set(input);
  32928. var i, j, k;
  32929. var t, u, v;
  32930. for (j = 0, k = 224; j < 16; ++j, ++k) {
  32931. state[j] ^= key[k];
  32932. }
  32933. for (i = 13; i >= 1; --i) {
  32934. t = state[13];
  32935. state[13] = state[9];
  32936. state[9] = state[5];
  32937. state[5] = state[1];
  32938. state[1] = t;
  32939. t = state[14];
  32940. u = state[10];
  32941. state[14] = state[6];
  32942. state[10] = state[2];
  32943. state[6] = t;
  32944. state[2] = u;
  32945. t = state[15];
  32946. u = state[11];
  32947. v = state[7];
  32948. state[15] = state[3];
  32949. state[11] = t;
  32950. state[7] = u;
  32951. state[3] = v;
  32952. for (j = 0; j < 16; ++j) {
  32953. state[j] = inv_s[state[j]];
  32954. }
  32955. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  32956. state[j] ^= key[k];
  32957. }
  32958. for (j = 0; j < 16; j += 4) {
  32959. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  32960. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  32961. state[j] = t >>> 24 & 0xFF;
  32962. state[j + 1] = t >> 16 & 0xFF;
  32963. state[j + 2] = t >> 8 & 0xFF;
  32964. state[j + 3] = t & 0xFF;
  32965. }
  32966. }
  32967. t = state[13];
  32968. state[13] = state[9];
  32969. state[9] = state[5];
  32970. state[5] = state[1];
  32971. state[1] = t;
  32972. t = state[14];
  32973. u = state[10];
  32974. state[14] = state[6];
  32975. state[10] = state[2];
  32976. state[6] = t;
  32977. state[2] = u;
  32978. t = state[15];
  32979. u = state[11];
  32980. v = state[7];
  32981. state[15] = state[3];
  32982. state[11] = t;
  32983. state[7] = u;
  32984. state[3] = v;
  32985. for (j = 0; j < 16; ++j) {
  32986. state[j] = inv_s[state[j]];
  32987. state[j] ^= key[j];
  32988. }
  32989. return state;
  32990. }
  32991. function encrypt256(input, key) {
  32992. var t, u, v, k;
  32993. var state = new Uint8Array(16);
  32994. state.set(input);
  32995. for (j = 0; j < 16; ++j) {
  32996. state[j] ^= key[j];
  32997. }
  32998. for (i = 1; i < 14; i++) {
  32999. for (j = 0; j < 16; ++j) {
  33000. state[j] = s[state[j]];
  33001. }
  33002. v = state[1];
  33003. state[1] = state[5];
  33004. state[5] = state[9];
  33005. state[9] = state[13];
  33006. state[13] = v;
  33007. v = state[2];
  33008. u = state[6];
  33009. state[2] = state[10];
  33010. state[6] = state[14];
  33011. state[10] = v;
  33012. state[14] = u;
  33013. v = state[3];
  33014. u = state[7];
  33015. t = state[11];
  33016. state[3] = state[15];
  33017. state[7] = v;
  33018. state[11] = u;
  33019. state[15] = t;
  33020. for (var j = 0; j < 16; j += 4) {
  33021. var s0 = state[j + 0], s1 = state[j + 1];
  33022. var s2 = state[j + 2], s3 = state[j + 3];
  33023. t = s0 ^ s1 ^ s2 ^ s3;
  33024. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  33025. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  33026. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  33027. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  33028. }
  33029. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  33030. state[j] ^= key[k];
  33031. }
  33032. }
  33033. for (j = 0; j < 16; ++j) {
  33034. state[j] = s[state[j]];
  33035. }
  33036. v = state[1];
  33037. state[1] = state[5];
  33038. state[5] = state[9];
  33039. state[9] = state[13];
  33040. state[13] = v;
  33041. v = state[2];
  33042. u = state[6];
  33043. state[2] = state[10];
  33044. state[6] = state[14];
  33045. state[10] = v;
  33046. state[14] = u;
  33047. v = state[3];
  33048. u = state[7];
  33049. t = state[11];
  33050. state[3] = state[15];
  33051. state[7] = v;
  33052. state[11] = u;
  33053. state[15] = t;
  33054. for (j = 0, k = 224; j < 16; ++j, ++k) {
  33055. state[j] ^= key[k];
  33056. }
  33057. return state;
  33058. }
  33059. function AES256Cipher(key) {
  33060. this.key = expandKey256(key);
  33061. this.buffer = new Uint8Array(16);
  33062. this.bufferPosition = 0;
  33063. }
  33064. function decryptBlock2(data, finalize) {
  33065. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  33066. for (i = 0; i < sourceLength; ++i) {
  33067. buffer[bufferLength] = data[i];
  33068. ++bufferLength;
  33069. if (bufferLength < 16) {
  33070. continue;
  33071. }
  33072. var plain = decrypt256(buffer, this.key);
  33073. for (j = 0; j < 16; ++j) {
  33074. plain[j] ^= iv[j];
  33075. }
  33076. iv = buffer;
  33077. result.push(plain);
  33078. buffer = new Uint8Array(16);
  33079. bufferLength = 0;
  33080. }
  33081. this.buffer = buffer;
  33082. this.bufferLength = bufferLength;
  33083. this.iv = iv;
  33084. if (result.length === 0) {
  33085. return new Uint8Array([]);
  33086. }
  33087. var outputLength = 16 * result.length;
  33088. if (finalize) {
  33089. var lastBlock = result[result.length - 1];
  33090. var psLen = lastBlock[15];
  33091. if (psLen <= 16) {
  33092. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  33093. if (lastBlock[i] !== psLen) {
  33094. psLen = 0;
  33095. break;
  33096. }
  33097. }
  33098. outputLength -= psLen;
  33099. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  33100. }
  33101. }
  33102. var output = new Uint8Array(outputLength);
  33103. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  33104. output.set(result[i], j);
  33105. }
  33106. return output;
  33107. }
  33108. AES256Cipher.prototype = {
  33109. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  33110. var i, sourceLength = data.length;
  33111. var buffer = this.buffer, bufferLength = this.bufferPosition;
  33112. if (iv) {
  33113. this.iv = iv;
  33114. } else {
  33115. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  33116. buffer[bufferLength] = data[i];
  33117. }
  33118. if (bufferLength < 16) {
  33119. this.bufferLength = bufferLength;
  33120. return new Uint8Array([]);
  33121. }
  33122. this.iv = buffer;
  33123. data = data.subarray(16);
  33124. }
  33125. this.buffer = new Uint8Array(16);
  33126. this.bufferLength = 0;
  33127. this.decryptBlock = decryptBlock2;
  33128. return this.decryptBlock(data, finalize);
  33129. },
  33130. encrypt: function AES256Cipher_encrypt(data, iv) {
  33131. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  33132. if (!iv) {
  33133. iv = new Uint8Array(16);
  33134. }
  33135. for (i = 0; i < sourceLength; ++i) {
  33136. buffer[bufferLength] = data[i];
  33137. ++bufferLength;
  33138. if (bufferLength < 16) {
  33139. continue;
  33140. }
  33141. for (j = 0; j < 16; ++j) {
  33142. buffer[j] ^= iv[j];
  33143. }
  33144. var cipher = encrypt256(buffer, this.key);
  33145. this.iv = cipher;
  33146. result.push(cipher);
  33147. buffer = new Uint8Array(16);
  33148. bufferLength = 0;
  33149. }
  33150. this.buffer = buffer;
  33151. this.bufferLength = bufferLength;
  33152. this.iv = iv;
  33153. if (result.length === 0) {
  33154. return new Uint8Array([]);
  33155. }
  33156. var outputLength = 16 * result.length;
  33157. var output = new Uint8Array(outputLength);
  33158. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  33159. output.set(result[i], j);
  33160. }
  33161. return output;
  33162. }
  33163. };
  33164. return AES256Cipher;
  33165. }();
  33166. var PDF17 = function PDF17Closure() {
  33167. function compareByteArrays(array1, array2) {
  33168. if (array1.length !== array2.length) {
  33169. return false;
  33170. }
  33171. for (var i = 0; i < array1.length; i++) {
  33172. if (array1[i] !== array2[i]) {
  33173. return false;
  33174. }
  33175. }
  33176. return true;
  33177. }
  33178. function PDF17() {
  33179. }
  33180. PDF17.prototype = {
  33181. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  33182. var hashData = new Uint8Array(password.length + 56);
  33183. hashData.set(password, 0);
  33184. hashData.set(ownerValidationSalt, password.length);
  33185. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  33186. var result = calculateSHA256(hashData, 0, hashData.length);
  33187. return compareByteArrays(result, ownerPassword);
  33188. },
  33189. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  33190. var hashData = new Uint8Array(password.length + 8);
  33191. hashData.set(password, 0);
  33192. hashData.set(userValidationSalt, password.length);
  33193. var result = calculateSHA256(hashData, 0, hashData.length);
  33194. return compareByteArrays(result, userPassword);
  33195. },
  33196. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  33197. var hashData = new Uint8Array(password.length + 56);
  33198. hashData.set(password, 0);
  33199. hashData.set(ownerKeySalt, password.length);
  33200. hashData.set(userBytes, password.length + ownerKeySalt.length);
  33201. var key = calculateSHA256(hashData, 0, hashData.length);
  33202. var cipher = new AES256Cipher(key);
  33203. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  33204. },
  33205. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  33206. var hashData = new Uint8Array(password.length + 8);
  33207. hashData.set(password, 0);
  33208. hashData.set(userKeySalt, password.length);
  33209. var key = calculateSHA256(hashData, 0, hashData.length);
  33210. var cipher = new AES256Cipher(key);
  33211. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  33212. }
  33213. };
  33214. return PDF17;
  33215. }();
  33216. var PDF20 = function PDF20Closure() {
  33217. function concatArrays(array1, array2) {
  33218. var t = new Uint8Array(array1.length + array2.length);
  33219. t.set(array1, 0);
  33220. t.set(array2, array1.length);
  33221. return t;
  33222. }
  33223. function calculatePDF20Hash(password, input, userBytes) {
  33224. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  33225. var e = [0];
  33226. var i = 0;
  33227. while (i < 64 || e[e.length - 1] > i - 32) {
  33228. var arrayLength = password.length + k.length + userBytes.length;
  33229. var k1 = new Uint8Array(arrayLength * 64);
  33230. var array = concatArrays(password, k);
  33231. array = concatArrays(array, userBytes);
  33232. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  33233. k1.set(array, pos);
  33234. }
  33235. var cipher = new AES128Cipher(k.subarray(0, 16));
  33236. e = cipher.encrypt(k1, k.subarray(16, 32));
  33237. var remainder = 0;
  33238. for (var z = 0; z < 16; z++) {
  33239. remainder *= 256 % 3;
  33240. remainder %= 3;
  33241. remainder += (e[z] >>> 0) % 3;
  33242. remainder %= 3;
  33243. }
  33244. if (remainder === 0) {
  33245. k = calculateSHA256(e, 0, e.length);
  33246. } else if (remainder === 1) {
  33247. k = calculateSHA384(e, 0, e.length);
  33248. } else if (remainder === 2) {
  33249. k = calculateSHA512(e, 0, e.length);
  33250. }
  33251. i++;
  33252. }
  33253. return k.subarray(0, 32);
  33254. }
  33255. function PDF20() {
  33256. }
  33257. function compareByteArrays(array1, array2) {
  33258. if (array1.length !== array2.length) {
  33259. return false;
  33260. }
  33261. for (var i = 0; i < array1.length; i++) {
  33262. if (array1[i] !== array2[i]) {
  33263. return false;
  33264. }
  33265. }
  33266. return true;
  33267. }
  33268. PDF20.prototype = {
  33269. hash: function PDF20_hash(password, concatBytes, userBytes) {
  33270. return calculatePDF20Hash(password, concatBytes, userBytes);
  33271. },
  33272. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  33273. var hashData = new Uint8Array(password.length + 56);
  33274. hashData.set(password, 0);
  33275. hashData.set(ownerValidationSalt, password.length);
  33276. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  33277. var result = calculatePDF20Hash(password, hashData, userBytes);
  33278. return compareByteArrays(result, ownerPassword);
  33279. },
  33280. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  33281. var hashData = new Uint8Array(password.length + 8);
  33282. hashData.set(password, 0);
  33283. hashData.set(userValidationSalt, password.length);
  33284. var result = calculatePDF20Hash(password, hashData, []);
  33285. return compareByteArrays(result, userPassword);
  33286. },
  33287. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  33288. var hashData = new Uint8Array(password.length + 56);
  33289. hashData.set(password, 0);
  33290. hashData.set(ownerKeySalt, password.length);
  33291. hashData.set(userBytes, password.length + ownerKeySalt.length);
  33292. var key = calculatePDF20Hash(password, hashData, userBytes);
  33293. var cipher = new AES256Cipher(key);
  33294. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  33295. },
  33296. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  33297. var hashData = new Uint8Array(password.length + 8);
  33298. hashData.set(password, 0);
  33299. hashData.set(userKeySalt, password.length);
  33300. var key = calculatePDF20Hash(password, hashData, []);
  33301. var cipher = new AES256Cipher(key);
  33302. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  33303. }
  33304. };
  33305. return PDF20;
  33306. }();
  33307. var CipherTransform = function CipherTransformClosure() {
  33308. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  33309. this.StringCipherConstructor = stringCipherConstructor;
  33310. this.StreamCipherConstructor = streamCipherConstructor;
  33311. }
  33312. CipherTransform.prototype = {
  33313. createStream: function CipherTransform_createStream(stream, length) {
  33314. var cipher = new this.StreamCipherConstructor();
  33315. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  33316. return cipher.decryptBlock(data, finalize);
  33317. });
  33318. },
  33319. decryptString: function CipherTransform_decryptString(s) {
  33320. var cipher = new this.StringCipherConstructor();
  33321. var data = stringToBytes(s);
  33322. data = cipher.decryptBlock(data, true);
  33323. return bytesToString(data);
  33324. }
  33325. };
  33326. return CipherTransform;
  33327. }();
  33328. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  33329. var defaultPasswordBytes = new Uint8Array([
  33330. 0x28,
  33331. 0xBF,
  33332. 0x4E,
  33333. 0x5E,
  33334. 0x4E,
  33335. 0x75,
  33336. 0x8A,
  33337. 0x41,
  33338. 0x64,
  33339. 0x00,
  33340. 0x4E,
  33341. 0x56,
  33342. 0xFF,
  33343. 0xFA,
  33344. 0x01,
  33345. 0x08,
  33346. 0x2E,
  33347. 0x2E,
  33348. 0x00,
  33349. 0xB6,
  33350. 0xD0,
  33351. 0x68,
  33352. 0x3E,
  33353. 0x80,
  33354. 0x2F,
  33355. 0x0C,
  33356. 0xA9,
  33357. 0xFE,
  33358. 0x64,
  33359. 0x53,
  33360. 0x69,
  33361. 0x7A
  33362. ]);
  33363. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  33364. if (password) {
  33365. var passwordLength = Math.min(127, password.length);
  33366. password = password.subarray(0, passwordLength);
  33367. } else {
  33368. password = [];
  33369. }
  33370. var pdfAlgorithm;
  33371. if (revision === 6) {
  33372. pdfAlgorithm = new PDF20();
  33373. } else {
  33374. pdfAlgorithm = new PDF17();
  33375. }
  33376. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  33377. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  33378. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  33379. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  33380. }
  33381. return null;
  33382. }
  33383. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  33384. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  33385. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  33386. if (password) {
  33387. n = Math.min(32, password.length);
  33388. for (; i < n; ++i) {
  33389. hashData[i] = password[i];
  33390. }
  33391. }
  33392. j = 0;
  33393. while (i < 32) {
  33394. hashData[i++] = defaultPasswordBytes[j++];
  33395. }
  33396. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  33397. hashData[i++] = ownerPassword[j];
  33398. }
  33399. hashData[i++] = flags & 0xFF;
  33400. hashData[i++] = flags >> 8 & 0xFF;
  33401. hashData[i++] = flags >> 16 & 0xFF;
  33402. hashData[i++] = flags >>> 24 & 0xFF;
  33403. for (j = 0, n = fileId.length; j < n; ++j) {
  33404. hashData[i++] = fileId[j];
  33405. }
  33406. if (revision >= 4 && !encryptMetadata) {
  33407. hashData[i++] = 0xFF;
  33408. hashData[i++] = 0xFF;
  33409. hashData[i++] = 0xFF;
  33410. hashData[i++] = 0xFF;
  33411. }
  33412. var hash = calculateMD5(hashData, 0, i);
  33413. var keyLengthInBytes = keyLength >> 3;
  33414. if (revision >= 3) {
  33415. for (j = 0; j < 50; ++j) {
  33416. hash = calculateMD5(hash, 0, keyLengthInBytes);
  33417. }
  33418. }
  33419. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  33420. var cipher, checkData;
  33421. if (revision >= 3) {
  33422. for (i = 0; i < 32; ++i) {
  33423. hashData[i] = defaultPasswordBytes[i];
  33424. }
  33425. for (j = 0, n = fileId.length; j < n; ++j) {
  33426. hashData[i++] = fileId[j];
  33427. }
  33428. cipher = new ARCFourCipher(encryptionKey);
  33429. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  33430. n = encryptionKey.length;
  33431. var derivedKey = new Uint8Array(n), k;
  33432. for (j = 1; j <= 19; ++j) {
  33433. for (k = 0; k < n; ++k) {
  33434. derivedKey[k] = encryptionKey[k] ^ j;
  33435. }
  33436. cipher = new ARCFourCipher(derivedKey);
  33437. checkData = cipher.encryptBlock(checkData);
  33438. }
  33439. for (j = 0, n = checkData.length; j < n; ++j) {
  33440. if (userPassword[j] !== checkData[j]) {
  33441. return null;
  33442. }
  33443. }
  33444. } else {
  33445. cipher = new ARCFourCipher(encryptionKey);
  33446. checkData = cipher.encryptBlock(defaultPasswordBytes);
  33447. for (j = 0, n = checkData.length; j < n; ++j) {
  33448. if (userPassword[j] !== checkData[j]) {
  33449. return null;
  33450. }
  33451. }
  33452. }
  33453. return encryptionKey;
  33454. }
  33455. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  33456. var hashData = new Uint8Array(32), i = 0, j, n;
  33457. n = Math.min(32, password.length);
  33458. for (; i < n; ++i) {
  33459. hashData[i] = password[i];
  33460. }
  33461. j = 0;
  33462. while (i < 32) {
  33463. hashData[i++] = defaultPasswordBytes[j++];
  33464. }
  33465. var hash = calculateMD5(hashData, 0, i);
  33466. var keyLengthInBytes = keyLength >> 3;
  33467. if (revision >= 3) {
  33468. for (j = 0; j < 50; ++j) {
  33469. hash = calculateMD5(hash, 0, hash.length);
  33470. }
  33471. }
  33472. var cipher, userPassword;
  33473. if (revision >= 3) {
  33474. userPassword = ownerPassword;
  33475. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  33476. for (j = 19; j >= 0; j--) {
  33477. for (k = 0; k < keyLengthInBytes; ++k) {
  33478. derivedKey[k] = hash[k] ^ j;
  33479. }
  33480. cipher = new ARCFourCipher(derivedKey);
  33481. userPassword = cipher.encryptBlock(userPassword);
  33482. }
  33483. } else {
  33484. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  33485. userPassword = cipher.encryptBlock(ownerPassword);
  33486. }
  33487. return userPassword;
  33488. }
  33489. var identityName = Name.get('Identity');
  33490. function CipherTransformFactory(dict, fileId, password) {
  33491. var filter = dict.get('Filter');
  33492. if (!isName(filter, 'Standard')) {
  33493. error('unknown encryption method');
  33494. }
  33495. this.dict = dict;
  33496. var algorithm = dict.get('V');
  33497. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  33498. error('unsupported encryption algorithm');
  33499. }
  33500. this.algorithm = algorithm;
  33501. var keyLength = dict.get('Length');
  33502. if (!keyLength) {
  33503. if (algorithm <= 3) {
  33504. keyLength = 40;
  33505. } else {
  33506. var cfDict = dict.get('CF');
  33507. var streamCryptoName = dict.get('StmF');
  33508. if (isDict(cfDict) && isName(streamCryptoName)) {
  33509. cfDict.suppressEncryption = true;
  33510. var handlerDict = cfDict.get(streamCryptoName.name);
  33511. keyLength = handlerDict && handlerDict.get('Length') || 128;
  33512. if (keyLength < 40) {
  33513. keyLength <<= 3;
  33514. }
  33515. }
  33516. }
  33517. }
  33518. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  33519. error('invalid key length');
  33520. }
  33521. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  33522. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  33523. var flags = dict.get('P');
  33524. var revision = dict.get('R');
  33525. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  33526. this.encryptMetadata = encryptMetadata;
  33527. var fileIdBytes = stringToBytes(fileId);
  33528. var passwordBytes;
  33529. if (password) {
  33530. if (revision === 6) {
  33531. try {
  33532. password = utf8StringToString(password);
  33533. } catch (ex) {
  33534. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  33535. }
  33536. }
  33537. passwordBytes = stringToBytes(password);
  33538. }
  33539. var encryptionKey;
  33540. if (algorithm !== 5) {
  33541. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  33542. } else {
  33543. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  33544. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  33545. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  33546. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  33547. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  33548. var ownerEncryption = stringToBytes(dict.get('OE'));
  33549. var userEncryption = stringToBytes(dict.get('UE'));
  33550. var perms = stringToBytes(dict.get('Perms'));
  33551. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  33552. }
  33553. if (!encryptionKey && !password) {
  33554. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  33555. } else if (!encryptionKey && password) {
  33556. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  33557. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  33558. }
  33559. if (!encryptionKey) {
  33560. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  33561. }
  33562. this.encryptionKey = encryptionKey;
  33563. if (algorithm >= 4) {
  33564. var cf = dict.get('CF');
  33565. if (isDict(cf)) {
  33566. cf.suppressEncryption = true;
  33567. }
  33568. this.cf = cf;
  33569. this.stmf = dict.get('StmF') || identityName;
  33570. this.strf = dict.get('StrF') || identityName;
  33571. this.eff = dict.get('EFF') || this.stmf;
  33572. }
  33573. }
  33574. function buildObjectKey(num, gen, encryptionKey, isAes) {
  33575. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  33576. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  33577. key[i] = encryptionKey[i];
  33578. }
  33579. key[i++] = num & 0xFF;
  33580. key[i++] = num >> 8 & 0xFF;
  33581. key[i++] = num >> 16 & 0xFF;
  33582. key[i++] = gen & 0xFF;
  33583. key[i++] = gen >> 8 & 0xFF;
  33584. if (isAes) {
  33585. key[i++] = 0x73;
  33586. key[i++] = 0x41;
  33587. key[i++] = 0x6C;
  33588. key[i++] = 0x54;
  33589. }
  33590. var hash = calculateMD5(key, 0, i);
  33591. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  33592. }
  33593. function buildCipherConstructor(cf, name, num, gen, key) {
  33594. assert(isName(name), 'Invalid crypt filter name.');
  33595. var cryptFilter = cf.get(name.name);
  33596. var cfm;
  33597. if (cryptFilter !== null && cryptFilter !== undefined) {
  33598. cfm = cryptFilter.get('CFM');
  33599. }
  33600. if (!cfm || cfm.name === 'None') {
  33601. return function cipherTransformFactoryBuildCipherConstructorNone() {
  33602. return new NullCipher();
  33603. };
  33604. }
  33605. if (cfm.name === 'V2') {
  33606. return function cipherTransformFactoryBuildCipherConstructorV2() {
  33607. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  33608. };
  33609. }
  33610. if (cfm.name === 'AESV2') {
  33611. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  33612. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  33613. };
  33614. }
  33615. if (cfm.name === 'AESV3') {
  33616. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  33617. return new AES256Cipher(key);
  33618. };
  33619. }
  33620. error('Unknown crypto method');
  33621. }
  33622. CipherTransformFactory.prototype = {
  33623. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  33624. if (this.algorithm === 4 || this.algorithm === 5) {
  33625. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  33626. }
  33627. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  33628. var cipherConstructor = function buildCipherCipherConstructor() {
  33629. return new ARCFourCipher(key);
  33630. };
  33631. return new CipherTransform(cipherConstructor, cipherConstructor);
  33632. }
  33633. };
  33634. return CipherTransformFactory;
  33635. }();
  33636. exports.AES128Cipher = AES128Cipher;
  33637. exports.AES256Cipher = AES256Cipher;
  33638. exports.ARCFourCipher = ARCFourCipher;
  33639. exports.CipherTransformFactory = CipherTransformFactory;
  33640. exports.PDF17 = PDF17;
  33641. exports.PDF20 = PDF20;
  33642. exports.calculateMD5 = calculateMD5;
  33643. exports.calculateSHA256 = calculateSHA256;
  33644. exports.calculateSHA384 = calculateSHA384;
  33645. exports.calculateSHA512 = calculateSHA512;
  33646. }));
  33647. (function (root, factory) {
  33648. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  33649. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  33650. var Util = sharedUtil.Util;
  33651. var bytesToString = sharedUtil.bytesToString;
  33652. var error = sharedUtil.error;
  33653. var Stream = coreStream.Stream;
  33654. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  33655. var StandardEncoding = coreEncodings.StandardEncoding;
  33656. var CFFParser = coreCFFParser.CFFParser;
  33657. var FontRendererFactory = function FontRendererFactoryClosure() {
  33658. function getLong(data, offset) {
  33659. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  33660. }
  33661. function getUshort(data, offset) {
  33662. return data[offset] << 8 | data[offset + 1];
  33663. }
  33664. function parseCmap(data, start, end) {
  33665. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  33666. var format = getUshort(data, start + offset);
  33667. var length, ranges, p, i;
  33668. if (format === 4) {
  33669. length = getUshort(data, start + offset + 2);
  33670. var segCount = getUshort(data, start + offset + 6) >> 1;
  33671. p = start + offset + 14;
  33672. ranges = [];
  33673. for (i = 0; i < segCount; i++, p += 2) {
  33674. ranges[i] = { end: getUshort(data, p) };
  33675. }
  33676. p += 2;
  33677. for (i = 0; i < segCount; i++, p += 2) {
  33678. ranges[i].start = getUshort(data, p);
  33679. }
  33680. for (i = 0; i < segCount; i++, p += 2) {
  33681. ranges[i].idDelta = getUshort(data, p);
  33682. }
  33683. for (i = 0; i < segCount; i++, p += 2) {
  33684. var idOffset = getUshort(data, p);
  33685. if (idOffset === 0) {
  33686. continue;
  33687. }
  33688. ranges[i].ids = [];
  33689. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  33690. ranges[i].ids[j] = getUshort(data, p + idOffset);
  33691. idOffset += 2;
  33692. }
  33693. }
  33694. return ranges;
  33695. } else if (format === 12) {
  33696. length = getLong(data, start + offset + 4);
  33697. var groups = getLong(data, start + offset + 12);
  33698. p = start + offset + 16;
  33699. ranges = [];
  33700. for (i = 0; i < groups; i++) {
  33701. ranges.push({
  33702. start: getLong(data, p),
  33703. end: getLong(data, p + 4),
  33704. idDelta: getLong(data, p + 8) - getLong(data, p)
  33705. });
  33706. p += 12;
  33707. }
  33708. return ranges;
  33709. }
  33710. error('not supported cmap: ' + format);
  33711. }
  33712. function parseCff(data, start, end, seacAnalysisEnabled) {
  33713. var properties = {};
  33714. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  33715. var cff = parser.parse();
  33716. return {
  33717. glyphs: cff.charStrings.objects,
  33718. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  33719. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  33720. };
  33721. }
  33722. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  33723. var itemSize, itemDecode;
  33724. if (isGlyphLocationsLong) {
  33725. itemSize = 4;
  33726. itemDecode = function fontItemDecodeLong(data, offset) {
  33727. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  33728. };
  33729. } else {
  33730. itemSize = 2;
  33731. itemDecode = function fontItemDecode(data, offset) {
  33732. return data[offset] << 9 | data[offset + 1] << 1;
  33733. };
  33734. }
  33735. var glyphs = [];
  33736. var startOffset = itemDecode(loca, 0);
  33737. for (var j = itemSize; j < loca.length; j += itemSize) {
  33738. var endOffset = itemDecode(loca, j);
  33739. glyphs.push(glyf.subarray(startOffset, endOffset));
  33740. startOffset = endOffset;
  33741. }
  33742. return glyphs;
  33743. }
  33744. function lookupCmap(ranges, unicode) {
  33745. var code = unicode.charCodeAt(0), gid = 0;
  33746. var l = 0, r = ranges.length - 1;
  33747. while (l < r) {
  33748. var c = l + r + 1 >> 1;
  33749. if (code < ranges[c].start) {
  33750. r = c - 1;
  33751. } else {
  33752. l = c;
  33753. }
  33754. }
  33755. if (ranges[l].start <= code && code <= ranges[l].end) {
  33756. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  33757. }
  33758. return {
  33759. charCode: code,
  33760. glyphId: gid
  33761. };
  33762. }
  33763. function compileGlyf(code, cmds, font) {
  33764. function moveTo(x, y) {
  33765. cmds.push({
  33766. cmd: 'moveTo',
  33767. args: [
  33768. x,
  33769. y
  33770. ]
  33771. });
  33772. }
  33773. function lineTo(x, y) {
  33774. cmds.push({
  33775. cmd: 'lineTo',
  33776. args: [
  33777. x,
  33778. y
  33779. ]
  33780. });
  33781. }
  33782. function quadraticCurveTo(xa, ya, x, y) {
  33783. cmds.push({
  33784. cmd: 'quadraticCurveTo',
  33785. args: [
  33786. xa,
  33787. ya,
  33788. x,
  33789. y
  33790. ]
  33791. });
  33792. }
  33793. var i = 0;
  33794. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  33795. var flags;
  33796. var x = 0, y = 0;
  33797. i += 10;
  33798. if (numberOfContours < 0) {
  33799. do {
  33800. flags = code[i] << 8 | code[i + 1];
  33801. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  33802. i += 4;
  33803. var arg1, arg2;
  33804. if (flags & 0x01) {
  33805. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  33806. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  33807. i += 4;
  33808. } else {
  33809. arg1 = code[i++];
  33810. arg2 = code[i++];
  33811. }
  33812. if (flags & 0x02) {
  33813. x = arg1;
  33814. y = arg2;
  33815. } else {
  33816. x = 0;
  33817. y = 0;
  33818. }
  33819. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  33820. if (flags & 0x08) {
  33821. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33822. i += 2;
  33823. } else if (flags & 0x40) {
  33824. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33825. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  33826. i += 4;
  33827. } else if (flags & 0x80) {
  33828. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33829. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  33830. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  33831. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  33832. i += 8;
  33833. }
  33834. var subglyph = font.glyphs[glyphIndex];
  33835. if (subglyph) {
  33836. cmds.push({ cmd: 'save' });
  33837. cmds.push({
  33838. cmd: 'transform',
  33839. args: [
  33840. scaleX,
  33841. scale01,
  33842. scale10,
  33843. scaleY,
  33844. x,
  33845. y
  33846. ]
  33847. });
  33848. compileGlyf(subglyph, cmds, font);
  33849. cmds.push({ cmd: 'restore' });
  33850. }
  33851. } while (flags & 0x20);
  33852. } else {
  33853. var endPtsOfContours = [];
  33854. var j, jj;
  33855. for (j = 0; j < numberOfContours; j++) {
  33856. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  33857. i += 2;
  33858. }
  33859. var instructionLength = code[i] << 8 | code[i + 1];
  33860. i += 2 + instructionLength;
  33861. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  33862. var points = [];
  33863. while (points.length < numberOfPoints) {
  33864. flags = code[i++];
  33865. var repeat = 1;
  33866. if (flags & 0x08) {
  33867. repeat += code[i++];
  33868. }
  33869. while (repeat-- > 0) {
  33870. points.push({ flags: flags });
  33871. }
  33872. }
  33873. for (j = 0; j < numberOfPoints; j++) {
  33874. switch (points[j].flags & 0x12) {
  33875. case 0x00:
  33876. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  33877. i += 2;
  33878. break;
  33879. case 0x02:
  33880. x -= code[i++];
  33881. break;
  33882. case 0x12:
  33883. x += code[i++];
  33884. break;
  33885. }
  33886. points[j].x = x;
  33887. }
  33888. for (j = 0; j < numberOfPoints; j++) {
  33889. switch (points[j].flags & 0x24) {
  33890. case 0x00:
  33891. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  33892. i += 2;
  33893. break;
  33894. case 0x04:
  33895. y -= code[i++];
  33896. break;
  33897. case 0x24:
  33898. y += code[i++];
  33899. break;
  33900. }
  33901. points[j].y = y;
  33902. }
  33903. var startPoint = 0;
  33904. for (i = 0; i < numberOfContours; i++) {
  33905. var endPoint = endPtsOfContours[i];
  33906. var contour = points.slice(startPoint, endPoint + 1);
  33907. if (contour[0].flags & 1) {
  33908. contour.push(contour[0]);
  33909. } else if (contour[contour.length - 1].flags & 1) {
  33910. contour.unshift(contour[contour.length - 1]);
  33911. } else {
  33912. var p = {
  33913. flags: 1,
  33914. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  33915. y: (contour[0].y + contour[contour.length - 1].y) / 2
  33916. };
  33917. contour.unshift(p);
  33918. contour.push(p);
  33919. }
  33920. moveTo(contour[0].x, contour[0].y);
  33921. for (j = 1, jj = contour.length; j < jj; j++) {
  33922. if (contour[j].flags & 1) {
  33923. lineTo(contour[j].x, contour[j].y);
  33924. } else if (contour[j + 1].flags & 1) {
  33925. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  33926. j++;
  33927. } else {
  33928. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  33929. }
  33930. }
  33931. startPoint = endPoint + 1;
  33932. }
  33933. }
  33934. }
  33935. function compileCharString(code, cmds, font) {
  33936. var stack = [];
  33937. var x = 0, y = 0;
  33938. var stems = 0;
  33939. function moveTo(x, y) {
  33940. cmds.push({
  33941. cmd: 'moveTo',
  33942. args: [
  33943. x,
  33944. y
  33945. ]
  33946. });
  33947. }
  33948. function lineTo(x, y) {
  33949. cmds.push({
  33950. cmd: 'lineTo',
  33951. args: [
  33952. x,
  33953. y
  33954. ]
  33955. });
  33956. }
  33957. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  33958. cmds.push({
  33959. cmd: 'bezierCurveTo',
  33960. args: [
  33961. x1,
  33962. y1,
  33963. x2,
  33964. y2,
  33965. x,
  33966. y
  33967. ]
  33968. });
  33969. }
  33970. function parse(code) {
  33971. var i = 0;
  33972. while (i < code.length) {
  33973. var stackClean = false;
  33974. var v = code[i++];
  33975. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  33976. switch (v) {
  33977. case 1:
  33978. stems += stack.length >> 1;
  33979. stackClean = true;
  33980. break;
  33981. case 3:
  33982. stems += stack.length >> 1;
  33983. stackClean = true;
  33984. break;
  33985. case 4:
  33986. y += stack.pop();
  33987. moveTo(x, y);
  33988. stackClean = true;
  33989. break;
  33990. case 5:
  33991. while (stack.length > 0) {
  33992. x += stack.shift();
  33993. y += stack.shift();
  33994. lineTo(x, y);
  33995. }
  33996. break;
  33997. case 6:
  33998. while (stack.length > 0) {
  33999. x += stack.shift();
  34000. lineTo(x, y);
  34001. if (stack.length === 0) {
  34002. break;
  34003. }
  34004. y += stack.shift();
  34005. lineTo(x, y);
  34006. }
  34007. break;
  34008. case 7:
  34009. while (stack.length > 0) {
  34010. y += stack.shift();
  34011. lineTo(x, y);
  34012. if (stack.length === 0) {
  34013. break;
  34014. }
  34015. x += stack.shift();
  34016. lineTo(x, y);
  34017. }
  34018. break;
  34019. case 8:
  34020. while (stack.length > 0) {
  34021. xa = x + stack.shift();
  34022. ya = y + stack.shift();
  34023. xb = xa + stack.shift();
  34024. yb = ya + stack.shift();
  34025. x = xb + stack.shift();
  34026. y = yb + stack.shift();
  34027. bezierCurveTo(xa, ya, xb, yb, x, y);
  34028. }
  34029. break;
  34030. case 10:
  34031. n = stack.pop() + font.subrsBias;
  34032. subrCode = font.subrs[n];
  34033. if (subrCode) {
  34034. parse(subrCode);
  34035. }
  34036. break;
  34037. case 11:
  34038. return;
  34039. case 12:
  34040. v = code[i++];
  34041. switch (v) {
  34042. case 34:
  34043. xa = x + stack.shift();
  34044. xb = xa + stack.shift();
  34045. y1 = y + stack.shift();
  34046. x = xb + stack.shift();
  34047. bezierCurveTo(xa, y, xb, y1, x, y1);
  34048. xa = x + stack.shift();
  34049. xb = xa + stack.shift();
  34050. x = xb + stack.shift();
  34051. bezierCurveTo(xa, y1, xb, y, x, y);
  34052. break;
  34053. case 35:
  34054. xa = x + stack.shift();
  34055. ya = y + stack.shift();
  34056. xb = xa + stack.shift();
  34057. yb = ya + stack.shift();
  34058. x = xb + stack.shift();
  34059. y = yb + stack.shift();
  34060. bezierCurveTo(xa, ya, xb, yb, x, y);
  34061. xa = x + stack.shift();
  34062. ya = y + stack.shift();
  34063. xb = xa + stack.shift();
  34064. yb = ya + stack.shift();
  34065. x = xb + stack.shift();
  34066. y = yb + stack.shift();
  34067. bezierCurveTo(xa, ya, xb, yb, x, y);
  34068. stack.pop();
  34069. break;
  34070. case 36:
  34071. xa = x + stack.shift();
  34072. y1 = y + stack.shift();
  34073. xb = xa + stack.shift();
  34074. y2 = y1 + stack.shift();
  34075. x = xb + stack.shift();
  34076. bezierCurveTo(xa, y1, xb, y2, x, y2);
  34077. xa = x + stack.shift();
  34078. xb = xa + stack.shift();
  34079. y3 = y2 + stack.shift();
  34080. x = xb + stack.shift();
  34081. bezierCurveTo(xa, y2, xb, y3, x, y);
  34082. break;
  34083. case 37:
  34084. var x0 = x, y0 = y;
  34085. xa = x + stack.shift();
  34086. ya = y + stack.shift();
  34087. xb = xa + stack.shift();
  34088. yb = ya + stack.shift();
  34089. x = xb + stack.shift();
  34090. y = yb + stack.shift();
  34091. bezierCurveTo(xa, ya, xb, yb, x, y);
  34092. xa = x + stack.shift();
  34093. ya = y + stack.shift();
  34094. xb = xa + stack.shift();
  34095. yb = ya + stack.shift();
  34096. x = xb;
  34097. y = yb;
  34098. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  34099. x += stack.shift();
  34100. } else {
  34101. y += stack.shift();
  34102. }
  34103. bezierCurveTo(xa, ya, xb, yb, x, y);
  34104. break;
  34105. default:
  34106. error('unknown operator: 12 ' + v);
  34107. }
  34108. break;
  34109. case 14:
  34110. if (stack.length >= 4) {
  34111. var achar = stack.pop();
  34112. var bchar = stack.pop();
  34113. y = stack.pop();
  34114. x = stack.pop();
  34115. cmds.push({ cmd: 'save' });
  34116. cmds.push({
  34117. cmd: 'translate',
  34118. args: [
  34119. x,
  34120. y
  34121. ]
  34122. });
  34123. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  34124. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  34125. cmds.push({ cmd: 'restore' });
  34126. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  34127. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  34128. }
  34129. return;
  34130. case 18:
  34131. stems += stack.length >> 1;
  34132. stackClean = true;
  34133. break;
  34134. case 19:
  34135. stems += stack.length >> 1;
  34136. i += stems + 7 >> 3;
  34137. stackClean = true;
  34138. break;
  34139. case 20:
  34140. stems += stack.length >> 1;
  34141. i += stems + 7 >> 3;
  34142. stackClean = true;
  34143. break;
  34144. case 21:
  34145. y += stack.pop();
  34146. x += stack.pop();
  34147. moveTo(x, y);
  34148. stackClean = true;
  34149. break;
  34150. case 22:
  34151. x += stack.pop();
  34152. moveTo(x, y);
  34153. stackClean = true;
  34154. break;
  34155. case 23:
  34156. stems += stack.length >> 1;
  34157. stackClean = true;
  34158. break;
  34159. case 24:
  34160. while (stack.length > 2) {
  34161. xa = x + stack.shift();
  34162. ya = y + stack.shift();
  34163. xb = xa + stack.shift();
  34164. yb = ya + stack.shift();
  34165. x = xb + stack.shift();
  34166. y = yb + stack.shift();
  34167. bezierCurveTo(xa, ya, xb, yb, x, y);
  34168. }
  34169. x += stack.shift();
  34170. y += stack.shift();
  34171. lineTo(x, y);
  34172. break;
  34173. case 25:
  34174. while (stack.length > 6) {
  34175. x += stack.shift();
  34176. y += stack.shift();
  34177. lineTo(x, y);
  34178. }
  34179. xa = x + stack.shift();
  34180. ya = y + stack.shift();
  34181. xb = xa + stack.shift();
  34182. yb = ya + stack.shift();
  34183. x = xb + stack.shift();
  34184. y = yb + stack.shift();
  34185. bezierCurveTo(xa, ya, xb, yb, x, y);
  34186. break;
  34187. case 26:
  34188. if (stack.length % 2) {
  34189. x += stack.shift();
  34190. }
  34191. while (stack.length > 0) {
  34192. xa = x;
  34193. ya = y + stack.shift();
  34194. xb = xa + stack.shift();
  34195. yb = ya + stack.shift();
  34196. x = xb;
  34197. y = yb + stack.shift();
  34198. bezierCurveTo(xa, ya, xb, yb, x, y);
  34199. }
  34200. break;
  34201. case 27:
  34202. if (stack.length % 2) {
  34203. y += stack.shift();
  34204. }
  34205. while (stack.length > 0) {
  34206. xa = x + stack.shift();
  34207. ya = y;
  34208. xb = xa + stack.shift();
  34209. yb = ya + stack.shift();
  34210. x = xb + stack.shift();
  34211. y = yb;
  34212. bezierCurveTo(xa, ya, xb, yb, x, y);
  34213. }
  34214. break;
  34215. case 28:
  34216. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  34217. i += 2;
  34218. break;
  34219. case 29:
  34220. n = stack.pop() + font.gsubrsBias;
  34221. subrCode = font.gsubrs[n];
  34222. if (subrCode) {
  34223. parse(subrCode);
  34224. }
  34225. break;
  34226. case 30:
  34227. while (stack.length > 0) {
  34228. xa = x;
  34229. ya = y + stack.shift();
  34230. xb = xa + stack.shift();
  34231. yb = ya + stack.shift();
  34232. x = xb + stack.shift();
  34233. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34234. bezierCurveTo(xa, ya, xb, yb, x, y);
  34235. if (stack.length === 0) {
  34236. break;
  34237. }
  34238. xa = x + stack.shift();
  34239. ya = y;
  34240. xb = xa + stack.shift();
  34241. yb = ya + stack.shift();
  34242. y = yb + stack.shift();
  34243. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34244. bezierCurveTo(xa, ya, xb, yb, x, y);
  34245. }
  34246. break;
  34247. case 31:
  34248. while (stack.length > 0) {
  34249. xa = x + stack.shift();
  34250. ya = y;
  34251. xb = xa + stack.shift();
  34252. yb = ya + stack.shift();
  34253. y = yb + stack.shift();
  34254. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34255. bezierCurveTo(xa, ya, xb, yb, x, y);
  34256. if (stack.length === 0) {
  34257. break;
  34258. }
  34259. xa = x;
  34260. ya = y + stack.shift();
  34261. xb = xa + stack.shift();
  34262. yb = ya + stack.shift();
  34263. x = xb + stack.shift();
  34264. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34265. bezierCurveTo(xa, ya, xb, yb, x, y);
  34266. }
  34267. break;
  34268. default:
  34269. if (v < 32) {
  34270. error('unknown operator: ' + v);
  34271. }
  34272. if (v < 247) {
  34273. stack.push(v - 139);
  34274. } else if (v < 251) {
  34275. stack.push((v - 247) * 256 + code[i++] + 108);
  34276. } else if (v < 255) {
  34277. stack.push(-(v - 251) * 256 - code[i++] - 108);
  34278. } else {
  34279. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  34280. i += 4;
  34281. }
  34282. break;
  34283. }
  34284. if (stackClean) {
  34285. stack.length = 0;
  34286. }
  34287. }
  34288. }
  34289. parse(code);
  34290. }
  34291. var noop = '';
  34292. function CompiledFont(fontMatrix) {
  34293. this.compiledGlyphs = Object.create(null);
  34294. this.compiledCharCodeToGlyphId = Object.create(null);
  34295. this.fontMatrix = fontMatrix;
  34296. }
  34297. CompiledFont.prototype = {
  34298. getPathJs: function (unicode) {
  34299. var cmap = lookupCmap(this.cmap, unicode);
  34300. var fn = this.compiledGlyphs[cmap.glyphId];
  34301. if (!fn) {
  34302. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  34303. this.compiledGlyphs[cmap.glyphId] = fn;
  34304. }
  34305. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  34306. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  34307. }
  34308. return fn;
  34309. },
  34310. compileGlyph: function (code) {
  34311. if (!code || code.length === 0 || code[0] === 14) {
  34312. return noop;
  34313. }
  34314. var cmds = [];
  34315. cmds.push({ cmd: 'save' });
  34316. cmds.push({
  34317. cmd: 'transform',
  34318. args: this.fontMatrix.slice()
  34319. });
  34320. cmds.push({
  34321. cmd: 'scale',
  34322. args: [
  34323. 'size',
  34324. '-size'
  34325. ]
  34326. });
  34327. this.compileGlyphImpl(code, cmds);
  34328. cmds.push({ cmd: 'restore' });
  34329. return cmds;
  34330. },
  34331. compileGlyphImpl: function () {
  34332. error('Children classes should implement this.');
  34333. },
  34334. hasBuiltPath: function (unicode) {
  34335. var cmap = lookupCmap(this.cmap, unicode);
  34336. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  34337. }
  34338. };
  34339. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  34340. fontMatrix = fontMatrix || [
  34341. 0.000488,
  34342. 0,
  34343. 0,
  34344. 0.000488,
  34345. 0,
  34346. 0
  34347. ];
  34348. CompiledFont.call(this, fontMatrix);
  34349. this.glyphs = glyphs;
  34350. this.cmap = cmap;
  34351. }
  34352. Util.inherit(TrueTypeCompiled, CompiledFont, {
  34353. compileGlyphImpl: function (code, cmds) {
  34354. compileGlyf(code, cmds, this);
  34355. }
  34356. });
  34357. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  34358. fontMatrix = fontMatrix || [
  34359. 0.001,
  34360. 0,
  34361. 0,
  34362. 0.001,
  34363. 0,
  34364. 0
  34365. ];
  34366. CompiledFont.call(this, fontMatrix);
  34367. this.glyphs = cffInfo.glyphs;
  34368. this.gsubrs = cffInfo.gsubrs || [];
  34369. this.subrs = cffInfo.subrs || [];
  34370. this.cmap = cmap;
  34371. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  34372. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  34373. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  34374. }
  34375. Util.inherit(Type2Compiled, CompiledFont, {
  34376. compileGlyphImpl: function (code, cmds) {
  34377. compileCharString(code, cmds, this);
  34378. }
  34379. });
  34380. return {
  34381. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  34382. var data = new Uint8Array(font.data);
  34383. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  34384. var numTables = getUshort(data, 4);
  34385. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  34386. var tag = bytesToString(data.subarray(p, p + 4));
  34387. var offset = getLong(data, p + 8);
  34388. var length = getLong(data, p + 12);
  34389. switch (tag) {
  34390. case 'cmap':
  34391. cmap = parseCmap(data, offset, offset + length);
  34392. break;
  34393. case 'glyf':
  34394. glyf = data.subarray(offset, offset + length);
  34395. break;
  34396. case 'loca':
  34397. loca = data.subarray(offset, offset + length);
  34398. break;
  34399. case 'head':
  34400. unitsPerEm = getUshort(data, offset + 18);
  34401. indexToLocFormat = getUshort(data, offset + 50);
  34402. break;
  34403. case 'CFF ':
  34404. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  34405. break;
  34406. }
  34407. }
  34408. if (glyf) {
  34409. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  34410. 1 / unitsPerEm,
  34411. 0,
  34412. 0,
  34413. 1 / unitsPerEm,
  34414. 0,
  34415. 0
  34416. ];
  34417. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  34418. } else {
  34419. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  34420. }
  34421. }
  34422. };
  34423. }();
  34424. exports.FontRendererFactory = FontRendererFactory;
  34425. }));
  34426. (function (root, factory) {
  34427. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  34428. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  34429. var MissingDataException = sharedUtil.MissingDataException;
  34430. var StreamType = sharedUtil.StreamType;
  34431. var assert = sharedUtil.assert;
  34432. var error = sharedUtil.error;
  34433. var info = sharedUtil.info;
  34434. var isArray = sharedUtil.isArray;
  34435. var isInt = sharedUtil.isInt;
  34436. var isNum = sharedUtil.isNum;
  34437. var isString = sharedUtil.isString;
  34438. var warn = sharedUtil.warn;
  34439. var Cmd = corePrimitives.Cmd;
  34440. var Dict = corePrimitives.Dict;
  34441. var Name = corePrimitives.Name;
  34442. var Ref = corePrimitives.Ref;
  34443. var isCmd = corePrimitives.isCmd;
  34444. var isDict = corePrimitives.isDict;
  34445. var isName = corePrimitives.isName;
  34446. var Ascii85Stream = coreStream.Ascii85Stream;
  34447. var AsciiHexStream = coreStream.AsciiHexStream;
  34448. var CCITTFaxStream = coreStream.CCITTFaxStream;
  34449. var FlateStream = coreStream.FlateStream;
  34450. var Jbig2Stream = coreStream.Jbig2Stream;
  34451. var JpegStream = coreStream.JpegStream;
  34452. var JpxStream = coreStream.JpxStream;
  34453. var LZWStream = coreStream.LZWStream;
  34454. var NullStream = coreStream.NullStream;
  34455. var PredictorStream = coreStream.PredictorStream;
  34456. var RunLengthStream = coreStream.RunLengthStream;
  34457. var EOF = {};
  34458. function isEOF(v) {
  34459. return v === EOF;
  34460. }
  34461. var MAX_LENGTH_TO_CACHE = 1000;
  34462. var Parser = function ParserClosure() {
  34463. function Parser(lexer, allowStreams, xref, recoveryMode) {
  34464. this.lexer = lexer;
  34465. this.allowStreams = allowStreams;
  34466. this.xref = xref;
  34467. this.recoveryMode = recoveryMode || false;
  34468. this.imageCache = Object.create(null);
  34469. this.refill();
  34470. }
  34471. Parser.prototype = {
  34472. refill: function Parser_refill() {
  34473. this.buf1 = this.lexer.getObj();
  34474. this.buf2 = this.lexer.getObj();
  34475. },
  34476. shift: function Parser_shift() {
  34477. if (isCmd(this.buf2, 'ID')) {
  34478. this.buf1 = this.buf2;
  34479. this.buf2 = null;
  34480. } else {
  34481. this.buf1 = this.buf2;
  34482. this.buf2 = this.lexer.getObj();
  34483. }
  34484. },
  34485. tryShift: function Parser_tryShift() {
  34486. try {
  34487. this.shift();
  34488. return true;
  34489. } catch (e) {
  34490. if (e instanceof MissingDataException) {
  34491. throw e;
  34492. }
  34493. return false;
  34494. }
  34495. },
  34496. getObj: function Parser_getObj(cipherTransform) {
  34497. var buf1 = this.buf1;
  34498. this.shift();
  34499. if (buf1 instanceof Cmd) {
  34500. switch (buf1.cmd) {
  34501. case 'BI':
  34502. return this.makeInlineImage(cipherTransform);
  34503. case '[':
  34504. var array = [];
  34505. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  34506. array.push(this.getObj(cipherTransform));
  34507. }
  34508. if (isEOF(this.buf1)) {
  34509. if (!this.recoveryMode) {
  34510. error('End of file inside array');
  34511. }
  34512. return array;
  34513. }
  34514. this.shift();
  34515. return array;
  34516. case '<<':
  34517. var dict = new Dict(this.xref);
  34518. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  34519. if (!isName(this.buf1)) {
  34520. info('Malformed dictionary: key must be a name object');
  34521. this.shift();
  34522. continue;
  34523. }
  34524. var key = this.buf1.name;
  34525. this.shift();
  34526. if (isEOF(this.buf1)) {
  34527. break;
  34528. }
  34529. dict.set(key, this.getObj(cipherTransform));
  34530. }
  34531. if (isEOF(this.buf1)) {
  34532. if (!this.recoveryMode) {
  34533. error('End of file inside dictionary');
  34534. }
  34535. return dict;
  34536. }
  34537. if (isCmd(this.buf2, 'stream')) {
  34538. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  34539. }
  34540. this.shift();
  34541. return dict;
  34542. default:
  34543. return buf1;
  34544. }
  34545. }
  34546. if (isInt(buf1)) {
  34547. var num = buf1;
  34548. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  34549. var ref = new Ref(num, this.buf1);
  34550. this.shift();
  34551. this.shift();
  34552. return ref;
  34553. }
  34554. return num;
  34555. }
  34556. if (isString(buf1)) {
  34557. var str = buf1;
  34558. if (cipherTransform) {
  34559. str = cipherTransform.decryptString(str);
  34560. }
  34561. return str;
  34562. }
  34563. return buf1;
  34564. },
  34565. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  34566. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  34567. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  34568. while ((ch = stream.getByte()) !== -1) {
  34569. if (state === 0) {
  34570. state = ch === E ? 1 : 0;
  34571. } else if (state === 1) {
  34572. state = ch === I ? 2 : 0;
  34573. } else {
  34574. assert(state === 2);
  34575. if (ch === SPACE || ch === LF || ch === CR) {
  34576. n = 5;
  34577. followingBytes = stream.peekBytes(n);
  34578. for (i = 0; i < n; i++) {
  34579. ch = followingBytes[i];
  34580. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  34581. state = 0;
  34582. break;
  34583. }
  34584. }
  34585. if (state === 2) {
  34586. break;
  34587. }
  34588. } else
  34589. {
  34590. state = 0;
  34591. }
  34592. }
  34593. }
  34594. return stream.pos - 4 - startPos;
  34595. },
  34596. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  34597. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  34598. while ((b = stream.getByte()) !== -1) {
  34599. if (b !== 0xFF) {
  34600. continue;
  34601. }
  34602. switch (stream.getByte()) {
  34603. case 0x00:
  34604. break;
  34605. case 0xFF:
  34606. stream.skip(-1);
  34607. break;
  34608. case 0xD9:
  34609. foundEOI = true;
  34610. break;
  34611. case 0xC0:
  34612. case 0xC1:
  34613. case 0xC2:
  34614. case 0xC3:
  34615. case 0xC5:
  34616. case 0xC6:
  34617. case 0xC7:
  34618. case 0xC9:
  34619. case 0xCA:
  34620. case 0xCB:
  34621. case 0xCD:
  34622. case 0xCE:
  34623. case 0xCF:
  34624. case 0xC4:
  34625. case 0xCC:
  34626. case 0xDA:
  34627. case 0xDB:
  34628. case 0xDC:
  34629. case 0xDD:
  34630. case 0xDE:
  34631. case 0xDF:
  34632. case 0xE0:
  34633. case 0xE1:
  34634. case 0xE2:
  34635. case 0xE3:
  34636. case 0xE4:
  34637. case 0xE5:
  34638. case 0xE6:
  34639. case 0xE7:
  34640. case 0xE8:
  34641. case 0xE9:
  34642. case 0xEA:
  34643. case 0xEB:
  34644. case 0xEC:
  34645. case 0xED:
  34646. case 0xEE:
  34647. case 0xEF:
  34648. case 0xFE:
  34649. markerLength = stream.getUint16();
  34650. if (markerLength > 2) {
  34651. stream.skip(markerLength - 2);
  34652. } else
  34653. {
  34654. stream.skip(-2);
  34655. }
  34656. break;
  34657. }
  34658. if (foundEOI) {
  34659. break;
  34660. }
  34661. }
  34662. length = stream.pos - startPos;
  34663. if (b === -1) {
  34664. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  34665. stream.skip(-length);
  34666. return this.findDefaultInlineStreamEnd(stream);
  34667. }
  34668. this.inlineStreamSkipEI(stream);
  34669. return length;
  34670. },
  34671. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  34672. var TILDE = 0x7E, GT = 0x3E;
  34673. var startPos = stream.pos, ch, length;
  34674. while ((ch = stream.getByte()) !== -1) {
  34675. if (ch === TILDE && stream.peekByte() === GT) {
  34676. stream.skip();
  34677. break;
  34678. }
  34679. }
  34680. length = stream.pos - startPos;
  34681. if (ch === -1) {
  34682. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  34683. stream.skip(-length);
  34684. return this.findDefaultInlineStreamEnd(stream);
  34685. }
  34686. this.inlineStreamSkipEI(stream);
  34687. return length;
  34688. },
  34689. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  34690. var GT = 0x3E;
  34691. var startPos = stream.pos, ch, length;
  34692. while ((ch = stream.getByte()) !== -1) {
  34693. if (ch === GT) {
  34694. break;
  34695. }
  34696. }
  34697. length = stream.pos - startPos;
  34698. if (ch === -1) {
  34699. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  34700. stream.skip(-length);
  34701. return this.findDefaultInlineStreamEnd(stream);
  34702. }
  34703. this.inlineStreamSkipEI(stream);
  34704. return length;
  34705. },
  34706. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  34707. var E = 0x45, I = 0x49;
  34708. var state = 0, ch;
  34709. while ((ch = stream.getByte()) !== -1) {
  34710. if (state === 0) {
  34711. state = ch === E ? 1 : 0;
  34712. } else if (state === 1) {
  34713. state = ch === I ? 2 : 0;
  34714. } else if (state === 2) {
  34715. break;
  34716. }
  34717. }
  34718. },
  34719. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  34720. var lexer = this.lexer;
  34721. var stream = lexer.stream;
  34722. var dict = new Dict(this.xref);
  34723. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  34724. if (!isName(this.buf1)) {
  34725. error('Dictionary key must be a name object');
  34726. }
  34727. var key = this.buf1.name;
  34728. this.shift();
  34729. if (isEOF(this.buf1)) {
  34730. break;
  34731. }
  34732. dict.set(key, this.getObj(cipherTransform));
  34733. }
  34734. var filter = dict.get('Filter', 'F'), filterName;
  34735. if (isName(filter)) {
  34736. filterName = filter.name;
  34737. } else if (isArray(filter)) {
  34738. var filterZero = this.xref.fetchIfRef(filter[0]);
  34739. if (isName(filterZero)) {
  34740. filterName = filterZero.name;
  34741. }
  34742. }
  34743. var startPos = stream.pos, length, i, ii;
  34744. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  34745. length = this.findDCTDecodeInlineStreamEnd(stream);
  34746. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  34747. length = this.findASCII85DecodeInlineStreamEnd(stream);
  34748. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  34749. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  34750. } else {
  34751. length = this.findDefaultInlineStreamEnd(stream);
  34752. }
  34753. var imageStream = stream.makeSubStream(startPos, length, dict);
  34754. var adler32;
  34755. if (length < MAX_LENGTH_TO_CACHE) {
  34756. var imageBytes = imageStream.getBytes();
  34757. imageStream.reset();
  34758. var a = 1;
  34759. var b = 0;
  34760. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  34761. a += imageBytes[i] & 0xff;
  34762. b += a;
  34763. }
  34764. adler32 = b % 65521 << 16 | a % 65521;
  34765. if (this.imageCache.adler32 === adler32) {
  34766. this.buf2 = Cmd.get('EI');
  34767. this.shift();
  34768. this.imageCache[adler32].reset();
  34769. return this.imageCache[adler32];
  34770. }
  34771. }
  34772. if (cipherTransform) {
  34773. imageStream = cipherTransform.createStream(imageStream, length);
  34774. }
  34775. imageStream = this.filter(imageStream, dict, length);
  34776. imageStream.dict = dict;
  34777. if (adler32 !== undefined) {
  34778. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  34779. this.imageCache[adler32] = imageStream;
  34780. }
  34781. this.buf2 = Cmd.get('EI');
  34782. this.shift();
  34783. return imageStream;
  34784. },
  34785. makeStream: function Parser_makeStream(dict, cipherTransform) {
  34786. var lexer = this.lexer;
  34787. var stream = lexer.stream;
  34788. lexer.skipToNextLine();
  34789. var pos = stream.pos - 1;
  34790. var length = dict.get('Length');
  34791. if (!isInt(length)) {
  34792. info('Bad ' + length + ' attribute in stream');
  34793. length = 0;
  34794. }
  34795. stream.pos = pos + length;
  34796. lexer.nextChar();
  34797. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  34798. this.shift();
  34799. } else
  34800. {
  34801. stream.pos = pos;
  34802. var SCAN_BLOCK_SIZE = 2048;
  34803. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  34804. var ENDSTREAM_SIGNATURE = [
  34805. 0x65,
  34806. 0x6E,
  34807. 0x64,
  34808. 0x73,
  34809. 0x74,
  34810. 0x72,
  34811. 0x65,
  34812. 0x61,
  34813. 0x6D
  34814. ];
  34815. var skipped = 0, found = false, i, j;
  34816. while (stream.pos < stream.end) {
  34817. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  34818. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  34819. if (scanLength <= 0) {
  34820. break;
  34821. }
  34822. found = false;
  34823. i = 0;
  34824. while (i < scanLength) {
  34825. j = 0;
  34826. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  34827. j++;
  34828. }
  34829. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  34830. found = true;
  34831. break;
  34832. }
  34833. i++;
  34834. }
  34835. if (found) {
  34836. skipped += i;
  34837. stream.pos += i;
  34838. break;
  34839. }
  34840. skipped += scanLength;
  34841. stream.pos += scanLength;
  34842. }
  34843. if (!found) {
  34844. error('Missing endstream');
  34845. }
  34846. length = skipped;
  34847. lexer.nextChar();
  34848. this.shift();
  34849. this.shift();
  34850. }
  34851. this.shift();
  34852. stream = stream.makeSubStream(pos, length, dict);
  34853. if (cipherTransform) {
  34854. stream = cipherTransform.createStream(stream, length);
  34855. }
  34856. stream = this.filter(stream, dict, length);
  34857. stream.dict = dict;
  34858. return stream;
  34859. },
  34860. filter: function Parser_filter(stream, dict, length) {
  34861. var filter = dict.get('Filter', 'F');
  34862. var params = dict.get('DecodeParms', 'DP');
  34863. if (isName(filter)) {
  34864. if (isArray(params)) {
  34865. params = this.xref.fetchIfRef(params[0]);
  34866. }
  34867. return this.makeFilter(stream, filter.name, length, params);
  34868. }
  34869. var maybeLength = length;
  34870. if (isArray(filter)) {
  34871. var filterArray = filter;
  34872. var paramsArray = params;
  34873. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  34874. filter = this.xref.fetchIfRef(filterArray[i]);
  34875. if (!isName(filter)) {
  34876. error('Bad filter name: ' + filter);
  34877. }
  34878. params = null;
  34879. if (isArray(paramsArray) && i in paramsArray) {
  34880. params = this.xref.fetchIfRef(paramsArray[i]);
  34881. }
  34882. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  34883. maybeLength = null;
  34884. }
  34885. }
  34886. return stream;
  34887. },
  34888. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  34889. if (maybeLength === 0) {
  34890. warn('Empty "' + name + '" stream.');
  34891. return new NullStream(stream);
  34892. }
  34893. try {
  34894. var xrefStreamStats = this.xref.stats.streamTypes;
  34895. if (name === 'FlateDecode' || name === 'Fl') {
  34896. xrefStreamStats[StreamType.FLATE] = true;
  34897. if (params) {
  34898. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  34899. }
  34900. return new FlateStream(stream, maybeLength);
  34901. }
  34902. if (name === 'LZWDecode' || name === 'LZW') {
  34903. xrefStreamStats[StreamType.LZW] = true;
  34904. var earlyChange = 1;
  34905. if (params) {
  34906. if (params.has('EarlyChange')) {
  34907. earlyChange = params.get('EarlyChange');
  34908. }
  34909. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  34910. }
  34911. return new LZWStream(stream, maybeLength, earlyChange);
  34912. }
  34913. if (name === 'DCTDecode' || name === 'DCT') {
  34914. xrefStreamStats[StreamType.DCT] = true;
  34915. return new JpegStream(stream, maybeLength, stream.dict, params);
  34916. }
  34917. if (name === 'JPXDecode' || name === 'JPX') {
  34918. xrefStreamStats[StreamType.JPX] = true;
  34919. return new JpxStream(stream, maybeLength, stream.dict, params);
  34920. }
  34921. if (name === 'ASCII85Decode' || name === 'A85') {
  34922. xrefStreamStats[StreamType.A85] = true;
  34923. return new Ascii85Stream(stream, maybeLength);
  34924. }
  34925. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  34926. xrefStreamStats[StreamType.AHX] = true;
  34927. return new AsciiHexStream(stream, maybeLength);
  34928. }
  34929. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  34930. xrefStreamStats[StreamType.CCF] = true;
  34931. return new CCITTFaxStream(stream, maybeLength, params);
  34932. }
  34933. if (name === 'RunLengthDecode' || name === 'RL') {
  34934. xrefStreamStats[StreamType.RL] = true;
  34935. return new RunLengthStream(stream, maybeLength);
  34936. }
  34937. if (name === 'JBIG2Decode') {
  34938. xrefStreamStats[StreamType.JBIG] = true;
  34939. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  34940. }
  34941. warn('filter "' + name + '" not supported yet');
  34942. return stream;
  34943. } catch (ex) {
  34944. if (ex instanceof MissingDataException) {
  34945. throw ex;
  34946. }
  34947. warn('Invalid stream: \"' + ex + '\"');
  34948. return new NullStream(stream);
  34949. }
  34950. }
  34951. };
  34952. return Parser;
  34953. }();
  34954. var Lexer = function LexerClosure() {
  34955. function Lexer(stream, knownCommands) {
  34956. this.stream = stream;
  34957. this.nextChar();
  34958. this.strBuf = [];
  34959. this.knownCommands = knownCommands;
  34960. }
  34961. var specialChars = [
  34962. 1,
  34963. 0,
  34964. 0,
  34965. 0,
  34966. 0,
  34967. 0,
  34968. 0,
  34969. 0,
  34970. 0,
  34971. 1,
  34972. 1,
  34973. 0,
  34974. 1,
  34975. 1,
  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. 1,
  34995. 0,
  34996. 0,
  34997. 0,
  34998. 0,
  34999. 2,
  35000. 0,
  35001. 0,
  35002. 2,
  35003. 2,
  35004. 0,
  35005. 0,
  35006. 0,
  35007. 0,
  35008. 0,
  35009. 2,
  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. 2,
  35023. 0,
  35024. 2,
  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. 2,
  35054. 0,
  35055. 2,
  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. 2,
  35086. 0,
  35087. 2,
  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. 0,
  35102. 0,
  35103. 0,
  35104. 0,
  35105. 0,
  35106. 0,
  35107. 0,
  35108. 0,
  35109. 0,
  35110. 0,
  35111. 0,
  35112. 0,
  35113. 0,
  35114. 0,
  35115. 0,
  35116. 0,
  35117. 0,
  35118. 0,
  35119. 0,
  35120. 0,
  35121. 0,
  35122. 0,
  35123. 0,
  35124. 0,
  35125. 0,
  35126. 0,
  35127. 0,
  35128. 0,
  35129. 0,
  35130. 0,
  35131. 0,
  35132. 0,
  35133. 0,
  35134. 0,
  35135. 0,
  35136. 0,
  35137. 0,
  35138. 0,
  35139. 0,
  35140. 0,
  35141. 0,
  35142. 0,
  35143. 0,
  35144. 0,
  35145. 0,
  35146. 0,
  35147. 0,
  35148. 0,
  35149. 0,
  35150. 0,
  35151. 0,
  35152. 0,
  35153. 0,
  35154. 0,
  35155. 0,
  35156. 0,
  35157. 0,
  35158. 0,
  35159. 0,
  35160. 0,
  35161. 0,
  35162. 0,
  35163. 0,
  35164. 0,
  35165. 0,
  35166. 0,
  35167. 0,
  35168. 0,
  35169. 0,
  35170. 0,
  35171. 0,
  35172. 0,
  35173. 0,
  35174. 0,
  35175. 0,
  35176. 0,
  35177. 0,
  35178. 0,
  35179. 0,
  35180. 0,
  35181. 0,
  35182. 0,
  35183. 0,
  35184. 0,
  35185. 0,
  35186. 0,
  35187. 0,
  35188. 0,
  35189. 0,
  35190. 0,
  35191. 0,
  35192. 0,
  35193. 0,
  35194. 0,
  35195. 0,
  35196. 0,
  35197. 0,
  35198. 0,
  35199. 0,
  35200. 0,
  35201. 0,
  35202. 0,
  35203. 0,
  35204. 0,
  35205. 0,
  35206. 0,
  35207. 0,
  35208. 0,
  35209. 0,
  35210. 0,
  35211. 0,
  35212. 0,
  35213. 0,
  35214. 0,
  35215. 0,
  35216. 0,
  35217. 0
  35218. ];
  35219. function toHexDigit(ch) {
  35220. if (ch >= 0x30 && ch <= 0x39) {
  35221. return ch & 0x0F;
  35222. }
  35223. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  35224. return (ch & 0x0F) + 9;
  35225. }
  35226. return -1;
  35227. }
  35228. Lexer.prototype = {
  35229. nextChar: function Lexer_nextChar() {
  35230. return this.currentChar = this.stream.getByte();
  35231. },
  35232. peekChar: function Lexer_peekChar() {
  35233. return this.stream.peekByte();
  35234. },
  35235. getNumber: function Lexer_getNumber() {
  35236. var ch = this.currentChar;
  35237. var eNotation = false;
  35238. var divideBy = 0;
  35239. var sign = 1;
  35240. if (ch === 0x2D) {
  35241. sign = -1;
  35242. ch = this.nextChar();
  35243. if (ch === 0x2D) {
  35244. ch = this.nextChar();
  35245. }
  35246. } else if (ch === 0x2B) {
  35247. ch = this.nextChar();
  35248. }
  35249. if (ch === 0x2E) {
  35250. divideBy = 10;
  35251. ch = this.nextChar();
  35252. }
  35253. if (ch < 0x30 || ch > 0x39) {
  35254. error('Invalid number: ' + String.fromCharCode(ch));
  35255. return 0;
  35256. }
  35257. var baseValue = ch - 0x30;
  35258. var powerValue = 0;
  35259. var powerValueSign = 1;
  35260. while ((ch = this.nextChar()) >= 0) {
  35261. if (0x30 <= ch && ch <= 0x39) {
  35262. var currentDigit = ch - 0x30;
  35263. if (eNotation) {
  35264. powerValue = powerValue * 10 + currentDigit;
  35265. } else {
  35266. if (divideBy !== 0) {
  35267. divideBy *= 10;
  35268. }
  35269. baseValue = baseValue * 10 + currentDigit;
  35270. }
  35271. } else if (ch === 0x2E) {
  35272. if (divideBy === 0) {
  35273. divideBy = 1;
  35274. } else {
  35275. break;
  35276. }
  35277. } else if (ch === 0x2D) {
  35278. warn('Badly formatted number');
  35279. } else if (ch === 0x45 || ch === 0x65) {
  35280. ch = this.peekChar();
  35281. if (ch === 0x2B || ch === 0x2D) {
  35282. powerValueSign = ch === 0x2D ? -1 : 1;
  35283. this.nextChar();
  35284. } else if (ch < 0x30 || ch > 0x39) {
  35285. break;
  35286. }
  35287. eNotation = true;
  35288. } else {
  35289. break;
  35290. }
  35291. }
  35292. if (divideBy !== 0) {
  35293. baseValue /= divideBy;
  35294. }
  35295. if (eNotation) {
  35296. baseValue *= Math.pow(10, powerValueSign * powerValue);
  35297. }
  35298. return sign * baseValue;
  35299. },
  35300. getString: function Lexer_getString() {
  35301. var numParen = 1;
  35302. var done = false;
  35303. var strBuf = this.strBuf;
  35304. strBuf.length = 0;
  35305. var ch = this.nextChar();
  35306. while (true) {
  35307. var charBuffered = false;
  35308. switch (ch | 0) {
  35309. case -1:
  35310. warn('Unterminated string');
  35311. done = true;
  35312. break;
  35313. case 0x28:
  35314. ++numParen;
  35315. strBuf.push('(');
  35316. break;
  35317. case 0x29:
  35318. if (--numParen === 0) {
  35319. this.nextChar();
  35320. done = true;
  35321. } else {
  35322. strBuf.push(')');
  35323. }
  35324. break;
  35325. case 0x5C:
  35326. ch = this.nextChar();
  35327. switch (ch) {
  35328. case -1:
  35329. warn('Unterminated string');
  35330. done = true;
  35331. break;
  35332. case 0x6E:
  35333. strBuf.push('\n');
  35334. break;
  35335. case 0x72:
  35336. strBuf.push('\r');
  35337. break;
  35338. case 0x74:
  35339. strBuf.push('\t');
  35340. break;
  35341. case 0x62:
  35342. strBuf.push('\b');
  35343. break;
  35344. case 0x66:
  35345. strBuf.push('\f');
  35346. break;
  35347. case 0x5C:
  35348. case 0x28:
  35349. case 0x29:
  35350. strBuf.push(String.fromCharCode(ch));
  35351. break;
  35352. case 0x30:
  35353. case 0x31:
  35354. case 0x32:
  35355. case 0x33:
  35356. case 0x34:
  35357. case 0x35:
  35358. case 0x36:
  35359. case 0x37:
  35360. var x = ch & 0x0F;
  35361. ch = this.nextChar();
  35362. charBuffered = true;
  35363. if (ch >= 0x30 && ch <= 0x37) {
  35364. x = (x << 3) + (ch & 0x0F);
  35365. ch = this.nextChar();
  35366. if (ch >= 0x30 && ch <= 0x37) {
  35367. charBuffered = false;
  35368. x = (x << 3) + (ch & 0x0F);
  35369. }
  35370. }
  35371. strBuf.push(String.fromCharCode(x));
  35372. break;
  35373. case 0x0D:
  35374. if (this.peekChar() === 0x0A) {
  35375. this.nextChar();
  35376. }
  35377. break;
  35378. case 0x0A:
  35379. break;
  35380. default:
  35381. strBuf.push(String.fromCharCode(ch));
  35382. break;
  35383. }
  35384. break;
  35385. default:
  35386. strBuf.push(String.fromCharCode(ch));
  35387. break;
  35388. }
  35389. if (done) {
  35390. break;
  35391. }
  35392. if (!charBuffered) {
  35393. ch = this.nextChar();
  35394. }
  35395. }
  35396. return strBuf.join('');
  35397. },
  35398. getName: function Lexer_getName() {
  35399. var ch, previousCh;
  35400. var strBuf = this.strBuf;
  35401. strBuf.length = 0;
  35402. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  35403. if (ch === 0x23) {
  35404. ch = this.nextChar();
  35405. if (specialChars[ch]) {
  35406. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  35407. strBuf.push('#');
  35408. break;
  35409. }
  35410. var x = toHexDigit(ch);
  35411. if (x !== -1) {
  35412. previousCh = ch;
  35413. ch = this.nextChar();
  35414. var x2 = toHexDigit(ch);
  35415. if (x2 === -1) {
  35416. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  35417. strBuf.push('#', String.fromCharCode(previousCh));
  35418. if (specialChars[ch]) {
  35419. break;
  35420. }
  35421. strBuf.push(String.fromCharCode(ch));
  35422. continue;
  35423. }
  35424. strBuf.push(String.fromCharCode(x << 4 | x2));
  35425. } else {
  35426. strBuf.push('#', String.fromCharCode(ch));
  35427. }
  35428. } else {
  35429. strBuf.push(String.fromCharCode(ch));
  35430. }
  35431. }
  35432. if (strBuf.length > 127) {
  35433. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  35434. }
  35435. return Name.get(strBuf.join(''));
  35436. },
  35437. getHexString: function Lexer_getHexString() {
  35438. var strBuf = this.strBuf;
  35439. strBuf.length = 0;
  35440. var ch = this.currentChar;
  35441. var isFirstHex = true;
  35442. var firstDigit;
  35443. var secondDigit;
  35444. while (true) {
  35445. if (ch < 0) {
  35446. warn('Unterminated hex string');
  35447. break;
  35448. } else if (ch === 0x3E) {
  35449. this.nextChar();
  35450. break;
  35451. } else if (specialChars[ch] === 1) {
  35452. ch = this.nextChar();
  35453. continue;
  35454. } else {
  35455. if (isFirstHex) {
  35456. firstDigit = toHexDigit(ch);
  35457. if (firstDigit === -1) {
  35458. warn('Ignoring invalid character "' + ch + '" in hex string');
  35459. ch = this.nextChar();
  35460. continue;
  35461. }
  35462. } else {
  35463. secondDigit = toHexDigit(ch);
  35464. if (secondDigit === -1) {
  35465. warn('Ignoring invalid character "' + ch + '" in hex string');
  35466. ch = this.nextChar();
  35467. continue;
  35468. }
  35469. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  35470. }
  35471. isFirstHex = !isFirstHex;
  35472. ch = this.nextChar();
  35473. }
  35474. }
  35475. return strBuf.join('');
  35476. },
  35477. getObj: function Lexer_getObj() {
  35478. var comment = false;
  35479. var ch = this.currentChar;
  35480. while (true) {
  35481. if (ch < 0) {
  35482. return EOF;
  35483. }
  35484. if (comment) {
  35485. if (ch === 0x0A || ch === 0x0D) {
  35486. comment = false;
  35487. }
  35488. } else if (ch === 0x25) {
  35489. comment = true;
  35490. } else if (specialChars[ch] !== 1) {
  35491. break;
  35492. }
  35493. ch = this.nextChar();
  35494. }
  35495. switch (ch | 0) {
  35496. case 0x30:
  35497. case 0x31:
  35498. case 0x32:
  35499. case 0x33:
  35500. case 0x34:
  35501. case 0x35:
  35502. case 0x36:
  35503. case 0x37:
  35504. case 0x38:
  35505. case 0x39:
  35506. case 0x2B:
  35507. case 0x2D:
  35508. case 0x2E:
  35509. return this.getNumber();
  35510. case 0x28:
  35511. return this.getString();
  35512. case 0x2F:
  35513. return this.getName();
  35514. case 0x5B:
  35515. this.nextChar();
  35516. return Cmd.get('[');
  35517. case 0x5D:
  35518. this.nextChar();
  35519. return Cmd.get(']');
  35520. case 0x3C:
  35521. ch = this.nextChar();
  35522. if (ch === 0x3C) {
  35523. this.nextChar();
  35524. return Cmd.get('<<');
  35525. }
  35526. return this.getHexString();
  35527. case 0x3E:
  35528. ch = this.nextChar();
  35529. if (ch === 0x3E) {
  35530. this.nextChar();
  35531. return Cmd.get('>>');
  35532. }
  35533. return Cmd.get('>');
  35534. case 0x7B:
  35535. this.nextChar();
  35536. return Cmd.get('{');
  35537. case 0x7D:
  35538. this.nextChar();
  35539. return Cmd.get('}');
  35540. case 0x29:
  35541. error('Illegal character: ' + ch);
  35542. break;
  35543. }
  35544. var str = String.fromCharCode(ch);
  35545. var knownCommands = this.knownCommands;
  35546. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  35547. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  35548. var possibleCommand = str + String.fromCharCode(ch);
  35549. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  35550. break;
  35551. }
  35552. if (str.length === 128) {
  35553. error('Command token too long: ' + str.length);
  35554. }
  35555. str = possibleCommand;
  35556. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  35557. }
  35558. if (str === 'true') {
  35559. return true;
  35560. }
  35561. if (str === 'false') {
  35562. return false;
  35563. }
  35564. if (str === 'null') {
  35565. return null;
  35566. }
  35567. return Cmd.get(str);
  35568. },
  35569. skipToNextLine: function Lexer_skipToNextLine() {
  35570. var ch = this.currentChar;
  35571. while (ch >= 0) {
  35572. if (ch === 0x0D) {
  35573. ch = this.nextChar();
  35574. if (ch === 0x0A) {
  35575. this.nextChar();
  35576. }
  35577. break;
  35578. } else if (ch === 0x0A) {
  35579. this.nextChar();
  35580. break;
  35581. }
  35582. ch = this.nextChar();
  35583. }
  35584. }
  35585. };
  35586. return Lexer;
  35587. }();
  35588. var Linearization = {
  35589. create: function LinearizationCreate(stream) {
  35590. function getInt(name, allowZeroValue) {
  35591. var obj = linDict.get(name);
  35592. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  35593. return obj;
  35594. }
  35595. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  35596. }
  35597. function getHints() {
  35598. var hints = linDict.get('H'), hintsLength, item;
  35599. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  35600. for (var index = 0; index < hintsLength; index++) {
  35601. if (!(isInt(item = hints[index]) && item > 0)) {
  35602. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  35603. }
  35604. }
  35605. return hints;
  35606. }
  35607. throw new Error('Hint array in the linearization dictionary is invalid.');
  35608. }
  35609. var parser = new Parser(new Lexer(stream), false, null);
  35610. var obj1 = parser.getObj();
  35611. var obj2 = parser.getObj();
  35612. var obj3 = parser.getObj();
  35613. var linDict = parser.getObj();
  35614. var obj, length;
  35615. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  35616. return null;
  35617. } else if ((length = getInt('L')) !== stream.length) {
  35618. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  35619. }
  35620. return {
  35621. length: length,
  35622. hints: getHints(),
  35623. objectNumberFirst: getInt('O'),
  35624. endFirst: getInt('E'),
  35625. numPages: getInt('N'),
  35626. mainXRefEntriesOffset: getInt('T'),
  35627. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  35628. };
  35629. }
  35630. };
  35631. exports.EOF = EOF;
  35632. exports.Lexer = Lexer;
  35633. exports.Linearization = Linearization;
  35634. exports.Parser = Parser;
  35635. exports.isEOF = isEOF;
  35636. }));
  35637. (function (root, factory) {
  35638. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  35639. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  35640. var warn = sharedUtil.warn;
  35641. var isSpace = sharedUtil.isSpace;
  35642. var Stream = coreStream.Stream;
  35643. var getEncoding = coreEncodings.getEncoding;
  35644. var HINTING_ENABLED = false;
  35645. var Type1CharString = function Type1CharStringClosure() {
  35646. var COMMAND_MAP = {
  35647. 'hstem': [1],
  35648. 'vstem': [3],
  35649. 'vmoveto': [4],
  35650. 'rlineto': [5],
  35651. 'hlineto': [6],
  35652. 'vlineto': [7],
  35653. 'rrcurveto': [8],
  35654. 'callsubr': [10],
  35655. 'flex': [
  35656. 12,
  35657. 35
  35658. ],
  35659. 'drop': [
  35660. 12,
  35661. 18
  35662. ],
  35663. 'endchar': [14],
  35664. 'rmoveto': [21],
  35665. 'hmoveto': [22],
  35666. 'vhcurveto': [30],
  35667. 'hvcurveto': [31]
  35668. };
  35669. function Type1CharString() {
  35670. this.width = 0;
  35671. this.lsb = 0;
  35672. this.flexing = false;
  35673. this.output = [];
  35674. this.stack = [];
  35675. }
  35676. Type1CharString.prototype = {
  35677. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  35678. var count = encoded.length;
  35679. var error = false;
  35680. var wx, sbx, subrNumber;
  35681. for (var i = 0; i < count; i++) {
  35682. var value = encoded[i];
  35683. if (value < 32) {
  35684. if (value === 12) {
  35685. value = (value << 8) + encoded[++i];
  35686. }
  35687. switch (value) {
  35688. case 1:
  35689. if (!HINTING_ENABLED) {
  35690. this.stack = [];
  35691. break;
  35692. }
  35693. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35694. break;
  35695. case 3:
  35696. if (!HINTING_ENABLED) {
  35697. this.stack = [];
  35698. break;
  35699. }
  35700. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35701. break;
  35702. case 4:
  35703. if (this.flexing) {
  35704. if (this.stack.length < 1) {
  35705. error = true;
  35706. break;
  35707. }
  35708. var dy = this.stack.pop();
  35709. this.stack.push(0, dy);
  35710. break;
  35711. }
  35712. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  35713. break;
  35714. case 5:
  35715. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  35716. break;
  35717. case 6:
  35718. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  35719. break;
  35720. case 7:
  35721. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  35722. break;
  35723. case 8:
  35724. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  35725. break;
  35726. case 9:
  35727. this.stack = [];
  35728. break;
  35729. case 10:
  35730. if (this.stack.length < 1) {
  35731. error = true;
  35732. break;
  35733. }
  35734. subrNumber = this.stack.pop();
  35735. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  35736. break;
  35737. case 11:
  35738. return error;
  35739. case 13:
  35740. if (this.stack.length < 2) {
  35741. error = true;
  35742. break;
  35743. }
  35744. wx = this.stack.pop();
  35745. sbx = this.stack.pop();
  35746. this.lsb = sbx;
  35747. this.width = wx;
  35748. this.stack.push(wx, sbx);
  35749. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  35750. break;
  35751. case 14:
  35752. this.output.push(COMMAND_MAP.endchar[0]);
  35753. break;
  35754. case 21:
  35755. if (this.flexing) {
  35756. break;
  35757. }
  35758. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  35759. break;
  35760. case 22:
  35761. if (this.flexing) {
  35762. this.stack.push(0);
  35763. break;
  35764. }
  35765. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  35766. break;
  35767. case 30:
  35768. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  35769. break;
  35770. case 31:
  35771. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  35772. break;
  35773. case (12 << 8) + 0:
  35774. this.stack = [];
  35775. break;
  35776. case (12 << 8) + 1:
  35777. if (!HINTING_ENABLED) {
  35778. this.stack = [];
  35779. break;
  35780. }
  35781. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35782. break;
  35783. case (12 << 8) + 2:
  35784. if (!HINTING_ENABLED) {
  35785. this.stack = [];
  35786. break;
  35787. }
  35788. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35789. break;
  35790. case (12 << 8) + 6:
  35791. if (seacAnalysisEnabled) {
  35792. this.seac = this.stack.splice(-4, 4);
  35793. error = this.executeCommand(0, COMMAND_MAP.endchar);
  35794. } else {
  35795. error = this.executeCommand(4, COMMAND_MAP.endchar);
  35796. }
  35797. break;
  35798. case (12 << 8) + 7:
  35799. if (this.stack.length < 4) {
  35800. error = true;
  35801. break;
  35802. }
  35803. var wy = this.stack.pop();
  35804. wx = this.stack.pop();
  35805. var sby = this.stack.pop();
  35806. sbx = this.stack.pop();
  35807. this.lsb = sbx;
  35808. this.width = wx;
  35809. this.stack.push(wx, sbx, sby);
  35810. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  35811. break;
  35812. case (12 << 8) + 12:
  35813. if (this.stack.length < 2) {
  35814. error = true;
  35815. break;
  35816. }
  35817. var num2 = this.stack.pop();
  35818. var num1 = this.stack.pop();
  35819. this.stack.push(num1 / num2);
  35820. break;
  35821. case (12 << 8) + 16:
  35822. if (this.stack.length < 2) {
  35823. error = true;
  35824. break;
  35825. }
  35826. subrNumber = this.stack.pop();
  35827. var numArgs = this.stack.pop();
  35828. if (subrNumber === 0 && numArgs === 3) {
  35829. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  35830. 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]);
  35831. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  35832. this.flexing = false;
  35833. this.stack.push(flexArgs[15], flexArgs[16]);
  35834. } else if (subrNumber === 1 && numArgs === 0) {
  35835. this.flexing = true;
  35836. }
  35837. break;
  35838. case (12 << 8) + 17:
  35839. break;
  35840. case (12 << 8) + 33:
  35841. this.stack = [];
  35842. break;
  35843. default:
  35844. warn('Unknown type 1 charstring command of "' + value + '"');
  35845. break;
  35846. }
  35847. if (error) {
  35848. break;
  35849. }
  35850. continue;
  35851. } else if (value <= 246) {
  35852. value = value - 139;
  35853. } else if (value <= 250) {
  35854. value = (value - 247) * 256 + encoded[++i] + 108;
  35855. } else if (value <= 254) {
  35856. value = -((value - 251) * 256) - encoded[++i] - 108;
  35857. } else {
  35858. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  35859. }
  35860. this.stack.push(value);
  35861. }
  35862. return error;
  35863. },
  35864. executeCommand: function (howManyArgs, command, keepStack) {
  35865. var stackLength = this.stack.length;
  35866. if (howManyArgs > stackLength) {
  35867. return true;
  35868. }
  35869. var start = stackLength - howManyArgs;
  35870. for (var i = start; i < stackLength; i++) {
  35871. var value = this.stack[i];
  35872. if (value === (value | 0)) {
  35873. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  35874. } else {
  35875. value = 65536 * value | 0;
  35876. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  35877. }
  35878. }
  35879. this.output.push.apply(this.output, command);
  35880. if (keepStack) {
  35881. this.stack.splice(start, howManyArgs);
  35882. } else {
  35883. this.stack.length = 0;
  35884. }
  35885. return false;
  35886. }
  35887. };
  35888. return Type1CharString;
  35889. }();
  35890. var Type1Parser = function Type1ParserClosure() {
  35891. var EEXEC_ENCRYPT_KEY = 55665;
  35892. var CHAR_STRS_ENCRYPT_KEY = 4330;
  35893. function isHexDigit(code) {
  35894. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  35895. }
  35896. function decrypt(data, key, discardNumber) {
  35897. if (discardNumber >= data.length) {
  35898. return new Uint8Array(0);
  35899. }
  35900. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  35901. for (i = 0; i < discardNumber; i++) {
  35902. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  35903. }
  35904. var count = data.length - discardNumber;
  35905. var decrypted = new Uint8Array(count);
  35906. for (i = discardNumber, j = 0; j < count; i++, j++) {
  35907. var value = data[i];
  35908. decrypted[j] = value ^ r >> 8;
  35909. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35910. }
  35911. return decrypted;
  35912. }
  35913. function decryptAscii(data, key, discardNumber) {
  35914. var r = key | 0, c1 = 52845, c2 = 22719;
  35915. var count = data.length, maybeLength = count >>> 1;
  35916. var decrypted = new Uint8Array(maybeLength);
  35917. var i, j;
  35918. for (i = 0, j = 0; i < count; i++) {
  35919. var digit1 = data[i];
  35920. if (!isHexDigit(digit1)) {
  35921. continue;
  35922. }
  35923. i++;
  35924. var digit2;
  35925. while (i < count && !isHexDigit(digit2 = data[i])) {
  35926. i++;
  35927. }
  35928. if (i < count) {
  35929. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  35930. decrypted[j++] = value ^ r >> 8;
  35931. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35932. }
  35933. }
  35934. return Array.prototype.slice.call(decrypted, discardNumber, j);
  35935. }
  35936. function isSpecial(c) {
  35937. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  35938. }
  35939. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  35940. if (encrypted) {
  35941. var data = stream.getBytes();
  35942. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  35943. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  35944. }
  35945. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  35946. this.stream = stream;
  35947. this.nextChar();
  35948. }
  35949. Type1Parser.prototype = {
  35950. readNumberArray: function Type1Parser_readNumberArray() {
  35951. this.getToken();
  35952. var array = [];
  35953. while (true) {
  35954. var token = this.getToken();
  35955. if (token === null || token === ']' || token === '}') {
  35956. break;
  35957. }
  35958. array.push(parseFloat(token || 0));
  35959. }
  35960. return array;
  35961. },
  35962. readNumber: function Type1Parser_readNumber() {
  35963. var token = this.getToken();
  35964. return parseFloat(token || 0);
  35965. },
  35966. readInt: function Type1Parser_readInt() {
  35967. var token = this.getToken();
  35968. return parseInt(token || 0, 10) | 0;
  35969. },
  35970. readBoolean: function Type1Parser_readBoolean() {
  35971. var token = this.getToken();
  35972. return token === 'true' ? 1 : 0;
  35973. },
  35974. nextChar: function Type1_nextChar() {
  35975. return this.currentChar = this.stream.getByte();
  35976. },
  35977. getToken: function Type1Parser_getToken() {
  35978. var comment = false;
  35979. var ch = this.currentChar;
  35980. while (true) {
  35981. if (ch === -1) {
  35982. return null;
  35983. }
  35984. if (comment) {
  35985. if (ch === 0x0A || ch === 0x0D) {
  35986. comment = false;
  35987. }
  35988. } else if (ch === 0x25) {
  35989. comment = true;
  35990. } else if (!isSpace(ch)) {
  35991. break;
  35992. }
  35993. ch = this.nextChar();
  35994. }
  35995. if (isSpecial(ch)) {
  35996. this.nextChar();
  35997. return String.fromCharCode(ch);
  35998. }
  35999. var token = '';
  36000. do {
  36001. token += String.fromCharCode(ch);
  36002. ch = this.nextChar();
  36003. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  36004. return token;
  36005. },
  36006. extractFontProgram: function Type1Parser_extractFontProgram() {
  36007. var stream = this.stream;
  36008. var subrs = [], charstrings = [];
  36009. var privateData = Object.create(null);
  36010. privateData['lenIV'] = 4;
  36011. var program = {
  36012. subrs: [],
  36013. charstrings: [],
  36014. properties: { 'privateData': privateData }
  36015. };
  36016. var token, length, data, lenIV, encoded;
  36017. while ((token = this.getToken()) !== null) {
  36018. if (token !== '/') {
  36019. continue;
  36020. }
  36021. token = this.getToken();
  36022. switch (token) {
  36023. case 'CharStrings':
  36024. this.getToken();
  36025. this.getToken();
  36026. this.getToken();
  36027. this.getToken();
  36028. while (true) {
  36029. token = this.getToken();
  36030. if (token === null || token === 'end') {
  36031. break;
  36032. }
  36033. if (token !== '/') {
  36034. continue;
  36035. }
  36036. var glyph = this.getToken();
  36037. length = this.readInt();
  36038. this.getToken();
  36039. data = stream.makeSubStream(stream.pos, length);
  36040. lenIV = program.properties.privateData['lenIV'];
  36041. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  36042. stream.skip(length);
  36043. this.nextChar();
  36044. token = this.getToken();
  36045. if (token === 'noaccess') {
  36046. this.getToken();
  36047. }
  36048. charstrings.push({
  36049. glyph: glyph,
  36050. encoded: encoded
  36051. });
  36052. }
  36053. break;
  36054. case 'Subrs':
  36055. var num = this.readInt();
  36056. this.getToken();
  36057. while ((token = this.getToken()) === 'dup') {
  36058. var index = this.readInt();
  36059. length = this.readInt();
  36060. this.getToken();
  36061. data = stream.makeSubStream(stream.pos, length);
  36062. lenIV = program.properties.privateData['lenIV'];
  36063. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  36064. stream.skip(length);
  36065. this.nextChar();
  36066. token = this.getToken();
  36067. if (token === 'noaccess') {
  36068. this.getToken();
  36069. }
  36070. subrs[index] = encoded;
  36071. }
  36072. break;
  36073. case 'BlueValues':
  36074. case 'OtherBlues':
  36075. case 'FamilyBlues':
  36076. case 'FamilyOtherBlues':
  36077. var blueArray = this.readNumberArray();
  36078. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  36079. program.properties.privateData[token] = blueArray;
  36080. }
  36081. break;
  36082. case 'StemSnapH':
  36083. case 'StemSnapV':
  36084. program.properties.privateData[token] = this.readNumberArray();
  36085. break;
  36086. case 'StdHW':
  36087. case 'StdVW':
  36088. program.properties.privateData[token] = this.readNumberArray()[0];
  36089. break;
  36090. case 'BlueShift':
  36091. case 'lenIV':
  36092. case 'BlueFuzz':
  36093. case 'BlueScale':
  36094. case 'LanguageGroup':
  36095. case 'ExpansionFactor':
  36096. program.properties.privateData[token] = this.readNumber();
  36097. break;
  36098. case 'ForceBold':
  36099. program.properties.privateData[token] = this.readBoolean();
  36100. break;
  36101. }
  36102. }
  36103. for (var i = 0; i < charstrings.length; i++) {
  36104. glyph = charstrings[i].glyph;
  36105. encoded = charstrings[i].encoded;
  36106. var charString = new Type1CharString();
  36107. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  36108. var output = charString.output;
  36109. if (error) {
  36110. output = [14];
  36111. }
  36112. program.charstrings.push({
  36113. glyphName: glyph,
  36114. charstring: output,
  36115. width: charString.width,
  36116. lsb: charString.lsb,
  36117. seac: charString.seac
  36118. });
  36119. }
  36120. return program;
  36121. },
  36122. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  36123. var token;
  36124. while ((token = this.getToken()) !== null) {
  36125. if (token !== '/') {
  36126. continue;
  36127. }
  36128. token = this.getToken();
  36129. switch (token) {
  36130. case 'FontMatrix':
  36131. var matrix = this.readNumberArray();
  36132. properties.fontMatrix = matrix;
  36133. break;
  36134. case 'Encoding':
  36135. var encodingArg = this.getToken();
  36136. var encoding;
  36137. if (!/^\d+$/.test(encodingArg)) {
  36138. encoding = getEncoding(encodingArg);
  36139. } else {
  36140. encoding = [];
  36141. var size = parseInt(encodingArg, 10) | 0;
  36142. this.getToken();
  36143. for (var j = 0; j < size; j++) {
  36144. token = this.getToken();
  36145. while (token !== 'dup' && token !== 'def') {
  36146. token = this.getToken();
  36147. if (token === null) {
  36148. return;
  36149. }
  36150. }
  36151. if (token === 'def') {
  36152. break;
  36153. }
  36154. var index = this.readInt();
  36155. this.getToken();
  36156. var glyph = this.getToken();
  36157. encoding[index] = glyph;
  36158. this.getToken();
  36159. }
  36160. }
  36161. properties.builtInEncoding = encoding;
  36162. break;
  36163. case 'FontBBox':
  36164. var fontBBox = this.readNumberArray();
  36165. properties.ascent = fontBBox[3];
  36166. properties.descent = fontBBox[1];
  36167. properties.ascentScaled = true;
  36168. break;
  36169. }
  36170. }
  36171. }
  36172. };
  36173. return Type1Parser;
  36174. }();
  36175. exports.Type1Parser = Type1Parser;
  36176. }));
  36177. (function (root, factory) {
  36178. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  36179. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  36180. var Util = sharedUtil.Util;
  36181. var assert = sharedUtil.assert;
  36182. var warn = sharedUtil.warn;
  36183. var error = sharedUtil.error;
  36184. var isInt = sharedUtil.isInt;
  36185. var isString = sharedUtil.isString;
  36186. var MissingDataException = sharedUtil.MissingDataException;
  36187. var isName = corePrimitives.isName;
  36188. var isCmd = corePrimitives.isCmd;
  36189. var isStream = corePrimitives.isStream;
  36190. var StringStream = coreStream.StringStream;
  36191. var Lexer = coreParser.Lexer;
  36192. var isEOF = coreParser.isEOF;
  36193. var BUILT_IN_CMAPS = [
  36194. 'Adobe-GB1-UCS2',
  36195. 'Adobe-CNS1-UCS2',
  36196. 'Adobe-Japan1-UCS2',
  36197. 'Adobe-Korea1-UCS2',
  36198. '78-EUC-H',
  36199. '78-EUC-V',
  36200. '78-H',
  36201. '78-RKSJ-H',
  36202. '78-RKSJ-V',
  36203. '78-V',
  36204. '78ms-RKSJ-H',
  36205. '78ms-RKSJ-V',
  36206. '83pv-RKSJ-H',
  36207. '90ms-RKSJ-H',
  36208. '90ms-RKSJ-V',
  36209. '90msp-RKSJ-H',
  36210. '90msp-RKSJ-V',
  36211. '90pv-RKSJ-H',
  36212. '90pv-RKSJ-V',
  36213. 'Add-H',
  36214. 'Add-RKSJ-H',
  36215. 'Add-RKSJ-V',
  36216. 'Add-V',
  36217. 'Adobe-CNS1-0',
  36218. 'Adobe-CNS1-1',
  36219. 'Adobe-CNS1-2',
  36220. 'Adobe-CNS1-3',
  36221. 'Adobe-CNS1-4',
  36222. 'Adobe-CNS1-5',
  36223. 'Adobe-CNS1-6',
  36224. 'Adobe-GB1-0',
  36225. 'Adobe-GB1-1',
  36226. 'Adobe-GB1-2',
  36227. 'Adobe-GB1-3',
  36228. 'Adobe-GB1-4',
  36229. 'Adobe-GB1-5',
  36230. 'Adobe-Japan1-0',
  36231. 'Adobe-Japan1-1',
  36232. 'Adobe-Japan1-2',
  36233. 'Adobe-Japan1-3',
  36234. 'Adobe-Japan1-4',
  36235. 'Adobe-Japan1-5',
  36236. 'Adobe-Japan1-6',
  36237. 'Adobe-Korea1-0',
  36238. 'Adobe-Korea1-1',
  36239. 'Adobe-Korea1-2',
  36240. 'B5-H',
  36241. 'B5-V',
  36242. 'B5pc-H',
  36243. 'B5pc-V',
  36244. 'CNS-EUC-H',
  36245. 'CNS-EUC-V',
  36246. 'CNS1-H',
  36247. 'CNS1-V',
  36248. 'CNS2-H',
  36249. 'CNS2-V',
  36250. 'ETHK-B5-H',
  36251. 'ETHK-B5-V',
  36252. 'ETen-B5-H',
  36253. 'ETen-B5-V',
  36254. 'ETenms-B5-H',
  36255. 'ETenms-B5-V',
  36256. 'EUC-H',
  36257. 'EUC-V',
  36258. 'Ext-H',
  36259. 'Ext-RKSJ-H',
  36260. 'Ext-RKSJ-V',
  36261. 'Ext-V',
  36262. 'GB-EUC-H',
  36263. 'GB-EUC-V',
  36264. 'GB-H',
  36265. 'GB-V',
  36266. 'GBK-EUC-H',
  36267. 'GBK-EUC-V',
  36268. 'GBK2K-H',
  36269. 'GBK2K-V',
  36270. 'GBKp-EUC-H',
  36271. 'GBKp-EUC-V',
  36272. 'GBT-EUC-H',
  36273. 'GBT-EUC-V',
  36274. 'GBT-H',
  36275. 'GBT-V',
  36276. 'GBTpc-EUC-H',
  36277. 'GBTpc-EUC-V',
  36278. 'GBpc-EUC-H',
  36279. 'GBpc-EUC-V',
  36280. 'H',
  36281. 'HKdla-B5-H',
  36282. 'HKdla-B5-V',
  36283. 'HKdlb-B5-H',
  36284. 'HKdlb-B5-V',
  36285. 'HKgccs-B5-H',
  36286. 'HKgccs-B5-V',
  36287. 'HKm314-B5-H',
  36288. 'HKm314-B5-V',
  36289. 'HKm471-B5-H',
  36290. 'HKm471-B5-V',
  36291. 'HKscs-B5-H',
  36292. 'HKscs-B5-V',
  36293. 'Hankaku',
  36294. 'Hiragana',
  36295. 'KSC-EUC-H',
  36296. 'KSC-EUC-V',
  36297. 'KSC-H',
  36298. 'KSC-Johab-H',
  36299. 'KSC-Johab-V',
  36300. 'KSC-V',
  36301. 'KSCms-UHC-H',
  36302. 'KSCms-UHC-HW-H',
  36303. 'KSCms-UHC-HW-V',
  36304. 'KSCms-UHC-V',
  36305. 'KSCpc-EUC-H',
  36306. 'KSCpc-EUC-V',
  36307. 'Katakana',
  36308. 'NWP-H',
  36309. 'NWP-V',
  36310. 'RKSJ-H',
  36311. 'RKSJ-V',
  36312. 'Roman',
  36313. 'UniCNS-UCS2-H',
  36314. 'UniCNS-UCS2-V',
  36315. 'UniCNS-UTF16-H',
  36316. 'UniCNS-UTF16-V',
  36317. 'UniCNS-UTF32-H',
  36318. 'UniCNS-UTF32-V',
  36319. 'UniCNS-UTF8-H',
  36320. 'UniCNS-UTF8-V',
  36321. 'UniGB-UCS2-H',
  36322. 'UniGB-UCS2-V',
  36323. 'UniGB-UTF16-H',
  36324. 'UniGB-UTF16-V',
  36325. 'UniGB-UTF32-H',
  36326. 'UniGB-UTF32-V',
  36327. 'UniGB-UTF8-H',
  36328. 'UniGB-UTF8-V',
  36329. 'UniJIS-UCS2-H',
  36330. 'UniJIS-UCS2-HW-H',
  36331. 'UniJIS-UCS2-HW-V',
  36332. 'UniJIS-UCS2-V',
  36333. 'UniJIS-UTF16-H',
  36334. 'UniJIS-UTF16-V',
  36335. 'UniJIS-UTF32-H',
  36336. 'UniJIS-UTF32-V',
  36337. 'UniJIS-UTF8-H',
  36338. 'UniJIS-UTF8-V',
  36339. 'UniJIS2004-UTF16-H',
  36340. 'UniJIS2004-UTF16-V',
  36341. 'UniJIS2004-UTF32-H',
  36342. 'UniJIS2004-UTF32-V',
  36343. 'UniJIS2004-UTF8-H',
  36344. 'UniJIS2004-UTF8-V',
  36345. 'UniJISPro-UCS2-HW-V',
  36346. 'UniJISPro-UCS2-V',
  36347. 'UniJISPro-UTF8-V',
  36348. 'UniJISX0213-UTF32-H',
  36349. 'UniJISX0213-UTF32-V',
  36350. 'UniJISX02132004-UTF32-H',
  36351. 'UniJISX02132004-UTF32-V',
  36352. 'UniKS-UCS2-H',
  36353. 'UniKS-UCS2-V',
  36354. 'UniKS-UTF16-H',
  36355. 'UniKS-UTF16-V',
  36356. 'UniKS-UTF32-H',
  36357. 'UniKS-UTF32-V',
  36358. 'UniKS-UTF8-H',
  36359. 'UniKS-UTF8-V',
  36360. 'V',
  36361. 'WP-Symbol'
  36362. ];
  36363. var CMap = function CMapClosure() {
  36364. function CMap(builtInCMap) {
  36365. this.codespaceRanges = [
  36366. [],
  36367. [],
  36368. [],
  36369. []
  36370. ];
  36371. this.numCodespaceRanges = 0;
  36372. this._map = [];
  36373. this.name = '';
  36374. this.vertical = false;
  36375. this.useCMap = null;
  36376. this.builtInCMap = builtInCMap;
  36377. }
  36378. CMap.prototype = {
  36379. addCodespaceRange: function (n, low, high) {
  36380. this.codespaceRanges[n - 1].push(low, high);
  36381. this.numCodespaceRanges++;
  36382. },
  36383. mapCidRange: function (low, high, dstLow) {
  36384. while (low <= high) {
  36385. this._map[low++] = dstLow++;
  36386. }
  36387. },
  36388. mapBfRange: function (low, high, dstLow) {
  36389. var lastByte = dstLow.length - 1;
  36390. while (low <= high) {
  36391. this._map[low++] = dstLow;
  36392. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  36393. }
  36394. },
  36395. mapBfRangeToArray: function (low, high, array) {
  36396. var i = 0, ii = array.length;
  36397. while (low <= high && i < ii) {
  36398. this._map[low] = array[i++];
  36399. ++low;
  36400. }
  36401. },
  36402. mapOne: function (src, dst) {
  36403. this._map[src] = dst;
  36404. },
  36405. lookup: function (code) {
  36406. return this._map[code];
  36407. },
  36408. contains: function (code) {
  36409. return this._map[code] !== undefined;
  36410. },
  36411. forEach: function (callback) {
  36412. var map = this._map;
  36413. var length = map.length;
  36414. var i;
  36415. if (length <= 0x10000) {
  36416. for (i = 0; i < length; i++) {
  36417. if (map[i] !== undefined) {
  36418. callback(i, map[i]);
  36419. }
  36420. }
  36421. } else {
  36422. for (i in this._map) {
  36423. callback(i, map[i]);
  36424. }
  36425. }
  36426. },
  36427. charCodeOf: function (value) {
  36428. return this._map.indexOf(value);
  36429. },
  36430. getMap: function () {
  36431. return this._map;
  36432. },
  36433. readCharCode: function (str, offset, out) {
  36434. var c = 0;
  36435. var codespaceRanges = this.codespaceRanges;
  36436. var codespaceRangesLen = this.codespaceRanges.length;
  36437. for (var n = 0; n < codespaceRangesLen; n++) {
  36438. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  36439. var codespaceRange = codespaceRanges[n];
  36440. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  36441. var low = codespaceRange[k++];
  36442. var high = codespaceRange[k++];
  36443. if (c >= low && c <= high) {
  36444. out.charcode = c;
  36445. out.length = n + 1;
  36446. return;
  36447. }
  36448. }
  36449. }
  36450. out.charcode = 0;
  36451. out.length = 1;
  36452. },
  36453. get length() {
  36454. return this._map.length;
  36455. },
  36456. get isIdentityCMap() {
  36457. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  36458. return false;
  36459. }
  36460. if (this._map.length !== 0x10000) {
  36461. return false;
  36462. }
  36463. for (var i = 0; i < 0x10000; i++) {
  36464. if (this._map[i] !== i) {
  36465. return false;
  36466. }
  36467. }
  36468. return true;
  36469. }
  36470. };
  36471. return CMap;
  36472. }();
  36473. var IdentityCMap = function IdentityCMapClosure() {
  36474. function IdentityCMap(vertical, n) {
  36475. CMap.call(this);
  36476. this.vertical = vertical;
  36477. this.addCodespaceRange(n, 0, 0xffff);
  36478. }
  36479. Util.inherit(IdentityCMap, CMap, {});
  36480. IdentityCMap.prototype = {
  36481. addCodespaceRange: CMap.prototype.addCodespaceRange,
  36482. mapCidRange: function (low, high, dstLow) {
  36483. error('should not call mapCidRange');
  36484. },
  36485. mapBfRange: function (low, high, dstLow) {
  36486. error('should not call mapBfRange');
  36487. },
  36488. mapBfRangeToArray: function (low, high, array) {
  36489. error('should not call mapBfRangeToArray');
  36490. },
  36491. mapOne: function (src, dst) {
  36492. error('should not call mapCidOne');
  36493. },
  36494. lookup: function (code) {
  36495. return isInt(code) && code <= 0xffff ? code : undefined;
  36496. },
  36497. contains: function (code) {
  36498. return isInt(code) && code <= 0xffff;
  36499. },
  36500. forEach: function (callback) {
  36501. for (var i = 0; i <= 0xffff; i++) {
  36502. callback(i, i);
  36503. }
  36504. },
  36505. charCodeOf: function (value) {
  36506. return isInt(value) && value <= 0xffff ? value : -1;
  36507. },
  36508. getMap: function () {
  36509. var map = new Array(0x10000);
  36510. for (var i = 0; i <= 0xffff; i++) {
  36511. map[i] = i;
  36512. }
  36513. return map;
  36514. },
  36515. readCharCode: CMap.prototype.readCharCode,
  36516. get length() {
  36517. return 0x10000;
  36518. },
  36519. get isIdentityCMap() {
  36520. error('should not access .isIdentityCMap');
  36521. }
  36522. };
  36523. return IdentityCMap;
  36524. }();
  36525. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  36526. function fetchBinaryData(url) {
  36527. return new Promise(function (resolve, reject) {
  36528. var request = new XMLHttpRequest();
  36529. request.open('GET', url, true);
  36530. request.responseType = 'arraybuffer';
  36531. request.onreadystatechange = function () {
  36532. if (request.readyState === XMLHttpRequest.DONE) {
  36533. if (!request.response || request.status !== 200 && request.status !== 0) {
  36534. reject(new Error('Unable to get binary cMap at: ' + url));
  36535. } else {
  36536. resolve(new Uint8Array(request.response));
  36537. }
  36538. }
  36539. };
  36540. request.send(null);
  36541. });
  36542. }
  36543. function hexToInt(a, size) {
  36544. var n = 0;
  36545. for (var i = 0; i <= size; i++) {
  36546. n = n << 8 | a[i];
  36547. }
  36548. return n >>> 0;
  36549. }
  36550. function hexToStr(a, size) {
  36551. if (size === 1) {
  36552. return String.fromCharCode(a[0], a[1]);
  36553. }
  36554. if (size === 3) {
  36555. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  36556. }
  36557. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  36558. }
  36559. function addHex(a, b, size) {
  36560. var c = 0;
  36561. for (var i = size; i >= 0; i--) {
  36562. c += a[i] + b[i];
  36563. a[i] = c & 255;
  36564. c >>= 8;
  36565. }
  36566. }
  36567. function incHex(a, size) {
  36568. var c = 1;
  36569. for (var i = size; i >= 0 && c > 0; i--) {
  36570. c += a[i];
  36571. a[i] = c & 255;
  36572. c >>= 8;
  36573. }
  36574. }
  36575. var MAX_NUM_SIZE = 16;
  36576. var MAX_ENCODED_NUM_SIZE = 19;
  36577. function BinaryCMapStream(data) {
  36578. this.buffer = data;
  36579. this.pos = 0;
  36580. this.end = data.length;
  36581. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  36582. }
  36583. BinaryCMapStream.prototype = {
  36584. readByte: function () {
  36585. if (this.pos >= this.end) {
  36586. return -1;
  36587. }
  36588. return this.buffer[this.pos++];
  36589. },
  36590. readNumber: function () {
  36591. var n = 0;
  36592. var last;
  36593. do {
  36594. var b = this.readByte();
  36595. if (b < 0) {
  36596. error('unexpected EOF in bcmap');
  36597. }
  36598. last = !(b & 0x80);
  36599. n = n << 7 | b & 0x7F;
  36600. } while (!last);
  36601. return n;
  36602. },
  36603. readSigned: function () {
  36604. var n = this.readNumber();
  36605. return n & 1 ? ~(n >>> 1) : n >>> 1;
  36606. },
  36607. readHex: function (num, size) {
  36608. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  36609. this.pos += size + 1;
  36610. },
  36611. readHexNumber: function (num, size) {
  36612. var last;
  36613. var stack = this.tmpBuf, sp = 0;
  36614. do {
  36615. var b = this.readByte();
  36616. if (b < 0) {
  36617. error('unexpected EOF in bcmap');
  36618. }
  36619. last = !(b & 0x80);
  36620. stack[sp++] = b & 0x7F;
  36621. } while (!last);
  36622. var i = size, buffer = 0, bufferSize = 0;
  36623. while (i >= 0) {
  36624. while (bufferSize < 8 && stack.length > 0) {
  36625. buffer = stack[--sp] << bufferSize | buffer;
  36626. bufferSize += 7;
  36627. }
  36628. num[i] = buffer & 255;
  36629. i--;
  36630. buffer >>= 8;
  36631. bufferSize -= 8;
  36632. }
  36633. },
  36634. readHexSigned: function (num, size) {
  36635. this.readHexNumber(num, size);
  36636. var sign = num[size] & 1 ? 255 : 0;
  36637. var c = 0;
  36638. for (var i = 0; i <= size; i++) {
  36639. c = (c & 1) << 8 | num[i];
  36640. num[i] = c >> 1 ^ sign;
  36641. }
  36642. },
  36643. readString: function () {
  36644. var len = this.readNumber();
  36645. var s = '';
  36646. for (var i = 0; i < len; i++) {
  36647. s += String.fromCharCode(this.readNumber());
  36648. }
  36649. return s;
  36650. }
  36651. };
  36652. function processBinaryCMap(url, cMap, extend) {
  36653. return fetchBinaryData(url).then(function (data) {
  36654. var stream = new BinaryCMapStream(data);
  36655. var header = stream.readByte();
  36656. cMap.vertical = !!(header & 1);
  36657. var useCMap = null;
  36658. var start = new Uint8Array(MAX_NUM_SIZE);
  36659. var end = new Uint8Array(MAX_NUM_SIZE);
  36660. var char = new Uint8Array(MAX_NUM_SIZE);
  36661. var charCode = new Uint8Array(MAX_NUM_SIZE);
  36662. var tmp = new Uint8Array(MAX_NUM_SIZE);
  36663. var code;
  36664. var b;
  36665. while ((b = stream.readByte()) >= 0) {
  36666. var type = b >> 5;
  36667. if (type === 7) {
  36668. switch (b & 0x1F) {
  36669. case 0:
  36670. stream.readString();
  36671. break;
  36672. case 1:
  36673. useCMap = stream.readString();
  36674. break;
  36675. }
  36676. continue;
  36677. }
  36678. var sequence = !!(b & 0x10);
  36679. var dataSize = b & 15;
  36680. assert(dataSize + 1 <= MAX_NUM_SIZE);
  36681. var ucs2DataSize = 1;
  36682. var subitemsCount = stream.readNumber();
  36683. var i;
  36684. switch (type) {
  36685. case 0:
  36686. stream.readHex(start, dataSize);
  36687. stream.readHexNumber(end, dataSize);
  36688. addHex(end, start, dataSize);
  36689. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  36690. for (i = 1; i < subitemsCount; i++) {
  36691. incHex(end, dataSize);
  36692. stream.readHexNumber(start, dataSize);
  36693. addHex(start, end, dataSize);
  36694. stream.readHexNumber(end, dataSize);
  36695. addHex(end, start, dataSize);
  36696. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  36697. }
  36698. break;
  36699. case 1:
  36700. stream.readHex(start, dataSize);
  36701. stream.readHexNumber(end, dataSize);
  36702. addHex(end, start, dataSize);
  36703. code = stream.readNumber();
  36704. for (i = 1; i < subitemsCount; i++) {
  36705. incHex(end, dataSize);
  36706. stream.readHexNumber(start, dataSize);
  36707. addHex(start, end, dataSize);
  36708. stream.readHexNumber(end, dataSize);
  36709. addHex(end, start, dataSize);
  36710. code = stream.readNumber();
  36711. }
  36712. break;
  36713. case 2:
  36714. stream.readHex(char, dataSize);
  36715. code = stream.readNumber();
  36716. cMap.mapOne(hexToInt(char, dataSize), code);
  36717. for (i = 1; i < subitemsCount; i++) {
  36718. incHex(char, dataSize);
  36719. if (!sequence) {
  36720. stream.readHexNumber(tmp, dataSize);
  36721. addHex(char, tmp, dataSize);
  36722. }
  36723. code = stream.readSigned() + (code + 1);
  36724. cMap.mapOne(hexToInt(char, dataSize), code);
  36725. }
  36726. break;
  36727. case 3:
  36728. stream.readHex(start, dataSize);
  36729. stream.readHexNumber(end, dataSize);
  36730. addHex(end, start, dataSize);
  36731. code = stream.readNumber();
  36732. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  36733. for (i = 1; i < subitemsCount; i++) {
  36734. incHex(end, dataSize);
  36735. if (!sequence) {
  36736. stream.readHexNumber(start, dataSize);
  36737. addHex(start, end, dataSize);
  36738. } else {
  36739. start.set(end);
  36740. }
  36741. stream.readHexNumber(end, dataSize);
  36742. addHex(end, start, dataSize);
  36743. code = stream.readNumber();
  36744. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  36745. }
  36746. break;
  36747. case 4:
  36748. stream.readHex(char, ucs2DataSize);
  36749. stream.readHex(charCode, dataSize);
  36750. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  36751. for (i = 1; i < subitemsCount; i++) {
  36752. incHex(char, ucs2DataSize);
  36753. if (!sequence) {
  36754. stream.readHexNumber(tmp, ucs2DataSize);
  36755. addHex(char, tmp, ucs2DataSize);
  36756. }
  36757. incHex(charCode, dataSize);
  36758. stream.readHexSigned(tmp, dataSize);
  36759. addHex(charCode, tmp, dataSize);
  36760. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  36761. }
  36762. break;
  36763. case 5:
  36764. stream.readHex(start, ucs2DataSize);
  36765. stream.readHexNumber(end, ucs2DataSize);
  36766. addHex(end, start, ucs2DataSize);
  36767. stream.readHex(charCode, dataSize);
  36768. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  36769. for (i = 1; i < subitemsCount; i++) {
  36770. incHex(end, ucs2DataSize);
  36771. if (!sequence) {
  36772. stream.readHexNumber(start, ucs2DataSize);
  36773. addHex(start, end, ucs2DataSize);
  36774. } else {
  36775. start.set(end);
  36776. }
  36777. stream.readHexNumber(end, ucs2DataSize);
  36778. addHex(end, start, ucs2DataSize);
  36779. stream.readHex(charCode, dataSize);
  36780. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  36781. }
  36782. break;
  36783. default:
  36784. error('Unknown type: ' + type);
  36785. break;
  36786. }
  36787. }
  36788. if (useCMap) {
  36789. return extend(useCMap);
  36790. }
  36791. return cMap;
  36792. });
  36793. }
  36794. function BinaryCMapReader() {
  36795. }
  36796. BinaryCMapReader.prototype = { read: processBinaryCMap };
  36797. return BinaryCMapReader;
  36798. }();
  36799. var CMapFactory = function CMapFactoryClosure() {
  36800. function strToInt(str) {
  36801. var a = 0;
  36802. for (var i = 0; i < str.length; i++) {
  36803. a = a << 8 | str.charCodeAt(i);
  36804. }
  36805. return a >>> 0;
  36806. }
  36807. function expectString(obj) {
  36808. if (!isString(obj)) {
  36809. error('Malformed CMap: expected string.');
  36810. }
  36811. }
  36812. function expectInt(obj) {
  36813. if (!isInt(obj)) {
  36814. error('Malformed CMap: expected int.');
  36815. }
  36816. }
  36817. function parseBfChar(cMap, lexer) {
  36818. while (true) {
  36819. var obj = lexer.getObj();
  36820. if (isEOF(obj)) {
  36821. break;
  36822. }
  36823. if (isCmd(obj, 'endbfchar')) {
  36824. return;
  36825. }
  36826. expectString(obj);
  36827. var src = strToInt(obj);
  36828. obj = lexer.getObj();
  36829. expectString(obj);
  36830. var dst = obj;
  36831. cMap.mapOne(src, dst);
  36832. }
  36833. }
  36834. function parseBfRange(cMap, lexer) {
  36835. while (true) {
  36836. var obj = lexer.getObj();
  36837. if (isEOF(obj)) {
  36838. break;
  36839. }
  36840. if (isCmd(obj, 'endbfrange')) {
  36841. return;
  36842. }
  36843. expectString(obj);
  36844. var low = strToInt(obj);
  36845. obj = lexer.getObj();
  36846. expectString(obj);
  36847. var high = strToInt(obj);
  36848. obj = lexer.getObj();
  36849. if (isInt(obj) || isString(obj)) {
  36850. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  36851. cMap.mapBfRange(low, high, dstLow);
  36852. } else if (isCmd(obj, '[')) {
  36853. obj = lexer.getObj();
  36854. var array = [];
  36855. while (!isCmd(obj, ']') && !isEOF(obj)) {
  36856. array.push(obj);
  36857. obj = lexer.getObj();
  36858. }
  36859. cMap.mapBfRangeToArray(low, high, array);
  36860. } else {
  36861. break;
  36862. }
  36863. }
  36864. error('Invalid bf range.');
  36865. }
  36866. function parseCidChar(cMap, lexer) {
  36867. while (true) {
  36868. var obj = lexer.getObj();
  36869. if (isEOF(obj)) {
  36870. break;
  36871. }
  36872. if (isCmd(obj, 'endcidchar')) {
  36873. return;
  36874. }
  36875. expectString(obj);
  36876. var src = strToInt(obj);
  36877. obj = lexer.getObj();
  36878. expectInt(obj);
  36879. var dst = obj;
  36880. cMap.mapOne(src, dst);
  36881. }
  36882. }
  36883. function parseCidRange(cMap, lexer) {
  36884. while (true) {
  36885. var obj = lexer.getObj();
  36886. if (isEOF(obj)) {
  36887. break;
  36888. }
  36889. if (isCmd(obj, 'endcidrange')) {
  36890. return;
  36891. }
  36892. expectString(obj);
  36893. var low = strToInt(obj);
  36894. obj = lexer.getObj();
  36895. expectString(obj);
  36896. var high = strToInt(obj);
  36897. obj = lexer.getObj();
  36898. expectInt(obj);
  36899. var dstLow = obj;
  36900. cMap.mapCidRange(low, high, dstLow);
  36901. }
  36902. }
  36903. function parseCodespaceRange(cMap, lexer) {
  36904. while (true) {
  36905. var obj = lexer.getObj();
  36906. if (isEOF(obj)) {
  36907. break;
  36908. }
  36909. if (isCmd(obj, 'endcodespacerange')) {
  36910. return;
  36911. }
  36912. if (!isString(obj)) {
  36913. break;
  36914. }
  36915. var low = strToInt(obj);
  36916. obj = lexer.getObj();
  36917. if (!isString(obj)) {
  36918. break;
  36919. }
  36920. var high = strToInt(obj);
  36921. cMap.addCodespaceRange(obj.length, low, high);
  36922. }
  36923. error('Invalid codespace range.');
  36924. }
  36925. function parseWMode(cMap, lexer) {
  36926. var obj = lexer.getObj();
  36927. if (isInt(obj)) {
  36928. cMap.vertical = !!obj;
  36929. }
  36930. }
  36931. function parseCMapName(cMap, lexer) {
  36932. var obj = lexer.getObj();
  36933. if (isName(obj) && isString(obj.name)) {
  36934. cMap.name = obj.name;
  36935. }
  36936. }
  36937. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  36938. var previous;
  36939. var embededUseCMap;
  36940. objLoop:
  36941. while (true) {
  36942. try {
  36943. var obj = lexer.getObj();
  36944. if (isEOF(obj)) {
  36945. break;
  36946. } else if (isName(obj)) {
  36947. if (obj.name === 'WMode') {
  36948. parseWMode(cMap, lexer);
  36949. } else if (obj.name === 'CMapName') {
  36950. parseCMapName(cMap, lexer);
  36951. }
  36952. previous = obj;
  36953. } else if (isCmd(obj)) {
  36954. switch (obj.cmd) {
  36955. case 'endcmap':
  36956. break objLoop;
  36957. case 'usecmap':
  36958. if (isName(previous)) {
  36959. embededUseCMap = previous.name;
  36960. }
  36961. break;
  36962. case 'begincodespacerange':
  36963. parseCodespaceRange(cMap, lexer);
  36964. break;
  36965. case 'beginbfchar':
  36966. parseBfChar(cMap, lexer);
  36967. break;
  36968. case 'begincidchar':
  36969. parseCidChar(cMap, lexer);
  36970. break;
  36971. case 'beginbfrange':
  36972. parseBfRange(cMap, lexer);
  36973. break;
  36974. case 'begincidrange':
  36975. parseCidRange(cMap, lexer);
  36976. break;
  36977. }
  36978. }
  36979. } catch (ex) {
  36980. if (ex instanceof MissingDataException) {
  36981. throw ex;
  36982. }
  36983. warn('Invalid cMap data: ' + ex);
  36984. continue;
  36985. }
  36986. }
  36987. if (!useCMap && embededUseCMap) {
  36988. useCMap = embededUseCMap;
  36989. }
  36990. if (useCMap) {
  36991. return extendCMap(cMap, builtInCMapParams, useCMap);
  36992. }
  36993. return Promise.resolve(cMap);
  36994. }
  36995. function extendCMap(cMap, builtInCMapParams, useCMap) {
  36996. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  36997. cMap.useCMap = newCMap;
  36998. if (cMap.numCodespaceRanges === 0) {
  36999. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  37000. for (var i = 0; i < useCodespaceRanges.length; i++) {
  37001. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  37002. }
  37003. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  37004. }
  37005. cMap.useCMap.forEach(function (key, value) {
  37006. if (!cMap.contains(key)) {
  37007. cMap.mapOne(key, cMap.useCMap.lookup(key));
  37008. }
  37009. });
  37010. return cMap;
  37011. });
  37012. }
  37013. function parseBinaryCMap(name, builtInCMapParams) {
  37014. var url = builtInCMapParams.url + name + '.bcmap';
  37015. var cMap = new CMap(true);
  37016. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  37017. return extendCMap(cMap, builtInCMapParams, useCMap);
  37018. });
  37019. }
  37020. function createBuiltInCMap(name, builtInCMapParams) {
  37021. if (name === 'Identity-H') {
  37022. return Promise.resolve(new IdentityCMap(false, 2));
  37023. } else if (name === 'Identity-V') {
  37024. return Promise.resolve(new IdentityCMap(true, 2));
  37025. }
  37026. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  37027. return Promise.reject(new Error('Unknown cMap name: ' + name));
  37028. }
  37029. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  37030. if (builtInCMapParams.packed) {
  37031. return parseBinaryCMap(name, builtInCMapParams);
  37032. }
  37033. return new Promise(function (resolve, reject) {
  37034. var url = builtInCMapParams.url + name;
  37035. var request = new XMLHttpRequest();
  37036. request.onreadystatechange = function () {
  37037. if (request.readyState === XMLHttpRequest.DONE) {
  37038. if (request.status === 200 || request.status === 0) {
  37039. var cMap = new CMap(true);
  37040. var lexer = new Lexer(new StringStream(request.responseText));
  37041. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  37042. resolve(parsedCMap);
  37043. });
  37044. } else {
  37045. reject(new Error('Unable to get cMap at: ' + url));
  37046. }
  37047. }
  37048. };
  37049. request.open('GET', url, true);
  37050. request.send(null);
  37051. });
  37052. }
  37053. return {
  37054. create: function (encoding, builtInCMapParams, useCMap) {
  37055. if (isName(encoding)) {
  37056. return createBuiltInCMap(encoding.name, builtInCMapParams);
  37057. } else if (isStream(encoding)) {
  37058. var cMap = new CMap();
  37059. var lexer = new Lexer(encoding);
  37060. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  37061. if (parsedCMap.isIdentityCMap) {
  37062. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  37063. }
  37064. return parsedCMap;
  37065. });
  37066. }
  37067. return Promise.reject(new Error('Encoding required.'));
  37068. }
  37069. };
  37070. }();
  37071. exports.CMap = CMap;
  37072. exports.CMapFactory = CMapFactory;
  37073. exports.IdentityCMap = IdentityCMap;
  37074. }));
  37075. (function (root, factory) {
  37076. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  37077. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  37078. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  37079. var FontType = sharedUtil.FontType;
  37080. var assert = sharedUtil.assert;
  37081. var bytesToString = sharedUtil.bytesToString;
  37082. var error = sharedUtil.error;
  37083. var info = sharedUtil.info;
  37084. var isArray = sharedUtil.isArray;
  37085. var isInt = sharedUtil.isInt;
  37086. var isNum = sharedUtil.isNum;
  37087. var readUint32 = sharedUtil.readUint32;
  37088. var shadow = sharedUtil.shadow;
  37089. var string32 = sharedUtil.string32;
  37090. var warn = sharedUtil.warn;
  37091. var MissingDataException = sharedUtil.MissingDataException;
  37092. var isSpace = sharedUtil.isSpace;
  37093. var Stream = coreStream.Stream;
  37094. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  37095. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  37096. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  37097. var StandardEncoding = coreEncodings.StandardEncoding;
  37098. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  37099. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  37100. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  37101. var getEncoding = coreEncodings.getEncoding;
  37102. var getStdFontMap = coreStandardFonts.getStdFontMap;
  37103. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  37104. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  37105. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  37106. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  37107. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  37108. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  37109. var Type1Parser = coreType1Parser.Type1Parser;
  37110. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  37111. var CFFParser = coreCFFParser.CFFParser;
  37112. var CFFCompiler = coreCFFParser.CFFCompiler;
  37113. var CFF = coreCFFParser.CFF;
  37114. var CFFHeader = coreCFFParser.CFFHeader;
  37115. var CFFTopDict = coreCFFParser.CFFTopDict;
  37116. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  37117. var CFFStrings = coreCFFParser.CFFStrings;
  37118. var CFFIndex = coreCFFParser.CFFIndex;
  37119. var CFFCharset = coreCFFParser.CFFCharset;
  37120. var PRIVATE_USE_OFFSET_START = 0xE000;
  37121. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  37122. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  37123. var PDF_GLYPH_SPACE_UNITS = 1000;
  37124. var SEAC_ANALYSIS_ENABLED = false;
  37125. var FontFlags = {
  37126. FixedPitch: 1,
  37127. Serif: 2,
  37128. Symbolic: 4,
  37129. Script: 8,
  37130. Nonsymbolic: 32,
  37131. Italic: 64,
  37132. AllCap: 65536,
  37133. SmallCap: 131072,
  37134. ForceBold: 262144
  37135. };
  37136. var MacStandardGlyphOrdering = [
  37137. '.notdef',
  37138. '.null',
  37139. 'nonmarkingreturn',
  37140. 'space',
  37141. 'exclam',
  37142. 'quotedbl',
  37143. 'numbersign',
  37144. 'dollar',
  37145. 'percent',
  37146. 'ampersand',
  37147. 'quotesingle',
  37148. 'parenleft',
  37149. 'parenright',
  37150. 'asterisk',
  37151. 'plus',
  37152. 'comma',
  37153. 'hyphen',
  37154. 'period',
  37155. 'slash',
  37156. 'zero',
  37157. 'one',
  37158. 'two',
  37159. 'three',
  37160. 'four',
  37161. 'five',
  37162. 'six',
  37163. 'seven',
  37164. 'eight',
  37165. 'nine',
  37166. 'colon',
  37167. 'semicolon',
  37168. 'less',
  37169. 'equal',
  37170. 'greater',
  37171. 'question',
  37172. 'at',
  37173. 'A',
  37174. 'B',
  37175. 'C',
  37176. 'D',
  37177. 'E',
  37178. 'F',
  37179. 'G',
  37180. 'H',
  37181. 'I',
  37182. 'J',
  37183. 'K',
  37184. 'L',
  37185. 'M',
  37186. 'N',
  37187. 'O',
  37188. 'P',
  37189. 'Q',
  37190. 'R',
  37191. 'S',
  37192. 'T',
  37193. 'U',
  37194. 'V',
  37195. 'W',
  37196. 'X',
  37197. 'Y',
  37198. 'Z',
  37199. 'bracketleft',
  37200. 'backslash',
  37201. 'bracketright',
  37202. 'asciicircum',
  37203. 'underscore',
  37204. 'grave',
  37205. 'a',
  37206. 'b',
  37207. 'c',
  37208. 'd',
  37209. 'e',
  37210. 'f',
  37211. 'g',
  37212. 'h',
  37213. 'i',
  37214. 'j',
  37215. 'k',
  37216. 'l',
  37217. 'm',
  37218. 'n',
  37219. 'o',
  37220. 'p',
  37221. 'q',
  37222. 'r',
  37223. 's',
  37224. 't',
  37225. 'u',
  37226. 'v',
  37227. 'w',
  37228. 'x',
  37229. 'y',
  37230. 'z',
  37231. 'braceleft',
  37232. 'bar',
  37233. 'braceright',
  37234. 'asciitilde',
  37235. 'Adieresis',
  37236. 'Aring',
  37237. 'Ccedilla',
  37238. 'Eacute',
  37239. 'Ntilde',
  37240. 'Odieresis',
  37241. 'Udieresis',
  37242. 'aacute',
  37243. 'agrave',
  37244. 'acircumflex',
  37245. 'adieresis',
  37246. 'atilde',
  37247. 'aring',
  37248. 'ccedilla',
  37249. 'eacute',
  37250. 'egrave',
  37251. 'ecircumflex',
  37252. 'edieresis',
  37253. 'iacute',
  37254. 'igrave',
  37255. 'icircumflex',
  37256. 'idieresis',
  37257. 'ntilde',
  37258. 'oacute',
  37259. 'ograve',
  37260. 'ocircumflex',
  37261. 'odieresis',
  37262. 'otilde',
  37263. 'uacute',
  37264. 'ugrave',
  37265. 'ucircumflex',
  37266. 'udieresis',
  37267. 'dagger',
  37268. 'degree',
  37269. 'cent',
  37270. 'sterling',
  37271. 'section',
  37272. 'bullet',
  37273. 'paragraph',
  37274. 'germandbls',
  37275. 'registered',
  37276. 'copyright',
  37277. 'trademark',
  37278. 'acute',
  37279. 'dieresis',
  37280. 'notequal',
  37281. 'AE',
  37282. 'Oslash',
  37283. 'infinity',
  37284. 'plusminus',
  37285. 'lessequal',
  37286. 'greaterequal',
  37287. 'yen',
  37288. 'mu',
  37289. 'partialdiff',
  37290. 'summation',
  37291. 'product',
  37292. 'pi',
  37293. 'integral',
  37294. 'ordfeminine',
  37295. 'ordmasculine',
  37296. 'Omega',
  37297. 'ae',
  37298. 'oslash',
  37299. 'questiondown',
  37300. 'exclamdown',
  37301. 'logicalnot',
  37302. 'radical',
  37303. 'florin',
  37304. 'approxequal',
  37305. 'Delta',
  37306. 'guillemotleft',
  37307. 'guillemotright',
  37308. 'ellipsis',
  37309. 'nonbreakingspace',
  37310. 'Agrave',
  37311. 'Atilde',
  37312. 'Otilde',
  37313. 'OE',
  37314. 'oe',
  37315. 'endash',
  37316. 'emdash',
  37317. 'quotedblleft',
  37318. 'quotedblright',
  37319. 'quoteleft',
  37320. 'quoteright',
  37321. 'divide',
  37322. 'lozenge',
  37323. 'ydieresis',
  37324. 'Ydieresis',
  37325. 'fraction',
  37326. 'currency',
  37327. 'guilsinglleft',
  37328. 'guilsinglright',
  37329. 'fi',
  37330. 'fl',
  37331. 'daggerdbl',
  37332. 'periodcentered',
  37333. 'quotesinglbase',
  37334. 'quotedblbase',
  37335. 'perthousand',
  37336. 'Acircumflex',
  37337. 'Ecircumflex',
  37338. 'Aacute',
  37339. 'Edieresis',
  37340. 'Egrave',
  37341. 'Iacute',
  37342. 'Icircumflex',
  37343. 'Idieresis',
  37344. 'Igrave',
  37345. 'Oacute',
  37346. 'Ocircumflex',
  37347. 'apple',
  37348. 'Ograve',
  37349. 'Uacute',
  37350. 'Ucircumflex',
  37351. 'Ugrave',
  37352. 'dotlessi',
  37353. 'circumflex',
  37354. 'tilde',
  37355. 'macron',
  37356. 'breve',
  37357. 'dotaccent',
  37358. 'ring',
  37359. 'cedilla',
  37360. 'hungarumlaut',
  37361. 'ogonek',
  37362. 'caron',
  37363. 'Lslash',
  37364. 'lslash',
  37365. 'Scaron',
  37366. 'scaron',
  37367. 'Zcaron',
  37368. 'zcaron',
  37369. 'brokenbar',
  37370. 'Eth',
  37371. 'eth',
  37372. 'Yacute',
  37373. 'yacute',
  37374. 'Thorn',
  37375. 'thorn',
  37376. 'minus',
  37377. 'multiply',
  37378. 'onesuperior',
  37379. 'twosuperior',
  37380. 'threesuperior',
  37381. 'onehalf',
  37382. 'onequarter',
  37383. 'threequarters',
  37384. 'franc',
  37385. 'Gbreve',
  37386. 'gbreve',
  37387. 'Idotaccent',
  37388. 'Scedilla',
  37389. 'scedilla',
  37390. 'Cacute',
  37391. 'cacute',
  37392. 'Ccaron',
  37393. 'ccaron',
  37394. 'dcroat'
  37395. ];
  37396. function adjustWidths(properties) {
  37397. if (!properties.fontMatrix) {
  37398. return;
  37399. }
  37400. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  37401. return;
  37402. }
  37403. var scale = 0.001 / properties.fontMatrix[0];
  37404. var glyphsWidths = properties.widths;
  37405. for (var glyph in glyphsWidths) {
  37406. glyphsWidths[glyph] *= scale;
  37407. }
  37408. properties.defaultWidth *= scale;
  37409. }
  37410. function adjustToUnicode(properties, builtInEncoding) {
  37411. if (properties.hasIncludedToUnicodeMap) {
  37412. return;
  37413. }
  37414. if (properties.hasEncoding) {
  37415. return;
  37416. }
  37417. if (builtInEncoding === properties.defaultEncoding) {
  37418. return;
  37419. }
  37420. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  37421. return;
  37422. }
  37423. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  37424. for (var charCode in builtInEncoding) {
  37425. var glyphName = builtInEncoding[charCode];
  37426. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  37427. if (unicode !== -1) {
  37428. toUnicode[charCode] = String.fromCharCode(unicode);
  37429. }
  37430. }
  37431. properties.toUnicode.amend(toUnicode);
  37432. }
  37433. function getFontType(type, subtype) {
  37434. switch (type) {
  37435. case 'Type1':
  37436. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  37437. case 'CIDFontType0':
  37438. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  37439. case 'OpenType':
  37440. return FontType.OPENTYPE;
  37441. case 'TrueType':
  37442. return FontType.TRUETYPE;
  37443. case 'CIDFontType2':
  37444. return FontType.CIDFONTTYPE2;
  37445. case 'MMType1':
  37446. return FontType.MMTYPE1;
  37447. case 'Type0':
  37448. return FontType.TYPE0;
  37449. default:
  37450. return FontType.UNKNOWN;
  37451. }
  37452. }
  37453. function recoverGlyphName(name, glyphsUnicodeMap) {
  37454. if (glyphsUnicodeMap[name] !== undefined) {
  37455. return name;
  37456. }
  37457. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  37458. if (unicode !== -1) {
  37459. for (var key in glyphsUnicodeMap) {
  37460. if (glyphsUnicodeMap[key] === unicode) {
  37461. return key;
  37462. }
  37463. }
  37464. }
  37465. info('Unable to recover a standard glyph name for: ' + name);
  37466. return name;
  37467. }
  37468. var Glyph = function GlyphClosure() {
  37469. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  37470. this.fontChar = fontChar;
  37471. this.unicode = unicode;
  37472. this.accent = accent;
  37473. this.width = width;
  37474. this.vmetric = vmetric;
  37475. this.operatorListId = operatorListId;
  37476. this.isSpace = isSpace;
  37477. this.isInFont = isInFont;
  37478. }
  37479. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  37480. 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;
  37481. };
  37482. return Glyph;
  37483. }();
  37484. var ToUnicodeMap = function ToUnicodeMapClosure() {
  37485. function ToUnicodeMap(cmap) {
  37486. this._map = cmap;
  37487. }
  37488. ToUnicodeMap.prototype = {
  37489. get length() {
  37490. return this._map.length;
  37491. },
  37492. forEach: function (callback) {
  37493. for (var charCode in this._map) {
  37494. callback(charCode, this._map[charCode].charCodeAt(0));
  37495. }
  37496. },
  37497. has: function (i) {
  37498. return this._map[i] !== undefined;
  37499. },
  37500. get: function (i) {
  37501. return this._map[i];
  37502. },
  37503. charCodeOf: function (v) {
  37504. return this._map.indexOf(v);
  37505. },
  37506. amend: function (map) {
  37507. for (var charCode in map) {
  37508. this._map[charCode] = map[charCode];
  37509. }
  37510. }
  37511. };
  37512. return ToUnicodeMap;
  37513. }();
  37514. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  37515. function IdentityToUnicodeMap(firstChar, lastChar) {
  37516. this.firstChar = firstChar;
  37517. this.lastChar = lastChar;
  37518. }
  37519. IdentityToUnicodeMap.prototype = {
  37520. get length() {
  37521. return this.lastChar + 1 - this.firstChar;
  37522. },
  37523. forEach: function (callback) {
  37524. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  37525. callback(i, i);
  37526. }
  37527. },
  37528. has: function (i) {
  37529. return this.firstChar <= i && i <= this.lastChar;
  37530. },
  37531. get: function (i) {
  37532. if (this.firstChar <= i && i <= this.lastChar) {
  37533. return String.fromCharCode(i);
  37534. }
  37535. return undefined;
  37536. },
  37537. charCodeOf: function (v) {
  37538. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  37539. },
  37540. amend: function (map) {
  37541. error('Should not call amend()');
  37542. }
  37543. };
  37544. return IdentityToUnicodeMap;
  37545. }();
  37546. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  37547. function writeInt16(dest, offset, num) {
  37548. dest[offset] = num >> 8 & 0xFF;
  37549. dest[offset + 1] = num & 0xFF;
  37550. }
  37551. function writeInt32(dest, offset, num) {
  37552. dest[offset] = num >> 24 & 0xFF;
  37553. dest[offset + 1] = num >> 16 & 0xFF;
  37554. dest[offset + 2] = num >> 8 & 0xFF;
  37555. dest[offset + 3] = num & 0xFF;
  37556. }
  37557. function writeData(dest, offset, data) {
  37558. var i, ii;
  37559. if (data instanceof Uint8Array) {
  37560. dest.set(data, offset);
  37561. } else if (typeof data === 'string') {
  37562. for (i = 0, ii = data.length; i < ii; i++) {
  37563. dest[offset++] = data.charCodeAt(i) & 0xFF;
  37564. }
  37565. } else {
  37566. for (i = 0, ii = data.length; i < ii; i++) {
  37567. dest[offset++] = data[i] & 0xFF;
  37568. }
  37569. }
  37570. }
  37571. function OpenTypeFileBuilder(sfnt) {
  37572. this.sfnt = sfnt;
  37573. this.tables = Object.create(null);
  37574. }
  37575. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  37576. var maxPower2 = 1, log2 = 0;
  37577. while ((maxPower2 ^ entriesCount) > maxPower2) {
  37578. maxPower2 <<= 1;
  37579. log2++;
  37580. }
  37581. var searchRange = maxPower2 * entrySize;
  37582. return {
  37583. range: searchRange,
  37584. entry: log2,
  37585. rangeShift: entrySize * entriesCount - searchRange
  37586. };
  37587. };
  37588. var OTF_HEADER_SIZE = 12;
  37589. var OTF_TABLE_ENTRY_SIZE = 16;
  37590. OpenTypeFileBuilder.prototype = {
  37591. toArray: function OpenTypeFileBuilder_toArray() {
  37592. var sfnt = this.sfnt;
  37593. var tables = this.tables;
  37594. var tablesNames = Object.keys(tables);
  37595. tablesNames.sort();
  37596. var numTables = tablesNames.length;
  37597. var i, j, jj, table, tableName;
  37598. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  37599. var tableOffsets = [offset];
  37600. for (i = 0; i < numTables; i++) {
  37601. table = tables[tablesNames[i]];
  37602. var paddedLength = (table.length + 3 & ~3) >>> 0;
  37603. offset += paddedLength;
  37604. tableOffsets.push(offset);
  37605. }
  37606. var file = new Uint8Array(offset);
  37607. for (i = 0; i < numTables; i++) {
  37608. table = tables[tablesNames[i]];
  37609. writeData(file, tableOffsets[i], table);
  37610. }
  37611. if (sfnt === 'true') {
  37612. sfnt = string32(0x00010000);
  37613. }
  37614. file[0] = sfnt.charCodeAt(0) & 0xFF;
  37615. file[1] = sfnt.charCodeAt(1) & 0xFF;
  37616. file[2] = sfnt.charCodeAt(2) & 0xFF;
  37617. file[3] = sfnt.charCodeAt(3) & 0xFF;
  37618. writeInt16(file, 4, numTables);
  37619. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  37620. writeInt16(file, 6, searchParams.range);
  37621. writeInt16(file, 8, searchParams.entry);
  37622. writeInt16(file, 10, searchParams.rangeShift);
  37623. offset = OTF_HEADER_SIZE;
  37624. for (i = 0; i < numTables; i++) {
  37625. tableName = tablesNames[i];
  37626. file[offset] = tableName.charCodeAt(0) & 0xFF;
  37627. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  37628. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  37629. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  37630. var checksum = 0;
  37631. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  37632. var quad = readUint32(file, j);
  37633. checksum = checksum + quad >>> 0;
  37634. }
  37635. writeInt32(file, offset + 4, checksum);
  37636. writeInt32(file, offset + 8, tableOffsets[i]);
  37637. writeInt32(file, offset + 12, tables[tableName].length);
  37638. offset += OTF_TABLE_ENTRY_SIZE;
  37639. }
  37640. return file;
  37641. },
  37642. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  37643. if (tag in this.tables) {
  37644. throw new Error('Table ' + tag + ' already exists');
  37645. }
  37646. this.tables[tag] = data;
  37647. }
  37648. };
  37649. return OpenTypeFileBuilder;
  37650. }();
  37651. var ProblematicCharRanges = new Int32Array([
  37652. 0x0000,
  37653. 0x0020,
  37654. 0x007F,
  37655. 0x00A1,
  37656. 0x00AD,
  37657. 0x00AE,
  37658. 0x0600,
  37659. 0x0780,
  37660. 0x08A0,
  37661. 0x10A0,
  37662. 0x1780,
  37663. 0x1800,
  37664. 0x1C00,
  37665. 0x1C50,
  37666. 0x2000,
  37667. 0x2010,
  37668. 0x2011,
  37669. 0x2012,
  37670. 0x2028,
  37671. 0x2030,
  37672. 0x205F,
  37673. 0x2070,
  37674. 0x25CC,
  37675. 0x25CD,
  37676. 0x3000,
  37677. 0x3001,
  37678. 0xAA60,
  37679. 0xAA80,
  37680. 0xFFF0,
  37681. 0x10000
  37682. ]);
  37683. var Font = function FontClosure() {
  37684. function Font(name, file, properties) {
  37685. var charCode, glyphName, unicode;
  37686. this.name = name;
  37687. this.loadedName = properties.loadedName;
  37688. this.isType3Font = properties.isType3Font;
  37689. this.sizes = [];
  37690. this.missingFile = false;
  37691. this.glyphCache = Object.create(null);
  37692. var names = name.split('+');
  37693. names = names.length > 1 ? names[1] : names[0];
  37694. names = names.split(/[-,_]/g)[0];
  37695. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  37696. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  37697. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  37698. var type = properties.type;
  37699. var subtype = properties.subtype;
  37700. this.type = type;
  37701. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  37702. this.differences = properties.differences;
  37703. this.widths = properties.widths;
  37704. this.defaultWidth = properties.defaultWidth;
  37705. this.composite = properties.composite;
  37706. this.wideChars = properties.wideChars;
  37707. this.cMap = properties.cMap;
  37708. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  37709. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  37710. this.fontMatrix = properties.fontMatrix;
  37711. this.bbox = properties.bbox;
  37712. this.toUnicode = properties.toUnicode;
  37713. this.toFontChar = [];
  37714. if (properties.type === 'Type3') {
  37715. for (charCode = 0; charCode < 256; charCode++) {
  37716. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  37717. }
  37718. this.fontType = FontType.TYPE3;
  37719. return;
  37720. }
  37721. this.cidEncoding = properties.cidEncoding;
  37722. this.vertical = properties.vertical;
  37723. if (this.vertical) {
  37724. this.vmetrics = properties.vmetrics;
  37725. this.defaultVMetrics = properties.defaultVMetrics;
  37726. }
  37727. var glyphsUnicodeMap;
  37728. if (!file || file.isEmpty) {
  37729. if (file) {
  37730. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  37731. }
  37732. this.missingFile = true;
  37733. var fontName = name.replace(/[,_]/g, '-');
  37734. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  37735. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  37736. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  37737. this.bold = fontName.search(/bold/gi) !== -1;
  37738. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  37739. this.black = name.search(/Black/g) !== -1;
  37740. this.remeasure = Object.keys(this.widths).length > 0;
  37741. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  37742. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  37743. var map = [];
  37744. for (charCode in GlyphMapForStandardFonts) {
  37745. map[+charCode] = GlyphMapForStandardFonts[charCode];
  37746. }
  37747. if (/Arial-?Black/i.test(name)) {
  37748. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  37749. for (charCode in SupplementalGlyphMapForArialBlack) {
  37750. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  37751. }
  37752. }
  37753. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  37754. if (!isIdentityUnicode) {
  37755. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  37756. map[+charCode] = unicodeCharCode;
  37757. });
  37758. }
  37759. this.toFontChar = map;
  37760. this.toUnicode = new ToUnicodeMap(map);
  37761. } else if (/Symbol/i.test(fontName)) {
  37762. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  37763. } else if (/Dingbats/i.test(fontName)) {
  37764. if (/Wingdings/i.test(name)) {
  37765. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  37766. }
  37767. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  37768. } else if (isStandardFont) {
  37769. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  37770. } else {
  37771. glyphsUnicodeMap = getGlyphsUnicode();
  37772. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  37773. if (!this.composite) {
  37774. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  37775. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  37776. if (unicode !== -1) {
  37777. unicodeCharCode = unicode;
  37778. }
  37779. }
  37780. this.toFontChar[charCode] = unicodeCharCode;
  37781. }.bind(this));
  37782. }
  37783. this.loadedName = fontName.split('-')[0];
  37784. this.loading = false;
  37785. this.fontType = getFontType(type, subtype);
  37786. return;
  37787. }
  37788. if (subtype === 'Type1C') {
  37789. if (type !== 'Type1' && type !== 'MMType1') {
  37790. if (isTrueTypeFile(file)) {
  37791. subtype = 'TrueType';
  37792. } else {
  37793. type = 'Type1';
  37794. }
  37795. } else if (isOpenTypeFile(file)) {
  37796. type = subtype = 'OpenType';
  37797. }
  37798. }
  37799. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  37800. type = 'CIDFontType0';
  37801. }
  37802. if (subtype === 'OpenType') {
  37803. type = 'OpenType';
  37804. }
  37805. if (type === 'CIDFontType0') {
  37806. if (isType1File(file)) {
  37807. subtype = 'CIDFontType0';
  37808. } else if (isOpenTypeFile(file)) {
  37809. type = subtype = 'OpenType';
  37810. } else {
  37811. subtype = 'CIDFontType0C';
  37812. }
  37813. }
  37814. var data;
  37815. switch (type) {
  37816. case 'MMType1':
  37817. info('MMType1 font (' + name + '), falling back to Type1.');
  37818. case 'Type1':
  37819. case 'CIDFontType0':
  37820. this.mimetype = 'font/opentype';
  37821. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  37822. adjustWidths(properties);
  37823. data = this.convert(name, cff, properties);
  37824. break;
  37825. case 'OpenType':
  37826. case 'TrueType':
  37827. case 'CIDFontType2':
  37828. this.mimetype = 'font/opentype';
  37829. data = this.checkAndRepair(name, file, properties);
  37830. if (this.isOpenType) {
  37831. adjustWidths(properties);
  37832. type = 'OpenType';
  37833. }
  37834. break;
  37835. default:
  37836. error('Font ' + type + ' is not supported');
  37837. break;
  37838. }
  37839. this.data = data;
  37840. this.fontType = getFontType(type, subtype);
  37841. this.fontMatrix = properties.fontMatrix;
  37842. this.widths = properties.widths;
  37843. this.defaultWidth = properties.defaultWidth;
  37844. this.toUnicode = properties.toUnicode;
  37845. this.encoding = properties.baseEncoding;
  37846. this.seacMap = properties.seacMap;
  37847. this.loading = true;
  37848. }
  37849. Font.getFontID = function () {
  37850. var ID = 1;
  37851. return function Font_getFontID() {
  37852. return String(ID++);
  37853. };
  37854. }();
  37855. function int16(b0, b1) {
  37856. return (b0 << 8) + b1;
  37857. }
  37858. function signedInt16(b0, b1) {
  37859. var value = (b0 << 8) + b1;
  37860. return value & 1 << 15 ? value - 0x10000 : value;
  37861. }
  37862. function int32(b0, b1, b2, b3) {
  37863. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  37864. }
  37865. function string16(value) {
  37866. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  37867. }
  37868. function safeString16(value) {
  37869. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  37870. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  37871. }
  37872. function isTrueTypeFile(file) {
  37873. var header = file.peekBytes(4);
  37874. return readUint32(header, 0) === 0x00010000;
  37875. }
  37876. function isOpenTypeFile(file) {
  37877. var header = file.peekBytes(4);
  37878. return bytesToString(header) === 'OTTO';
  37879. }
  37880. function isType1File(file) {
  37881. var header = file.peekBytes(2);
  37882. if (header[0] === 0x25 && header[1] === 0x21) {
  37883. return true;
  37884. }
  37885. if (header[0] === 0x80 && header[1] === 0x01) {
  37886. return true;
  37887. }
  37888. return false;
  37889. }
  37890. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  37891. var toFontChar = [], unicode;
  37892. for (var i = 0, ii = encoding.length; i < ii; i++) {
  37893. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  37894. if (unicode !== -1) {
  37895. toFontChar[i] = unicode;
  37896. }
  37897. }
  37898. for (var charCode in differences) {
  37899. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  37900. if (unicode !== -1) {
  37901. toFontChar[+charCode] = unicode;
  37902. }
  37903. }
  37904. return toFontChar;
  37905. }
  37906. function isProblematicUnicodeLocation(code) {
  37907. var i = 0, j = ProblematicCharRanges.length - 1;
  37908. while (i < j) {
  37909. var c = i + j + 1 >> 1;
  37910. if (code < ProblematicCharRanges[c]) {
  37911. j = c - 1;
  37912. } else {
  37913. i = c;
  37914. }
  37915. }
  37916. return !(i & 1);
  37917. }
  37918. function adjustMapping(charCodeToGlyphId, properties) {
  37919. var toUnicode = properties.toUnicode;
  37920. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  37921. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  37922. var newMap = Object.create(null);
  37923. var toFontChar = [];
  37924. var usedFontCharCodes = [];
  37925. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  37926. for (var originalCharCode in charCodeToGlyphId) {
  37927. originalCharCode |= 0;
  37928. var glyphId = charCodeToGlyphId[originalCharCode];
  37929. var fontCharCode = originalCharCode;
  37930. var hasUnicodeValue = false;
  37931. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  37932. hasUnicodeValue = true;
  37933. var unicode = toUnicode.get(fontCharCode);
  37934. if (unicode.length === 1) {
  37935. fontCharCode = unicode.charCodeAt(0);
  37936. }
  37937. }
  37938. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  37939. do {
  37940. fontCharCode = nextAvailableFontCharCode++;
  37941. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  37942. fontCharCode = 0xF020;
  37943. nextAvailableFontCharCode = fontCharCode + 1;
  37944. }
  37945. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  37946. }
  37947. newMap[fontCharCode] = glyphId;
  37948. toFontChar[originalCharCode] = fontCharCode;
  37949. usedFontCharCodes[fontCharCode] = true;
  37950. }
  37951. return {
  37952. toFontChar: toFontChar,
  37953. charCodeToGlyphId: newMap,
  37954. nextAvailableFontCharCode: nextAvailableFontCharCode
  37955. };
  37956. }
  37957. function getRanges(glyphs, numGlyphs) {
  37958. var codes = [];
  37959. for (var charCode in glyphs) {
  37960. if (glyphs[charCode] >= numGlyphs) {
  37961. continue;
  37962. }
  37963. codes.push({
  37964. fontCharCode: charCode | 0,
  37965. glyphId: glyphs[charCode]
  37966. });
  37967. }
  37968. codes.sort(function fontGetRangesSort(a, b) {
  37969. return a.fontCharCode - b.fontCharCode;
  37970. });
  37971. var ranges = [];
  37972. var length = codes.length;
  37973. for (var n = 0; n < length;) {
  37974. var start = codes[n].fontCharCode;
  37975. var codeIndices = [codes[n].glyphId];
  37976. ++n;
  37977. var end = start;
  37978. while (n < length && end + 1 === codes[n].fontCharCode) {
  37979. codeIndices.push(codes[n].glyphId);
  37980. ++end;
  37981. ++n;
  37982. if (end === 0xFFFF) {
  37983. break;
  37984. }
  37985. }
  37986. ranges.push([
  37987. start,
  37988. end,
  37989. codeIndices
  37990. ]);
  37991. }
  37992. return ranges;
  37993. }
  37994. function createCmapTable(glyphs, numGlyphs) {
  37995. var ranges = getRanges(glyphs, numGlyphs);
  37996. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  37997. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  37998. var i, ii, j, jj;
  37999. for (i = ranges.length - 1; i >= 0; --i) {
  38000. if (ranges[i][0] <= 0xFFFF) {
  38001. break;
  38002. }
  38003. }
  38004. var bmpLength = i + 1;
  38005. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  38006. ranges[i][1] = 0xFFFE;
  38007. }
  38008. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  38009. var segCount = bmpLength + trailingRangesCount;
  38010. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  38011. var startCount = '';
  38012. var endCount = '';
  38013. var idDeltas = '';
  38014. var idRangeOffsets = '';
  38015. var glyphsIds = '';
  38016. var bias = 0;
  38017. var range, start, end, codes;
  38018. for (i = 0, ii = bmpLength; i < ii; i++) {
  38019. range = ranges[i];
  38020. start = range[0];
  38021. end = range[1];
  38022. startCount += string16(start);
  38023. endCount += string16(end);
  38024. codes = range[2];
  38025. var contiguous = true;
  38026. for (j = 1, jj = codes.length; j < jj; ++j) {
  38027. if (codes[j] !== codes[j - 1] + 1) {
  38028. contiguous = false;
  38029. break;
  38030. }
  38031. }
  38032. if (!contiguous) {
  38033. var offset = (segCount - i) * 2 + bias * 2;
  38034. bias += end - start + 1;
  38035. idDeltas += string16(0);
  38036. idRangeOffsets += string16(offset);
  38037. for (j = 0, jj = codes.length; j < jj; ++j) {
  38038. glyphsIds += string16(codes[j]);
  38039. }
  38040. } else {
  38041. var startCode = codes[0];
  38042. idDeltas += string16(startCode - start & 0xFFFF);
  38043. idRangeOffsets += string16(0);
  38044. }
  38045. }
  38046. if (trailingRangesCount > 0) {
  38047. endCount += '\xFF\xFF';
  38048. startCount += '\xFF\xFF';
  38049. idDeltas += '\x00\x01';
  38050. idRangeOffsets += '\x00\x00';
  38051. }
  38052. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  38053. var format31012 = '';
  38054. var header31012 = '';
  38055. if (numTables > 1) {
  38056. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  38057. format31012 = '';
  38058. for (i = 0, ii = ranges.length; i < ii; i++) {
  38059. range = ranges[i];
  38060. start = range[0];
  38061. codes = range[2];
  38062. var code = codes[0];
  38063. for (j = 1, jj = codes.length; j < jj; ++j) {
  38064. if (codes[j] !== codes[j - 1] + 1) {
  38065. end = range[0] + j - 1;
  38066. format31012 += string32(start) + string32(end) + string32(code);
  38067. start = end + 1;
  38068. code = codes[j];
  38069. }
  38070. }
  38071. format31012 += string32(start) + string32(range[1]) + string32(code);
  38072. }
  38073. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  38074. }
  38075. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  38076. }
  38077. function validateOS2Table(os2) {
  38078. var stream = new Stream(os2.data);
  38079. var version = stream.getUint16();
  38080. stream.getBytes(60);
  38081. var selection = stream.getUint16();
  38082. if (version < 4 && selection & 0x0300) {
  38083. return false;
  38084. }
  38085. var firstChar = stream.getUint16();
  38086. var lastChar = stream.getUint16();
  38087. if (firstChar > lastChar) {
  38088. return false;
  38089. }
  38090. stream.getBytes(6);
  38091. var usWinAscent = stream.getUint16();
  38092. if (usWinAscent === 0) {
  38093. return false;
  38094. }
  38095. os2.data[8] = os2.data[9] = 0;
  38096. return true;
  38097. }
  38098. function createOS2Table(properties, charstrings, override) {
  38099. override = override || {
  38100. unitsPerEm: 0,
  38101. yMax: 0,
  38102. yMin: 0,
  38103. ascent: 0,
  38104. descent: 0
  38105. };
  38106. var ulUnicodeRange1 = 0;
  38107. var ulUnicodeRange2 = 0;
  38108. var ulUnicodeRange3 = 0;
  38109. var ulUnicodeRange4 = 0;
  38110. var firstCharIndex = null;
  38111. var lastCharIndex = 0;
  38112. if (charstrings) {
  38113. for (var code in charstrings) {
  38114. code |= 0;
  38115. if (firstCharIndex > code || !firstCharIndex) {
  38116. firstCharIndex = code;
  38117. }
  38118. if (lastCharIndex < code) {
  38119. lastCharIndex = code;
  38120. }
  38121. var position = getUnicodeRangeFor(code);
  38122. if (position < 32) {
  38123. ulUnicodeRange1 |= 1 << position;
  38124. } else if (position < 64) {
  38125. ulUnicodeRange2 |= 1 << position - 32;
  38126. } else if (position < 96) {
  38127. ulUnicodeRange3 |= 1 << position - 64;
  38128. } else if (position < 123) {
  38129. ulUnicodeRange4 |= 1 << position - 96;
  38130. } else {
  38131. error('Unicode ranges Bits > 123 are reserved for internal usage');
  38132. }
  38133. }
  38134. } else {
  38135. firstCharIndex = 0;
  38136. lastCharIndex = 255;
  38137. }
  38138. var bbox = properties.bbox || [
  38139. 0,
  38140. 0,
  38141. 0,
  38142. 0
  38143. ];
  38144. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  38145. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  38146. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  38147. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  38148. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  38149. typoDescent = -typoDescent;
  38150. }
  38151. var winAscent = override.yMax || typoAscent;
  38152. var winDescent = -override.yMin || -typoDescent;
  38153. 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';
  38154. }
  38155. function createPostTable(properties) {
  38156. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  38157. 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';
  38158. }
  38159. function createNameTable(name, proto) {
  38160. if (!proto) {
  38161. proto = [
  38162. [],
  38163. []
  38164. ];
  38165. }
  38166. var strings = [
  38167. proto[0][0] || 'Original licence',
  38168. proto[0][1] || name,
  38169. proto[0][2] || 'Unknown',
  38170. proto[0][3] || 'uniqueID',
  38171. proto[0][4] || name,
  38172. proto[0][5] || 'Version 0.11',
  38173. proto[0][6] || '',
  38174. proto[0][7] || 'Unknown',
  38175. proto[0][8] || 'Unknown',
  38176. proto[0][9] || 'Unknown'
  38177. ];
  38178. var stringsUnicode = [];
  38179. var i, ii, j, jj, str;
  38180. for (i = 0, ii = strings.length; i < ii; i++) {
  38181. str = proto[1][i] || strings[i];
  38182. var strBufUnicode = [];
  38183. for (j = 0, jj = str.length; j < jj; j++) {
  38184. strBufUnicode.push(string16(str.charCodeAt(j)));
  38185. }
  38186. stringsUnicode.push(strBufUnicode.join(''));
  38187. }
  38188. var names = [
  38189. strings,
  38190. stringsUnicode
  38191. ];
  38192. var platforms = [
  38193. '\x00\x01',
  38194. '\x00\x03'
  38195. ];
  38196. var encodings = [
  38197. '\x00\x00',
  38198. '\x00\x01'
  38199. ];
  38200. var languages = [
  38201. '\x00\x00',
  38202. '\x04\x09'
  38203. ];
  38204. var namesRecordCount = strings.length * platforms.length;
  38205. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  38206. var strOffset = 0;
  38207. for (i = 0, ii = platforms.length; i < ii; i++) {
  38208. var strs = names[i];
  38209. for (j = 0, jj = strs.length; j < jj; j++) {
  38210. str = strs[j];
  38211. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  38212. nameTable += nameRecord;
  38213. strOffset += str.length;
  38214. }
  38215. }
  38216. nameTable += strings.join('') + stringsUnicode.join('');
  38217. return nameTable;
  38218. }
  38219. Font.prototype = {
  38220. name: null,
  38221. font: null,
  38222. mimetype: null,
  38223. encoding: null,
  38224. get renderer() {
  38225. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  38226. return shadow(this, 'renderer', renderer);
  38227. },
  38228. exportData: function Font_exportData() {
  38229. var data = {};
  38230. for (var i in this) {
  38231. if (this.hasOwnProperty(i)) {
  38232. data[i] = this[i];
  38233. }
  38234. }
  38235. return data;
  38236. },
  38237. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  38238. function readTableEntry(file) {
  38239. var tag = bytesToString(file.getBytes(4));
  38240. var checksum = file.getInt32() >>> 0;
  38241. var offset = file.getInt32() >>> 0;
  38242. var length = file.getInt32() >>> 0;
  38243. var previousPosition = file.pos;
  38244. file.pos = file.start ? file.start : 0;
  38245. file.skip(offset);
  38246. var data = file.getBytes(length);
  38247. file.pos = previousPosition;
  38248. if (tag === 'head') {
  38249. data[8] = data[9] = data[10] = data[11] = 0;
  38250. data[17] |= 0x20;
  38251. }
  38252. return {
  38253. tag: tag,
  38254. checksum: checksum,
  38255. length: length,
  38256. offset: offset,
  38257. data: data
  38258. };
  38259. }
  38260. function readOpenTypeHeader(ttf) {
  38261. return {
  38262. version: bytesToString(ttf.getBytes(4)),
  38263. numTables: ttf.getUint16(),
  38264. searchRange: ttf.getUint16(),
  38265. entrySelector: ttf.getUint16(),
  38266. rangeShift: ttf.getUint16()
  38267. };
  38268. }
  38269. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  38270. if (!cmap) {
  38271. warn('No cmap table available.');
  38272. return {
  38273. platformId: -1,
  38274. encodingId: -1,
  38275. mappings: [],
  38276. hasShortCmap: false
  38277. };
  38278. }
  38279. var segment;
  38280. var start = (font.start ? font.start : 0) + cmap.offset;
  38281. font.pos = start;
  38282. var version = font.getUint16();
  38283. var numTables = font.getUint16();
  38284. var potentialTable;
  38285. var canBreak = false;
  38286. for (var i = 0; i < numTables; i++) {
  38287. var platformId = font.getUint16();
  38288. var encodingId = font.getUint16();
  38289. var offset = font.getInt32() >>> 0;
  38290. var useTable = false;
  38291. if (platformId === 0 && encodingId === 0) {
  38292. useTable = true;
  38293. } else if (platformId === 1 && encodingId === 0) {
  38294. useTable = true;
  38295. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  38296. useTable = true;
  38297. if (!isSymbolicFont) {
  38298. canBreak = true;
  38299. }
  38300. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  38301. useTable = true;
  38302. canBreak = true;
  38303. }
  38304. if (useTable) {
  38305. potentialTable = {
  38306. platformId: platformId,
  38307. encodingId: encodingId,
  38308. offset: offset
  38309. };
  38310. }
  38311. if (canBreak) {
  38312. break;
  38313. }
  38314. }
  38315. if (potentialTable) {
  38316. font.pos = start + potentialTable.offset;
  38317. }
  38318. if (!potentialTable || font.peekByte() === -1) {
  38319. warn('Could not find a preferred cmap table.');
  38320. return {
  38321. platformId: -1,
  38322. encodingId: -1,
  38323. mappings: [],
  38324. hasShortCmap: false
  38325. };
  38326. }
  38327. var format = font.getUint16();
  38328. var length = font.getUint16();
  38329. var language = font.getUint16();
  38330. var hasShortCmap = false;
  38331. var mappings = [];
  38332. var j, glyphId;
  38333. if (format === 0) {
  38334. for (j = 0; j < 256; j++) {
  38335. var index = font.getByte();
  38336. if (!index) {
  38337. continue;
  38338. }
  38339. mappings.push({
  38340. charCode: j,
  38341. glyphId: index
  38342. });
  38343. }
  38344. hasShortCmap = true;
  38345. } else if (format === 4) {
  38346. var segCount = font.getUint16() >> 1;
  38347. font.getBytes(6);
  38348. var segIndex, segments = [];
  38349. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38350. segments.push({ end: font.getUint16() });
  38351. }
  38352. font.getUint16();
  38353. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38354. segments[segIndex].start = font.getUint16();
  38355. }
  38356. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38357. segments[segIndex].delta = font.getUint16();
  38358. }
  38359. var offsetsCount = 0;
  38360. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38361. segment = segments[segIndex];
  38362. var rangeOffset = font.getUint16();
  38363. if (!rangeOffset) {
  38364. segment.offsetIndex = -1;
  38365. continue;
  38366. }
  38367. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  38368. segment.offsetIndex = offsetIndex;
  38369. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  38370. }
  38371. var offsets = [];
  38372. for (j = 0; j < offsetsCount; j++) {
  38373. offsets.push(font.getUint16());
  38374. }
  38375. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38376. segment = segments[segIndex];
  38377. start = segment.start;
  38378. var end = segment.end;
  38379. var delta = segment.delta;
  38380. offsetIndex = segment.offsetIndex;
  38381. for (j = start; j <= end; j++) {
  38382. if (j === 0xFFFF) {
  38383. continue;
  38384. }
  38385. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  38386. glyphId = glyphId + delta & 0xFFFF;
  38387. if (glyphId === 0) {
  38388. continue;
  38389. }
  38390. mappings.push({
  38391. charCode: j,
  38392. glyphId: glyphId
  38393. });
  38394. }
  38395. }
  38396. } else if (format === 6) {
  38397. var firstCode = font.getUint16();
  38398. var entryCount = font.getUint16();
  38399. for (j = 0; j < entryCount; j++) {
  38400. glyphId = font.getUint16();
  38401. var charCode = firstCode + j;
  38402. mappings.push({
  38403. charCode: charCode,
  38404. glyphId: glyphId
  38405. });
  38406. }
  38407. } else {
  38408. warn('cmap table has unsupported format: ' + format);
  38409. return {
  38410. platformId: -1,
  38411. encodingId: -1,
  38412. mappings: [],
  38413. hasShortCmap: false
  38414. };
  38415. }
  38416. mappings.sort(function (a, b) {
  38417. return a.charCode - b.charCode;
  38418. });
  38419. for (i = 1; i < mappings.length; i++) {
  38420. if (mappings[i - 1].charCode === mappings[i].charCode) {
  38421. mappings.splice(i, 1);
  38422. i--;
  38423. }
  38424. }
  38425. return {
  38426. platformId: potentialTable.platformId,
  38427. encodingId: potentialTable.encodingId,
  38428. mappings: mappings,
  38429. hasShortCmap: hasShortCmap
  38430. };
  38431. }
  38432. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  38433. if (!header) {
  38434. if (metrics) {
  38435. metrics.data = null;
  38436. }
  38437. return;
  38438. }
  38439. font.pos = (font.start ? font.start : 0) + header.offset;
  38440. font.pos += header.length - 2;
  38441. var numOfMetrics = font.getUint16();
  38442. if (numOfMetrics > numGlyphs) {
  38443. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  38444. numOfMetrics = numGlyphs;
  38445. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  38446. header.data[35] = numOfMetrics & 0x00ff;
  38447. }
  38448. var numOfSidebearings = numGlyphs - numOfMetrics;
  38449. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  38450. if (numMissing > 0) {
  38451. var entries = new Uint8Array(metrics.length + numMissing * 2);
  38452. entries.set(metrics.data);
  38453. metrics.data = entries;
  38454. }
  38455. }
  38456. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  38457. if (sourceEnd - sourceStart <= 12) {
  38458. return 0;
  38459. }
  38460. var glyf = source.subarray(sourceStart, sourceEnd);
  38461. var contoursCount = glyf[0] << 8 | glyf[1];
  38462. if (contoursCount & 0x8000) {
  38463. dest.set(glyf, destStart);
  38464. return glyf.length;
  38465. }
  38466. var i, j = 10, flagsCount = 0;
  38467. for (i = 0; i < contoursCount; i++) {
  38468. var endPoint = glyf[j] << 8 | glyf[j + 1];
  38469. flagsCount = endPoint + 1;
  38470. j += 2;
  38471. }
  38472. var instructionsStart = j;
  38473. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  38474. j += 2 + instructionsLength;
  38475. var instructionsEnd = j;
  38476. var coordinatesLength = 0;
  38477. for (i = 0; i < flagsCount; i++) {
  38478. var flag = glyf[j++];
  38479. if (flag & 0xC0) {
  38480. glyf[j - 1] = flag & 0x3F;
  38481. }
  38482. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  38483. coordinatesLength += xyLength;
  38484. if (flag & 8) {
  38485. var repeat = glyf[j++];
  38486. i += repeat;
  38487. coordinatesLength += repeat * xyLength;
  38488. }
  38489. }
  38490. if (coordinatesLength === 0) {
  38491. return 0;
  38492. }
  38493. var glyphDataLength = j + coordinatesLength;
  38494. if (glyphDataLength > glyf.length) {
  38495. return 0;
  38496. }
  38497. if (!hintsValid && instructionsLength > 0) {
  38498. dest.set(glyf.subarray(0, instructionsStart), destStart);
  38499. dest.set([
  38500. 0,
  38501. 0
  38502. ], destStart + instructionsStart);
  38503. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  38504. glyphDataLength -= instructionsLength;
  38505. if (glyf.length - glyphDataLength > 3) {
  38506. glyphDataLength = glyphDataLength + 3 & ~3;
  38507. }
  38508. return glyphDataLength;
  38509. }
  38510. if (glyf.length - glyphDataLength > 3) {
  38511. glyphDataLength = glyphDataLength + 3 & ~3;
  38512. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  38513. return glyphDataLength;
  38514. }
  38515. dest.set(glyf, destStart);
  38516. return glyf.length;
  38517. }
  38518. function sanitizeHead(head, numGlyphs, locaLength) {
  38519. var data = head.data;
  38520. var version = int32(data[0], data[1], data[2], data[3]);
  38521. if (version >> 16 !== 1) {
  38522. info('Attempting to fix invalid version in head table: ' + version);
  38523. data[0] = 0;
  38524. data[1] = 1;
  38525. data[2] = 0;
  38526. data[3] = 0;
  38527. }
  38528. var indexToLocFormat = int16(data[50], data[51]);
  38529. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  38530. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  38531. var numGlyphsPlusOne = numGlyphs + 1;
  38532. if (locaLength === numGlyphsPlusOne << 1) {
  38533. data[50] = 0;
  38534. data[51] = 0;
  38535. } else if (locaLength === numGlyphsPlusOne << 2) {
  38536. data[50] = 0;
  38537. data[51] = 1;
  38538. } else {
  38539. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  38540. }
  38541. }
  38542. }
  38543. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  38544. var itemSize, itemDecode, itemEncode;
  38545. if (isGlyphLocationsLong) {
  38546. itemSize = 4;
  38547. itemDecode = function fontItemDecodeLong(data, offset) {
  38548. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  38549. };
  38550. itemEncode = function fontItemEncodeLong(data, offset, value) {
  38551. data[offset] = value >>> 24 & 0xFF;
  38552. data[offset + 1] = value >> 16 & 0xFF;
  38553. data[offset + 2] = value >> 8 & 0xFF;
  38554. data[offset + 3] = value & 0xFF;
  38555. };
  38556. } else {
  38557. itemSize = 2;
  38558. itemDecode = function fontItemDecode(data, offset) {
  38559. return data[offset] << 9 | data[offset + 1] << 1;
  38560. };
  38561. itemEncode = function fontItemEncode(data, offset, value) {
  38562. data[offset] = value >> 9 & 0xFF;
  38563. data[offset + 1] = value >> 1 & 0xFF;
  38564. };
  38565. }
  38566. var locaData = loca.data;
  38567. var locaDataSize = itemSize * (1 + numGlyphs);
  38568. if (locaData.length !== locaDataSize) {
  38569. locaData = new Uint8Array(locaDataSize);
  38570. locaData.set(loca.data.subarray(0, locaDataSize));
  38571. loca.data = locaData;
  38572. }
  38573. var oldGlyfData = glyf.data;
  38574. var oldGlyfDataLength = oldGlyfData.length;
  38575. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  38576. var startOffset = itemDecode(locaData, 0);
  38577. var writeOffset = 0;
  38578. var missingGlyphData = Object.create(null);
  38579. itemEncode(locaData, 0, writeOffset);
  38580. var i, j;
  38581. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  38582. var endOffset = itemDecode(locaData, j);
  38583. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  38584. endOffset = oldGlyfDataLength;
  38585. }
  38586. if (endOffset > oldGlyfDataLength) {
  38587. itemEncode(locaData, j, writeOffset);
  38588. startOffset = endOffset;
  38589. continue;
  38590. }
  38591. if (startOffset === endOffset) {
  38592. missingGlyphData[i] = true;
  38593. }
  38594. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  38595. writeOffset += newLength;
  38596. itemEncode(locaData, j, writeOffset);
  38597. startOffset = endOffset;
  38598. }
  38599. if (writeOffset === 0) {
  38600. var simpleGlyph = new Uint8Array([
  38601. 0,
  38602. 1,
  38603. 0,
  38604. 0,
  38605. 0,
  38606. 0,
  38607. 0,
  38608. 0,
  38609. 0,
  38610. 0,
  38611. 0,
  38612. 0,
  38613. 0,
  38614. 0,
  38615. 49,
  38616. 0
  38617. ]);
  38618. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  38619. itemEncode(locaData, j, simpleGlyph.length);
  38620. }
  38621. glyf.data = simpleGlyph;
  38622. return missingGlyphData;
  38623. }
  38624. if (dupFirstEntry) {
  38625. var firstEntryLength = itemDecode(locaData, itemSize);
  38626. if (newGlyfData.length > firstEntryLength + writeOffset) {
  38627. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  38628. } else {
  38629. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  38630. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  38631. }
  38632. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  38633. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  38634. } else {
  38635. glyf.data = newGlyfData.subarray(0, writeOffset);
  38636. }
  38637. return missingGlyphData;
  38638. }
  38639. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  38640. var start = (font.start ? font.start : 0) + post.offset;
  38641. font.pos = start;
  38642. var length = post.length, end = start + length;
  38643. var version = font.getInt32();
  38644. font.getBytes(28);
  38645. var glyphNames;
  38646. var valid = true;
  38647. var i;
  38648. switch (version) {
  38649. case 0x00010000:
  38650. glyphNames = MacStandardGlyphOrdering;
  38651. break;
  38652. case 0x00020000:
  38653. var numGlyphs = font.getUint16();
  38654. if (numGlyphs !== maxpNumGlyphs) {
  38655. valid = false;
  38656. break;
  38657. }
  38658. var glyphNameIndexes = [];
  38659. for (i = 0; i < numGlyphs; ++i) {
  38660. var index = font.getUint16();
  38661. if (index >= 32768) {
  38662. valid = false;
  38663. break;
  38664. }
  38665. glyphNameIndexes.push(index);
  38666. }
  38667. if (!valid) {
  38668. break;
  38669. }
  38670. var customNames = [];
  38671. var strBuf = [];
  38672. while (font.pos < end) {
  38673. var stringLength = font.getByte();
  38674. strBuf.length = stringLength;
  38675. for (i = 0; i < stringLength; ++i) {
  38676. strBuf[i] = String.fromCharCode(font.getByte());
  38677. }
  38678. customNames.push(strBuf.join(''));
  38679. }
  38680. glyphNames = [];
  38681. for (i = 0; i < numGlyphs; ++i) {
  38682. var j = glyphNameIndexes[i];
  38683. if (j < 258) {
  38684. glyphNames.push(MacStandardGlyphOrdering[j]);
  38685. continue;
  38686. }
  38687. glyphNames.push(customNames[j - 258]);
  38688. }
  38689. break;
  38690. case 0x00030000:
  38691. break;
  38692. default:
  38693. warn('Unknown/unsupported post table version ' + version);
  38694. valid = false;
  38695. if (properties.defaultEncoding) {
  38696. glyphNames = properties.defaultEncoding;
  38697. }
  38698. break;
  38699. }
  38700. properties.glyphNames = glyphNames;
  38701. return valid;
  38702. }
  38703. function readNameTable(nameTable) {
  38704. var start = (font.start ? font.start : 0) + nameTable.offset;
  38705. font.pos = start;
  38706. var names = [
  38707. [],
  38708. []
  38709. ];
  38710. var length = nameTable.length, end = start + length;
  38711. var format = font.getUint16();
  38712. var FORMAT_0_HEADER_LENGTH = 6;
  38713. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  38714. return names;
  38715. }
  38716. var numRecords = font.getUint16();
  38717. var stringsStart = font.getUint16();
  38718. var records = [];
  38719. var NAME_RECORD_LENGTH = 12;
  38720. var i, ii;
  38721. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  38722. var r = {
  38723. platform: font.getUint16(),
  38724. encoding: font.getUint16(),
  38725. language: font.getUint16(),
  38726. name: font.getUint16(),
  38727. length: font.getUint16(),
  38728. offset: font.getUint16()
  38729. };
  38730. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  38731. records.push(r);
  38732. }
  38733. }
  38734. for (i = 0, ii = records.length; i < ii; i++) {
  38735. var record = records[i];
  38736. if (record.length <= 0) {
  38737. continue;
  38738. }
  38739. var pos = start + stringsStart + record.offset;
  38740. if (pos + record.length > end) {
  38741. continue;
  38742. }
  38743. font.pos = pos;
  38744. var nameIndex = record.name;
  38745. if (record.encoding) {
  38746. var str = '';
  38747. for (var j = 0, jj = record.length; j < jj; j += 2) {
  38748. str += String.fromCharCode(font.getUint16());
  38749. }
  38750. names[1][nameIndex] = str;
  38751. } else {
  38752. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  38753. }
  38754. }
  38755. return names;
  38756. }
  38757. var TTOpsStackDeltas = [
  38758. 0,
  38759. 0,
  38760. 0,
  38761. 0,
  38762. 0,
  38763. 0,
  38764. 0,
  38765. 0,
  38766. -2,
  38767. -2,
  38768. -2,
  38769. -2,
  38770. 0,
  38771. 0,
  38772. -2,
  38773. -5,
  38774. -1,
  38775. -1,
  38776. -1,
  38777. -1,
  38778. -1,
  38779. -1,
  38780. -1,
  38781. -1,
  38782. 0,
  38783. 0,
  38784. -1,
  38785. 0,
  38786. -1,
  38787. -1,
  38788. -1,
  38789. -1,
  38790. 1,
  38791. -1,
  38792. -999,
  38793. 0,
  38794. 1,
  38795. 0,
  38796. -1,
  38797. -2,
  38798. 0,
  38799. -1,
  38800. -2,
  38801. -1,
  38802. -1,
  38803. 0,
  38804. -1,
  38805. -1,
  38806. 0,
  38807. 0,
  38808. -999,
  38809. -999,
  38810. -1,
  38811. -1,
  38812. -1,
  38813. -1,
  38814. -2,
  38815. -999,
  38816. -2,
  38817. -2,
  38818. -999,
  38819. 0,
  38820. -2,
  38821. -2,
  38822. 0,
  38823. 0,
  38824. -2,
  38825. 0,
  38826. -2,
  38827. 0,
  38828. 0,
  38829. 0,
  38830. -2,
  38831. -1,
  38832. -1,
  38833. 1,
  38834. 1,
  38835. 0,
  38836. 0,
  38837. -1,
  38838. -1,
  38839. -1,
  38840. -1,
  38841. -1,
  38842. -1,
  38843. -1,
  38844. 0,
  38845. 0,
  38846. -1,
  38847. 0,
  38848. -1,
  38849. -1,
  38850. 0,
  38851. -999,
  38852. -1,
  38853. -1,
  38854. -1,
  38855. -1,
  38856. -1,
  38857. -1,
  38858. 0,
  38859. 0,
  38860. 0,
  38861. 0,
  38862. 0,
  38863. 0,
  38864. 0,
  38865. 0,
  38866. 0,
  38867. 0,
  38868. 0,
  38869. 0,
  38870. -2,
  38871. -999,
  38872. -999,
  38873. -999,
  38874. -999,
  38875. -999,
  38876. -1,
  38877. -1,
  38878. -2,
  38879. -2,
  38880. 0,
  38881. 0,
  38882. 0,
  38883. 0,
  38884. -1,
  38885. -1,
  38886. -999,
  38887. -2,
  38888. -2,
  38889. 0,
  38890. 0,
  38891. -1,
  38892. -2,
  38893. -2,
  38894. 0,
  38895. 0,
  38896. 0,
  38897. -1,
  38898. -1,
  38899. -1,
  38900. -2
  38901. ];
  38902. function sanitizeTTProgram(table, ttContext) {
  38903. var data = table.data;
  38904. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  38905. var stack = [];
  38906. var callstack = [];
  38907. var functionsCalled = [];
  38908. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  38909. var inFDEF = false, ifLevel = 0, inELSE = 0;
  38910. for (var ii = data.length; i < ii;) {
  38911. var op = data[i++];
  38912. if (op === 0x40) {
  38913. n = data[i++];
  38914. if (inFDEF || inELSE) {
  38915. i += n;
  38916. } else {
  38917. for (j = 0; j < n; j++) {
  38918. stack.push(data[i++]);
  38919. }
  38920. }
  38921. } else if (op === 0x41) {
  38922. n = data[i++];
  38923. if (inFDEF || inELSE) {
  38924. i += n * 2;
  38925. } else {
  38926. for (j = 0; j < n; j++) {
  38927. b = data[i++];
  38928. stack.push(b << 8 | data[i++]);
  38929. }
  38930. }
  38931. } else if ((op & 0xF8) === 0xB0) {
  38932. n = op - 0xB0 + 1;
  38933. if (inFDEF || inELSE) {
  38934. i += n;
  38935. } else {
  38936. for (j = 0; j < n; j++) {
  38937. stack.push(data[i++]);
  38938. }
  38939. }
  38940. } else if ((op & 0xF8) === 0xB8) {
  38941. n = op - 0xB8 + 1;
  38942. if (inFDEF || inELSE) {
  38943. i += n * 2;
  38944. } else {
  38945. for (j = 0; j < n; j++) {
  38946. b = data[i++];
  38947. stack.push(b << 8 | data[i++]);
  38948. }
  38949. }
  38950. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  38951. if (!inFDEF && !inELSE) {
  38952. funcId = stack[stack.length - 1];
  38953. ttContext.functionsUsed[funcId] = true;
  38954. if (funcId in ttContext.functionsStackDeltas) {
  38955. stack.length += ttContext.functionsStackDeltas[funcId];
  38956. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  38957. callstack.push({
  38958. data: data,
  38959. i: i,
  38960. stackTop: stack.length - 1
  38961. });
  38962. functionsCalled.push(funcId);
  38963. pc = ttContext.functionsDefined[funcId];
  38964. if (!pc) {
  38965. warn('TT: CALL non-existent function');
  38966. ttContext.hintsValid = false;
  38967. return;
  38968. }
  38969. data = pc.data;
  38970. i = pc.i;
  38971. }
  38972. }
  38973. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  38974. if (inFDEF || inELSE) {
  38975. warn('TT: nested FDEFs not allowed');
  38976. tooComplexToFollowFunctions = true;
  38977. }
  38978. inFDEF = true;
  38979. lastDeff = i;
  38980. funcId = stack.pop();
  38981. ttContext.functionsDefined[funcId] = {
  38982. data: data,
  38983. i: i
  38984. };
  38985. } else if (op === 0x2D) {
  38986. if (inFDEF) {
  38987. inFDEF = false;
  38988. lastEndf = i;
  38989. } else {
  38990. pc = callstack.pop();
  38991. if (!pc) {
  38992. warn('TT: ENDF bad stack');
  38993. ttContext.hintsValid = false;
  38994. return;
  38995. }
  38996. funcId = functionsCalled.pop();
  38997. data = pc.data;
  38998. i = pc.i;
  38999. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  39000. }
  39001. } else if (op === 0x89) {
  39002. if (inFDEF || inELSE) {
  39003. warn('TT: nested IDEFs not allowed');
  39004. tooComplexToFollowFunctions = true;
  39005. }
  39006. inFDEF = true;
  39007. lastDeff = i;
  39008. } else if (op === 0x58) {
  39009. ++ifLevel;
  39010. } else if (op === 0x1B) {
  39011. inELSE = ifLevel;
  39012. } else if (op === 0x59) {
  39013. if (inELSE === ifLevel) {
  39014. inELSE = 0;
  39015. }
  39016. --ifLevel;
  39017. } else if (op === 0x1C) {
  39018. if (!inFDEF && !inELSE) {
  39019. var offset = stack[stack.length - 1];
  39020. if (offset > 0) {
  39021. i += offset - 1;
  39022. }
  39023. }
  39024. }
  39025. if (!inFDEF && !inELSE) {
  39026. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  39027. if (op >= 0x71 && op <= 0x75) {
  39028. n = stack.pop();
  39029. if (n === n) {
  39030. stackDelta = -n * 2;
  39031. }
  39032. }
  39033. while (stackDelta < 0 && stack.length > 0) {
  39034. stack.pop();
  39035. stackDelta++;
  39036. }
  39037. while (stackDelta > 0) {
  39038. stack.push(NaN);
  39039. stackDelta--;
  39040. }
  39041. }
  39042. }
  39043. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  39044. var content = [data];
  39045. if (i > data.length) {
  39046. content.push(new Uint8Array(i - data.length));
  39047. }
  39048. if (lastDeff > lastEndf) {
  39049. warn('TT: complementing a missing function tail');
  39050. content.push(new Uint8Array([
  39051. 0x22,
  39052. 0x2D
  39053. ]));
  39054. }
  39055. foldTTTable(table, content);
  39056. }
  39057. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  39058. if (ttContext.tooComplexToFollowFunctions) {
  39059. return;
  39060. }
  39061. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  39062. warn('TT: more functions defined than expected');
  39063. ttContext.hintsValid = false;
  39064. return;
  39065. }
  39066. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  39067. if (j > maxFunctionDefs) {
  39068. warn('TT: invalid function id: ' + j);
  39069. ttContext.hintsValid = false;
  39070. return;
  39071. }
  39072. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  39073. warn('TT: undefined function: ' + j);
  39074. ttContext.hintsValid = false;
  39075. return;
  39076. }
  39077. }
  39078. }
  39079. function foldTTTable(table, content) {
  39080. if (content.length > 1) {
  39081. var newLength = 0;
  39082. var j, jj;
  39083. for (j = 0, jj = content.length; j < jj; j++) {
  39084. newLength += content[j].length;
  39085. }
  39086. newLength = newLength + 3 & ~3;
  39087. var result = new Uint8Array(newLength);
  39088. var pos = 0;
  39089. for (j = 0, jj = content.length; j < jj; j++) {
  39090. result.set(content[j], pos);
  39091. pos += content[j].length;
  39092. }
  39093. table.data = result;
  39094. table.length = newLength;
  39095. }
  39096. }
  39097. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  39098. var ttContext = {
  39099. functionsDefined: [],
  39100. functionsUsed: [],
  39101. functionsStackDeltas: [],
  39102. tooComplexToFollowFunctions: false,
  39103. hintsValid: true
  39104. };
  39105. if (fpgm) {
  39106. sanitizeTTProgram(fpgm, ttContext);
  39107. }
  39108. if (prep) {
  39109. sanitizeTTProgram(prep, ttContext);
  39110. }
  39111. if (fpgm) {
  39112. checkInvalidFunctions(ttContext, maxFunctionDefs);
  39113. }
  39114. if (cvt && cvt.length & 1) {
  39115. var cvtData = new Uint8Array(cvt.length + 1);
  39116. cvtData.set(cvt.data);
  39117. cvt.data = cvtData;
  39118. }
  39119. return ttContext.hintsValid;
  39120. }
  39121. font = new Stream(new Uint8Array(font.getBytes()));
  39122. var VALID_TABLES = [
  39123. 'OS/2',
  39124. 'cmap',
  39125. 'head',
  39126. 'hhea',
  39127. 'hmtx',
  39128. 'maxp',
  39129. 'name',
  39130. 'post',
  39131. 'loca',
  39132. 'glyf',
  39133. 'fpgm',
  39134. 'prep',
  39135. 'cvt ',
  39136. 'CFF '
  39137. ];
  39138. var header = readOpenTypeHeader(font);
  39139. var numTables = header.numTables;
  39140. var cff, cffFile;
  39141. var tables = Object.create(null);
  39142. tables['OS/2'] = null;
  39143. tables['cmap'] = null;
  39144. tables['head'] = null;
  39145. tables['hhea'] = null;
  39146. tables['hmtx'] = null;
  39147. tables['maxp'] = null;
  39148. tables['name'] = null;
  39149. tables['post'] = null;
  39150. var table;
  39151. for (var i = 0; i < numTables; i++) {
  39152. table = readTableEntry(font);
  39153. if (VALID_TABLES.indexOf(table.tag) < 0) {
  39154. continue;
  39155. }
  39156. if (table.length === 0) {
  39157. continue;
  39158. }
  39159. tables[table.tag] = table;
  39160. }
  39161. var isTrueType = !tables['CFF '];
  39162. if (!isTrueType) {
  39163. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  39164. cffFile = new Stream(tables['CFF '].data);
  39165. cff = new CFFFont(cffFile, properties);
  39166. adjustWidths(properties);
  39167. return this.convert(name, cff, properties);
  39168. }
  39169. delete tables['glyf'];
  39170. delete tables['loca'];
  39171. delete tables['fpgm'];
  39172. delete tables['prep'];
  39173. delete tables['cvt '];
  39174. this.isOpenType = true;
  39175. } else {
  39176. if (!tables['loca']) {
  39177. error('Required "loca" table is not found');
  39178. }
  39179. if (!tables['glyf']) {
  39180. warn('Required "glyf" table is not found -- trying to recover.');
  39181. tables['glyf'] = {
  39182. tag: 'glyf',
  39183. data: new Uint8Array(0)
  39184. };
  39185. }
  39186. this.isOpenType = false;
  39187. }
  39188. if (!tables['maxp']) {
  39189. error('Required "maxp" table is not found');
  39190. }
  39191. font.pos = (font.start || 0) + tables['maxp'].offset;
  39192. var version = font.getInt32();
  39193. var numGlyphs = font.getUint16();
  39194. var maxFunctionDefs = 0;
  39195. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  39196. font.pos += 8;
  39197. var maxZones = font.getUint16();
  39198. if (maxZones > 2) {
  39199. tables['maxp'].data[14] = 0;
  39200. tables['maxp'].data[15] = 2;
  39201. }
  39202. font.pos += 4;
  39203. maxFunctionDefs = font.getUint16();
  39204. }
  39205. var dupFirstEntry = false;
  39206. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  39207. dupFirstEntry = true;
  39208. numGlyphs++;
  39209. tables['maxp'].data[4] = numGlyphs >> 8;
  39210. tables['maxp'].data[5] = numGlyphs & 255;
  39211. }
  39212. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  39213. if (!hintsValid) {
  39214. delete tables['fpgm'];
  39215. delete tables['prep'];
  39216. delete tables['cvt '];
  39217. }
  39218. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  39219. if (!tables['head']) {
  39220. error('Required "head" table is not found');
  39221. }
  39222. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  39223. var missingGlyphs = Object.create(null);
  39224. if (isTrueType) {
  39225. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  39226. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  39227. }
  39228. if (!tables['hhea']) {
  39229. error('Required "hhea" table is not found');
  39230. }
  39231. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  39232. tables['hhea'].data[10] = 0xFF;
  39233. tables['hhea'].data[11] = 0xFF;
  39234. }
  39235. var metricsOverride = {
  39236. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  39237. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  39238. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  39239. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  39240. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  39241. };
  39242. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  39243. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  39244. if (tables['post']) {
  39245. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  39246. if (!valid) {
  39247. tables['post'] = null;
  39248. }
  39249. }
  39250. var charCodeToGlyphId = [], charCode;
  39251. var toUnicode = properties.toUnicode, widths = properties.widths;
  39252. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  39253. function hasGlyph(glyphId, charCode, widthCode) {
  39254. if (!missingGlyphs[glyphId]) {
  39255. return true;
  39256. }
  39257. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  39258. return true;
  39259. }
  39260. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  39261. return true;
  39262. }
  39263. return false;
  39264. }
  39265. if (properties.type === 'CIDFontType2') {
  39266. var cidToGidMap = properties.cidToGidMap || [];
  39267. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  39268. properties.cMap.forEach(function (charCode, cid) {
  39269. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  39270. var glyphId = -1;
  39271. if (isCidToGidMapEmpty) {
  39272. glyphId = cid;
  39273. } else if (cidToGidMap[cid] !== undefined) {
  39274. glyphId = cidToGidMap[cid];
  39275. }
  39276. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  39277. charCodeToGlyphId[charCode] = glyphId;
  39278. }
  39279. });
  39280. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  39281. charCodeToGlyphId[0] = numGlyphs - 1;
  39282. }
  39283. } else {
  39284. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  39285. var cmapPlatformId = cmapTable.platformId;
  39286. var cmapEncodingId = cmapTable.encodingId;
  39287. var cmapMappings = cmapTable.mappings;
  39288. var cmapMappingsLength = cmapMappings.length;
  39289. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  39290. var baseEncoding = [];
  39291. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  39292. baseEncoding = getEncoding(properties.baseEncodingName);
  39293. }
  39294. var glyphsUnicodeMap = getGlyphsUnicode();
  39295. for (charCode = 0; charCode < 256; charCode++) {
  39296. var glyphName, standardGlyphName;
  39297. if (this.differences && charCode in this.differences) {
  39298. glyphName = this.differences[charCode];
  39299. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  39300. glyphName = baseEncoding[charCode];
  39301. } else {
  39302. glyphName = StandardEncoding[charCode];
  39303. }
  39304. if (!glyphName) {
  39305. continue;
  39306. }
  39307. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  39308. var unicodeOrCharCode, isUnicode = false;
  39309. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  39310. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  39311. isUnicode = true;
  39312. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  39313. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  39314. }
  39315. var found = false;
  39316. for (i = 0; i < cmapMappingsLength; ++i) {
  39317. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  39318. continue;
  39319. }
  39320. var code = isUnicode ? charCode : unicodeOrCharCode;
  39321. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  39322. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  39323. found = true;
  39324. break;
  39325. }
  39326. }
  39327. if (!found && properties.glyphNames) {
  39328. var glyphId = properties.glyphNames.indexOf(glyphName);
  39329. if (glyphId === -1 && standardGlyphName !== glyphName) {
  39330. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  39331. }
  39332. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  39333. charCodeToGlyphId[charCode] = glyphId;
  39334. found = true;
  39335. }
  39336. }
  39337. if (!found) {
  39338. charCodeToGlyphId[charCode] = 0;
  39339. }
  39340. }
  39341. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  39342. for (i = 0; i < cmapMappingsLength; ++i) {
  39343. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  39344. }
  39345. } else {
  39346. for (i = 0; i < cmapMappingsLength; ++i) {
  39347. charCode = cmapMappings[i].charCode & 0xFF;
  39348. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  39349. }
  39350. }
  39351. }
  39352. if (charCodeToGlyphId.length === 0) {
  39353. charCodeToGlyphId[0] = 0;
  39354. }
  39355. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  39356. this.toFontChar = newMapping.toFontChar;
  39357. tables['cmap'] = {
  39358. tag: 'cmap',
  39359. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  39360. };
  39361. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  39362. tables['OS/2'] = {
  39363. tag: 'OS/2',
  39364. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  39365. };
  39366. }
  39367. if (!tables['post']) {
  39368. tables['post'] = {
  39369. tag: 'post',
  39370. data: createPostTable(properties)
  39371. };
  39372. }
  39373. if (!isTrueType) {
  39374. try {
  39375. cffFile = new Stream(tables['CFF '].data);
  39376. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  39377. cff = parser.parse();
  39378. var compiler = new CFFCompiler(cff);
  39379. tables['CFF '].data = compiler.compile();
  39380. } catch (e) {
  39381. warn('Failed to compile font ' + properties.loadedName);
  39382. }
  39383. }
  39384. if (!tables['name']) {
  39385. tables['name'] = {
  39386. tag: 'name',
  39387. data: createNameTable(this.name)
  39388. };
  39389. } else {
  39390. var namePrototype = readNameTable(tables['name']);
  39391. tables['name'].data = createNameTable(name, namePrototype);
  39392. }
  39393. var builder = new OpenTypeFileBuilder(header.version);
  39394. for (var tableTag in tables) {
  39395. builder.addTable(tableTag, tables[tableTag].data);
  39396. }
  39397. return builder.toArray();
  39398. },
  39399. convert: function Font_convert(fontName, font, properties) {
  39400. properties.fixedPitch = false;
  39401. if (properties.builtInEncoding) {
  39402. adjustToUnicode(properties, properties.builtInEncoding);
  39403. }
  39404. var mapping = font.getGlyphMapping(properties);
  39405. var newMapping = adjustMapping(mapping, properties);
  39406. this.toFontChar = newMapping.toFontChar;
  39407. var numGlyphs = font.numGlyphs;
  39408. function getCharCodes(charCodeToGlyphId, glyphId) {
  39409. var charCodes = null;
  39410. for (var charCode in charCodeToGlyphId) {
  39411. if (glyphId === charCodeToGlyphId[charCode]) {
  39412. if (!charCodes) {
  39413. charCodes = [];
  39414. }
  39415. charCodes.push(charCode | 0);
  39416. }
  39417. }
  39418. return charCodes;
  39419. }
  39420. function createCharCode(charCodeToGlyphId, glyphId) {
  39421. for (var charCode in charCodeToGlyphId) {
  39422. if (glyphId === charCodeToGlyphId[charCode]) {
  39423. return charCode | 0;
  39424. }
  39425. }
  39426. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  39427. return newMapping.nextAvailableFontCharCode++;
  39428. }
  39429. var seacs = font.seacs;
  39430. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  39431. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  39432. var charset = font.getCharset();
  39433. var seacMap = Object.create(null);
  39434. for (var glyphId in seacs) {
  39435. glyphId |= 0;
  39436. var seac = seacs[glyphId];
  39437. var baseGlyphName = StandardEncoding[seac[2]];
  39438. var accentGlyphName = StandardEncoding[seac[3]];
  39439. var baseGlyphId = charset.indexOf(baseGlyphName);
  39440. var accentGlyphId = charset.indexOf(accentGlyphName);
  39441. if (baseGlyphId < 0 || accentGlyphId < 0) {
  39442. continue;
  39443. }
  39444. var accentOffset = {
  39445. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  39446. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  39447. };
  39448. var charCodes = getCharCodes(mapping, glyphId);
  39449. if (!charCodes) {
  39450. continue;
  39451. }
  39452. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  39453. var charCode = charCodes[i];
  39454. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  39455. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  39456. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  39457. seacMap[charCode] = {
  39458. baseFontCharCode: baseFontCharCode,
  39459. accentFontCharCode: accentFontCharCode,
  39460. accentOffset: accentOffset
  39461. };
  39462. }
  39463. }
  39464. properties.seacMap = seacMap;
  39465. }
  39466. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  39467. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  39468. builder.addTable('CFF ', font.data);
  39469. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  39470. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  39471. 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');
  39472. 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));
  39473. builder.addTable('hmtx', function fontFieldsHmtx() {
  39474. var charstrings = font.charstrings;
  39475. var cffWidths = font.cff ? font.cff.widths : null;
  39476. var hmtx = '\x00\x00\x00\x00';
  39477. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  39478. var width = 0;
  39479. if (charstrings) {
  39480. var charstring = charstrings[i - 1];
  39481. width = 'width' in charstring ? charstring.width : 0;
  39482. } else if (cffWidths) {
  39483. width = Math.ceil(cffWidths[i] || 0);
  39484. }
  39485. hmtx += string16(width) + string16(0);
  39486. }
  39487. return hmtx;
  39488. }());
  39489. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  39490. builder.addTable('name', createNameTable(fontName));
  39491. builder.addTable('post', createPostTable(properties));
  39492. return builder.toArray();
  39493. },
  39494. get spaceWidth() {
  39495. if ('_shadowWidth' in this) {
  39496. return this._shadowWidth;
  39497. }
  39498. var possibleSpaceReplacements = [
  39499. 'space',
  39500. 'minus',
  39501. 'one',
  39502. 'i',
  39503. 'I'
  39504. ];
  39505. var width;
  39506. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  39507. var glyphName = possibleSpaceReplacements[i];
  39508. if (glyphName in this.widths) {
  39509. width = this.widths[glyphName];
  39510. break;
  39511. }
  39512. var glyphsUnicodeMap = getGlyphsUnicode();
  39513. var glyphUnicode = glyphsUnicodeMap[glyphName];
  39514. var charcode = 0;
  39515. if (this.composite) {
  39516. if (this.cMap.contains(glyphUnicode)) {
  39517. charcode = this.cMap.lookup(glyphUnicode);
  39518. }
  39519. }
  39520. if (!charcode && this.toUnicode) {
  39521. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  39522. }
  39523. if (charcode <= 0) {
  39524. charcode = glyphUnicode;
  39525. }
  39526. width = this.widths[charcode];
  39527. if (width) {
  39528. break;
  39529. }
  39530. }
  39531. width = width || this.defaultWidth;
  39532. this._shadowWidth = width;
  39533. return width;
  39534. },
  39535. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  39536. var fontCharCode, width, operatorListId;
  39537. var widthCode = charcode;
  39538. if (this.cMap && this.cMap.contains(charcode)) {
  39539. widthCode = this.cMap.lookup(charcode);
  39540. }
  39541. width = this.widths[widthCode];
  39542. width = isNum(width) ? width : this.defaultWidth;
  39543. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  39544. var unicode = this.toUnicode.get(charcode) || charcode;
  39545. if (typeof unicode === 'number') {
  39546. unicode = String.fromCharCode(unicode);
  39547. }
  39548. var isInFont = charcode in this.toFontChar;
  39549. fontCharCode = this.toFontChar[charcode] || charcode;
  39550. if (this.missingFile) {
  39551. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  39552. }
  39553. if (this.isType3Font) {
  39554. operatorListId = fontCharCode;
  39555. }
  39556. var accent = null;
  39557. if (this.seacMap && this.seacMap[charcode]) {
  39558. isInFont = true;
  39559. var seac = this.seacMap[charcode];
  39560. fontCharCode = seac.baseFontCharCode;
  39561. accent = {
  39562. fontChar: String.fromCharCode(seac.accentFontCharCode),
  39563. offset: seac.accentOffset
  39564. };
  39565. }
  39566. var fontChar = String.fromCharCode(fontCharCode);
  39567. var glyph = this.glyphCache[charcode];
  39568. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  39569. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  39570. this.glyphCache[charcode] = glyph;
  39571. }
  39572. return glyph;
  39573. },
  39574. charsToGlyphs: function Font_charsToGlyphs(chars) {
  39575. var charsCache = this.charsCache;
  39576. var glyphs, glyph, charcode;
  39577. if (charsCache) {
  39578. glyphs = charsCache[chars];
  39579. if (glyphs) {
  39580. return glyphs;
  39581. }
  39582. }
  39583. if (!charsCache) {
  39584. charsCache = this.charsCache = Object.create(null);
  39585. }
  39586. glyphs = [];
  39587. var charsCacheKey = chars;
  39588. var i = 0, ii;
  39589. if (this.cMap) {
  39590. var c = Object.create(null);
  39591. while (i < chars.length) {
  39592. this.cMap.readCharCode(chars, i, c);
  39593. charcode = c.charcode;
  39594. var length = c.length;
  39595. i += length;
  39596. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  39597. glyph = this.charToGlyph(charcode, isSpace);
  39598. glyphs.push(glyph);
  39599. }
  39600. } else {
  39601. for (i = 0, ii = chars.length; i < ii; ++i) {
  39602. charcode = chars.charCodeAt(i);
  39603. glyph = this.charToGlyph(charcode, charcode === 0x20);
  39604. glyphs.push(glyph);
  39605. }
  39606. }
  39607. return charsCache[charsCacheKey] = glyphs;
  39608. }
  39609. };
  39610. return Font;
  39611. }();
  39612. var ErrorFont = function ErrorFontClosure() {
  39613. function ErrorFont(error) {
  39614. this.error = error;
  39615. this.loadedName = 'g_font_error';
  39616. this.loading = false;
  39617. }
  39618. ErrorFont.prototype = {
  39619. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  39620. return [];
  39621. },
  39622. exportData: function ErrorFont_exportData() {
  39623. return { error: this.error };
  39624. }
  39625. };
  39626. return ErrorFont;
  39627. }();
  39628. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  39629. var charCodeToGlyphId = Object.create(null);
  39630. var glyphId, charCode, baseEncoding;
  39631. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  39632. if (properties.baseEncodingName) {
  39633. baseEncoding = getEncoding(properties.baseEncodingName);
  39634. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  39635. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  39636. if (glyphId >= 0) {
  39637. charCodeToGlyphId[charCode] = glyphId;
  39638. } else {
  39639. charCodeToGlyphId[charCode] = 0;
  39640. }
  39641. }
  39642. } else if (isSymbolicFont) {
  39643. for (charCode in builtInEncoding) {
  39644. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  39645. }
  39646. } else {
  39647. baseEncoding = StandardEncoding;
  39648. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  39649. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  39650. if (glyphId >= 0) {
  39651. charCodeToGlyphId[charCode] = glyphId;
  39652. } else {
  39653. charCodeToGlyphId[charCode] = 0;
  39654. }
  39655. }
  39656. }
  39657. var differences = properties.differences, glyphsUnicodeMap;
  39658. if (differences) {
  39659. for (charCode in differences) {
  39660. var glyphName = differences[charCode];
  39661. glyphId = glyphNames.indexOf(glyphName);
  39662. if (glyphId === -1) {
  39663. if (!glyphsUnicodeMap) {
  39664. glyphsUnicodeMap = getGlyphsUnicode();
  39665. }
  39666. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  39667. if (standardGlyphName !== glyphName) {
  39668. glyphId = glyphNames.indexOf(standardGlyphName);
  39669. }
  39670. }
  39671. if (glyphId >= 0) {
  39672. charCodeToGlyphId[charCode] = glyphId;
  39673. } else {
  39674. charCodeToGlyphId[charCode] = 0;
  39675. }
  39676. }
  39677. }
  39678. return charCodeToGlyphId;
  39679. }
  39680. var Type1Font = function Type1FontClosure() {
  39681. function findBlock(streamBytes, signature, startIndex) {
  39682. var streamBytesLength = streamBytes.length;
  39683. var signatureLength = signature.length;
  39684. var scanLength = streamBytesLength - signatureLength;
  39685. var i = startIndex, j, found = false;
  39686. while (i < scanLength) {
  39687. j = 0;
  39688. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  39689. j++;
  39690. }
  39691. if (j >= signatureLength) {
  39692. i += j;
  39693. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  39694. i++;
  39695. }
  39696. found = true;
  39697. break;
  39698. }
  39699. i++;
  39700. }
  39701. return {
  39702. found: found,
  39703. length: i
  39704. };
  39705. }
  39706. function getHeaderBlock(stream, suggestedLength) {
  39707. var EEXEC_SIGNATURE = [
  39708. 0x65,
  39709. 0x65,
  39710. 0x78,
  39711. 0x65,
  39712. 0x63
  39713. ];
  39714. var streamStartPos = stream.pos;
  39715. var headerBytes, headerBytesLength, block;
  39716. try {
  39717. headerBytes = stream.getBytes(suggestedLength);
  39718. headerBytesLength = headerBytes.length;
  39719. } catch (ex) {
  39720. if (ex instanceof MissingDataException) {
  39721. throw ex;
  39722. }
  39723. }
  39724. if (headerBytesLength === suggestedLength) {
  39725. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  39726. if (block.found && block.length === suggestedLength) {
  39727. return {
  39728. stream: new Stream(headerBytes),
  39729. length: suggestedLength
  39730. };
  39731. }
  39732. }
  39733. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  39734. stream.pos = streamStartPos;
  39735. var SCAN_BLOCK_LENGTH = 2048;
  39736. var actualLength;
  39737. while (true) {
  39738. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  39739. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  39740. if (block.length === 0) {
  39741. break;
  39742. }
  39743. stream.pos += block.length;
  39744. if (block.found) {
  39745. actualLength = stream.pos - streamStartPos;
  39746. break;
  39747. }
  39748. }
  39749. stream.pos = streamStartPos;
  39750. if (actualLength) {
  39751. return {
  39752. stream: new Stream(stream.getBytes(actualLength)),
  39753. length: actualLength
  39754. };
  39755. }
  39756. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  39757. return {
  39758. stream: new Stream(stream.getBytes(suggestedLength)),
  39759. length: suggestedLength
  39760. };
  39761. }
  39762. function getEexecBlock(stream, suggestedLength) {
  39763. var eexecBytes = stream.getBytes();
  39764. return {
  39765. stream: new Stream(eexecBytes),
  39766. length: eexecBytes.length
  39767. };
  39768. }
  39769. function Type1Font(name, file, properties) {
  39770. var PFB_HEADER_SIZE = 6;
  39771. var headerBlockLength = properties.length1;
  39772. var eexecBlockLength = properties.length2;
  39773. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  39774. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  39775. if (pfbHeaderPresent) {
  39776. file.skip(PFB_HEADER_SIZE);
  39777. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  39778. }
  39779. var headerBlock = getHeaderBlock(file, headerBlockLength);
  39780. headerBlockLength = headerBlock.length;
  39781. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  39782. headerBlockParser.extractFontHeader(properties);
  39783. if (pfbHeaderPresent) {
  39784. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  39785. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  39786. }
  39787. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  39788. eexecBlockLength = eexecBlock.length;
  39789. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  39790. var data = eexecBlockParser.extractFontProgram();
  39791. for (var info in data.properties) {
  39792. properties[info] = data.properties[info];
  39793. }
  39794. var charstrings = data.charstrings;
  39795. var type2Charstrings = this.getType2Charstrings(charstrings);
  39796. var subrs = this.getType2Subrs(data.subrs);
  39797. this.charstrings = charstrings;
  39798. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  39799. this.seacs = this.getSeacs(data.charstrings);
  39800. }
  39801. Type1Font.prototype = {
  39802. get numGlyphs() {
  39803. return this.charstrings.length + 1;
  39804. },
  39805. getCharset: function Type1Font_getCharset() {
  39806. var charset = ['.notdef'];
  39807. var charstrings = this.charstrings;
  39808. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  39809. charset.push(charstrings[glyphId].glyphName);
  39810. }
  39811. return charset;
  39812. },
  39813. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  39814. var charstrings = this.charstrings;
  39815. var glyphNames = ['.notdef'], glyphId;
  39816. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  39817. glyphNames.push(charstrings[glyphId].glyphName);
  39818. }
  39819. var encoding = properties.builtInEncoding;
  39820. if (encoding) {
  39821. var builtInEncoding = Object.create(null);
  39822. for (var charCode in encoding) {
  39823. glyphId = glyphNames.indexOf(encoding[charCode]);
  39824. if (glyphId >= 0) {
  39825. builtInEncoding[charCode] = glyphId;
  39826. }
  39827. }
  39828. }
  39829. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  39830. },
  39831. getSeacs: function Type1Font_getSeacs(charstrings) {
  39832. var i, ii;
  39833. var seacMap = [];
  39834. for (i = 0, ii = charstrings.length; i < ii; i++) {
  39835. var charstring = charstrings[i];
  39836. if (charstring.seac) {
  39837. seacMap[i + 1] = charstring.seac;
  39838. }
  39839. }
  39840. return seacMap;
  39841. },
  39842. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  39843. var type2Charstrings = [];
  39844. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  39845. type2Charstrings.push(type1Charstrings[i].charstring);
  39846. }
  39847. return type2Charstrings;
  39848. },
  39849. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  39850. var bias = 0;
  39851. var count = type1Subrs.length;
  39852. if (count < 1133) {
  39853. bias = 107;
  39854. } else if (count < 33769) {
  39855. bias = 1131;
  39856. } else {
  39857. bias = 32768;
  39858. }
  39859. var type2Subrs = [];
  39860. var i;
  39861. for (i = 0; i < bias; i++) {
  39862. type2Subrs.push([0x0B]);
  39863. }
  39864. for (i = 0; i < count; i++) {
  39865. type2Subrs.push(type1Subrs[i]);
  39866. }
  39867. return type2Subrs;
  39868. },
  39869. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  39870. var cff = new CFF();
  39871. cff.header = new CFFHeader(1, 0, 4, 4);
  39872. cff.names = [name];
  39873. var topDict = new CFFTopDict();
  39874. topDict.setByName('version', 391);
  39875. topDict.setByName('Notice', 392);
  39876. topDict.setByName('FullName', 393);
  39877. topDict.setByName('FamilyName', 394);
  39878. topDict.setByName('Weight', 395);
  39879. topDict.setByName('Encoding', null);
  39880. topDict.setByName('FontMatrix', properties.fontMatrix);
  39881. topDict.setByName('FontBBox', properties.bbox);
  39882. topDict.setByName('charset', null);
  39883. topDict.setByName('CharStrings', null);
  39884. topDict.setByName('Private', null);
  39885. cff.topDict = topDict;
  39886. var strings = new CFFStrings();
  39887. strings.add('Version 0.11');
  39888. strings.add('See original notice');
  39889. strings.add(name);
  39890. strings.add(name);
  39891. strings.add('Medium');
  39892. cff.strings = strings;
  39893. cff.globalSubrIndex = new CFFIndex();
  39894. var count = glyphs.length;
  39895. var charsetArray = [0];
  39896. var i, ii;
  39897. for (i = 0; i < count; i++) {
  39898. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  39899. if (index === -1) {
  39900. index = 0;
  39901. }
  39902. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  39903. }
  39904. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  39905. var charStringsIndex = new CFFIndex();
  39906. charStringsIndex.add([
  39907. 0x8B,
  39908. 0x0E
  39909. ]);
  39910. for (i = 0; i < count; i++) {
  39911. var glyph = glyphs[i];
  39912. if (glyph.length === 0) {
  39913. charStringsIndex.add([
  39914. 0x8B,
  39915. 0x0E
  39916. ]);
  39917. continue;
  39918. }
  39919. charStringsIndex.add(glyph);
  39920. }
  39921. cff.charStrings = charStringsIndex;
  39922. var privateDict = new CFFPrivateDict();
  39923. privateDict.setByName('Subrs', null);
  39924. var fields = [
  39925. 'BlueValues',
  39926. 'OtherBlues',
  39927. 'FamilyBlues',
  39928. 'FamilyOtherBlues',
  39929. 'StemSnapH',
  39930. 'StemSnapV',
  39931. 'BlueShift',
  39932. 'BlueFuzz',
  39933. 'BlueScale',
  39934. 'LanguageGroup',
  39935. 'ExpansionFactor',
  39936. 'ForceBold',
  39937. 'StdHW',
  39938. 'StdVW'
  39939. ];
  39940. for (i = 0, ii = fields.length; i < ii; i++) {
  39941. var field = fields[i];
  39942. if (!(field in properties.privateData)) {
  39943. continue;
  39944. }
  39945. var value = properties.privateData[field];
  39946. if (isArray(value)) {
  39947. for (var j = value.length - 1; j > 0; j--) {
  39948. value[j] -= value[j - 1];
  39949. }
  39950. }
  39951. privateDict.setByName(field, value);
  39952. }
  39953. cff.topDict.privateDict = privateDict;
  39954. var subrIndex = new CFFIndex();
  39955. for (i = 0, ii = subrs.length; i < ii; i++) {
  39956. subrIndex.add(subrs[i]);
  39957. }
  39958. privateDict.subrsIndex = subrIndex;
  39959. var compiler = new CFFCompiler(cff);
  39960. return compiler.compile();
  39961. }
  39962. };
  39963. return Type1Font;
  39964. }();
  39965. var CFFFont = function CFFFontClosure() {
  39966. function CFFFont(file, properties) {
  39967. this.properties = properties;
  39968. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  39969. this.cff = parser.parse();
  39970. var compiler = new CFFCompiler(this.cff);
  39971. this.seacs = this.cff.seacs;
  39972. try {
  39973. this.data = compiler.compile();
  39974. } catch (e) {
  39975. warn('Failed to compile font ' + properties.loadedName);
  39976. this.data = file;
  39977. }
  39978. }
  39979. CFFFont.prototype = {
  39980. get numGlyphs() {
  39981. return this.cff.charStrings.count;
  39982. },
  39983. getCharset: function CFFFont_getCharset() {
  39984. return this.cff.charset.charset;
  39985. },
  39986. getGlyphMapping: function CFFFont_getGlyphMapping() {
  39987. var cff = this.cff;
  39988. var properties = this.properties;
  39989. var charsets = cff.charset.charset;
  39990. var charCodeToGlyphId;
  39991. var glyphId;
  39992. if (properties.composite) {
  39993. charCodeToGlyphId = Object.create(null);
  39994. if (cff.isCIDFont) {
  39995. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  39996. var cid = charsets[glyphId];
  39997. var charCode = properties.cMap.charCodeOf(cid);
  39998. charCodeToGlyphId[charCode] = glyphId;
  39999. }
  40000. } else {
  40001. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  40002. charCodeToGlyphId[glyphId] = glyphId;
  40003. }
  40004. }
  40005. return charCodeToGlyphId;
  40006. }
  40007. var encoding = cff.encoding ? cff.encoding.encoding : null;
  40008. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  40009. return charCodeToGlyphId;
  40010. }
  40011. };
  40012. return CFFFont;
  40013. }();
  40014. (function checkSeacSupport() {
  40015. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  40016. SEAC_ANALYSIS_ENABLED = true;
  40017. }
  40018. }());
  40019. (function checkChromeWindows() {
  40020. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  40021. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  40022. }
  40023. }());
  40024. exports.ErrorFont = ErrorFont;
  40025. exports.Font = Font;
  40026. exports.FontFlags = FontFlags;
  40027. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  40028. exports.ToUnicodeMap = ToUnicodeMap;
  40029. exports.getFontType = getFontType;
  40030. }));
  40031. (function (root, factory) {
  40032. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  40033. }(this, function (exports, sharedUtil, coreParser) {
  40034. var error = sharedUtil.error;
  40035. var isSpace = sharedUtil.isSpace;
  40036. var EOF = coreParser.EOF;
  40037. var PostScriptParser = function PostScriptParserClosure() {
  40038. function PostScriptParser(lexer) {
  40039. this.lexer = lexer;
  40040. this.operators = [];
  40041. this.token = null;
  40042. this.prev = null;
  40043. }
  40044. PostScriptParser.prototype = {
  40045. nextToken: function PostScriptParser_nextToken() {
  40046. this.prev = this.token;
  40047. this.token = this.lexer.getToken();
  40048. },
  40049. accept: function PostScriptParser_accept(type) {
  40050. if (this.token.type === type) {
  40051. this.nextToken();
  40052. return true;
  40053. }
  40054. return false;
  40055. },
  40056. expect: function PostScriptParser_expect(type) {
  40057. if (this.accept(type)) {
  40058. return true;
  40059. }
  40060. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  40061. },
  40062. parse: function PostScriptParser_parse() {
  40063. this.nextToken();
  40064. this.expect(PostScriptTokenTypes.LBRACE);
  40065. this.parseBlock();
  40066. this.expect(PostScriptTokenTypes.RBRACE);
  40067. return this.operators;
  40068. },
  40069. parseBlock: function PostScriptParser_parseBlock() {
  40070. while (true) {
  40071. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  40072. this.operators.push(this.prev.value);
  40073. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  40074. this.operators.push(this.prev.value);
  40075. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  40076. this.parseCondition();
  40077. } else {
  40078. return;
  40079. }
  40080. }
  40081. },
  40082. parseCondition: function PostScriptParser_parseCondition() {
  40083. var conditionLocation = this.operators.length;
  40084. this.operators.push(null, null);
  40085. this.parseBlock();
  40086. this.expect(PostScriptTokenTypes.RBRACE);
  40087. if (this.accept(PostScriptTokenTypes.IF)) {
  40088. this.operators[conditionLocation] = this.operators.length;
  40089. this.operators[conditionLocation + 1] = 'jz';
  40090. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  40091. var jumpLocation = this.operators.length;
  40092. this.operators.push(null, null);
  40093. var endOfTrue = this.operators.length;
  40094. this.parseBlock();
  40095. this.expect(PostScriptTokenTypes.RBRACE);
  40096. this.expect(PostScriptTokenTypes.IFELSE);
  40097. this.operators[jumpLocation] = this.operators.length;
  40098. this.operators[jumpLocation + 1] = 'j';
  40099. this.operators[conditionLocation] = endOfTrue;
  40100. this.operators[conditionLocation + 1] = 'jz';
  40101. } else {
  40102. error('PS Function: error parsing conditional.');
  40103. }
  40104. }
  40105. };
  40106. return PostScriptParser;
  40107. }();
  40108. var PostScriptTokenTypes = {
  40109. LBRACE: 0,
  40110. RBRACE: 1,
  40111. NUMBER: 2,
  40112. OPERATOR: 3,
  40113. IF: 4,
  40114. IFELSE: 5
  40115. };
  40116. var PostScriptToken = function PostScriptTokenClosure() {
  40117. function PostScriptToken(type, value) {
  40118. this.type = type;
  40119. this.value = value;
  40120. }
  40121. var opCache = Object.create(null);
  40122. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  40123. var opValue = opCache[op];
  40124. if (opValue) {
  40125. return opValue;
  40126. }
  40127. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  40128. };
  40129. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  40130. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  40131. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  40132. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  40133. return PostScriptToken;
  40134. }();
  40135. var PostScriptLexer = function PostScriptLexerClosure() {
  40136. function PostScriptLexer(stream) {
  40137. this.stream = stream;
  40138. this.nextChar();
  40139. this.strBuf = [];
  40140. }
  40141. PostScriptLexer.prototype = {
  40142. nextChar: function PostScriptLexer_nextChar() {
  40143. return this.currentChar = this.stream.getByte();
  40144. },
  40145. getToken: function PostScriptLexer_getToken() {
  40146. var comment = false;
  40147. var ch = this.currentChar;
  40148. while (true) {
  40149. if (ch < 0) {
  40150. return EOF;
  40151. }
  40152. if (comment) {
  40153. if (ch === 0x0A || ch === 0x0D) {
  40154. comment = false;
  40155. }
  40156. } else if (ch === 0x25) {
  40157. comment = true;
  40158. } else if (!isSpace(ch)) {
  40159. break;
  40160. }
  40161. ch = this.nextChar();
  40162. }
  40163. switch (ch | 0) {
  40164. case 0x30:
  40165. case 0x31:
  40166. case 0x32:
  40167. case 0x33:
  40168. case 0x34:
  40169. case 0x35:
  40170. case 0x36:
  40171. case 0x37:
  40172. case 0x38:
  40173. case 0x39:
  40174. case 0x2B:
  40175. case 0x2D:
  40176. case 0x2E:
  40177. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  40178. case 0x7B:
  40179. this.nextChar();
  40180. return PostScriptToken.LBRACE;
  40181. case 0x7D:
  40182. this.nextChar();
  40183. return PostScriptToken.RBRACE;
  40184. }
  40185. var strBuf = this.strBuf;
  40186. strBuf.length = 0;
  40187. strBuf[0] = String.fromCharCode(ch);
  40188. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  40189. strBuf.push(String.fromCharCode(ch));
  40190. }
  40191. var str = strBuf.join('');
  40192. switch (str.toLowerCase()) {
  40193. case 'if':
  40194. return PostScriptToken.IF;
  40195. case 'ifelse':
  40196. return PostScriptToken.IFELSE;
  40197. default:
  40198. return PostScriptToken.getOperator(str);
  40199. }
  40200. },
  40201. getNumber: function PostScriptLexer_getNumber() {
  40202. var ch = this.currentChar;
  40203. var strBuf = this.strBuf;
  40204. strBuf.length = 0;
  40205. strBuf[0] = String.fromCharCode(ch);
  40206. while ((ch = this.nextChar()) >= 0) {
  40207. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  40208. strBuf.push(String.fromCharCode(ch));
  40209. } else {
  40210. break;
  40211. }
  40212. }
  40213. var value = parseFloat(strBuf.join(''));
  40214. if (isNaN(value)) {
  40215. error('Invalid floating point number: ' + value);
  40216. }
  40217. return value;
  40218. }
  40219. };
  40220. return PostScriptLexer;
  40221. }();
  40222. exports.PostScriptLexer = PostScriptLexer;
  40223. exports.PostScriptParser = PostScriptParser;
  40224. }));
  40225. (function (root, factory) {
  40226. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  40227. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  40228. var error = sharedUtil.error;
  40229. var info = sharedUtil.info;
  40230. var isArray = sharedUtil.isArray;
  40231. var isBool = sharedUtil.isBool;
  40232. var isDict = corePrimitives.isDict;
  40233. var isStream = corePrimitives.isStream;
  40234. var PostScriptLexer = corePsParser.PostScriptLexer;
  40235. var PostScriptParser = corePsParser.PostScriptParser;
  40236. var PDFFunction = function PDFFunctionClosure() {
  40237. var CONSTRUCT_SAMPLED = 0;
  40238. var CONSTRUCT_INTERPOLATED = 2;
  40239. var CONSTRUCT_STICHED = 3;
  40240. var CONSTRUCT_POSTSCRIPT = 4;
  40241. return {
  40242. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  40243. var i, ii;
  40244. var length = 1;
  40245. for (i = 0, ii = size.length; i < ii; i++) {
  40246. length *= size[i];
  40247. }
  40248. length *= outputSize;
  40249. var array = new Array(length);
  40250. var codeSize = 0;
  40251. var codeBuf = 0;
  40252. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  40253. var strBytes = str.getBytes((length * bps + 7) / 8);
  40254. var strIdx = 0;
  40255. for (i = 0; i < length; i++) {
  40256. while (codeSize < bps) {
  40257. codeBuf <<= 8;
  40258. codeBuf |= strBytes[strIdx++];
  40259. codeSize += 8;
  40260. }
  40261. codeSize -= bps;
  40262. array[i] = (codeBuf >> codeSize) * sampleMul;
  40263. codeBuf &= (1 << codeSize) - 1;
  40264. }
  40265. return array;
  40266. },
  40267. getIR: function PDFFunction_getIR(xref, fn) {
  40268. var dict = fn.dict;
  40269. if (!dict) {
  40270. dict = fn;
  40271. }
  40272. var types = [
  40273. this.constructSampled,
  40274. null,
  40275. this.constructInterpolated,
  40276. this.constructStiched,
  40277. this.constructPostScript
  40278. ];
  40279. var typeNum = dict.get('FunctionType');
  40280. var typeFn = types[typeNum];
  40281. if (!typeFn) {
  40282. error('Unknown type of function');
  40283. }
  40284. return typeFn.call(this, fn, dict, xref);
  40285. },
  40286. fromIR: function PDFFunction_fromIR(IR) {
  40287. var type = IR[0];
  40288. switch (type) {
  40289. case CONSTRUCT_SAMPLED:
  40290. return this.constructSampledFromIR(IR);
  40291. case CONSTRUCT_INTERPOLATED:
  40292. return this.constructInterpolatedFromIR(IR);
  40293. case CONSTRUCT_STICHED:
  40294. return this.constructStichedFromIR(IR);
  40295. default:
  40296. return this.constructPostScriptFromIR(IR);
  40297. }
  40298. },
  40299. parse: function PDFFunction_parse(xref, fn) {
  40300. var IR = this.getIR(xref, fn);
  40301. return this.fromIR(IR);
  40302. },
  40303. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  40304. if (!isArray(fnObj)) {
  40305. return this.parse(xref, fnObj);
  40306. }
  40307. var fnArray = [];
  40308. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  40309. var obj = xref.fetchIfRef(fnObj[j]);
  40310. fnArray.push(PDFFunction.parse(xref, obj));
  40311. }
  40312. return function (src, srcOffset, dest, destOffset) {
  40313. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  40314. fnArray[i](src, srcOffset, dest, destOffset + i);
  40315. }
  40316. };
  40317. },
  40318. constructSampled: function PDFFunction_constructSampled(str, dict) {
  40319. function toMultiArray(arr) {
  40320. var inputLength = arr.length;
  40321. var out = [];
  40322. var index = 0;
  40323. for (var i = 0; i < inputLength; i += 2) {
  40324. out[index] = [
  40325. arr[i],
  40326. arr[i + 1]
  40327. ];
  40328. ++index;
  40329. }
  40330. return out;
  40331. }
  40332. var domain = dict.getArray('Domain');
  40333. var range = dict.getArray('Range');
  40334. if (!domain || !range) {
  40335. error('No domain or range');
  40336. }
  40337. var inputSize = domain.length / 2;
  40338. var outputSize = range.length / 2;
  40339. domain = toMultiArray(domain);
  40340. range = toMultiArray(range);
  40341. var size = dict.get('Size');
  40342. var bps = dict.get('BitsPerSample');
  40343. var order = dict.get('Order') || 1;
  40344. if (order !== 1) {
  40345. info('No support for cubic spline interpolation: ' + order);
  40346. }
  40347. var encode = dict.getArray('Encode');
  40348. if (!encode) {
  40349. encode = [];
  40350. for (var i = 0; i < inputSize; ++i) {
  40351. encode.push(0);
  40352. encode.push(size[i] - 1);
  40353. }
  40354. }
  40355. encode = toMultiArray(encode);
  40356. var decode = dict.getArray('Decode');
  40357. if (!decode) {
  40358. decode = range;
  40359. } else {
  40360. decode = toMultiArray(decode);
  40361. }
  40362. var samples = this.getSampleArray(size, outputSize, bps, str);
  40363. return [
  40364. CONSTRUCT_SAMPLED,
  40365. inputSize,
  40366. domain,
  40367. encode,
  40368. decode,
  40369. samples,
  40370. size,
  40371. outputSize,
  40372. Math.pow(2, bps) - 1,
  40373. range
  40374. ];
  40375. },
  40376. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  40377. function interpolate(x, xmin, xmax, ymin, ymax) {
  40378. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  40379. }
  40380. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  40381. var m = IR[1];
  40382. var domain = IR[2];
  40383. var encode = IR[3];
  40384. var decode = IR[4];
  40385. var samples = IR[5];
  40386. var size = IR[6];
  40387. var n = IR[7];
  40388. var range = IR[9];
  40389. var cubeVertices = 1 << m;
  40390. var cubeN = new Float64Array(cubeVertices);
  40391. var cubeVertex = new Uint32Array(cubeVertices);
  40392. var i, j;
  40393. for (j = 0; j < cubeVertices; j++) {
  40394. cubeN[j] = 1;
  40395. }
  40396. var k = n, pos = 1;
  40397. for (i = 0; i < m; ++i) {
  40398. var domain_2i = domain[i][0];
  40399. var domain_2i_1 = domain[i][1];
  40400. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  40401. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  40402. var size_i = size[i];
  40403. e = Math.min(Math.max(e, 0), size_i - 1);
  40404. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  40405. var n0 = e0 + 1 - e;
  40406. var n1 = e - e0;
  40407. var offset0 = e0 * k;
  40408. var offset1 = offset0 + k;
  40409. for (j = 0; j < cubeVertices; j++) {
  40410. if (j & pos) {
  40411. cubeN[j] *= n1;
  40412. cubeVertex[j] += offset1;
  40413. } else {
  40414. cubeN[j] *= n0;
  40415. cubeVertex[j] += offset0;
  40416. }
  40417. }
  40418. k *= size_i;
  40419. pos <<= 1;
  40420. }
  40421. for (j = 0; j < n; ++j) {
  40422. var rj = 0;
  40423. for (i = 0; i < cubeVertices; i++) {
  40424. rj += samples[cubeVertex[i] + j] * cubeN[i];
  40425. }
  40426. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  40427. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  40428. }
  40429. };
  40430. },
  40431. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  40432. var c0 = dict.getArray('C0') || [0];
  40433. var c1 = dict.getArray('C1') || [1];
  40434. var n = dict.get('N');
  40435. if (!isArray(c0) || !isArray(c1)) {
  40436. error('Illegal dictionary for interpolated function');
  40437. }
  40438. var length = c0.length;
  40439. var diff = [];
  40440. for (var i = 0; i < length; ++i) {
  40441. diff.push(c1[i] - c0[i]);
  40442. }
  40443. return [
  40444. CONSTRUCT_INTERPOLATED,
  40445. c0,
  40446. diff,
  40447. n
  40448. ];
  40449. },
  40450. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  40451. var c0 = IR[1];
  40452. var diff = IR[2];
  40453. var n = IR[3];
  40454. var length = diff.length;
  40455. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  40456. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  40457. for (var j = 0; j < length; ++j) {
  40458. dest[destOffset + j] = c0[j] + x * diff[j];
  40459. }
  40460. };
  40461. },
  40462. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  40463. var domain = dict.getArray('Domain');
  40464. if (!domain) {
  40465. error('No domain');
  40466. }
  40467. var inputSize = domain.length / 2;
  40468. if (inputSize !== 1) {
  40469. error('Bad domain for stiched function');
  40470. }
  40471. var fnRefs = dict.get('Functions');
  40472. var fns = [];
  40473. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  40474. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  40475. }
  40476. var bounds = dict.getArray('Bounds');
  40477. var encode = dict.getArray('Encode');
  40478. return [
  40479. CONSTRUCT_STICHED,
  40480. domain,
  40481. bounds,
  40482. encode,
  40483. fns
  40484. ];
  40485. },
  40486. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  40487. var domain = IR[1];
  40488. var bounds = IR[2];
  40489. var encode = IR[3];
  40490. var fnsIR = IR[4];
  40491. var fns = [];
  40492. var tmpBuf = new Float32Array(1);
  40493. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  40494. fns.push(PDFFunction.fromIR(fnsIR[i]));
  40495. }
  40496. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  40497. var clip = function constructStichedFromIRClip(v, min, max) {
  40498. if (v > max) {
  40499. v = max;
  40500. } else if (v < min) {
  40501. v = min;
  40502. }
  40503. return v;
  40504. };
  40505. var v = clip(src[srcOffset], domain[0], domain[1]);
  40506. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  40507. if (v < bounds[i]) {
  40508. break;
  40509. }
  40510. }
  40511. var dmin = domain[0];
  40512. if (i > 0) {
  40513. dmin = bounds[i - 1];
  40514. }
  40515. var dmax = domain[1];
  40516. if (i < bounds.length) {
  40517. dmax = bounds[i];
  40518. }
  40519. var rmin = encode[2 * i];
  40520. var rmax = encode[2 * i + 1];
  40521. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  40522. fns[i](tmpBuf, 0, dest, destOffset);
  40523. };
  40524. },
  40525. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  40526. var domain = dict.getArray('Domain');
  40527. var range = dict.getArray('Range');
  40528. if (!domain) {
  40529. error('No domain.');
  40530. }
  40531. if (!range) {
  40532. error('No range.');
  40533. }
  40534. var lexer = new PostScriptLexer(fn);
  40535. var parser = new PostScriptParser(lexer);
  40536. var code = parser.parse();
  40537. return [
  40538. CONSTRUCT_POSTSCRIPT,
  40539. domain,
  40540. range,
  40541. code
  40542. ];
  40543. },
  40544. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  40545. var domain = IR[1];
  40546. var range = IR[2];
  40547. var code = IR[3];
  40548. var compiled = new PostScriptCompiler().compile(code, domain, range);
  40549. if (compiled) {
  40550. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  40551. }
  40552. info('Unable to compile PS function');
  40553. var numOutputs = range.length >> 1;
  40554. var numInputs = domain.length >> 1;
  40555. var evaluator = new PostScriptEvaluator(code);
  40556. var cache = Object.create(null);
  40557. var MAX_CACHE_SIZE = 2048 * 4;
  40558. var cache_available = MAX_CACHE_SIZE;
  40559. var tmpBuf = new Float32Array(numInputs);
  40560. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  40561. var i, value;
  40562. var key = '';
  40563. var input = tmpBuf;
  40564. for (i = 0; i < numInputs; i++) {
  40565. value = src[srcOffset + i];
  40566. input[i] = value;
  40567. key += value + '_';
  40568. }
  40569. var cachedValue = cache[key];
  40570. if (cachedValue !== undefined) {
  40571. dest.set(cachedValue, destOffset);
  40572. return;
  40573. }
  40574. var output = new Float32Array(numOutputs);
  40575. var stack = evaluator.execute(input);
  40576. var stackIndex = stack.length - numOutputs;
  40577. for (i = 0; i < numOutputs; i++) {
  40578. value = stack[stackIndex + i];
  40579. var bound = range[i * 2];
  40580. if (value < bound) {
  40581. value = bound;
  40582. } else {
  40583. bound = range[i * 2 + 1];
  40584. if (value > bound) {
  40585. value = bound;
  40586. }
  40587. }
  40588. output[i] = value;
  40589. }
  40590. if (cache_available > 0) {
  40591. cache_available--;
  40592. cache[key] = output;
  40593. }
  40594. dest.set(output, destOffset);
  40595. };
  40596. }
  40597. };
  40598. }();
  40599. function isPDFFunction(v) {
  40600. var fnDict;
  40601. if (typeof v !== 'object') {
  40602. return false;
  40603. } else if (isDict(v)) {
  40604. fnDict = v;
  40605. } else if (isStream(v)) {
  40606. fnDict = v.dict;
  40607. } else {
  40608. return false;
  40609. }
  40610. return fnDict.has('FunctionType');
  40611. }
  40612. var PostScriptStack = function PostScriptStackClosure() {
  40613. var MAX_STACK_SIZE = 100;
  40614. function PostScriptStack(initialStack) {
  40615. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  40616. }
  40617. PostScriptStack.prototype = {
  40618. push: function PostScriptStack_push(value) {
  40619. if (this.stack.length >= MAX_STACK_SIZE) {
  40620. error('PostScript function stack overflow.');
  40621. }
  40622. this.stack.push(value);
  40623. },
  40624. pop: function PostScriptStack_pop() {
  40625. if (this.stack.length <= 0) {
  40626. error('PostScript function stack underflow.');
  40627. }
  40628. return this.stack.pop();
  40629. },
  40630. copy: function PostScriptStack_copy(n) {
  40631. if (this.stack.length + n >= MAX_STACK_SIZE) {
  40632. error('PostScript function stack overflow.');
  40633. }
  40634. var stack = this.stack;
  40635. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  40636. stack.push(stack[i]);
  40637. }
  40638. },
  40639. index: function PostScriptStack_index(n) {
  40640. this.push(this.stack[this.stack.length - n - 1]);
  40641. },
  40642. roll: function PostScriptStack_roll(n, p) {
  40643. var stack = this.stack;
  40644. var l = stack.length - n;
  40645. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  40646. for (i = l, j = r; i < j; i++, j--) {
  40647. t = stack[i];
  40648. stack[i] = stack[j];
  40649. stack[j] = t;
  40650. }
  40651. for (i = l, j = c - 1; i < j; i++, j--) {
  40652. t = stack[i];
  40653. stack[i] = stack[j];
  40654. stack[j] = t;
  40655. }
  40656. for (i = c, j = r; i < j; i++, j--) {
  40657. t = stack[i];
  40658. stack[i] = stack[j];
  40659. stack[j] = t;
  40660. }
  40661. }
  40662. };
  40663. return PostScriptStack;
  40664. }();
  40665. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  40666. function PostScriptEvaluator(operators) {
  40667. this.operators = operators;
  40668. }
  40669. PostScriptEvaluator.prototype = {
  40670. execute: function PostScriptEvaluator_execute(initialStack) {
  40671. var stack = new PostScriptStack(initialStack);
  40672. var counter = 0;
  40673. var operators = this.operators;
  40674. var length = operators.length;
  40675. var operator, a, b;
  40676. while (counter < length) {
  40677. operator = operators[counter++];
  40678. if (typeof operator === 'number') {
  40679. stack.push(operator);
  40680. continue;
  40681. }
  40682. switch (operator) {
  40683. case 'jz':
  40684. b = stack.pop();
  40685. a = stack.pop();
  40686. if (!a) {
  40687. counter = b;
  40688. }
  40689. break;
  40690. case 'j':
  40691. a = stack.pop();
  40692. counter = a;
  40693. break;
  40694. case 'abs':
  40695. a = stack.pop();
  40696. stack.push(Math.abs(a));
  40697. break;
  40698. case 'add':
  40699. b = stack.pop();
  40700. a = stack.pop();
  40701. stack.push(a + b);
  40702. break;
  40703. case 'and':
  40704. b = stack.pop();
  40705. a = stack.pop();
  40706. if (isBool(a) && isBool(b)) {
  40707. stack.push(a && b);
  40708. } else {
  40709. stack.push(a & b);
  40710. }
  40711. break;
  40712. case 'atan':
  40713. a = stack.pop();
  40714. stack.push(Math.atan(a));
  40715. break;
  40716. case 'bitshift':
  40717. b = stack.pop();
  40718. a = stack.pop();
  40719. if (a > 0) {
  40720. stack.push(a << b);
  40721. } else {
  40722. stack.push(a >> b);
  40723. }
  40724. break;
  40725. case 'ceiling':
  40726. a = stack.pop();
  40727. stack.push(Math.ceil(a));
  40728. break;
  40729. case 'copy':
  40730. a = stack.pop();
  40731. stack.copy(a);
  40732. break;
  40733. case 'cos':
  40734. a = stack.pop();
  40735. stack.push(Math.cos(a));
  40736. break;
  40737. case 'cvi':
  40738. a = stack.pop() | 0;
  40739. stack.push(a);
  40740. break;
  40741. case 'cvr':
  40742. break;
  40743. case 'div':
  40744. b = stack.pop();
  40745. a = stack.pop();
  40746. stack.push(a / b);
  40747. break;
  40748. case 'dup':
  40749. stack.copy(1);
  40750. break;
  40751. case 'eq':
  40752. b = stack.pop();
  40753. a = stack.pop();
  40754. stack.push(a === b);
  40755. break;
  40756. case 'exch':
  40757. stack.roll(2, 1);
  40758. break;
  40759. case 'exp':
  40760. b = stack.pop();
  40761. a = stack.pop();
  40762. stack.push(Math.pow(a, b));
  40763. break;
  40764. case 'false':
  40765. stack.push(false);
  40766. break;
  40767. case 'floor':
  40768. a = stack.pop();
  40769. stack.push(Math.floor(a));
  40770. break;
  40771. case 'ge':
  40772. b = stack.pop();
  40773. a = stack.pop();
  40774. stack.push(a >= b);
  40775. break;
  40776. case 'gt':
  40777. b = stack.pop();
  40778. a = stack.pop();
  40779. stack.push(a > b);
  40780. break;
  40781. case 'idiv':
  40782. b = stack.pop();
  40783. a = stack.pop();
  40784. stack.push(a / b | 0);
  40785. break;
  40786. case 'index':
  40787. a = stack.pop();
  40788. stack.index(a);
  40789. break;
  40790. case 'le':
  40791. b = stack.pop();
  40792. a = stack.pop();
  40793. stack.push(a <= b);
  40794. break;
  40795. case 'ln':
  40796. a = stack.pop();
  40797. stack.push(Math.log(a));
  40798. break;
  40799. case 'log':
  40800. a = stack.pop();
  40801. stack.push(Math.log(a) / Math.LN10);
  40802. break;
  40803. case 'lt':
  40804. b = stack.pop();
  40805. a = stack.pop();
  40806. stack.push(a < b);
  40807. break;
  40808. case 'mod':
  40809. b = stack.pop();
  40810. a = stack.pop();
  40811. stack.push(a % b);
  40812. break;
  40813. case 'mul':
  40814. b = stack.pop();
  40815. a = stack.pop();
  40816. stack.push(a * b);
  40817. break;
  40818. case 'ne':
  40819. b = stack.pop();
  40820. a = stack.pop();
  40821. stack.push(a !== b);
  40822. break;
  40823. case 'neg':
  40824. a = stack.pop();
  40825. stack.push(-a);
  40826. break;
  40827. case 'not':
  40828. a = stack.pop();
  40829. if (isBool(a)) {
  40830. stack.push(!a);
  40831. } else {
  40832. stack.push(~a);
  40833. }
  40834. break;
  40835. case 'or':
  40836. b = stack.pop();
  40837. a = stack.pop();
  40838. if (isBool(a) && isBool(b)) {
  40839. stack.push(a || b);
  40840. } else {
  40841. stack.push(a | b);
  40842. }
  40843. break;
  40844. case 'pop':
  40845. stack.pop();
  40846. break;
  40847. case 'roll':
  40848. b = stack.pop();
  40849. a = stack.pop();
  40850. stack.roll(a, b);
  40851. break;
  40852. case 'round':
  40853. a = stack.pop();
  40854. stack.push(Math.round(a));
  40855. break;
  40856. case 'sin':
  40857. a = stack.pop();
  40858. stack.push(Math.sin(a));
  40859. break;
  40860. case 'sqrt':
  40861. a = stack.pop();
  40862. stack.push(Math.sqrt(a));
  40863. break;
  40864. case 'sub':
  40865. b = stack.pop();
  40866. a = stack.pop();
  40867. stack.push(a - b);
  40868. break;
  40869. case 'true':
  40870. stack.push(true);
  40871. break;
  40872. case 'truncate':
  40873. a = stack.pop();
  40874. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  40875. stack.push(a);
  40876. break;
  40877. case 'xor':
  40878. b = stack.pop();
  40879. a = stack.pop();
  40880. if (isBool(a) && isBool(b)) {
  40881. stack.push(a !== b);
  40882. } else {
  40883. stack.push(a ^ b);
  40884. }
  40885. break;
  40886. default:
  40887. error('Unknown operator ' + operator);
  40888. break;
  40889. }
  40890. }
  40891. return stack.stack;
  40892. }
  40893. };
  40894. return PostScriptEvaluator;
  40895. }();
  40896. var PostScriptCompiler = function PostScriptCompilerClosure() {
  40897. function AstNode(type) {
  40898. this.type = type;
  40899. }
  40900. AstNode.prototype.visit = function (visitor) {
  40901. throw new Error('abstract method');
  40902. };
  40903. function AstArgument(index, min, max) {
  40904. AstNode.call(this, 'args');
  40905. this.index = index;
  40906. this.min = min;
  40907. this.max = max;
  40908. }
  40909. AstArgument.prototype = Object.create(AstNode.prototype);
  40910. AstArgument.prototype.visit = function (visitor) {
  40911. visitor.visitArgument(this);
  40912. };
  40913. function AstLiteral(number) {
  40914. AstNode.call(this, 'literal');
  40915. this.number = number;
  40916. this.min = number;
  40917. this.max = number;
  40918. }
  40919. AstLiteral.prototype = Object.create(AstNode.prototype);
  40920. AstLiteral.prototype.visit = function (visitor) {
  40921. visitor.visitLiteral(this);
  40922. };
  40923. function AstBinaryOperation(op, arg1, arg2, min, max) {
  40924. AstNode.call(this, 'binary');
  40925. this.op = op;
  40926. this.arg1 = arg1;
  40927. this.arg2 = arg2;
  40928. this.min = min;
  40929. this.max = max;
  40930. }
  40931. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  40932. AstBinaryOperation.prototype.visit = function (visitor) {
  40933. visitor.visitBinaryOperation(this);
  40934. };
  40935. function AstMin(arg, max) {
  40936. AstNode.call(this, 'max');
  40937. this.arg = arg;
  40938. this.min = arg.min;
  40939. this.max = max;
  40940. }
  40941. AstMin.prototype = Object.create(AstNode.prototype);
  40942. AstMin.prototype.visit = function (visitor) {
  40943. visitor.visitMin(this);
  40944. };
  40945. function AstVariable(index, min, max) {
  40946. AstNode.call(this, 'var');
  40947. this.index = index;
  40948. this.min = min;
  40949. this.max = max;
  40950. }
  40951. AstVariable.prototype = Object.create(AstNode.prototype);
  40952. AstVariable.prototype.visit = function (visitor) {
  40953. visitor.visitVariable(this);
  40954. };
  40955. function AstVariableDefinition(variable, arg) {
  40956. AstNode.call(this, 'definition');
  40957. this.variable = variable;
  40958. this.arg = arg;
  40959. }
  40960. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  40961. AstVariableDefinition.prototype.visit = function (visitor) {
  40962. visitor.visitVariableDefinition(this);
  40963. };
  40964. function ExpressionBuilderVisitor() {
  40965. this.parts = [];
  40966. }
  40967. ExpressionBuilderVisitor.prototype = {
  40968. visitArgument: function (arg) {
  40969. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  40970. },
  40971. visitVariable: function (variable) {
  40972. this.parts.push('v', variable.index);
  40973. },
  40974. visitLiteral: function (literal) {
  40975. this.parts.push(literal.number);
  40976. },
  40977. visitBinaryOperation: function (operation) {
  40978. this.parts.push('(');
  40979. operation.arg1.visit(this);
  40980. this.parts.push(' ', operation.op, ' ');
  40981. operation.arg2.visit(this);
  40982. this.parts.push(')');
  40983. },
  40984. visitVariableDefinition: function (definition) {
  40985. this.parts.push('var ');
  40986. definition.variable.visit(this);
  40987. this.parts.push(' = ');
  40988. definition.arg.visit(this);
  40989. this.parts.push(';');
  40990. },
  40991. visitMin: function (max) {
  40992. this.parts.push('Math.min(');
  40993. max.arg.visit(this);
  40994. this.parts.push(', ', max.max, ')');
  40995. },
  40996. toString: function () {
  40997. return this.parts.join('');
  40998. }
  40999. };
  41000. function buildAddOperation(num1, num2) {
  41001. if (num2.type === 'literal' && num2.number === 0) {
  41002. return num1;
  41003. }
  41004. if (num1.type === 'literal' && num1.number === 0) {
  41005. return num2;
  41006. }
  41007. if (num2.type === 'literal' && num1.type === 'literal') {
  41008. return new AstLiteral(num1.number + num2.number);
  41009. }
  41010. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  41011. }
  41012. function buildMulOperation(num1, num2) {
  41013. if (num2.type === 'literal') {
  41014. if (num2.number === 0) {
  41015. return new AstLiteral(0);
  41016. } else if (num2.number === 1) {
  41017. return num1;
  41018. } else if (num1.type === 'literal') {
  41019. return new AstLiteral(num1.number * num2.number);
  41020. }
  41021. }
  41022. if (num1.type === 'literal') {
  41023. if (num1.number === 0) {
  41024. return new AstLiteral(0);
  41025. } else if (num1.number === 1) {
  41026. return num2;
  41027. }
  41028. }
  41029. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  41030. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  41031. return new AstBinaryOperation('*', num1, num2, min, max);
  41032. }
  41033. function buildSubOperation(num1, num2) {
  41034. if (num2.type === 'literal') {
  41035. if (num2.number === 0) {
  41036. return num1;
  41037. } else if (num1.type === 'literal') {
  41038. return new AstLiteral(num1.number - num2.number);
  41039. }
  41040. }
  41041. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  41042. return num2.arg2;
  41043. }
  41044. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  41045. }
  41046. function buildMinOperation(num1, max) {
  41047. if (num1.min >= max) {
  41048. return new AstLiteral(max);
  41049. } else if (num1.max <= max) {
  41050. return num1;
  41051. }
  41052. return new AstMin(num1, max);
  41053. }
  41054. function PostScriptCompiler() {
  41055. }
  41056. PostScriptCompiler.prototype = {
  41057. compile: function PostScriptCompiler_compile(code, domain, range) {
  41058. var stack = [];
  41059. var i, ii;
  41060. var instructions = [];
  41061. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  41062. var lastRegister = 0;
  41063. var n, j;
  41064. var num1, num2, ast1, ast2, tmpVar, item;
  41065. for (i = 0; i < inputSize; i++) {
  41066. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  41067. }
  41068. for (i = 0, ii = code.length; i < ii; i++) {
  41069. item = code[i];
  41070. if (typeof item === 'number') {
  41071. stack.push(new AstLiteral(item));
  41072. continue;
  41073. }
  41074. switch (item) {
  41075. case 'add':
  41076. if (stack.length < 2) {
  41077. return null;
  41078. }
  41079. num2 = stack.pop();
  41080. num1 = stack.pop();
  41081. stack.push(buildAddOperation(num1, num2));
  41082. break;
  41083. case 'cvr':
  41084. if (stack.length < 1) {
  41085. return null;
  41086. }
  41087. break;
  41088. case 'mul':
  41089. if (stack.length < 2) {
  41090. return null;
  41091. }
  41092. num2 = stack.pop();
  41093. num1 = stack.pop();
  41094. stack.push(buildMulOperation(num1, num2));
  41095. break;
  41096. case 'sub':
  41097. if (stack.length < 2) {
  41098. return null;
  41099. }
  41100. num2 = stack.pop();
  41101. num1 = stack.pop();
  41102. stack.push(buildSubOperation(num1, num2));
  41103. break;
  41104. case 'exch':
  41105. if (stack.length < 2) {
  41106. return null;
  41107. }
  41108. ast1 = stack.pop();
  41109. ast2 = stack.pop();
  41110. stack.push(ast1, ast2);
  41111. break;
  41112. case 'pop':
  41113. if (stack.length < 1) {
  41114. return null;
  41115. }
  41116. stack.pop();
  41117. break;
  41118. case 'index':
  41119. if (stack.length < 1) {
  41120. return null;
  41121. }
  41122. num1 = stack.pop();
  41123. if (num1.type !== 'literal') {
  41124. return null;
  41125. }
  41126. n = num1.number;
  41127. if (n < 0 || (n | 0) !== n || stack.length < n) {
  41128. return null;
  41129. }
  41130. ast1 = stack[stack.length - n - 1];
  41131. if (ast1.type === 'literal' || ast1.type === 'var') {
  41132. stack.push(ast1);
  41133. break;
  41134. }
  41135. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41136. stack[stack.length - n - 1] = tmpVar;
  41137. stack.push(tmpVar);
  41138. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41139. break;
  41140. case 'dup':
  41141. if (stack.length < 1) {
  41142. return null;
  41143. }
  41144. 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]) {
  41145. num1 = stack.pop();
  41146. stack.push(buildMinOperation(num1, code[i + 1]));
  41147. i += 6;
  41148. break;
  41149. }
  41150. ast1 = stack[stack.length - 1];
  41151. if (ast1.type === 'literal' || ast1.type === 'var') {
  41152. stack.push(ast1);
  41153. break;
  41154. }
  41155. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41156. stack[stack.length - 1] = tmpVar;
  41157. stack.push(tmpVar);
  41158. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41159. break;
  41160. case 'roll':
  41161. if (stack.length < 2) {
  41162. return null;
  41163. }
  41164. num2 = stack.pop();
  41165. num1 = stack.pop();
  41166. if (num2.type !== 'literal' || num1.type !== 'literal') {
  41167. return null;
  41168. }
  41169. j = num2.number;
  41170. n = num1.number;
  41171. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  41172. return null;
  41173. }
  41174. j = (j % n + n) % n;
  41175. if (j === 0) {
  41176. break;
  41177. }
  41178. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  41179. break;
  41180. default:
  41181. return null;
  41182. }
  41183. }
  41184. if (stack.length !== outputSize) {
  41185. return null;
  41186. }
  41187. var result = [];
  41188. instructions.forEach(function (instruction) {
  41189. var statementBuilder = new ExpressionBuilderVisitor();
  41190. instruction.visit(statementBuilder);
  41191. result.push(statementBuilder.toString());
  41192. });
  41193. stack.forEach(function (expr, i) {
  41194. var statementBuilder = new ExpressionBuilderVisitor();
  41195. expr.visit(statementBuilder);
  41196. var min = range[i * 2], max = range[i * 2 + 1];
  41197. var out = [statementBuilder.toString()];
  41198. if (min > expr.min) {
  41199. out.unshift('Math.max(', min, ', ');
  41200. out.push(')');
  41201. }
  41202. if (max < expr.max) {
  41203. out.unshift('Math.min(', max, ', ');
  41204. out.push(')');
  41205. }
  41206. out.unshift('dest[destOffset + ', i, '] = ');
  41207. out.push(';');
  41208. result.push(out.join(''));
  41209. });
  41210. return result.join('\n');
  41211. }
  41212. };
  41213. return PostScriptCompiler;
  41214. }();
  41215. exports.isPDFFunction = isPDFFunction;
  41216. exports.PDFFunction = PDFFunction;
  41217. exports.PostScriptEvaluator = PostScriptEvaluator;
  41218. exports.PostScriptCompiler = PostScriptCompiler;
  41219. }));
  41220. (function (root, factory) {
  41221. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  41222. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  41223. var error = sharedUtil.error;
  41224. var info = sharedUtil.info;
  41225. var isArray = sharedUtil.isArray;
  41226. var isString = sharedUtil.isString;
  41227. var shadow = sharedUtil.shadow;
  41228. var warn = sharedUtil.warn;
  41229. var isDict = corePrimitives.isDict;
  41230. var isName = corePrimitives.isName;
  41231. var isStream = corePrimitives.isStream;
  41232. var PDFFunction = coreFunction.PDFFunction;
  41233. var ColorSpace = function ColorSpaceClosure() {
  41234. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  41235. var COMPONENTS = 3;
  41236. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  41237. var xRatio = w1 / w2;
  41238. var yRatio = h1 / h2;
  41239. var i, j, py, newIndex = 0, oldIndex;
  41240. var xScaled = new Uint16Array(w2);
  41241. var w1Scanline = w1 * COMPONENTS;
  41242. for (i = 0; i < w2; i++) {
  41243. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  41244. }
  41245. for (i = 0; i < h2; i++) {
  41246. py = Math.floor(i * yRatio) * w1Scanline;
  41247. for (j = 0; j < w2; j++) {
  41248. oldIndex = py + xScaled[j];
  41249. dest[newIndex++] = src[oldIndex++];
  41250. dest[newIndex++] = src[oldIndex++];
  41251. dest[newIndex++] = src[oldIndex++];
  41252. newIndex += alpha01;
  41253. }
  41254. }
  41255. }
  41256. function ColorSpace() {
  41257. error('should not call ColorSpace constructor');
  41258. }
  41259. ColorSpace.prototype = {
  41260. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  41261. var rgb = new Uint8Array(3);
  41262. this.getRgbItem(src, srcOffset, rgb, 0);
  41263. return rgb;
  41264. },
  41265. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  41266. error('Should not call ColorSpace.getRgbItem');
  41267. },
  41268. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41269. error('Should not call ColorSpace.getRgbBuffer');
  41270. },
  41271. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  41272. error('Should not call ColorSpace.getOutputLength');
  41273. },
  41274. isPassthrough: function ColorSpace_isPassthrough(bits) {
  41275. return false;
  41276. },
  41277. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  41278. var count = originalWidth * originalHeight;
  41279. var rgbBuf = null;
  41280. var numComponentColors = 1 << bpc;
  41281. var needsResizing = originalHeight !== height || originalWidth !== width;
  41282. var i, ii;
  41283. if (this.isPassthrough(bpc)) {
  41284. rgbBuf = comps;
  41285. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  41286. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  41287. var key;
  41288. for (i = 0; i < numComponentColors; i++) {
  41289. allColors[i] = i;
  41290. }
  41291. var colorMap = new Uint8Array(numComponentColors * 3);
  41292. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  41293. var destPos, rgbPos;
  41294. if (!needsResizing) {
  41295. destPos = 0;
  41296. for (i = 0; i < count; ++i) {
  41297. key = comps[i] * 3;
  41298. dest[destPos++] = colorMap[key];
  41299. dest[destPos++] = colorMap[key + 1];
  41300. dest[destPos++] = colorMap[key + 2];
  41301. destPos += alpha01;
  41302. }
  41303. } else {
  41304. rgbBuf = new Uint8Array(count * 3);
  41305. rgbPos = 0;
  41306. for (i = 0; i < count; ++i) {
  41307. key = comps[i] * 3;
  41308. rgbBuf[rgbPos++] = colorMap[key];
  41309. rgbBuf[rgbPos++] = colorMap[key + 1];
  41310. rgbBuf[rgbPos++] = colorMap[key + 2];
  41311. }
  41312. }
  41313. } else {
  41314. if (!needsResizing) {
  41315. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  41316. } else {
  41317. rgbBuf = new Uint8Array(count * 3);
  41318. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  41319. }
  41320. }
  41321. if (rgbBuf) {
  41322. if (needsResizing) {
  41323. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  41324. } else {
  41325. rgbPos = 0;
  41326. destPos = 0;
  41327. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  41328. dest[destPos++] = rgbBuf[rgbPos++];
  41329. dest[destPos++] = rgbBuf[rgbPos++];
  41330. dest[destPos++] = rgbBuf[rgbPos++];
  41331. destPos += alpha01;
  41332. }
  41333. }
  41334. }
  41335. },
  41336. usesZeroToOneRange: true
  41337. };
  41338. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  41339. var IR = ColorSpace.parseToIR(cs, xref, res);
  41340. if (IR instanceof AlternateCS) {
  41341. return IR;
  41342. }
  41343. return ColorSpace.fromIR(IR);
  41344. };
  41345. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  41346. var name = isArray(IR) ? IR[0] : IR;
  41347. var whitePoint, blackPoint, gamma;
  41348. switch (name) {
  41349. case 'DeviceGrayCS':
  41350. return this.singletons.gray;
  41351. case 'DeviceRgbCS':
  41352. return this.singletons.rgb;
  41353. case 'DeviceCmykCS':
  41354. return this.singletons.cmyk;
  41355. case 'CalGrayCS':
  41356. whitePoint = IR[1];
  41357. blackPoint = IR[2];
  41358. gamma = IR[3];
  41359. return new CalGrayCS(whitePoint, blackPoint, gamma);
  41360. case 'CalRGBCS':
  41361. whitePoint = IR[1];
  41362. blackPoint = IR[2];
  41363. gamma = IR[3];
  41364. var matrix = IR[4];
  41365. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  41366. case 'PatternCS':
  41367. var basePatternCS = IR[1];
  41368. if (basePatternCS) {
  41369. basePatternCS = ColorSpace.fromIR(basePatternCS);
  41370. }
  41371. return new PatternCS(basePatternCS);
  41372. case 'IndexedCS':
  41373. var baseIndexedCS = IR[1];
  41374. var hiVal = IR[2];
  41375. var lookup = IR[3];
  41376. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  41377. case 'AlternateCS':
  41378. var numComps = IR[1];
  41379. var alt = IR[2];
  41380. var tintFnIR = IR[3];
  41381. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  41382. case 'LabCS':
  41383. whitePoint = IR[1];
  41384. blackPoint = IR[2];
  41385. var range = IR[3];
  41386. return new LabCS(whitePoint, blackPoint, range);
  41387. default:
  41388. error('Unknown name ' + name);
  41389. }
  41390. return null;
  41391. };
  41392. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  41393. if (isName(cs)) {
  41394. var colorSpaces = res.get('ColorSpace');
  41395. if (isDict(colorSpaces)) {
  41396. var refcs = colorSpaces.get(cs.name);
  41397. if (refcs) {
  41398. cs = refcs;
  41399. }
  41400. }
  41401. }
  41402. cs = xref.fetchIfRef(cs);
  41403. if (isName(cs)) {
  41404. switch (cs.name) {
  41405. case 'DeviceGray':
  41406. case 'G':
  41407. return 'DeviceGrayCS';
  41408. case 'DeviceRGB':
  41409. case 'RGB':
  41410. return 'DeviceRgbCS';
  41411. case 'DeviceCMYK':
  41412. case 'CMYK':
  41413. return 'DeviceCmykCS';
  41414. case 'Pattern':
  41415. return [
  41416. 'PatternCS',
  41417. null
  41418. ];
  41419. default:
  41420. error('unrecognized colorspace ' + cs.name);
  41421. }
  41422. } else if (isArray(cs)) {
  41423. var mode = xref.fetchIfRef(cs[0]).name;
  41424. var numComps, params, alt, whitePoint, blackPoint, gamma;
  41425. switch (mode) {
  41426. case 'DeviceGray':
  41427. case 'G':
  41428. return 'DeviceGrayCS';
  41429. case 'DeviceRGB':
  41430. case 'RGB':
  41431. return 'DeviceRgbCS';
  41432. case 'DeviceCMYK':
  41433. case 'CMYK':
  41434. return 'DeviceCmykCS';
  41435. case 'CalGray':
  41436. params = xref.fetchIfRef(cs[1]);
  41437. whitePoint = params.getArray('WhitePoint');
  41438. blackPoint = params.getArray('BlackPoint');
  41439. gamma = params.get('Gamma');
  41440. return [
  41441. 'CalGrayCS',
  41442. whitePoint,
  41443. blackPoint,
  41444. gamma
  41445. ];
  41446. case 'CalRGB':
  41447. params = xref.fetchIfRef(cs[1]);
  41448. whitePoint = params.getArray('WhitePoint');
  41449. blackPoint = params.getArray('BlackPoint');
  41450. gamma = params.getArray('Gamma');
  41451. var matrix = params.getArray('Matrix');
  41452. return [
  41453. 'CalRGBCS',
  41454. whitePoint,
  41455. blackPoint,
  41456. gamma,
  41457. matrix
  41458. ];
  41459. case 'ICCBased':
  41460. var stream = xref.fetchIfRef(cs[1]);
  41461. var dict = stream.dict;
  41462. numComps = dict.get('N');
  41463. alt = dict.get('Alternate');
  41464. if (alt) {
  41465. var altIR = ColorSpace.parseToIR(alt, xref, res);
  41466. var altCS = ColorSpace.fromIR(altIR);
  41467. if (altCS.numComps === numComps) {
  41468. return altIR;
  41469. }
  41470. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  41471. }
  41472. if (numComps === 1) {
  41473. return 'DeviceGrayCS';
  41474. } else if (numComps === 3) {
  41475. return 'DeviceRgbCS';
  41476. } else if (numComps === 4) {
  41477. return 'DeviceCmykCS';
  41478. }
  41479. break;
  41480. case 'Pattern':
  41481. var basePatternCS = cs[1] || null;
  41482. if (basePatternCS) {
  41483. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  41484. }
  41485. return [
  41486. 'PatternCS',
  41487. basePatternCS
  41488. ];
  41489. case 'Indexed':
  41490. case 'I':
  41491. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  41492. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  41493. var lookup = xref.fetchIfRef(cs[3]);
  41494. if (isStream(lookup)) {
  41495. lookup = lookup.getBytes();
  41496. }
  41497. return [
  41498. 'IndexedCS',
  41499. baseIndexedCS,
  41500. hiVal,
  41501. lookup
  41502. ];
  41503. case 'Separation':
  41504. case 'DeviceN':
  41505. var name = xref.fetchIfRef(cs[1]);
  41506. numComps = isArray(name) ? name.length : 1;
  41507. alt = ColorSpace.parseToIR(cs[2], xref, res);
  41508. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  41509. return [
  41510. 'AlternateCS',
  41511. numComps,
  41512. alt,
  41513. tintFnIR
  41514. ];
  41515. case 'Lab':
  41516. params = xref.fetchIfRef(cs[1]);
  41517. whitePoint = params.getArray('WhitePoint');
  41518. blackPoint = params.getArray('BlackPoint');
  41519. var range = params.getArray('Range');
  41520. return [
  41521. 'LabCS',
  41522. whitePoint,
  41523. blackPoint,
  41524. range
  41525. ];
  41526. default:
  41527. error('unimplemented color space object "' + mode + '"');
  41528. }
  41529. } else {
  41530. error('unrecognized color space object: "' + cs + '"');
  41531. }
  41532. return null;
  41533. };
  41534. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  41535. if (!isArray(decode)) {
  41536. return true;
  41537. }
  41538. if (n * 2 !== decode.length) {
  41539. warn('The decode map is not the correct length');
  41540. return true;
  41541. }
  41542. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  41543. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  41544. return false;
  41545. }
  41546. }
  41547. return true;
  41548. };
  41549. ColorSpace.singletons = {
  41550. get gray() {
  41551. return shadow(this, 'gray', new DeviceGrayCS());
  41552. },
  41553. get rgb() {
  41554. return shadow(this, 'rgb', new DeviceRgbCS());
  41555. },
  41556. get cmyk() {
  41557. return shadow(this, 'cmyk', new DeviceCmykCS());
  41558. }
  41559. };
  41560. return ColorSpace;
  41561. }();
  41562. var AlternateCS = function AlternateCSClosure() {
  41563. function AlternateCS(numComps, base, tintFn) {
  41564. this.name = 'Alternate';
  41565. this.numComps = numComps;
  41566. this.defaultColor = new Float32Array(numComps);
  41567. for (var i = 0; i < numComps; ++i) {
  41568. this.defaultColor[i] = 1;
  41569. }
  41570. this.base = base;
  41571. this.tintFn = tintFn;
  41572. this.tmpBuf = new Float32Array(base.numComps);
  41573. }
  41574. AlternateCS.prototype = {
  41575. getRgb: ColorSpace.prototype.getRgb,
  41576. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41577. var tmpBuf = this.tmpBuf;
  41578. this.tintFn(src, srcOffset, tmpBuf, 0);
  41579. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  41580. },
  41581. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41582. var tintFn = this.tintFn;
  41583. var base = this.base;
  41584. var scale = 1 / ((1 << bits) - 1);
  41585. var baseNumComps = base.numComps;
  41586. var usesZeroToOneRange = base.usesZeroToOneRange;
  41587. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  41588. var pos = isPassthrough ? destOffset : 0;
  41589. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  41590. var numComps = this.numComps;
  41591. var scaled = new Float32Array(numComps);
  41592. var tinted = new Float32Array(baseNumComps);
  41593. var i, j;
  41594. for (i = 0; i < count; i++) {
  41595. for (j = 0; j < numComps; j++) {
  41596. scaled[j] = src[srcOffset++] * scale;
  41597. }
  41598. tintFn(scaled, 0, tinted, 0);
  41599. if (usesZeroToOneRange) {
  41600. for (j = 0; j < baseNumComps; j++) {
  41601. baseBuf[pos++] = tinted[j] * 255;
  41602. }
  41603. } else {
  41604. base.getRgbItem(tinted, 0, baseBuf, pos);
  41605. pos += baseNumComps;
  41606. }
  41607. }
  41608. if (!isPassthrough) {
  41609. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  41610. }
  41611. },
  41612. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  41613. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  41614. },
  41615. isPassthrough: ColorSpace.prototype.isPassthrough,
  41616. fillRgb: ColorSpace.prototype.fillRgb,
  41617. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  41618. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41619. },
  41620. usesZeroToOneRange: true
  41621. };
  41622. return AlternateCS;
  41623. }();
  41624. var PatternCS = function PatternCSClosure() {
  41625. function PatternCS(baseCS) {
  41626. this.name = 'Pattern';
  41627. this.base = baseCS;
  41628. }
  41629. PatternCS.prototype = {};
  41630. return PatternCS;
  41631. }();
  41632. var IndexedCS = function IndexedCSClosure() {
  41633. function IndexedCS(base, highVal, lookup) {
  41634. this.name = 'Indexed';
  41635. this.numComps = 1;
  41636. this.defaultColor = new Uint8Array(this.numComps);
  41637. this.base = base;
  41638. this.highVal = highVal;
  41639. var baseNumComps = base.numComps;
  41640. var length = baseNumComps * highVal;
  41641. if (isStream(lookup)) {
  41642. this.lookup = new Uint8Array(length);
  41643. var bytes = lookup.getBytes(length);
  41644. this.lookup.set(bytes);
  41645. } else if (isString(lookup)) {
  41646. this.lookup = new Uint8Array(length);
  41647. for (var i = 0; i < length; ++i) {
  41648. this.lookup[i] = lookup.charCodeAt(i);
  41649. }
  41650. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  41651. this.lookup = lookup;
  41652. } else {
  41653. error('Unrecognized lookup table: ' + lookup);
  41654. }
  41655. }
  41656. IndexedCS.prototype = {
  41657. getRgb: ColorSpace.prototype.getRgb,
  41658. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41659. var numComps = this.base.numComps;
  41660. var start = src[srcOffset] * numComps;
  41661. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  41662. },
  41663. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41664. var base = this.base;
  41665. var numComps = base.numComps;
  41666. var outputDelta = base.getOutputLength(numComps, alpha01);
  41667. var lookup = this.lookup;
  41668. for (var i = 0; i < count; ++i) {
  41669. var lookupPos = src[srcOffset++] * numComps;
  41670. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  41671. destOffset += outputDelta;
  41672. }
  41673. },
  41674. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  41675. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  41676. },
  41677. isPassthrough: ColorSpace.prototype.isPassthrough,
  41678. fillRgb: ColorSpace.prototype.fillRgb,
  41679. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  41680. return true;
  41681. },
  41682. usesZeroToOneRange: true
  41683. };
  41684. return IndexedCS;
  41685. }();
  41686. var DeviceGrayCS = function DeviceGrayCSClosure() {
  41687. function DeviceGrayCS() {
  41688. this.name = 'DeviceGray';
  41689. this.numComps = 1;
  41690. this.defaultColor = new Float32Array(this.numComps);
  41691. }
  41692. DeviceGrayCS.prototype = {
  41693. getRgb: ColorSpace.prototype.getRgb,
  41694. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41695. var c = src[srcOffset] * 255 | 0;
  41696. c = c < 0 ? 0 : c > 255 ? 255 : c;
  41697. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  41698. },
  41699. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41700. var scale = 255 / ((1 << bits) - 1);
  41701. var j = srcOffset, q = destOffset;
  41702. for (var i = 0; i < count; ++i) {
  41703. var c = scale * src[j++] | 0;
  41704. dest[q++] = c;
  41705. dest[q++] = c;
  41706. dest[q++] = c;
  41707. q += alpha01;
  41708. }
  41709. },
  41710. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  41711. return inputLength * (3 + alpha01);
  41712. },
  41713. isPassthrough: ColorSpace.prototype.isPassthrough,
  41714. fillRgb: ColorSpace.prototype.fillRgb,
  41715. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  41716. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41717. },
  41718. usesZeroToOneRange: true
  41719. };
  41720. return DeviceGrayCS;
  41721. }();
  41722. var DeviceRgbCS = function DeviceRgbCSClosure() {
  41723. function DeviceRgbCS() {
  41724. this.name = 'DeviceRGB';
  41725. this.numComps = 3;
  41726. this.defaultColor = new Float32Array(this.numComps);
  41727. }
  41728. DeviceRgbCS.prototype = {
  41729. getRgb: ColorSpace.prototype.getRgb,
  41730. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41731. var r = src[srcOffset] * 255 | 0;
  41732. var g = src[srcOffset + 1] * 255 | 0;
  41733. var b = src[srcOffset + 2] * 255 | 0;
  41734. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  41735. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  41736. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  41737. },
  41738. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41739. if (bits === 8 && alpha01 === 0) {
  41740. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  41741. return;
  41742. }
  41743. var scale = 255 / ((1 << bits) - 1);
  41744. var j = srcOffset, q = destOffset;
  41745. for (var i = 0; i < count; ++i) {
  41746. dest[q++] = scale * src[j++] | 0;
  41747. dest[q++] = scale * src[j++] | 0;
  41748. dest[q++] = scale * src[j++] | 0;
  41749. q += alpha01;
  41750. }
  41751. },
  41752. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  41753. return inputLength * (3 + alpha01) / 3 | 0;
  41754. },
  41755. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  41756. return bits === 8;
  41757. },
  41758. fillRgb: ColorSpace.prototype.fillRgb,
  41759. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  41760. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41761. },
  41762. usesZeroToOneRange: true
  41763. };
  41764. return DeviceRgbCS;
  41765. }();
  41766. var DeviceCmykCS = function DeviceCmykCSClosure() {
  41767. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  41768. var c = src[srcOffset + 0] * srcScale;
  41769. var m = src[srcOffset + 1] * srcScale;
  41770. var y = src[srcOffset + 2] * srcScale;
  41771. var k = src[srcOffset + 3] * srcScale;
  41772. 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;
  41773. 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;
  41774. 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;
  41775. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  41776. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  41777. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  41778. }
  41779. function DeviceCmykCS() {
  41780. this.name = 'DeviceCMYK';
  41781. this.numComps = 4;
  41782. this.defaultColor = new Float32Array(this.numComps);
  41783. this.defaultColor[3] = 1;
  41784. }
  41785. DeviceCmykCS.prototype = {
  41786. getRgb: ColorSpace.prototype.getRgb,
  41787. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41788. convertToRgb(src, srcOffset, 1, dest, destOffset);
  41789. },
  41790. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41791. var scale = 1 / ((1 << bits) - 1);
  41792. for (var i = 0; i < count; i++) {
  41793. convertToRgb(src, srcOffset, scale, dest, destOffset);
  41794. srcOffset += 4;
  41795. destOffset += 3 + alpha01;
  41796. }
  41797. },
  41798. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  41799. return inputLength / 4 * (3 + alpha01) | 0;
  41800. },
  41801. isPassthrough: ColorSpace.prototype.isPassthrough,
  41802. fillRgb: ColorSpace.prototype.fillRgb,
  41803. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  41804. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41805. },
  41806. usesZeroToOneRange: true
  41807. };
  41808. return DeviceCmykCS;
  41809. }();
  41810. var CalGrayCS = function CalGrayCSClosure() {
  41811. function CalGrayCS(whitePoint, blackPoint, gamma) {
  41812. this.name = 'CalGray';
  41813. this.numComps = 1;
  41814. this.defaultColor = new Float32Array(this.numComps);
  41815. if (!whitePoint) {
  41816. error('WhitePoint missing - required for color space CalGray');
  41817. }
  41818. blackPoint = blackPoint || [
  41819. 0,
  41820. 0,
  41821. 0
  41822. ];
  41823. gamma = gamma || 1;
  41824. this.XW = whitePoint[0];
  41825. this.YW = whitePoint[1];
  41826. this.ZW = whitePoint[2];
  41827. this.XB = blackPoint[0];
  41828. this.YB = blackPoint[1];
  41829. this.ZB = blackPoint[2];
  41830. this.G = gamma;
  41831. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  41832. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41833. }
  41834. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  41835. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  41836. this.XB = this.YB = this.ZB = 0;
  41837. }
  41838. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  41839. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  41840. }
  41841. if (this.G < 1) {
  41842. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  41843. this.G = 1;
  41844. }
  41845. }
  41846. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  41847. var A = src[srcOffset] * scale;
  41848. var AG = Math.pow(A, cs.G);
  41849. var L = cs.YW * AG;
  41850. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  41851. dest[destOffset] = val;
  41852. dest[destOffset + 1] = val;
  41853. dest[destOffset + 2] = val;
  41854. }
  41855. CalGrayCS.prototype = {
  41856. getRgb: ColorSpace.prototype.getRgb,
  41857. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41858. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  41859. },
  41860. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41861. var scale = 1 / ((1 << bits) - 1);
  41862. for (var i = 0; i < count; ++i) {
  41863. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  41864. srcOffset += 1;
  41865. destOffset += 3 + alpha01;
  41866. }
  41867. },
  41868. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  41869. return inputLength * (3 + alpha01);
  41870. },
  41871. isPassthrough: ColorSpace.prototype.isPassthrough,
  41872. fillRgb: ColorSpace.prototype.fillRgb,
  41873. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  41874. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41875. },
  41876. usesZeroToOneRange: true
  41877. };
  41878. return CalGrayCS;
  41879. }();
  41880. var CalRGBCS = function CalRGBCSClosure() {
  41881. var BRADFORD_SCALE_MATRIX = new Float32Array([
  41882. 0.8951,
  41883. 0.2664,
  41884. -0.1614,
  41885. -0.7502,
  41886. 1.7135,
  41887. 0.0367,
  41888. 0.0389,
  41889. -0.0685,
  41890. 1.0296
  41891. ]);
  41892. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  41893. 0.9869929,
  41894. -0.1470543,
  41895. 0.1599627,
  41896. 0.4323053,
  41897. 0.5183603,
  41898. 0.0492912,
  41899. -0.0085287,
  41900. 0.0400428,
  41901. 0.9684867
  41902. ]);
  41903. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  41904. 3.2404542,
  41905. -1.5371385,
  41906. -0.4985314,
  41907. -0.9692660,
  41908. 1.8760108,
  41909. 0.0415560,
  41910. 0.0556434,
  41911. -0.2040259,
  41912. 1.0572252
  41913. ]);
  41914. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  41915. 1,
  41916. 1,
  41917. 1
  41918. ]);
  41919. var tempNormalizeMatrix = new Float32Array(3);
  41920. var tempConvertMatrix1 = new Float32Array(3);
  41921. var tempConvertMatrix2 = new Float32Array(3);
  41922. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  41923. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  41924. this.name = 'CalRGB';
  41925. this.numComps = 3;
  41926. this.defaultColor = new Float32Array(this.numComps);
  41927. if (!whitePoint) {
  41928. error('WhitePoint missing - required for color space CalRGB');
  41929. }
  41930. blackPoint = blackPoint || new Float32Array(3);
  41931. gamma = gamma || new Float32Array([
  41932. 1,
  41933. 1,
  41934. 1
  41935. ]);
  41936. matrix = matrix || new Float32Array([
  41937. 1,
  41938. 0,
  41939. 0,
  41940. 0,
  41941. 1,
  41942. 0,
  41943. 0,
  41944. 0,
  41945. 1
  41946. ]);
  41947. var XW = whitePoint[0];
  41948. var YW = whitePoint[1];
  41949. var ZW = whitePoint[2];
  41950. this.whitePoint = whitePoint;
  41951. var XB = blackPoint[0];
  41952. var YB = blackPoint[1];
  41953. var ZB = blackPoint[2];
  41954. this.blackPoint = blackPoint;
  41955. this.GR = gamma[0];
  41956. this.GG = gamma[1];
  41957. this.GB = gamma[2];
  41958. this.MXA = matrix[0];
  41959. this.MYA = matrix[1];
  41960. this.MZA = matrix[2];
  41961. this.MXB = matrix[3];
  41962. this.MYB = matrix[4];
  41963. this.MZB = matrix[5];
  41964. this.MXC = matrix[6];
  41965. this.MYC = matrix[7];
  41966. this.MZC = matrix[8];
  41967. if (XW < 0 || ZW < 0 || YW !== 1) {
  41968. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41969. }
  41970. if (XB < 0 || YB < 0 || ZB < 0) {
  41971. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  41972. this.blackPoint = new Float32Array(3);
  41973. }
  41974. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  41975. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  41976. this.GR = this.GG = this.GB = 1;
  41977. }
  41978. 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) {
  41979. 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');
  41980. this.MXA = this.MYB = this.MZC = 1;
  41981. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  41982. }
  41983. }
  41984. function matrixProduct(a, b, result) {
  41985. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  41986. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  41987. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  41988. }
  41989. function convertToFlat(sourceWhitePoint, LMS, result) {
  41990. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  41991. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  41992. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  41993. }
  41994. function convertToD65(sourceWhitePoint, LMS, result) {
  41995. var D65X = 0.95047;
  41996. var D65Y = 1;
  41997. var D65Z = 1.08883;
  41998. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  41999. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  42000. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  42001. }
  42002. function sRGBTransferFunction(color) {
  42003. if (color <= 0.0031308) {
  42004. return adjustToRange(0, 1, 12.92 * color);
  42005. }
  42006. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  42007. }
  42008. function adjustToRange(min, max, value) {
  42009. return Math.max(min, Math.min(max, value));
  42010. }
  42011. function decodeL(L) {
  42012. if (L < 0) {
  42013. return -decodeL(-L);
  42014. }
  42015. if (L > 8.0) {
  42016. return Math.pow((L + 16) / 116, 3);
  42017. }
  42018. return L * DECODE_L_CONSTANT;
  42019. }
  42020. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  42021. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  42022. result[0] = XYZ_Flat[0];
  42023. result[1] = XYZ_Flat[1];
  42024. result[2] = XYZ_Flat[2];
  42025. return;
  42026. }
  42027. var zeroDecodeL = decodeL(0);
  42028. var X_DST = zeroDecodeL;
  42029. var X_SRC = decodeL(sourceBlackPoint[0]);
  42030. var Y_DST = zeroDecodeL;
  42031. var Y_SRC = decodeL(sourceBlackPoint[1]);
  42032. var Z_DST = zeroDecodeL;
  42033. var Z_SRC = decodeL(sourceBlackPoint[2]);
  42034. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  42035. var X_Offset = 1 - X_Scale;
  42036. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  42037. var Y_Offset = 1 - Y_Scale;
  42038. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  42039. var Z_Offset = 1 - Z_Scale;
  42040. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  42041. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  42042. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  42043. }
  42044. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  42045. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  42046. result[0] = XYZ_In[0];
  42047. result[1] = XYZ_In[1];
  42048. result[2] = XYZ_In[2];
  42049. return;
  42050. }
  42051. var LMS = result;
  42052. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  42053. var LMS_Flat = tempNormalizeMatrix;
  42054. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  42055. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  42056. }
  42057. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  42058. var LMS = result;
  42059. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  42060. var LMS_D65 = tempNormalizeMatrix;
  42061. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  42062. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  42063. }
  42064. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  42065. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  42066. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  42067. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  42068. var AGR = Math.pow(A, cs.GR);
  42069. var BGG = Math.pow(B, cs.GG);
  42070. var CGB = Math.pow(C, cs.GB);
  42071. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  42072. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  42073. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  42074. var XYZ = tempConvertMatrix1;
  42075. XYZ[0] = X;
  42076. XYZ[1] = Y;
  42077. XYZ[2] = Z;
  42078. var XYZ_Flat = tempConvertMatrix2;
  42079. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  42080. var XYZ_Black = tempConvertMatrix1;
  42081. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  42082. var XYZ_D65 = tempConvertMatrix2;
  42083. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  42084. var SRGB = tempConvertMatrix1;
  42085. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  42086. var sR = sRGBTransferFunction(SRGB[0]);
  42087. var sG = sRGBTransferFunction(SRGB[1]);
  42088. var sB = sRGBTransferFunction(SRGB[2]);
  42089. dest[destOffset] = Math.round(sR * 255);
  42090. dest[destOffset + 1] = Math.round(sG * 255);
  42091. dest[destOffset + 2] = Math.round(sB * 255);
  42092. }
  42093. CalRGBCS.prototype = {
  42094. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  42095. var rgb = new Uint8Array(3);
  42096. this.getRgbItem(src, srcOffset, rgb, 0);
  42097. return rgb;
  42098. },
  42099. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42100. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  42101. },
  42102. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42103. var scale = 1 / ((1 << bits) - 1);
  42104. for (var i = 0; i < count; ++i) {
  42105. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  42106. srcOffset += 3;
  42107. destOffset += 3 + alpha01;
  42108. }
  42109. },
  42110. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  42111. return inputLength * (3 + alpha01) / 3 | 0;
  42112. },
  42113. isPassthrough: ColorSpace.prototype.isPassthrough,
  42114. fillRgb: ColorSpace.prototype.fillRgb,
  42115. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  42116. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  42117. },
  42118. usesZeroToOneRange: true
  42119. };
  42120. return CalRGBCS;
  42121. }();
  42122. var LabCS = function LabCSClosure() {
  42123. function LabCS(whitePoint, blackPoint, range) {
  42124. this.name = 'Lab';
  42125. this.numComps = 3;
  42126. this.defaultColor = new Float32Array(this.numComps);
  42127. if (!whitePoint) {
  42128. error('WhitePoint missing - required for color space Lab');
  42129. }
  42130. blackPoint = blackPoint || [
  42131. 0,
  42132. 0,
  42133. 0
  42134. ];
  42135. range = range || [
  42136. -100,
  42137. 100,
  42138. -100,
  42139. 100
  42140. ];
  42141. this.XW = whitePoint[0];
  42142. this.YW = whitePoint[1];
  42143. this.ZW = whitePoint[2];
  42144. this.amin = range[0];
  42145. this.amax = range[1];
  42146. this.bmin = range[2];
  42147. this.bmax = range[3];
  42148. this.XB = blackPoint[0];
  42149. this.YB = blackPoint[1];
  42150. this.ZB = blackPoint[2];
  42151. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  42152. error('Invalid WhitePoint components, no fallback available');
  42153. }
  42154. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  42155. info('Invalid BlackPoint, falling back to default');
  42156. this.XB = this.YB = this.ZB = 0;
  42157. }
  42158. if (this.amin > this.amax || this.bmin > this.bmax) {
  42159. info('Invalid Range, falling back to defaults');
  42160. this.amin = -100;
  42161. this.amax = 100;
  42162. this.bmin = -100;
  42163. this.bmax = 100;
  42164. }
  42165. }
  42166. function fn_g(x) {
  42167. if (x >= 6 / 29) {
  42168. return x * x * x;
  42169. } else {
  42170. return 108 / 841 * (x - 4 / 29);
  42171. }
  42172. }
  42173. function decode(value, high1, low2, high2) {
  42174. return low2 + value * (high2 - low2) / high1;
  42175. }
  42176. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  42177. var Ls = src[srcOffset];
  42178. var as = src[srcOffset + 1];
  42179. var bs = src[srcOffset + 2];
  42180. if (maxVal !== false) {
  42181. Ls = decode(Ls, maxVal, 0, 100);
  42182. as = decode(as, maxVal, cs.amin, cs.amax);
  42183. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  42184. }
  42185. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  42186. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  42187. var M = (Ls + 16) / 116;
  42188. var L = M + as / 500;
  42189. var N = M - bs / 200;
  42190. var X = cs.XW * fn_g(L);
  42191. var Y = cs.YW * fn_g(M);
  42192. var Z = cs.ZW * fn_g(N);
  42193. var r, g, b;
  42194. if (cs.ZW < 1) {
  42195. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  42196. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  42197. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  42198. } else {
  42199. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  42200. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  42201. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  42202. }
  42203. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  42204. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  42205. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  42206. }
  42207. LabCS.prototype = {
  42208. getRgb: ColorSpace.prototype.getRgb,
  42209. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42210. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  42211. },
  42212. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42213. var maxVal = (1 << bits) - 1;
  42214. for (var i = 0; i < count; i++) {
  42215. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  42216. srcOffset += 3;
  42217. destOffset += 3 + alpha01;
  42218. }
  42219. },
  42220. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  42221. return inputLength * (3 + alpha01) / 3 | 0;
  42222. },
  42223. isPassthrough: ColorSpace.prototype.isPassthrough,
  42224. fillRgb: ColorSpace.prototype.fillRgb,
  42225. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  42226. return true;
  42227. },
  42228. usesZeroToOneRange: false
  42229. };
  42230. return LabCS;
  42231. }();
  42232. exports.ColorSpace = ColorSpace;
  42233. }));
  42234. (function (root, factory) {
  42235. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  42236. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  42237. var ImageKind = sharedUtil.ImageKind;
  42238. var assert = sharedUtil.assert;
  42239. var error = sharedUtil.error;
  42240. var info = sharedUtil.info;
  42241. var isArray = sharedUtil.isArray;
  42242. var warn = sharedUtil.warn;
  42243. var Name = corePrimitives.Name;
  42244. var isStream = corePrimitives.isStream;
  42245. var ColorSpace = coreColorSpace.ColorSpace;
  42246. var DecodeStream = coreStream.DecodeStream;
  42247. var JpegStream = coreStream.JpegStream;
  42248. var JpxImage = coreJpx.JpxImage;
  42249. var PDFImage = function PDFImageClosure() {
  42250. function handleImageData(image, nativeDecoder) {
  42251. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  42252. return nativeDecoder.decode(image);
  42253. } else {
  42254. return Promise.resolve(image);
  42255. }
  42256. }
  42257. function decodeAndClamp(value, addend, coefficient, max) {
  42258. value = addend + value * coefficient;
  42259. return value < 0 ? 0 : value > max ? max : value;
  42260. }
  42261. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  42262. var length = w2 * h2;
  42263. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42264. var xRatio = w1 / w2;
  42265. var yRatio = h1 / h2;
  42266. var i, j, py, newIndex = 0, oldIndex;
  42267. var xScaled = new Uint16Array(w2);
  42268. var w1Scanline = w1;
  42269. for (i = 0; i < w2; i++) {
  42270. xScaled[i] = Math.floor(i * xRatio);
  42271. }
  42272. for (i = 0; i < h2; i++) {
  42273. py = Math.floor(i * yRatio) * w1Scanline;
  42274. for (j = 0; j < w2; j++) {
  42275. oldIndex = py + xScaled[j];
  42276. dest[newIndex++] = src[oldIndex];
  42277. }
  42278. }
  42279. return dest;
  42280. }
  42281. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  42282. this.image = image;
  42283. var dict = image.dict;
  42284. if (dict.has('Filter')) {
  42285. var filter = dict.get('Filter').name;
  42286. if (filter === 'JPXDecode') {
  42287. var jpxImage = new JpxImage();
  42288. jpxImage.parseImageProperties(image.stream);
  42289. image.stream.reset();
  42290. image.bitsPerComponent = jpxImage.bitsPerComponent;
  42291. image.numComps = jpxImage.componentsCount;
  42292. } else if (filter === 'JBIG2Decode') {
  42293. image.bitsPerComponent = 1;
  42294. image.numComps = 1;
  42295. }
  42296. }
  42297. this.width = dict.get('Width', 'W');
  42298. this.height = dict.get('Height', 'H');
  42299. if (this.width < 1 || this.height < 1) {
  42300. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  42301. }
  42302. this.interpolate = dict.get('Interpolate', 'I') || false;
  42303. this.imageMask = dict.get('ImageMask', 'IM') || false;
  42304. this.matte = dict.get('Matte') || false;
  42305. var bitsPerComponent = image.bitsPerComponent;
  42306. if (!bitsPerComponent) {
  42307. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  42308. if (!bitsPerComponent) {
  42309. if (this.imageMask) {
  42310. bitsPerComponent = 1;
  42311. } else {
  42312. error('Bits per component missing in image: ' + this.imageMask);
  42313. }
  42314. }
  42315. }
  42316. this.bpc = bitsPerComponent;
  42317. if (!this.imageMask) {
  42318. var colorSpace = dict.get('ColorSpace', 'CS');
  42319. if (!colorSpace) {
  42320. info('JPX images (which do not require color spaces)');
  42321. switch (image.numComps) {
  42322. case 1:
  42323. colorSpace = Name.get('DeviceGray');
  42324. break;
  42325. case 3:
  42326. colorSpace = Name.get('DeviceRGB');
  42327. break;
  42328. case 4:
  42329. colorSpace = Name.get('DeviceCMYK');
  42330. break;
  42331. default:
  42332. error('JPX images with ' + this.numComps + ' color components not supported.');
  42333. }
  42334. }
  42335. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  42336. this.numComps = this.colorSpace.numComps;
  42337. }
  42338. this.decode = dict.getArray('Decode', 'D');
  42339. this.needsDecode = false;
  42340. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  42341. this.needsDecode = true;
  42342. var max = (1 << bitsPerComponent) - 1;
  42343. this.decodeCoefficients = [];
  42344. this.decodeAddends = [];
  42345. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  42346. var dmin = this.decode[i];
  42347. var dmax = this.decode[i + 1];
  42348. this.decodeCoefficients[j] = dmax - dmin;
  42349. this.decodeAddends[j] = max * dmin;
  42350. }
  42351. }
  42352. if (smask) {
  42353. this.smask = new PDFImage(xref, res, smask, false);
  42354. } else if (mask) {
  42355. if (isStream(mask)) {
  42356. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  42357. if (!imageMask) {
  42358. warn('Ignoring /Mask in image without /ImageMask.');
  42359. } else {
  42360. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  42361. }
  42362. } else {
  42363. this.mask = mask;
  42364. }
  42365. }
  42366. }
  42367. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  42368. var imagePromise = handleImageData(image, nativeDecoder);
  42369. var smaskPromise;
  42370. var maskPromise;
  42371. var smask = image.dict.get('SMask');
  42372. var mask = image.dict.get('Mask');
  42373. if (smask) {
  42374. smaskPromise = handleImageData(smask, nativeDecoder);
  42375. maskPromise = Promise.resolve(null);
  42376. } else {
  42377. smaskPromise = Promise.resolve(null);
  42378. if (mask) {
  42379. if (isStream(mask)) {
  42380. maskPromise = handleImageData(mask, nativeDecoder);
  42381. } else if (isArray(mask)) {
  42382. maskPromise = Promise.resolve(mask);
  42383. } else {
  42384. warn('Unsupported mask format.');
  42385. maskPromise = Promise.resolve(null);
  42386. }
  42387. } else {
  42388. maskPromise = Promise.resolve(null);
  42389. }
  42390. }
  42391. return Promise.all([
  42392. imagePromise,
  42393. smaskPromise,
  42394. maskPromise
  42395. ]).then(function (results) {
  42396. var imageData = results[0];
  42397. var smaskData = results[1];
  42398. var maskData = results[2];
  42399. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  42400. });
  42401. };
  42402. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  42403. var computedLength = (width + 7 >> 3) * height;
  42404. var actualLength = imgArray.byteLength;
  42405. var haveFullData = computedLength === actualLength;
  42406. var data, i;
  42407. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  42408. data = imgArray;
  42409. } else if (!inverseDecode) {
  42410. data = new Uint8Array(actualLength);
  42411. data.set(imgArray);
  42412. } else {
  42413. data = new Uint8Array(computedLength);
  42414. data.set(imgArray);
  42415. for (i = actualLength; i < computedLength; i++) {
  42416. data[i] = 0xff;
  42417. }
  42418. }
  42419. if (inverseDecode) {
  42420. for (i = 0; i < actualLength; i++) {
  42421. data[i] = ~data[i];
  42422. }
  42423. }
  42424. return {
  42425. data: data,
  42426. width: width,
  42427. height: height
  42428. };
  42429. };
  42430. PDFImage.prototype = {
  42431. get drawWidth() {
  42432. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  42433. },
  42434. get drawHeight() {
  42435. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  42436. },
  42437. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  42438. var bpc = this.bpc;
  42439. var numComps = this.numComps;
  42440. var decodeAddends = this.decodeAddends;
  42441. var decodeCoefficients = this.decodeCoefficients;
  42442. var max = (1 << bpc) - 1;
  42443. var i, ii;
  42444. if (bpc === 1) {
  42445. for (i = 0, ii = buffer.length; i < ii; i++) {
  42446. buffer[i] = +!buffer[i];
  42447. }
  42448. return;
  42449. }
  42450. var index = 0;
  42451. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  42452. for (var j = 0; j < numComps; j++) {
  42453. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  42454. index++;
  42455. }
  42456. }
  42457. },
  42458. getComponents: function PDFImage_getComponents(buffer) {
  42459. var bpc = this.bpc;
  42460. if (bpc === 8) {
  42461. return buffer;
  42462. }
  42463. var width = this.width;
  42464. var height = this.height;
  42465. var numComps = this.numComps;
  42466. var length = width * height * numComps;
  42467. var bufferPos = 0;
  42468. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42469. var rowComps = width * numComps;
  42470. var max = (1 << bpc) - 1;
  42471. var i = 0, ii, buf;
  42472. if (bpc === 1) {
  42473. var mask, loop1End, loop2End;
  42474. for (var j = 0; j < height; j++) {
  42475. loop1End = i + (rowComps & ~7);
  42476. loop2End = i + rowComps;
  42477. while (i < loop1End) {
  42478. buf = buffer[bufferPos++];
  42479. output[i] = buf >> 7 & 1;
  42480. output[i + 1] = buf >> 6 & 1;
  42481. output[i + 2] = buf >> 5 & 1;
  42482. output[i + 3] = buf >> 4 & 1;
  42483. output[i + 4] = buf >> 3 & 1;
  42484. output[i + 5] = buf >> 2 & 1;
  42485. output[i + 6] = buf >> 1 & 1;
  42486. output[i + 7] = buf & 1;
  42487. i += 8;
  42488. }
  42489. if (i < loop2End) {
  42490. buf = buffer[bufferPos++];
  42491. mask = 128;
  42492. while (i < loop2End) {
  42493. output[i++] = +!!(buf & mask);
  42494. mask >>= 1;
  42495. }
  42496. }
  42497. }
  42498. } else {
  42499. var bits = 0;
  42500. buf = 0;
  42501. for (i = 0, ii = length; i < ii; ++i) {
  42502. if (i % rowComps === 0) {
  42503. buf = 0;
  42504. bits = 0;
  42505. }
  42506. while (bits < bpc) {
  42507. buf = buf << 8 | buffer[bufferPos++];
  42508. bits += 8;
  42509. }
  42510. var remainingBits = bits - bpc;
  42511. var value = buf >> remainingBits;
  42512. output[i] = value < 0 ? 0 : value > max ? max : value;
  42513. buf = buf & (1 << remainingBits) - 1;
  42514. bits = remainingBits;
  42515. }
  42516. }
  42517. return output;
  42518. },
  42519. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  42520. var smask = this.smask;
  42521. var mask = this.mask;
  42522. var alphaBuf, sw, sh, i, ii, j;
  42523. if (smask) {
  42524. sw = smask.width;
  42525. sh = smask.height;
  42526. alphaBuf = new Uint8Array(sw * sh);
  42527. smask.fillGrayBuffer(alphaBuf);
  42528. if (sw !== width || sh !== height) {
  42529. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  42530. }
  42531. } else if (mask) {
  42532. if (mask instanceof PDFImage) {
  42533. sw = mask.width;
  42534. sh = mask.height;
  42535. alphaBuf = new Uint8Array(sw * sh);
  42536. mask.numComps = 1;
  42537. mask.fillGrayBuffer(alphaBuf);
  42538. for (i = 0, ii = sw * sh; i < ii; ++i) {
  42539. alphaBuf[i] = 255 - alphaBuf[i];
  42540. }
  42541. if (sw !== width || sh !== height) {
  42542. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  42543. }
  42544. } else if (isArray(mask)) {
  42545. alphaBuf = new Uint8Array(width * height);
  42546. var numComps = this.numComps;
  42547. for (i = 0, ii = width * height; i < ii; ++i) {
  42548. var opacity = 0;
  42549. var imageOffset = i * numComps;
  42550. for (j = 0; j < numComps; ++j) {
  42551. var color = image[imageOffset + j];
  42552. var maskOffset = j * 2;
  42553. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  42554. opacity = 255;
  42555. break;
  42556. }
  42557. }
  42558. alphaBuf[i] = opacity;
  42559. }
  42560. } else {
  42561. error('Unknown mask format.');
  42562. }
  42563. }
  42564. if (alphaBuf) {
  42565. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42566. rgbaBuf[j] = alphaBuf[i];
  42567. }
  42568. } else {
  42569. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42570. rgbaBuf[j] = 255;
  42571. }
  42572. }
  42573. },
  42574. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  42575. var matte = this.smask && this.smask.matte;
  42576. if (!matte) {
  42577. return;
  42578. }
  42579. var matteRgb = this.colorSpace.getRgb(matte, 0);
  42580. var matteR = matteRgb[0];
  42581. var matteG = matteRgb[1];
  42582. var matteB = matteRgb[2];
  42583. var length = width * height * 4;
  42584. var r, g, b;
  42585. for (var i = 0; i < length; i += 4) {
  42586. var alpha = buffer[i + 3];
  42587. if (alpha === 0) {
  42588. buffer[i] = 255;
  42589. buffer[i + 1] = 255;
  42590. buffer[i + 2] = 255;
  42591. continue;
  42592. }
  42593. var k = 255 / alpha;
  42594. r = (buffer[i] - matteR) * k + matteR;
  42595. g = (buffer[i + 1] - matteG) * k + matteG;
  42596. b = (buffer[i + 2] - matteB) * k + matteB;
  42597. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  42598. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  42599. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  42600. }
  42601. },
  42602. createImageData: function PDFImage_createImageData(forceRGBA) {
  42603. var drawWidth = this.drawWidth;
  42604. var drawHeight = this.drawHeight;
  42605. var imgData = {
  42606. width: drawWidth,
  42607. height: drawHeight
  42608. };
  42609. var numComps = this.numComps;
  42610. var originalWidth = this.width;
  42611. var originalHeight = this.height;
  42612. var bpc = this.bpc;
  42613. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  42614. var imgArray;
  42615. if (!forceRGBA) {
  42616. var kind;
  42617. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  42618. kind = ImageKind.GRAYSCALE_1BPP;
  42619. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  42620. kind = ImageKind.RGB_24BPP;
  42621. }
  42622. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  42623. imgData.kind = kind;
  42624. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42625. if (this.image instanceof DecodeStream) {
  42626. imgData.data = imgArray;
  42627. } else {
  42628. var newArray = new Uint8Array(imgArray.length);
  42629. newArray.set(imgArray);
  42630. imgData.data = newArray;
  42631. }
  42632. if (this.needsDecode) {
  42633. assert(kind === ImageKind.GRAYSCALE_1BPP);
  42634. var buffer = imgData.data;
  42635. for (var i = 0, ii = buffer.length; i < ii; i++) {
  42636. buffer[i] ^= 0xff;
  42637. }
  42638. }
  42639. return imgData;
  42640. }
  42641. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  42642. imgData.kind = ImageKind.RGB_24BPP;
  42643. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  42644. return imgData;
  42645. }
  42646. }
  42647. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42648. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  42649. var comps = this.getComponents(imgArray);
  42650. var alpha01, maybeUndoPreblend;
  42651. if (!forceRGBA && !this.smask && !this.mask) {
  42652. imgData.kind = ImageKind.RGB_24BPP;
  42653. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  42654. alpha01 = 0;
  42655. maybeUndoPreblend = false;
  42656. } else {
  42657. imgData.kind = ImageKind.RGBA_32BPP;
  42658. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  42659. alpha01 = 1;
  42660. maybeUndoPreblend = true;
  42661. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  42662. }
  42663. if (this.needsDecode) {
  42664. this.decodeBuffer(comps);
  42665. }
  42666. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  42667. if (maybeUndoPreblend) {
  42668. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  42669. }
  42670. return imgData;
  42671. },
  42672. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  42673. var numComps = this.numComps;
  42674. if (numComps !== 1) {
  42675. error('Reading gray scale from a color image: ' + numComps);
  42676. }
  42677. var width = this.width;
  42678. var height = this.height;
  42679. var bpc = this.bpc;
  42680. var rowBytes = width * numComps * bpc + 7 >> 3;
  42681. var imgArray = this.getImageBytes(height * rowBytes);
  42682. var comps = this.getComponents(imgArray);
  42683. var i, length;
  42684. if (bpc === 1) {
  42685. length = width * height;
  42686. if (this.needsDecode) {
  42687. for (i = 0; i < length; ++i) {
  42688. buffer[i] = comps[i] - 1 & 255;
  42689. }
  42690. } else {
  42691. for (i = 0; i < length; ++i) {
  42692. buffer[i] = -comps[i] & 255;
  42693. }
  42694. }
  42695. return;
  42696. }
  42697. if (this.needsDecode) {
  42698. this.decodeBuffer(comps);
  42699. }
  42700. length = width * height;
  42701. var scale = 255 / ((1 << bpc) - 1);
  42702. for (i = 0; i < length; ++i) {
  42703. buffer[i] = scale * comps[i] | 0;
  42704. }
  42705. },
  42706. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  42707. this.image.reset();
  42708. this.image.drawWidth = drawWidth || this.width;
  42709. this.image.drawHeight = drawHeight || this.height;
  42710. this.image.forceRGB = !!forceRGB;
  42711. return this.image.getBytes(length);
  42712. }
  42713. };
  42714. return PDFImage;
  42715. }();
  42716. exports.PDFImage = PDFImage;
  42717. }));
  42718. (function (root, factory) {
  42719. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  42720. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  42721. var InvalidPDFException = sharedUtil.InvalidPDFException;
  42722. var MissingDataException = sharedUtil.MissingDataException;
  42723. var XRefParseException = sharedUtil.XRefParseException;
  42724. var assert = sharedUtil.assert;
  42725. var bytesToString = sharedUtil.bytesToString;
  42726. var createPromiseCapability = sharedUtil.createPromiseCapability;
  42727. var error = sharedUtil.error;
  42728. var info = sharedUtil.info;
  42729. var isArray = sharedUtil.isArray;
  42730. var isBool = sharedUtil.isBool;
  42731. var isInt = sharedUtil.isInt;
  42732. var isString = sharedUtil.isString;
  42733. var shadow = sharedUtil.shadow;
  42734. var stringToPDFString = sharedUtil.stringToPDFString;
  42735. var stringToUTF8String = sharedUtil.stringToUTF8String;
  42736. var warn = sharedUtil.warn;
  42737. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  42738. var Util = sharedUtil.Util;
  42739. var Ref = corePrimitives.Ref;
  42740. var RefSet = corePrimitives.RefSet;
  42741. var RefSetCache = corePrimitives.RefSetCache;
  42742. var isName = corePrimitives.isName;
  42743. var isCmd = corePrimitives.isCmd;
  42744. var isDict = corePrimitives.isDict;
  42745. var isRef = corePrimitives.isRef;
  42746. var isRefsEqual = corePrimitives.isRefsEqual;
  42747. var isStream = corePrimitives.isStream;
  42748. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  42749. var Lexer = coreParser.Lexer;
  42750. var Parser = coreParser.Parser;
  42751. var ChunkedStream = coreChunkedStream.ChunkedStream;
  42752. var ColorSpace = coreColorSpace.ColorSpace;
  42753. var Catalog = function CatalogClosure() {
  42754. function Catalog(pdfManager, xref, pageFactory) {
  42755. this.pdfManager = pdfManager;
  42756. this.xref = xref;
  42757. this.catDict = xref.getCatalogObj();
  42758. this.fontCache = new RefSetCache();
  42759. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  42760. this.pageFactory = pageFactory;
  42761. this.pagePromises = [];
  42762. }
  42763. Catalog.prototype = {
  42764. get metadata() {
  42765. var streamRef = this.catDict.getRaw('Metadata');
  42766. if (!isRef(streamRef)) {
  42767. return shadow(this, 'metadata', null);
  42768. }
  42769. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  42770. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  42771. var metadata;
  42772. if (stream && isDict(stream.dict)) {
  42773. var type = stream.dict.get('Type');
  42774. var subtype = stream.dict.get('Subtype');
  42775. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  42776. try {
  42777. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  42778. } catch (e) {
  42779. info('Skipping invalid metadata.');
  42780. }
  42781. }
  42782. }
  42783. return shadow(this, 'metadata', metadata);
  42784. },
  42785. get toplevelPagesDict() {
  42786. var pagesObj = this.catDict.get('Pages');
  42787. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  42788. return shadow(this, 'toplevelPagesDict', pagesObj);
  42789. },
  42790. get documentOutline() {
  42791. var obj = null;
  42792. try {
  42793. obj = this.readDocumentOutline();
  42794. } catch (ex) {
  42795. if (ex instanceof MissingDataException) {
  42796. throw ex;
  42797. }
  42798. warn('Unable to read document outline');
  42799. }
  42800. return shadow(this, 'documentOutline', obj);
  42801. },
  42802. readDocumentOutline: function Catalog_readDocumentOutline() {
  42803. var obj = this.catDict.get('Outlines');
  42804. if (!isDict(obj)) {
  42805. return null;
  42806. }
  42807. obj = obj.getRaw('First');
  42808. if (!isRef(obj)) {
  42809. return null;
  42810. }
  42811. var root = { items: [] };
  42812. var queue = [{
  42813. obj: obj,
  42814. parent: root
  42815. }];
  42816. var processed = new RefSet();
  42817. processed.put(obj);
  42818. var xref = this.xref, blackColor = new Uint8Array(3);
  42819. while (queue.length > 0) {
  42820. var i = queue.shift();
  42821. var outlineDict = xref.fetchIfRef(i.obj);
  42822. if (outlineDict === null) {
  42823. continue;
  42824. }
  42825. assert(outlineDict.has('Title'), 'Invalid outline item');
  42826. var data = {
  42827. url: null,
  42828. dest: null
  42829. };
  42830. Catalog.parseDestDictionary({
  42831. destDict: outlineDict,
  42832. resultObj: data,
  42833. docBaseUrl: this.pdfManager.docBaseUrl
  42834. });
  42835. var title = outlineDict.get('Title');
  42836. var flags = outlineDict.get('F') || 0;
  42837. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  42838. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  42839. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  42840. }
  42841. var outlineItem = {
  42842. dest: data.dest,
  42843. url: data.url,
  42844. unsafeUrl: data.unsafeUrl,
  42845. newWindow: data.newWindow,
  42846. title: stringToPDFString(title),
  42847. color: rgbColor,
  42848. count: outlineDict.get('Count'),
  42849. bold: !!(flags & 2),
  42850. italic: !!(flags & 1),
  42851. items: []
  42852. };
  42853. i.parent.items.push(outlineItem);
  42854. obj = outlineDict.getRaw('First');
  42855. if (isRef(obj) && !processed.has(obj)) {
  42856. queue.push({
  42857. obj: obj,
  42858. parent: outlineItem
  42859. });
  42860. processed.put(obj);
  42861. }
  42862. obj = outlineDict.getRaw('Next');
  42863. if (isRef(obj) && !processed.has(obj)) {
  42864. queue.push({
  42865. obj: obj,
  42866. parent: i.parent
  42867. });
  42868. processed.put(obj);
  42869. }
  42870. }
  42871. return root.items.length > 0 ? root.items : null;
  42872. },
  42873. get numPages() {
  42874. var obj = this.toplevelPagesDict.get('Count');
  42875. assert(isInt(obj), 'page count in top level pages object is not an integer');
  42876. return shadow(this, 'num', obj);
  42877. },
  42878. get destinations() {
  42879. function fetchDestination(dest) {
  42880. return isDict(dest) ? dest.get('D') : dest;
  42881. }
  42882. var xref = this.xref;
  42883. var dests = {}, nameTreeRef, nameDictionaryRef;
  42884. var obj = this.catDict.get('Names');
  42885. if (obj && obj.has('Dests')) {
  42886. nameTreeRef = obj.getRaw('Dests');
  42887. } else if (this.catDict.has('Dests')) {
  42888. nameDictionaryRef = this.catDict.get('Dests');
  42889. }
  42890. if (nameDictionaryRef) {
  42891. obj = nameDictionaryRef;
  42892. obj.forEach(function catalogForEach(key, value) {
  42893. if (!value) {
  42894. return;
  42895. }
  42896. dests[key] = fetchDestination(value);
  42897. });
  42898. }
  42899. if (nameTreeRef) {
  42900. var nameTree = new NameTree(nameTreeRef, xref);
  42901. var names = nameTree.getAll();
  42902. for (var name in names) {
  42903. dests[name] = fetchDestination(names[name]);
  42904. }
  42905. }
  42906. return shadow(this, 'destinations', dests);
  42907. },
  42908. getDestination: function Catalog_getDestination(destinationId) {
  42909. function fetchDestination(dest) {
  42910. return isDict(dest) ? dest.get('D') : dest;
  42911. }
  42912. var xref = this.xref;
  42913. var dest = null, nameTreeRef, nameDictionaryRef;
  42914. var obj = this.catDict.get('Names');
  42915. if (obj && obj.has('Dests')) {
  42916. nameTreeRef = obj.getRaw('Dests');
  42917. } else if (this.catDict.has('Dests')) {
  42918. nameDictionaryRef = this.catDict.get('Dests');
  42919. }
  42920. if (nameDictionaryRef) {
  42921. var value = nameDictionaryRef.get(destinationId);
  42922. if (value) {
  42923. dest = fetchDestination(value);
  42924. }
  42925. }
  42926. if (nameTreeRef) {
  42927. var nameTree = new NameTree(nameTreeRef, xref);
  42928. dest = fetchDestination(nameTree.get(destinationId));
  42929. }
  42930. return dest;
  42931. },
  42932. get pageLabels() {
  42933. var obj = null;
  42934. try {
  42935. obj = this.readPageLabels();
  42936. } catch (ex) {
  42937. if (ex instanceof MissingDataException) {
  42938. throw ex;
  42939. }
  42940. warn('Unable to read page labels.');
  42941. }
  42942. return shadow(this, 'pageLabels', obj);
  42943. },
  42944. readPageLabels: function Catalog_readPageLabels() {
  42945. var obj = this.catDict.getRaw('PageLabels');
  42946. if (!obj) {
  42947. return null;
  42948. }
  42949. var pageLabels = new Array(this.numPages);
  42950. var style = null;
  42951. var prefix = '';
  42952. var numberTree = new NumberTree(obj, this.xref);
  42953. var nums = numberTree.getAll();
  42954. var currentLabel = '', currentIndex = 1;
  42955. for (var i = 0, ii = this.numPages; i < ii; i++) {
  42956. if (i in nums) {
  42957. var labelDict = nums[i];
  42958. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  42959. var type = labelDict.get('Type');
  42960. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  42961. var s = labelDict.get('S');
  42962. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  42963. style = s ? s.name : null;
  42964. var p = labelDict.get('P');
  42965. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  42966. prefix = p ? stringToPDFString(p) : '';
  42967. var st = labelDict.get('St');
  42968. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  42969. currentIndex = st || 1;
  42970. }
  42971. switch (style) {
  42972. case 'D':
  42973. currentLabel = currentIndex;
  42974. break;
  42975. case 'R':
  42976. case 'r':
  42977. currentLabel = Util.toRoman(currentIndex, style === 'r');
  42978. break;
  42979. case 'A':
  42980. case 'a':
  42981. var LIMIT = 26;
  42982. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  42983. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  42984. var letterIndex = currentIndex - 1;
  42985. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  42986. var charBuf = [];
  42987. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  42988. charBuf.push(character);
  42989. }
  42990. currentLabel = charBuf.join('');
  42991. break;
  42992. default:
  42993. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  42994. }
  42995. pageLabels[i] = prefix + currentLabel;
  42996. currentLabel = '';
  42997. currentIndex++;
  42998. }
  42999. return pageLabels;
  43000. },
  43001. get attachments() {
  43002. var xref = this.xref;
  43003. var attachments = null, nameTreeRef;
  43004. var obj = this.catDict.get('Names');
  43005. if (obj) {
  43006. nameTreeRef = obj.getRaw('EmbeddedFiles');
  43007. }
  43008. if (nameTreeRef) {
  43009. var nameTree = new NameTree(nameTreeRef, xref);
  43010. var names = nameTree.getAll();
  43011. for (var name in names) {
  43012. var fs = new FileSpec(names[name], xref);
  43013. if (!attachments) {
  43014. attachments = Object.create(null);
  43015. }
  43016. attachments[stringToPDFString(name)] = fs.serializable;
  43017. }
  43018. }
  43019. return shadow(this, 'attachments', attachments);
  43020. },
  43021. get javaScript() {
  43022. var xref = this.xref;
  43023. var obj = this.catDict.get('Names');
  43024. var javaScript = [];
  43025. function appendIfJavaScriptDict(jsDict) {
  43026. var type = jsDict.get('S');
  43027. if (!isName(type, 'JavaScript')) {
  43028. return;
  43029. }
  43030. var js = jsDict.get('JS');
  43031. if (isStream(js)) {
  43032. js = bytesToString(js.getBytes());
  43033. } else if (!isString(js)) {
  43034. return;
  43035. }
  43036. javaScript.push(stringToPDFString(js));
  43037. }
  43038. if (obj && obj.has('JavaScript')) {
  43039. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  43040. var names = nameTree.getAll();
  43041. for (var name in names) {
  43042. var jsDict = names[name];
  43043. if (isDict(jsDict)) {
  43044. appendIfJavaScriptDict(jsDict);
  43045. }
  43046. }
  43047. }
  43048. var openactionDict = this.catDict.get('OpenAction');
  43049. if (isDict(openactionDict, 'Action')) {
  43050. var actionType = openactionDict.get('S');
  43051. if (isName(actionType, 'Named')) {
  43052. var action = openactionDict.get('N');
  43053. if (isName(action, 'Print')) {
  43054. javaScript.push('print({});');
  43055. }
  43056. } else {
  43057. appendIfJavaScriptDict(openactionDict);
  43058. }
  43059. }
  43060. return shadow(this, 'javaScript', javaScript);
  43061. },
  43062. cleanup: function Catalog_cleanup() {
  43063. var promises = [];
  43064. this.fontCache.forEach(function (promise) {
  43065. promises.push(promise);
  43066. });
  43067. return Promise.all(promises).then(function (translatedFonts) {
  43068. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  43069. var font = translatedFonts[i].dict;
  43070. delete font.translated;
  43071. }
  43072. this.fontCache.clear();
  43073. }.bind(this));
  43074. },
  43075. getPage: function Catalog_getPage(pageIndex) {
  43076. if (!(pageIndex in this.pagePromises)) {
  43077. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  43078. var dict = a[0];
  43079. var ref = a[1];
  43080. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  43081. }.bind(this));
  43082. }
  43083. return this.pagePromises[pageIndex];
  43084. },
  43085. getPageDict: function Catalog_getPageDict(pageIndex) {
  43086. var capability = createPromiseCapability();
  43087. var nodesToVisit = [this.catDict.getRaw('Pages')];
  43088. var currentPageIndex = 0;
  43089. var xref = this.xref;
  43090. var checkAllKids = false;
  43091. function next() {
  43092. while (nodesToVisit.length) {
  43093. var currentNode = nodesToVisit.pop();
  43094. if (isRef(currentNode)) {
  43095. xref.fetchAsync(currentNode).then(function (obj) {
  43096. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  43097. if (pageIndex === currentPageIndex) {
  43098. capability.resolve([
  43099. obj,
  43100. currentNode
  43101. ]);
  43102. } else {
  43103. currentPageIndex++;
  43104. next();
  43105. }
  43106. return;
  43107. }
  43108. nodesToVisit.push(obj);
  43109. next();
  43110. }, capability.reject);
  43111. return;
  43112. }
  43113. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  43114. var count = currentNode.get('Count');
  43115. if (count === 0) {
  43116. checkAllKids = true;
  43117. }
  43118. if (currentPageIndex + count <= pageIndex) {
  43119. currentPageIndex += count;
  43120. continue;
  43121. }
  43122. var kids = currentNode.get('Kids');
  43123. assert(isArray(kids), 'page dictionary kids object is not an array');
  43124. if (!checkAllKids && count === kids.length) {
  43125. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  43126. currentPageIndex = pageIndex;
  43127. continue;
  43128. } else {
  43129. for (var last = kids.length - 1; last >= 0; last--) {
  43130. nodesToVisit.push(kids[last]);
  43131. }
  43132. }
  43133. }
  43134. capability.reject('Page index ' + pageIndex + ' not found.');
  43135. }
  43136. next();
  43137. return capability.promise;
  43138. },
  43139. getPageIndex: function Catalog_getPageIndex(pageRef) {
  43140. var xref = this.xref;
  43141. function pagesBeforeRef(kidRef) {
  43142. var total = 0;
  43143. var parentRef;
  43144. return xref.fetchAsync(kidRef).then(function (node) {
  43145. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  43146. throw new Error('The reference does not point to a /Page Dict.');
  43147. }
  43148. if (!node) {
  43149. return null;
  43150. }
  43151. assert(isDict(node), 'node must be a Dict.');
  43152. parentRef = node.getRaw('Parent');
  43153. return node.getAsync('Parent');
  43154. }).then(function (parent) {
  43155. if (!parent) {
  43156. return null;
  43157. }
  43158. assert(isDict(parent), 'parent must be a Dict.');
  43159. return parent.getAsync('Kids');
  43160. }).then(function (kids) {
  43161. if (!kids) {
  43162. return null;
  43163. }
  43164. var kidPromises = [];
  43165. var found = false;
  43166. for (var i = 0; i < kids.length; i++) {
  43167. var kid = kids[i];
  43168. assert(isRef(kid), 'kid must be a Ref.');
  43169. if (kid.num === kidRef.num) {
  43170. found = true;
  43171. break;
  43172. }
  43173. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  43174. if (kid.has('Count')) {
  43175. var count = kid.get('Count');
  43176. total += count;
  43177. } else {
  43178. total++;
  43179. }
  43180. }));
  43181. }
  43182. if (!found) {
  43183. error('kid ref not found in parents kids');
  43184. }
  43185. return Promise.all(kidPromises).then(function () {
  43186. return [
  43187. total,
  43188. parentRef
  43189. ];
  43190. });
  43191. });
  43192. }
  43193. var total = 0;
  43194. function next(ref) {
  43195. return pagesBeforeRef(ref).then(function (args) {
  43196. if (!args) {
  43197. return total;
  43198. }
  43199. var count = args[0];
  43200. var parentRef = args[1];
  43201. total += count;
  43202. return next(parentRef);
  43203. });
  43204. }
  43205. return next(pageRef);
  43206. }
  43207. };
  43208. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  43209. function addDefaultProtocolToUrl(url) {
  43210. if (url.indexOf('www.') === 0) {
  43211. return 'http://' + url;
  43212. }
  43213. return url;
  43214. }
  43215. function tryConvertUrlEncoding(url) {
  43216. try {
  43217. return stringToUTF8String(url);
  43218. } catch (e) {
  43219. return url;
  43220. }
  43221. }
  43222. var destDict = params.destDict;
  43223. if (!isDict(destDict)) {
  43224. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  43225. return;
  43226. }
  43227. var resultObj = params.resultObj;
  43228. if (typeof resultObj !== 'object') {
  43229. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  43230. return;
  43231. }
  43232. var docBaseUrl = params.docBaseUrl || null;
  43233. var action = destDict.get('A'), url, dest;
  43234. if (isDict(action)) {
  43235. var linkType = action.get('S').name;
  43236. switch (linkType) {
  43237. case 'URI':
  43238. url = action.get('URI');
  43239. if (isName(url)) {
  43240. url = '/' + url.name;
  43241. } else if (isString(url)) {
  43242. url = addDefaultProtocolToUrl(url);
  43243. }
  43244. break;
  43245. case 'GoTo':
  43246. dest = action.get('D');
  43247. break;
  43248. case 'Launch':
  43249. case 'GoToR':
  43250. var urlDict = action.get('F');
  43251. if (isDict(urlDict)) {
  43252. url = urlDict.get('F') || null;
  43253. } else if (isString(urlDict)) {
  43254. url = urlDict;
  43255. }
  43256. var remoteDest = action.get('D');
  43257. if (remoteDest) {
  43258. if (isName(remoteDest)) {
  43259. remoteDest = remoteDest.name;
  43260. }
  43261. if (isString(url)) {
  43262. var baseUrl = url.split('#')[0];
  43263. if (isString(remoteDest)) {
  43264. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  43265. } else if (isArray(remoteDest)) {
  43266. url = baseUrl + '#' + JSON.stringify(remoteDest);
  43267. }
  43268. }
  43269. }
  43270. var newWindow = action.get('NewWindow');
  43271. if (isBool(newWindow)) {
  43272. resultObj.newWindow = newWindow;
  43273. }
  43274. break;
  43275. case 'Named':
  43276. var namedAction = action.get('N');
  43277. if (isName(namedAction)) {
  43278. resultObj.action = namedAction.name;
  43279. }
  43280. break;
  43281. case 'JavaScript':
  43282. var jsAction = action.get('JS'), js;
  43283. if (isStream(jsAction)) {
  43284. js = bytesToString(jsAction.getBytes());
  43285. } else if (isString(jsAction)) {
  43286. js = jsAction;
  43287. }
  43288. if (js) {
  43289. var URL_OPEN_METHODS = [
  43290. 'app.launchURL',
  43291. 'window.open'
  43292. ];
  43293. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  43294. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  43295. if (jsUrl && jsUrl[1]) {
  43296. url = jsUrl[1];
  43297. break;
  43298. }
  43299. }
  43300. default:
  43301. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  43302. break;
  43303. }
  43304. } else if (destDict.has('Dest')) {
  43305. dest = destDict.get('Dest');
  43306. }
  43307. if (isString(url)) {
  43308. url = tryConvertUrlEncoding(url);
  43309. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  43310. if (absoluteUrl) {
  43311. resultObj.url = absoluteUrl.href;
  43312. }
  43313. resultObj.unsafeUrl = url;
  43314. }
  43315. if (dest) {
  43316. if (isName(dest)) {
  43317. dest = dest.name;
  43318. }
  43319. if (isString(dest) || isArray(dest)) {
  43320. resultObj.dest = dest;
  43321. }
  43322. }
  43323. };
  43324. return Catalog;
  43325. }();
  43326. var XRef = function XRefClosure() {
  43327. function XRef(stream, password) {
  43328. this.stream = stream;
  43329. this.entries = [];
  43330. this.xrefstms = Object.create(null);
  43331. this.cache = [];
  43332. this.password = password;
  43333. this.stats = {
  43334. streamTypes: [],
  43335. fontTypes: []
  43336. };
  43337. }
  43338. XRef.prototype = {
  43339. setStartXRef: function XRef_setStartXRef(startXRef) {
  43340. this.startXRefQueue = [startXRef];
  43341. },
  43342. parse: function XRef_parse(recoveryMode) {
  43343. var trailerDict;
  43344. if (!recoveryMode) {
  43345. trailerDict = this.readXRef();
  43346. } else {
  43347. warn('Indexing all PDF objects');
  43348. trailerDict = this.indexObjects();
  43349. }
  43350. trailerDict.assignXref(this);
  43351. this.trailer = trailerDict;
  43352. var encrypt = trailerDict.get('Encrypt');
  43353. if (encrypt) {
  43354. var ids = trailerDict.get('ID');
  43355. var fileId = ids && ids.length ? ids[0] : '';
  43356. encrypt.suppressEncryption = true;
  43357. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  43358. }
  43359. if (!(this.root = trailerDict.get('Root'))) {
  43360. error('Invalid root reference');
  43361. }
  43362. },
  43363. processXRefTable: function XRef_processXRefTable(parser) {
  43364. if (!('tableState' in this)) {
  43365. this.tableState = {
  43366. entryNum: 0,
  43367. streamPos: parser.lexer.stream.pos,
  43368. parserBuf1: parser.buf1,
  43369. parserBuf2: parser.buf2
  43370. };
  43371. }
  43372. var obj = this.readXRefTable(parser);
  43373. if (!isCmd(obj, 'trailer')) {
  43374. error('Invalid XRef table: could not find trailer dictionary');
  43375. }
  43376. var dict = parser.getObj();
  43377. if (!isDict(dict) && dict.dict) {
  43378. dict = dict.dict;
  43379. }
  43380. if (!isDict(dict)) {
  43381. error('Invalid XRef table: could not parse trailer dictionary');
  43382. }
  43383. delete this.tableState;
  43384. return dict;
  43385. },
  43386. readXRefTable: function XRef_readXRefTable(parser) {
  43387. var stream = parser.lexer.stream;
  43388. var tableState = this.tableState;
  43389. stream.pos = tableState.streamPos;
  43390. parser.buf1 = tableState.parserBuf1;
  43391. parser.buf2 = tableState.parserBuf2;
  43392. var obj;
  43393. while (true) {
  43394. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  43395. if (isCmd(obj = parser.getObj(), 'trailer')) {
  43396. break;
  43397. }
  43398. tableState.firstEntryNum = obj;
  43399. tableState.entryCount = parser.getObj();
  43400. }
  43401. var first = tableState.firstEntryNum;
  43402. var count = tableState.entryCount;
  43403. if (!isInt(first) || !isInt(count)) {
  43404. error('Invalid XRef table: wrong types in subsection header');
  43405. }
  43406. for (var i = tableState.entryNum; i < count; i++) {
  43407. tableState.streamPos = stream.pos;
  43408. tableState.entryNum = i;
  43409. tableState.parserBuf1 = parser.buf1;
  43410. tableState.parserBuf2 = parser.buf2;
  43411. var entry = {};
  43412. entry.offset = parser.getObj();
  43413. entry.gen = parser.getObj();
  43414. var type = parser.getObj();
  43415. if (isCmd(type, 'f')) {
  43416. entry.free = true;
  43417. } else if (isCmd(type, 'n')) {
  43418. entry.uncompressed = true;
  43419. }
  43420. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  43421. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  43422. }
  43423. if (i === 0 && entry.free && first === 1) {
  43424. first = 0;
  43425. }
  43426. if (!this.entries[i + first]) {
  43427. this.entries[i + first] = entry;
  43428. }
  43429. }
  43430. tableState.entryNum = 0;
  43431. tableState.streamPos = stream.pos;
  43432. tableState.parserBuf1 = parser.buf1;
  43433. tableState.parserBuf2 = parser.buf2;
  43434. delete tableState.firstEntryNum;
  43435. delete tableState.entryCount;
  43436. }
  43437. if (this.entries[0] && !this.entries[0].free) {
  43438. error('Invalid XRef table: unexpected first object');
  43439. }
  43440. return obj;
  43441. },
  43442. processXRefStream: function XRef_processXRefStream(stream) {
  43443. if (!('streamState' in this)) {
  43444. var streamParameters = stream.dict;
  43445. var byteWidths = streamParameters.get('W');
  43446. var range = streamParameters.get('Index');
  43447. if (!range) {
  43448. range = [
  43449. 0,
  43450. streamParameters.get('Size')
  43451. ];
  43452. }
  43453. this.streamState = {
  43454. entryRanges: range,
  43455. byteWidths: byteWidths,
  43456. entryNum: 0,
  43457. streamPos: stream.pos
  43458. };
  43459. }
  43460. this.readXRefStream(stream);
  43461. delete this.streamState;
  43462. return stream.dict;
  43463. },
  43464. readXRefStream: function XRef_readXRefStream(stream) {
  43465. var i, j;
  43466. var streamState = this.streamState;
  43467. stream.pos = streamState.streamPos;
  43468. var byteWidths = streamState.byteWidths;
  43469. var typeFieldWidth = byteWidths[0];
  43470. var offsetFieldWidth = byteWidths[1];
  43471. var generationFieldWidth = byteWidths[2];
  43472. var entryRanges = streamState.entryRanges;
  43473. while (entryRanges.length > 0) {
  43474. var first = entryRanges[0];
  43475. var n = entryRanges[1];
  43476. if (!isInt(first) || !isInt(n)) {
  43477. error('Invalid XRef range fields: ' + first + ', ' + n);
  43478. }
  43479. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  43480. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  43481. }
  43482. for (i = streamState.entryNum; i < n; ++i) {
  43483. streamState.entryNum = i;
  43484. streamState.streamPos = stream.pos;
  43485. var type = 0, offset = 0, generation = 0;
  43486. for (j = 0; j < typeFieldWidth; ++j) {
  43487. type = type << 8 | stream.getByte();
  43488. }
  43489. if (typeFieldWidth === 0) {
  43490. type = 1;
  43491. }
  43492. for (j = 0; j < offsetFieldWidth; ++j) {
  43493. offset = offset << 8 | stream.getByte();
  43494. }
  43495. for (j = 0; j < generationFieldWidth; ++j) {
  43496. generation = generation << 8 | stream.getByte();
  43497. }
  43498. var entry = {};
  43499. entry.offset = offset;
  43500. entry.gen = generation;
  43501. switch (type) {
  43502. case 0:
  43503. entry.free = true;
  43504. break;
  43505. case 1:
  43506. entry.uncompressed = true;
  43507. break;
  43508. case 2:
  43509. break;
  43510. default:
  43511. error('Invalid XRef entry type: ' + type);
  43512. }
  43513. if (!this.entries[first + i]) {
  43514. this.entries[first + i] = entry;
  43515. }
  43516. }
  43517. streamState.entryNum = 0;
  43518. streamState.streamPos = stream.pos;
  43519. entryRanges.splice(0, 2);
  43520. }
  43521. },
  43522. indexObjects: function XRef_indexObjects() {
  43523. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  43524. var PERCENT = 0x25, LT = 0x3C;
  43525. function readToken(data, offset) {
  43526. var token = '', ch = data[offset];
  43527. while (ch !== LF && ch !== CR && ch !== LT) {
  43528. if (++offset >= data.length) {
  43529. break;
  43530. }
  43531. token += String.fromCharCode(ch);
  43532. ch = data[offset];
  43533. }
  43534. return token;
  43535. }
  43536. function skipUntil(data, offset, what) {
  43537. var length = what.length, dataLength = data.length;
  43538. var skipped = 0;
  43539. while (offset < dataLength) {
  43540. var i = 0;
  43541. while (i < length && data[offset + i] === what[i]) {
  43542. ++i;
  43543. }
  43544. if (i >= length) {
  43545. break;
  43546. }
  43547. offset++;
  43548. skipped++;
  43549. }
  43550. return skipped;
  43551. }
  43552. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  43553. var trailerBytes = new Uint8Array([
  43554. 116,
  43555. 114,
  43556. 97,
  43557. 105,
  43558. 108,
  43559. 101,
  43560. 114
  43561. ]);
  43562. var startxrefBytes = new Uint8Array([
  43563. 115,
  43564. 116,
  43565. 97,
  43566. 114,
  43567. 116,
  43568. 120,
  43569. 114,
  43570. 101,
  43571. 102
  43572. ]);
  43573. var endobjBytes = new Uint8Array([
  43574. 101,
  43575. 110,
  43576. 100,
  43577. 111,
  43578. 98,
  43579. 106
  43580. ]);
  43581. var xrefBytes = new Uint8Array([
  43582. 47,
  43583. 88,
  43584. 82,
  43585. 101,
  43586. 102
  43587. ]);
  43588. this.entries.length = 0;
  43589. var stream = this.stream;
  43590. stream.pos = 0;
  43591. var buffer = stream.getBytes();
  43592. var position = stream.start, length = buffer.length;
  43593. var trailers = [], xrefStms = [];
  43594. while (position < length) {
  43595. var ch = buffer[position];
  43596. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  43597. ++position;
  43598. continue;
  43599. }
  43600. if (ch === PERCENT) {
  43601. do {
  43602. ++position;
  43603. if (position >= length) {
  43604. break;
  43605. }
  43606. ch = buffer[position];
  43607. } while (ch !== LF && ch !== CR);
  43608. continue;
  43609. }
  43610. var token = readToken(buffer, position);
  43611. var m;
  43612. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  43613. position += skipUntil(buffer, position, trailerBytes);
  43614. trailers.push(position);
  43615. position += skipUntil(buffer, position, startxrefBytes);
  43616. } else if (m = objRegExp.exec(token)) {
  43617. if (typeof this.entries[m[1]] === 'undefined') {
  43618. this.entries[m[1]] = {
  43619. offset: position - stream.start,
  43620. gen: m[2] | 0,
  43621. uncompressed: true
  43622. };
  43623. }
  43624. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  43625. var content = buffer.subarray(position, position + contentLength);
  43626. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  43627. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  43628. xrefStms.push(position - stream.start);
  43629. this.xrefstms[position - stream.start] = 1;
  43630. }
  43631. position += contentLength;
  43632. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  43633. trailers.push(position);
  43634. position += skipUntil(buffer, position, startxrefBytes);
  43635. } else {
  43636. position += token.length + 1;
  43637. }
  43638. }
  43639. var i, ii;
  43640. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  43641. this.startXRefQueue.push(xrefStms[i]);
  43642. this.readXRef(true);
  43643. }
  43644. var dict;
  43645. for (i = 0, ii = trailers.length; i < ii; ++i) {
  43646. stream.pos = trailers[i];
  43647. var parser = new Parser(new Lexer(stream), true, this, true);
  43648. var obj = parser.getObj();
  43649. if (!isCmd(obj, 'trailer')) {
  43650. continue;
  43651. }
  43652. dict = parser.getObj();
  43653. if (!isDict(dict)) {
  43654. continue;
  43655. }
  43656. if (dict.has('ID')) {
  43657. return dict;
  43658. }
  43659. }
  43660. if (dict) {
  43661. return dict;
  43662. }
  43663. throw new InvalidPDFException('Invalid PDF structure');
  43664. },
  43665. readXRef: function XRef_readXRef(recoveryMode) {
  43666. var stream = this.stream;
  43667. try {
  43668. while (this.startXRefQueue.length) {
  43669. var startXRef = this.startXRefQueue[0];
  43670. stream.pos = startXRef + stream.start;
  43671. var parser = new Parser(new Lexer(stream), true, this);
  43672. var obj = parser.getObj();
  43673. var dict;
  43674. if (isCmd(obj, 'xref')) {
  43675. dict = this.processXRefTable(parser);
  43676. if (!this.topDict) {
  43677. this.topDict = dict;
  43678. }
  43679. obj = dict.get('XRefStm');
  43680. if (isInt(obj)) {
  43681. var pos = obj;
  43682. if (!(pos in this.xrefstms)) {
  43683. this.xrefstms[pos] = 1;
  43684. this.startXRefQueue.push(pos);
  43685. }
  43686. }
  43687. } else if (isInt(obj)) {
  43688. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  43689. error('Invalid XRef stream');
  43690. }
  43691. dict = this.processXRefStream(obj);
  43692. if (!this.topDict) {
  43693. this.topDict = dict;
  43694. }
  43695. if (!dict) {
  43696. error('Failed to read XRef stream');
  43697. }
  43698. } else {
  43699. error('Invalid XRef stream header');
  43700. }
  43701. obj = dict.get('Prev');
  43702. if (isInt(obj)) {
  43703. this.startXRefQueue.push(obj);
  43704. } else if (isRef(obj)) {
  43705. this.startXRefQueue.push(obj.num);
  43706. }
  43707. this.startXRefQueue.shift();
  43708. }
  43709. return this.topDict;
  43710. } catch (e) {
  43711. if (e instanceof MissingDataException) {
  43712. throw e;
  43713. }
  43714. info('(while reading XRef): ' + e);
  43715. }
  43716. if (recoveryMode) {
  43717. return;
  43718. }
  43719. throw new XRefParseException();
  43720. },
  43721. getEntry: function XRef_getEntry(i) {
  43722. var xrefEntry = this.entries[i];
  43723. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  43724. return xrefEntry;
  43725. }
  43726. return null;
  43727. },
  43728. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  43729. if (!isRef(obj)) {
  43730. return obj;
  43731. }
  43732. return this.fetch(obj, suppressEncryption);
  43733. },
  43734. fetch: function XRef_fetch(ref, suppressEncryption) {
  43735. assert(isRef(ref), 'ref object is not a reference');
  43736. var num = ref.num;
  43737. if (num in this.cache) {
  43738. var cacheEntry = this.cache[num];
  43739. return cacheEntry;
  43740. }
  43741. var xrefEntry = this.getEntry(num);
  43742. if (xrefEntry === null) {
  43743. return this.cache[num] = null;
  43744. }
  43745. if (xrefEntry.uncompressed) {
  43746. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  43747. } else {
  43748. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  43749. }
  43750. if (isDict(xrefEntry)) {
  43751. xrefEntry.objId = ref.toString();
  43752. } else if (isStream(xrefEntry)) {
  43753. xrefEntry.dict.objId = ref.toString();
  43754. }
  43755. return xrefEntry;
  43756. },
  43757. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  43758. var gen = ref.gen;
  43759. var num = ref.num;
  43760. if (xrefEntry.gen !== gen) {
  43761. error('inconsistent generation in XRef');
  43762. }
  43763. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  43764. var parser = new Parser(new Lexer(stream), true, this);
  43765. var obj1 = parser.getObj();
  43766. var obj2 = parser.getObj();
  43767. var obj3 = parser.getObj();
  43768. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  43769. error('bad XRef entry');
  43770. }
  43771. if (!isCmd(obj3, 'obj')) {
  43772. if (obj3.cmd.indexOf('obj') === 0) {
  43773. num = parseInt(obj3.cmd.substring(3), 10);
  43774. if (!isNaN(num)) {
  43775. return num;
  43776. }
  43777. }
  43778. error('bad XRef entry');
  43779. }
  43780. if (this.encrypt && !suppressEncryption) {
  43781. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  43782. } else {
  43783. xrefEntry = parser.getObj();
  43784. }
  43785. if (!isStream(xrefEntry)) {
  43786. this.cache[num] = xrefEntry;
  43787. }
  43788. return xrefEntry;
  43789. },
  43790. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  43791. var tableOffset = xrefEntry.offset;
  43792. var stream = this.fetch(new Ref(tableOffset, 0));
  43793. if (!isStream(stream)) {
  43794. error('bad ObjStm stream');
  43795. }
  43796. var first = stream.dict.get('First');
  43797. var n = stream.dict.get('N');
  43798. if (!isInt(first) || !isInt(n)) {
  43799. error('invalid first and n parameters for ObjStm stream');
  43800. }
  43801. var parser = new Parser(new Lexer(stream), false, this);
  43802. parser.allowStreams = true;
  43803. var i, entries = [], num, nums = [];
  43804. for (i = 0; i < n; ++i) {
  43805. num = parser.getObj();
  43806. if (!isInt(num)) {
  43807. error('invalid object number in the ObjStm stream: ' + num);
  43808. }
  43809. nums.push(num);
  43810. var offset = parser.getObj();
  43811. if (!isInt(offset)) {
  43812. error('invalid object offset in the ObjStm stream: ' + offset);
  43813. }
  43814. }
  43815. for (i = 0; i < n; ++i) {
  43816. entries.push(parser.getObj());
  43817. if (isCmd(parser.buf1, 'endobj')) {
  43818. parser.shift();
  43819. }
  43820. num = nums[i];
  43821. var entry = this.entries[num];
  43822. if (entry && entry.offset === tableOffset && entry.gen === i) {
  43823. this.cache[num] = entries[i];
  43824. }
  43825. }
  43826. xrefEntry = entries[xrefEntry.gen];
  43827. if (xrefEntry === undefined) {
  43828. error('bad XRef entry for compressed object');
  43829. }
  43830. return xrefEntry;
  43831. },
  43832. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  43833. if (!isRef(obj)) {
  43834. return Promise.resolve(obj);
  43835. }
  43836. return this.fetchAsync(obj, suppressEncryption);
  43837. },
  43838. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  43839. var streamManager = this.stream.manager;
  43840. var xref = this;
  43841. return new Promise(function tryFetch(resolve, reject) {
  43842. try {
  43843. resolve(xref.fetch(ref, suppressEncryption));
  43844. } catch (e) {
  43845. if (e instanceof MissingDataException) {
  43846. streamManager.requestRange(e.begin, e.end).then(function () {
  43847. tryFetch(resolve, reject);
  43848. }, reject);
  43849. return;
  43850. }
  43851. reject(e);
  43852. }
  43853. });
  43854. },
  43855. getCatalogObj: function XRef_getCatalogObj() {
  43856. return this.root;
  43857. }
  43858. };
  43859. return XRef;
  43860. }();
  43861. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  43862. function NameOrNumberTree(root, xref) {
  43863. throw new Error('Cannot initialize NameOrNumberTree.');
  43864. }
  43865. NameOrNumberTree.prototype = {
  43866. getAll: function NameOrNumberTree_getAll() {
  43867. var dict = Object.create(null);
  43868. if (!this.root) {
  43869. return dict;
  43870. }
  43871. var xref = this.xref;
  43872. var processed = new RefSet();
  43873. processed.put(this.root);
  43874. var queue = [this.root];
  43875. while (queue.length > 0) {
  43876. var i, n;
  43877. var obj = xref.fetchIfRef(queue.shift());
  43878. if (!isDict(obj)) {
  43879. continue;
  43880. }
  43881. if (obj.has('Kids')) {
  43882. var kids = obj.get('Kids');
  43883. for (i = 0, n = kids.length; i < n; i++) {
  43884. var kid = kids[i];
  43885. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  43886. queue.push(kid);
  43887. processed.put(kid);
  43888. }
  43889. continue;
  43890. }
  43891. var entries = obj.get(this._type);
  43892. if (isArray(entries)) {
  43893. for (i = 0, n = entries.length; i < n; i += 2) {
  43894. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  43895. }
  43896. }
  43897. }
  43898. return dict;
  43899. },
  43900. get: function NameOrNumberTree_get(key) {
  43901. if (!this.root) {
  43902. return null;
  43903. }
  43904. var xref = this.xref;
  43905. var kidsOrEntries = xref.fetchIfRef(this.root);
  43906. var loopCount = 0;
  43907. var MAX_LEVELS = 10;
  43908. var l, r, m;
  43909. while (kidsOrEntries.has('Kids')) {
  43910. if (++loopCount > MAX_LEVELS) {
  43911. warn('Search depth limit reached for "' + this._type + '" tree.');
  43912. return null;
  43913. }
  43914. var kids = kidsOrEntries.get('Kids');
  43915. if (!isArray(kids)) {
  43916. return null;
  43917. }
  43918. l = 0;
  43919. r = kids.length - 1;
  43920. while (l <= r) {
  43921. m = l + r >> 1;
  43922. var kid = xref.fetchIfRef(kids[m]);
  43923. var limits = kid.get('Limits');
  43924. if (key < xref.fetchIfRef(limits[0])) {
  43925. r = m - 1;
  43926. } else if (key > xref.fetchIfRef(limits[1])) {
  43927. l = m + 1;
  43928. } else {
  43929. kidsOrEntries = xref.fetchIfRef(kids[m]);
  43930. break;
  43931. }
  43932. }
  43933. if (l > r) {
  43934. return null;
  43935. }
  43936. }
  43937. var entries = kidsOrEntries.get(this._type);
  43938. if (isArray(entries)) {
  43939. l = 0;
  43940. r = entries.length - 2;
  43941. while (l <= r) {
  43942. m = l + r & ~1;
  43943. var currentKey = xref.fetchIfRef(entries[m]);
  43944. if (key < currentKey) {
  43945. r = m - 2;
  43946. } else if (key > currentKey) {
  43947. l = m + 2;
  43948. } else {
  43949. return xref.fetchIfRef(entries[m + 1]);
  43950. }
  43951. }
  43952. }
  43953. return null;
  43954. }
  43955. };
  43956. return NameOrNumberTree;
  43957. }();
  43958. var NameTree = function NameTreeClosure() {
  43959. function NameTree(root, xref) {
  43960. this.root = root;
  43961. this.xref = xref;
  43962. this._type = 'Names';
  43963. }
  43964. Util.inherit(NameTree, NameOrNumberTree, {});
  43965. return NameTree;
  43966. }();
  43967. var NumberTree = function NumberTreeClosure() {
  43968. function NumberTree(root, xref) {
  43969. this.root = root;
  43970. this.xref = xref;
  43971. this._type = 'Nums';
  43972. }
  43973. Util.inherit(NumberTree, NameOrNumberTree, {});
  43974. return NumberTree;
  43975. }();
  43976. var FileSpec = function FileSpecClosure() {
  43977. function FileSpec(root, xref) {
  43978. if (!root || !isDict(root)) {
  43979. return;
  43980. }
  43981. this.xref = xref;
  43982. this.root = root;
  43983. if (root.has('FS')) {
  43984. this.fs = root.get('FS');
  43985. }
  43986. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  43987. if (root.has('RF')) {
  43988. warn('Related file specifications are not supported');
  43989. }
  43990. this.contentAvailable = true;
  43991. if (!root.has('EF')) {
  43992. this.contentAvailable = false;
  43993. warn('Non-embedded file specifications are not supported');
  43994. }
  43995. }
  43996. function pickPlatformItem(dict) {
  43997. if (dict.has('UF')) {
  43998. return dict.get('UF');
  43999. } else if (dict.has('F')) {
  44000. return dict.get('F');
  44001. } else if (dict.has('Unix')) {
  44002. return dict.get('Unix');
  44003. } else if (dict.has('Mac')) {
  44004. return dict.get('Mac');
  44005. } else if (dict.has('DOS')) {
  44006. return dict.get('DOS');
  44007. } else {
  44008. return null;
  44009. }
  44010. }
  44011. FileSpec.prototype = {
  44012. get filename() {
  44013. if (!this._filename && this.root) {
  44014. var filename = pickPlatformItem(this.root) || 'unnamed';
  44015. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  44016. }
  44017. return this._filename;
  44018. },
  44019. get content() {
  44020. if (!this.contentAvailable) {
  44021. return null;
  44022. }
  44023. if (!this.contentRef && this.root) {
  44024. this.contentRef = pickPlatformItem(this.root.get('EF'));
  44025. }
  44026. var content = null;
  44027. if (this.contentRef) {
  44028. var xref = this.xref;
  44029. var fileObj = xref.fetchIfRef(this.contentRef);
  44030. if (fileObj && isStream(fileObj)) {
  44031. content = fileObj.getBytes();
  44032. } else {
  44033. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  44034. }
  44035. } else {
  44036. warn('Embedded file specification does not have a content');
  44037. }
  44038. return content;
  44039. },
  44040. get serializable() {
  44041. return {
  44042. filename: this.filename,
  44043. content: this.content
  44044. };
  44045. }
  44046. };
  44047. return FileSpec;
  44048. }();
  44049. var ObjectLoader = function () {
  44050. function mayHaveChildren(value) {
  44051. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  44052. }
  44053. function addChildren(node, nodesToVisit) {
  44054. var value;
  44055. if (isDict(node) || isStream(node)) {
  44056. var map;
  44057. if (isDict(node)) {
  44058. map = node.map;
  44059. } else {
  44060. map = node.dict.map;
  44061. }
  44062. for (var key in map) {
  44063. value = map[key];
  44064. if (mayHaveChildren(value)) {
  44065. nodesToVisit.push(value);
  44066. }
  44067. }
  44068. } else if (isArray(node)) {
  44069. for (var i = 0, ii = node.length; i < ii; i++) {
  44070. value = node[i];
  44071. if (mayHaveChildren(value)) {
  44072. nodesToVisit.push(value);
  44073. }
  44074. }
  44075. }
  44076. }
  44077. function ObjectLoader(obj, keys, xref) {
  44078. this.obj = obj;
  44079. this.keys = keys;
  44080. this.xref = xref;
  44081. this.refSet = null;
  44082. this.capability = null;
  44083. }
  44084. ObjectLoader.prototype = {
  44085. load: function ObjectLoader_load() {
  44086. var keys = this.keys;
  44087. this.capability = createPromiseCapability();
  44088. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  44089. this.capability.resolve();
  44090. return this.capability.promise;
  44091. }
  44092. this.refSet = new RefSet();
  44093. var nodesToVisit = [];
  44094. for (var i = 0; i < keys.length; i++) {
  44095. nodesToVisit.push(this.obj[keys[i]]);
  44096. }
  44097. this._walk(nodesToVisit);
  44098. return this.capability.promise;
  44099. },
  44100. _walk: function ObjectLoader_walk(nodesToVisit) {
  44101. var nodesToRevisit = [];
  44102. var pendingRequests = [];
  44103. while (nodesToVisit.length) {
  44104. var currentNode = nodesToVisit.pop();
  44105. if (isRef(currentNode)) {
  44106. if (this.refSet.has(currentNode)) {
  44107. continue;
  44108. }
  44109. try {
  44110. var ref = currentNode;
  44111. this.refSet.put(ref);
  44112. currentNode = this.xref.fetch(currentNode);
  44113. } catch (e) {
  44114. if (!(e instanceof MissingDataException)) {
  44115. throw e;
  44116. }
  44117. nodesToRevisit.push(currentNode);
  44118. pendingRequests.push({
  44119. begin: e.begin,
  44120. end: e.end
  44121. });
  44122. }
  44123. }
  44124. if (currentNode && currentNode.getBaseStreams) {
  44125. var baseStreams = currentNode.getBaseStreams();
  44126. var foundMissingData = false;
  44127. for (var i = 0; i < baseStreams.length; i++) {
  44128. var stream = baseStreams[i];
  44129. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  44130. foundMissingData = true;
  44131. pendingRequests.push({
  44132. begin: stream.start,
  44133. end: stream.end
  44134. });
  44135. }
  44136. }
  44137. if (foundMissingData) {
  44138. nodesToRevisit.push(currentNode);
  44139. }
  44140. }
  44141. addChildren(currentNode, nodesToVisit);
  44142. }
  44143. if (pendingRequests.length) {
  44144. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  44145. nodesToVisit = nodesToRevisit;
  44146. for (var i = 0; i < nodesToRevisit.length; i++) {
  44147. var node = nodesToRevisit[i];
  44148. if (isRef(node)) {
  44149. this.refSet.remove(node);
  44150. }
  44151. }
  44152. this._walk(nodesToVisit);
  44153. }.bind(this), this.capability.reject);
  44154. return;
  44155. }
  44156. this.refSet = null;
  44157. this.capability.resolve();
  44158. }
  44159. };
  44160. return ObjectLoader;
  44161. }();
  44162. exports.Catalog = Catalog;
  44163. exports.ObjectLoader = ObjectLoader;
  44164. exports.XRef = XRef;
  44165. exports.FileSpec = FileSpec;
  44166. }));
  44167. (function (root, factory) {
  44168. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  44169. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  44170. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  44171. var MissingDataException = sharedUtil.MissingDataException;
  44172. var Util = sharedUtil.Util;
  44173. var assert = sharedUtil.assert;
  44174. var error = sharedUtil.error;
  44175. var info = sharedUtil.info;
  44176. var warn = sharedUtil.warn;
  44177. var isStream = corePrimitives.isStream;
  44178. var PDFFunction = coreFunction.PDFFunction;
  44179. var ColorSpace = coreColorSpace.ColorSpace;
  44180. var ShadingType = {
  44181. FUNCTION_BASED: 1,
  44182. AXIAL: 2,
  44183. RADIAL: 3,
  44184. FREE_FORM_MESH: 4,
  44185. LATTICE_FORM_MESH: 5,
  44186. COONS_PATCH_MESH: 6,
  44187. TENSOR_PATCH_MESH: 7
  44188. };
  44189. var Pattern = function PatternClosure() {
  44190. function Pattern() {
  44191. error('should not call Pattern constructor');
  44192. }
  44193. Pattern.prototype = {
  44194. getPattern: function Pattern_getPattern(ctx) {
  44195. error('Should not call Pattern.getStyle: ' + ctx);
  44196. }
  44197. };
  44198. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  44199. var dict = isStream(shading) ? shading.dict : shading;
  44200. var type = dict.get('ShadingType');
  44201. try {
  44202. switch (type) {
  44203. case ShadingType.AXIAL:
  44204. case ShadingType.RADIAL:
  44205. return new Shadings.RadialAxial(dict, matrix, xref, res);
  44206. case ShadingType.FREE_FORM_MESH:
  44207. case ShadingType.LATTICE_FORM_MESH:
  44208. case ShadingType.COONS_PATCH_MESH:
  44209. case ShadingType.TENSOR_PATCH_MESH:
  44210. return new Shadings.Mesh(shading, matrix, xref, res);
  44211. default:
  44212. throw new Error('Unsupported ShadingType: ' + type);
  44213. }
  44214. } catch (ex) {
  44215. if (ex instanceof MissingDataException) {
  44216. throw ex;
  44217. }
  44218. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  44219. warn(ex);
  44220. return new Shadings.Dummy();
  44221. }
  44222. };
  44223. return Pattern;
  44224. }();
  44225. var Shadings = {};
  44226. Shadings.SMALL_NUMBER = 1e-6;
  44227. Shadings.RadialAxial = function RadialAxialClosure() {
  44228. function RadialAxial(dict, matrix, xref, res) {
  44229. this.matrix = matrix;
  44230. this.coordsArr = dict.getArray('Coords');
  44231. this.shadingType = dict.get('ShadingType');
  44232. this.type = 'Pattern';
  44233. var cs = dict.get('ColorSpace', 'CS');
  44234. cs = ColorSpace.parse(cs, xref, res);
  44235. this.cs = cs;
  44236. var t0 = 0.0, t1 = 1.0;
  44237. if (dict.has('Domain')) {
  44238. var domainArr = dict.getArray('Domain');
  44239. t0 = domainArr[0];
  44240. t1 = domainArr[1];
  44241. }
  44242. var extendStart = false, extendEnd = false;
  44243. if (dict.has('Extend')) {
  44244. var extendArr = dict.getArray('Extend');
  44245. extendStart = extendArr[0];
  44246. extendEnd = extendArr[1];
  44247. }
  44248. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  44249. var x1 = this.coordsArr[0];
  44250. var y1 = this.coordsArr[1];
  44251. var r1 = this.coordsArr[2];
  44252. var x2 = this.coordsArr[3];
  44253. var y2 = this.coordsArr[4];
  44254. var r2 = this.coordsArr[5];
  44255. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  44256. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  44257. warn('Unsupported radial gradient.');
  44258. }
  44259. }
  44260. this.extendStart = extendStart;
  44261. this.extendEnd = extendEnd;
  44262. var fnObj = dict.get('Function');
  44263. var fn = PDFFunction.parseArray(xref, fnObj);
  44264. var diff = t1 - t0;
  44265. var step = diff / 10;
  44266. var colorStops = this.colorStops = [];
  44267. if (t0 >= t1 || step <= 0) {
  44268. info('Bad shading domain.');
  44269. return;
  44270. }
  44271. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  44272. var rgbColor;
  44273. for (var i = t0; i <= t1; i += step) {
  44274. ratio[0] = i;
  44275. fn(ratio, 0, color, 0);
  44276. rgbColor = cs.getRgb(color, 0);
  44277. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44278. colorStops.push([
  44279. (i - t0) / diff,
  44280. cssColor
  44281. ]);
  44282. }
  44283. var background = 'transparent';
  44284. if (dict.has('Background')) {
  44285. rgbColor = cs.getRgb(dict.get('Background'), 0);
  44286. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44287. }
  44288. if (!extendStart) {
  44289. colorStops.unshift([
  44290. 0,
  44291. background
  44292. ]);
  44293. colorStops[1][0] += Shadings.SMALL_NUMBER;
  44294. }
  44295. if (!extendEnd) {
  44296. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  44297. colorStops.push([
  44298. 1,
  44299. background
  44300. ]);
  44301. }
  44302. this.colorStops = colorStops;
  44303. }
  44304. RadialAxial.prototype = {
  44305. getIR: function RadialAxial_getIR() {
  44306. var coordsArr = this.coordsArr;
  44307. var shadingType = this.shadingType;
  44308. var type, p0, p1, r0, r1;
  44309. if (shadingType === ShadingType.AXIAL) {
  44310. p0 = [
  44311. coordsArr[0],
  44312. coordsArr[1]
  44313. ];
  44314. p1 = [
  44315. coordsArr[2],
  44316. coordsArr[3]
  44317. ];
  44318. r0 = null;
  44319. r1 = null;
  44320. type = 'axial';
  44321. } else if (shadingType === ShadingType.RADIAL) {
  44322. p0 = [
  44323. coordsArr[0],
  44324. coordsArr[1]
  44325. ];
  44326. p1 = [
  44327. coordsArr[3],
  44328. coordsArr[4]
  44329. ];
  44330. r0 = coordsArr[2];
  44331. r1 = coordsArr[5];
  44332. type = 'radial';
  44333. } else {
  44334. error('getPattern type unknown: ' + shadingType);
  44335. }
  44336. var matrix = this.matrix;
  44337. if (matrix) {
  44338. p0 = Util.applyTransform(p0, matrix);
  44339. p1 = Util.applyTransform(p1, matrix);
  44340. if (shadingType === ShadingType.RADIAL) {
  44341. var scale = Util.singularValueDecompose2dScale(matrix);
  44342. r0 *= scale[0];
  44343. r1 *= scale[1];
  44344. }
  44345. }
  44346. return [
  44347. 'RadialAxial',
  44348. type,
  44349. this.colorStops,
  44350. p0,
  44351. p1,
  44352. r0,
  44353. r1
  44354. ];
  44355. }
  44356. };
  44357. return RadialAxial;
  44358. }();
  44359. Shadings.Mesh = function MeshClosure() {
  44360. function MeshStreamReader(stream, context) {
  44361. this.stream = stream;
  44362. this.context = context;
  44363. this.buffer = 0;
  44364. this.bufferLength = 0;
  44365. var numComps = context.numComps;
  44366. this.tmpCompsBuf = new Float32Array(numComps);
  44367. var csNumComps = context.colorSpace.numComps;
  44368. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  44369. }
  44370. MeshStreamReader.prototype = {
  44371. get hasData() {
  44372. if (this.stream.end) {
  44373. return this.stream.pos < this.stream.end;
  44374. }
  44375. if (this.bufferLength > 0) {
  44376. return true;
  44377. }
  44378. var nextByte = this.stream.getByte();
  44379. if (nextByte < 0) {
  44380. return false;
  44381. }
  44382. this.buffer = nextByte;
  44383. this.bufferLength = 8;
  44384. return true;
  44385. },
  44386. readBits: function MeshStreamReader_readBits(n) {
  44387. var buffer = this.buffer;
  44388. var bufferLength = this.bufferLength;
  44389. if (n === 32) {
  44390. if (bufferLength === 0) {
  44391. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  44392. }
  44393. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  44394. var nextByte = this.stream.getByte();
  44395. this.buffer = nextByte & (1 << bufferLength) - 1;
  44396. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  44397. }
  44398. if (n === 8 && bufferLength === 0) {
  44399. return this.stream.getByte();
  44400. }
  44401. while (bufferLength < n) {
  44402. buffer = buffer << 8 | this.stream.getByte();
  44403. bufferLength += 8;
  44404. }
  44405. bufferLength -= n;
  44406. this.bufferLength = bufferLength;
  44407. this.buffer = buffer & (1 << bufferLength) - 1;
  44408. return buffer >> bufferLength;
  44409. },
  44410. align: function MeshStreamReader_align() {
  44411. this.buffer = 0;
  44412. this.bufferLength = 0;
  44413. },
  44414. readFlag: function MeshStreamReader_readFlag() {
  44415. return this.readBits(this.context.bitsPerFlag);
  44416. },
  44417. readCoordinate: function MeshStreamReader_readCoordinate() {
  44418. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  44419. var xi = this.readBits(bitsPerCoordinate);
  44420. var yi = this.readBits(bitsPerCoordinate);
  44421. var decode = this.context.decode;
  44422. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  44423. return [
  44424. xi * scale * (decode[1] - decode[0]) + decode[0],
  44425. yi * scale * (decode[3] - decode[2]) + decode[2]
  44426. ];
  44427. },
  44428. readComponents: function MeshStreamReader_readComponents() {
  44429. var numComps = this.context.numComps;
  44430. var bitsPerComponent = this.context.bitsPerComponent;
  44431. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  44432. var decode = this.context.decode;
  44433. var components = this.tmpCompsBuf;
  44434. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  44435. var ci = this.readBits(bitsPerComponent);
  44436. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  44437. }
  44438. var color = this.tmpCsCompsBuf;
  44439. if (this.context.colorFn) {
  44440. this.context.colorFn(components, 0, color, 0);
  44441. }
  44442. return this.context.colorSpace.getRgb(color, 0);
  44443. }
  44444. };
  44445. function decodeType4Shading(mesh, reader) {
  44446. var coords = mesh.coords;
  44447. var colors = mesh.colors;
  44448. var operators = [];
  44449. var ps = [];
  44450. var verticesLeft = 0;
  44451. while (reader.hasData) {
  44452. var f = reader.readFlag();
  44453. var coord = reader.readCoordinate();
  44454. var color = reader.readComponents();
  44455. if (verticesLeft === 0) {
  44456. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  44457. switch (f) {
  44458. case 0:
  44459. verticesLeft = 3;
  44460. break;
  44461. case 1:
  44462. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  44463. verticesLeft = 1;
  44464. break;
  44465. case 2:
  44466. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  44467. verticesLeft = 1;
  44468. break;
  44469. }
  44470. operators.push(f);
  44471. }
  44472. ps.push(coords.length);
  44473. coords.push(coord);
  44474. colors.push(color);
  44475. verticesLeft--;
  44476. reader.align();
  44477. }
  44478. mesh.figures.push({
  44479. type: 'triangles',
  44480. coords: new Int32Array(ps),
  44481. colors: new Int32Array(ps)
  44482. });
  44483. }
  44484. function decodeType5Shading(mesh, reader, verticesPerRow) {
  44485. var coords = mesh.coords;
  44486. var colors = mesh.colors;
  44487. var ps = [];
  44488. while (reader.hasData) {
  44489. var coord = reader.readCoordinate();
  44490. var color = reader.readComponents();
  44491. ps.push(coords.length);
  44492. coords.push(coord);
  44493. colors.push(color);
  44494. }
  44495. mesh.figures.push({
  44496. type: 'lattice',
  44497. coords: new Int32Array(ps),
  44498. colors: new Int32Array(ps),
  44499. verticesPerRow: verticesPerRow
  44500. });
  44501. }
  44502. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  44503. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  44504. var TRIANGLE_DENSITY = 20;
  44505. var getB = function getBClosure() {
  44506. function buildB(count) {
  44507. var lut = [];
  44508. for (var i = 0; i <= count; i++) {
  44509. var t = i / count, t_ = 1 - t;
  44510. lut.push(new Float32Array([
  44511. t_ * t_ * t_,
  44512. 3 * t * t_ * t_,
  44513. 3 * t * t * t_,
  44514. t * t * t
  44515. ]));
  44516. }
  44517. return lut;
  44518. }
  44519. var cache = [];
  44520. return function getB(count) {
  44521. if (!cache[count]) {
  44522. cache[count] = buildB(count);
  44523. }
  44524. return cache[count];
  44525. };
  44526. }();
  44527. function buildFigureFromPatch(mesh, index) {
  44528. var figure = mesh.figures[index];
  44529. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  44530. var coords = mesh.coords, colors = mesh.colors;
  44531. var pi = figure.coords;
  44532. var ci = figure.colors;
  44533. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44534. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44535. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44536. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44537. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  44538. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  44539. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  44540. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  44541. var verticesPerRow = splitXBy + 1;
  44542. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  44543. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  44544. var k = 0;
  44545. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  44546. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  44547. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  44548. for (var row = 0; row <= splitYBy; row++) {
  44549. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  44550. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  44551. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  44552. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  44553. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  44554. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  44555. for (var col = 0; col <= splitXBy; col++, k++) {
  44556. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  44557. continue;
  44558. }
  44559. var x = 0, y = 0;
  44560. var q = 0;
  44561. for (var i = 0; i <= 3; i++) {
  44562. for (var j = 0; j <= 3; j++, q++) {
  44563. var m = bRow[row][i] * bCol[col][j];
  44564. x += coords[pi[q]][0] * m;
  44565. y += coords[pi[q]][1] * m;
  44566. }
  44567. }
  44568. figureCoords[k] = coords.length;
  44569. coords.push([
  44570. x,
  44571. y
  44572. ]);
  44573. figureColors[k] = colors.length;
  44574. var newColor = new Uint8Array(3);
  44575. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  44576. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  44577. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  44578. colors.push(newColor);
  44579. }
  44580. }
  44581. figureCoords[0] = pi[0];
  44582. figureColors[0] = ci[0];
  44583. figureCoords[splitXBy] = pi[3];
  44584. figureColors[splitXBy] = ci[1];
  44585. figureCoords[verticesPerRow * splitYBy] = pi[12];
  44586. figureColors[verticesPerRow * splitYBy] = ci[2];
  44587. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  44588. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  44589. mesh.figures[index] = {
  44590. type: 'lattice',
  44591. coords: figureCoords,
  44592. colors: figureColors,
  44593. verticesPerRow: verticesPerRow
  44594. };
  44595. }
  44596. function decodeType6Shading(mesh, reader) {
  44597. var coords = mesh.coords;
  44598. var colors = mesh.colors;
  44599. var ps = new Int32Array(16);
  44600. var cs = new Int32Array(4);
  44601. while (reader.hasData) {
  44602. var f = reader.readFlag();
  44603. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  44604. var i, ii;
  44605. var pi = coords.length;
  44606. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  44607. coords.push(reader.readCoordinate());
  44608. }
  44609. var ci = colors.length;
  44610. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44611. colors.push(reader.readComponents());
  44612. }
  44613. var tmp1, tmp2, tmp3, tmp4;
  44614. switch (f) {
  44615. case 0:
  44616. ps[12] = pi + 3;
  44617. ps[13] = pi + 4;
  44618. ps[14] = pi + 5;
  44619. ps[15] = pi + 6;
  44620. ps[8] = pi + 2;
  44621. ps[11] = pi + 7;
  44622. ps[4] = pi + 1;
  44623. ps[7] = pi + 8;
  44624. ps[0] = pi;
  44625. ps[1] = pi + 11;
  44626. ps[2] = pi + 10;
  44627. ps[3] = pi + 9;
  44628. cs[2] = ci + 1;
  44629. cs[3] = ci + 2;
  44630. cs[0] = ci;
  44631. cs[1] = ci + 3;
  44632. break;
  44633. case 1:
  44634. tmp1 = ps[12];
  44635. tmp2 = ps[13];
  44636. tmp3 = ps[14];
  44637. tmp4 = ps[15];
  44638. ps[12] = tmp4;
  44639. ps[13] = pi + 0;
  44640. ps[14] = pi + 1;
  44641. ps[15] = pi + 2;
  44642. ps[8] = tmp3;
  44643. ps[11] = pi + 3;
  44644. ps[4] = tmp2;
  44645. ps[7] = pi + 4;
  44646. ps[0] = tmp1;
  44647. ps[1] = pi + 7;
  44648. ps[2] = pi + 6;
  44649. ps[3] = pi + 5;
  44650. tmp1 = cs[2];
  44651. tmp2 = cs[3];
  44652. cs[2] = tmp2;
  44653. cs[3] = ci;
  44654. cs[0] = tmp1;
  44655. cs[1] = ci + 1;
  44656. break;
  44657. case 2:
  44658. tmp1 = ps[15];
  44659. tmp2 = ps[11];
  44660. ps[12] = ps[3];
  44661. ps[13] = pi + 0;
  44662. ps[14] = pi + 1;
  44663. ps[15] = pi + 2;
  44664. ps[8] = ps[7];
  44665. ps[11] = pi + 3;
  44666. ps[4] = tmp2;
  44667. ps[7] = pi + 4;
  44668. ps[0] = tmp1;
  44669. ps[1] = pi + 7;
  44670. ps[2] = pi + 6;
  44671. ps[3] = pi + 5;
  44672. tmp1 = cs[3];
  44673. cs[2] = cs[1];
  44674. cs[3] = ci;
  44675. cs[0] = tmp1;
  44676. cs[1] = ci + 1;
  44677. break;
  44678. case 3:
  44679. ps[12] = ps[0];
  44680. ps[13] = pi + 0;
  44681. ps[14] = pi + 1;
  44682. ps[15] = pi + 2;
  44683. ps[8] = ps[1];
  44684. ps[11] = pi + 3;
  44685. ps[4] = ps[2];
  44686. ps[7] = pi + 4;
  44687. ps[0] = ps[3];
  44688. ps[1] = pi + 7;
  44689. ps[2] = pi + 6;
  44690. ps[3] = pi + 5;
  44691. cs[2] = cs[0];
  44692. cs[3] = ci;
  44693. cs[0] = cs[1];
  44694. cs[1] = ci + 1;
  44695. break;
  44696. }
  44697. ps[5] = coords.length;
  44698. coords.push([
  44699. (-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,
  44700. (-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
  44701. ]);
  44702. ps[6] = coords.length;
  44703. coords.push([
  44704. (-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,
  44705. (-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
  44706. ]);
  44707. ps[9] = coords.length;
  44708. coords.push([
  44709. (-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,
  44710. (-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
  44711. ]);
  44712. ps[10] = coords.length;
  44713. coords.push([
  44714. (-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,
  44715. (-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
  44716. ]);
  44717. mesh.figures.push({
  44718. type: 'patch',
  44719. coords: new Int32Array(ps),
  44720. colors: new Int32Array(cs)
  44721. });
  44722. }
  44723. }
  44724. function decodeType7Shading(mesh, reader) {
  44725. var coords = mesh.coords;
  44726. var colors = mesh.colors;
  44727. var ps = new Int32Array(16);
  44728. var cs = new Int32Array(4);
  44729. while (reader.hasData) {
  44730. var f = reader.readFlag();
  44731. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  44732. var i, ii;
  44733. var pi = coords.length;
  44734. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  44735. coords.push(reader.readCoordinate());
  44736. }
  44737. var ci = colors.length;
  44738. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44739. colors.push(reader.readComponents());
  44740. }
  44741. var tmp1, tmp2, tmp3, tmp4;
  44742. switch (f) {
  44743. case 0:
  44744. ps[12] = pi + 3;
  44745. ps[13] = pi + 4;
  44746. ps[14] = pi + 5;
  44747. ps[15] = pi + 6;
  44748. ps[8] = pi + 2;
  44749. ps[9] = pi + 13;
  44750. ps[10] = pi + 14;
  44751. ps[11] = pi + 7;
  44752. ps[4] = pi + 1;
  44753. ps[5] = pi + 12;
  44754. ps[6] = pi + 15;
  44755. ps[7] = pi + 8;
  44756. ps[0] = pi;
  44757. ps[1] = pi + 11;
  44758. ps[2] = pi + 10;
  44759. ps[3] = pi + 9;
  44760. cs[2] = ci + 1;
  44761. cs[3] = ci + 2;
  44762. cs[0] = ci;
  44763. cs[1] = ci + 3;
  44764. break;
  44765. case 1:
  44766. tmp1 = ps[12];
  44767. tmp2 = ps[13];
  44768. tmp3 = ps[14];
  44769. tmp4 = ps[15];
  44770. ps[12] = tmp4;
  44771. ps[13] = pi + 0;
  44772. ps[14] = pi + 1;
  44773. ps[15] = pi + 2;
  44774. ps[8] = tmp3;
  44775. ps[9] = pi + 9;
  44776. ps[10] = pi + 10;
  44777. ps[11] = pi + 3;
  44778. ps[4] = tmp2;
  44779. ps[5] = pi + 8;
  44780. ps[6] = pi + 11;
  44781. ps[7] = pi + 4;
  44782. ps[0] = tmp1;
  44783. ps[1] = pi + 7;
  44784. ps[2] = pi + 6;
  44785. ps[3] = pi + 5;
  44786. tmp1 = cs[2];
  44787. tmp2 = cs[3];
  44788. cs[2] = tmp2;
  44789. cs[3] = ci;
  44790. cs[0] = tmp1;
  44791. cs[1] = ci + 1;
  44792. break;
  44793. case 2:
  44794. tmp1 = ps[15];
  44795. tmp2 = ps[11];
  44796. ps[12] = ps[3];
  44797. ps[13] = pi + 0;
  44798. ps[14] = pi + 1;
  44799. ps[15] = pi + 2;
  44800. ps[8] = ps[7];
  44801. ps[9] = pi + 9;
  44802. ps[10] = pi + 10;
  44803. ps[11] = pi + 3;
  44804. ps[4] = tmp2;
  44805. ps[5] = pi + 8;
  44806. ps[6] = pi + 11;
  44807. ps[7] = pi + 4;
  44808. ps[0] = tmp1;
  44809. ps[1] = pi + 7;
  44810. ps[2] = pi + 6;
  44811. ps[3] = pi + 5;
  44812. tmp1 = cs[3];
  44813. cs[2] = cs[1];
  44814. cs[3] = ci;
  44815. cs[0] = tmp1;
  44816. cs[1] = ci + 1;
  44817. break;
  44818. case 3:
  44819. ps[12] = ps[0];
  44820. ps[13] = pi + 0;
  44821. ps[14] = pi + 1;
  44822. ps[15] = pi + 2;
  44823. ps[8] = ps[1];
  44824. ps[9] = pi + 9;
  44825. ps[10] = pi + 10;
  44826. ps[11] = pi + 3;
  44827. ps[4] = ps[2];
  44828. ps[5] = pi + 8;
  44829. ps[6] = pi + 11;
  44830. ps[7] = pi + 4;
  44831. ps[0] = ps[3];
  44832. ps[1] = pi + 7;
  44833. ps[2] = pi + 6;
  44834. ps[3] = pi + 5;
  44835. cs[2] = cs[0];
  44836. cs[3] = ci;
  44837. cs[0] = cs[1];
  44838. cs[1] = ci + 1;
  44839. break;
  44840. }
  44841. mesh.figures.push({
  44842. type: 'patch',
  44843. coords: new Int32Array(ps),
  44844. colors: new Int32Array(cs)
  44845. });
  44846. }
  44847. }
  44848. function updateBounds(mesh) {
  44849. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  44850. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  44851. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  44852. minX = minX > x ? x : minX;
  44853. minY = minY > y ? y : minY;
  44854. maxX = maxX < x ? x : maxX;
  44855. maxY = maxY < y ? y : maxY;
  44856. }
  44857. mesh.bounds = [
  44858. minX,
  44859. minY,
  44860. maxX,
  44861. maxY
  44862. ];
  44863. }
  44864. function packData(mesh) {
  44865. var i, ii, j, jj;
  44866. var coords = mesh.coords;
  44867. var coordsPacked = new Float32Array(coords.length * 2);
  44868. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  44869. var xy = coords[i];
  44870. coordsPacked[j++] = xy[0];
  44871. coordsPacked[j++] = xy[1];
  44872. }
  44873. mesh.coords = coordsPacked;
  44874. var colors = mesh.colors;
  44875. var colorsPacked = new Uint8Array(colors.length * 3);
  44876. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  44877. var c = colors[i];
  44878. colorsPacked[j++] = c[0];
  44879. colorsPacked[j++] = c[1];
  44880. colorsPacked[j++] = c[2];
  44881. }
  44882. mesh.colors = colorsPacked;
  44883. var figures = mesh.figures;
  44884. for (i = 0, ii = figures.length; i < ii; i++) {
  44885. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  44886. for (j = 0, jj = ps.length; j < jj; j++) {
  44887. ps[j] *= 2;
  44888. cs[j] *= 3;
  44889. }
  44890. }
  44891. }
  44892. function Mesh(stream, matrix, xref, res) {
  44893. assert(isStream(stream), 'Mesh data is not a stream');
  44894. var dict = stream.dict;
  44895. this.matrix = matrix;
  44896. this.shadingType = dict.get('ShadingType');
  44897. this.type = 'Pattern';
  44898. this.bbox = dict.getArray('BBox');
  44899. var cs = dict.get('ColorSpace', 'CS');
  44900. cs = ColorSpace.parse(cs, xref, res);
  44901. this.cs = cs;
  44902. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  44903. var fnObj = dict.get('Function');
  44904. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  44905. this.coords = [];
  44906. this.colors = [];
  44907. this.figures = [];
  44908. var decodeContext = {
  44909. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  44910. bitsPerComponent: dict.get('BitsPerComponent'),
  44911. bitsPerFlag: dict.get('BitsPerFlag'),
  44912. decode: dict.getArray('Decode'),
  44913. colorFn: fn,
  44914. colorSpace: cs,
  44915. numComps: fn ? 1 : cs.numComps
  44916. };
  44917. var reader = new MeshStreamReader(stream, decodeContext);
  44918. var patchMesh = false;
  44919. switch (this.shadingType) {
  44920. case ShadingType.FREE_FORM_MESH:
  44921. decodeType4Shading(this, reader);
  44922. break;
  44923. case ShadingType.LATTICE_FORM_MESH:
  44924. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  44925. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  44926. decodeType5Shading(this, reader, verticesPerRow);
  44927. break;
  44928. case ShadingType.COONS_PATCH_MESH:
  44929. decodeType6Shading(this, reader);
  44930. patchMesh = true;
  44931. break;
  44932. case ShadingType.TENSOR_PATCH_MESH:
  44933. decodeType7Shading(this, reader);
  44934. patchMesh = true;
  44935. break;
  44936. default:
  44937. error('Unsupported mesh type.');
  44938. break;
  44939. }
  44940. if (patchMesh) {
  44941. updateBounds(this);
  44942. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  44943. buildFigureFromPatch(this, i);
  44944. }
  44945. }
  44946. updateBounds(this);
  44947. packData(this);
  44948. }
  44949. Mesh.prototype = {
  44950. getIR: function Mesh_getIR() {
  44951. return [
  44952. 'Mesh',
  44953. this.shadingType,
  44954. this.coords,
  44955. this.colors,
  44956. this.figures,
  44957. this.bounds,
  44958. this.matrix,
  44959. this.bbox,
  44960. this.background
  44961. ];
  44962. }
  44963. };
  44964. return Mesh;
  44965. }();
  44966. Shadings.Dummy = function DummyClosure() {
  44967. function Dummy() {
  44968. this.type = 'Pattern';
  44969. }
  44970. Dummy.prototype = {
  44971. getIR: function Dummy_getIR() {
  44972. return ['Dummy'];
  44973. }
  44974. };
  44975. return Dummy;
  44976. }();
  44977. function getTilingPatternIR(operatorList, dict, args) {
  44978. var matrix = dict.getArray('Matrix');
  44979. var bbox = dict.getArray('BBox');
  44980. var xstep = dict.get('XStep');
  44981. var ystep = dict.get('YStep');
  44982. var paintType = dict.get('PaintType');
  44983. var tilingType = dict.get('TilingType');
  44984. return [
  44985. 'TilingPattern',
  44986. args,
  44987. operatorList,
  44988. matrix,
  44989. bbox,
  44990. xstep,
  44991. ystep,
  44992. paintType,
  44993. tilingType
  44994. ];
  44995. }
  44996. exports.Pattern = Pattern;
  44997. exports.getTilingPatternIR = getTilingPatternIR;
  44998. }));
  44999. (function (root, factory) {
  45000. 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);
  45001. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  45002. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  45003. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  45004. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  45005. var ImageKind = sharedUtil.ImageKind;
  45006. var OPS = sharedUtil.OPS;
  45007. var TextRenderingMode = sharedUtil.TextRenderingMode;
  45008. var Util = sharedUtil.Util;
  45009. var assert = sharedUtil.assert;
  45010. var createPromiseCapability = sharedUtil.createPromiseCapability;
  45011. var error = sharedUtil.error;
  45012. var info = sharedUtil.info;
  45013. var isArray = sharedUtil.isArray;
  45014. var isNum = sharedUtil.isNum;
  45015. var isString = sharedUtil.isString;
  45016. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  45017. var warn = sharedUtil.warn;
  45018. var Dict = corePrimitives.Dict;
  45019. var Name = corePrimitives.Name;
  45020. var isCmd = corePrimitives.isCmd;
  45021. var isDict = corePrimitives.isDict;
  45022. var isName = corePrimitives.isName;
  45023. var isRef = corePrimitives.isRef;
  45024. var isStream = corePrimitives.isStream;
  45025. var DecodeStream = coreStream.DecodeStream;
  45026. var JpegStream = coreStream.JpegStream;
  45027. var Stream = coreStream.Stream;
  45028. var Lexer = coreParser.Lexer;
  45029. var Parser = coreParser.Parser;
  45030. var isEOF = coreParser.isEOF;
  45031. var PDFImage = coreImage.PDFImage;
  45032. var ColorSpace = coreColorSpace.ColorSpace;
  45033. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  45034. var ErrorFont = coreFonts.ErrorFont;
  45035. var FontFlags = coreFonts.FontFlags;
  45036. var Font = coreFonts.Font;
  45037. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  45038. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  45039. var getFontType = coreFonts.getFontType;
  45040. var isPDFFunction = coreFunction.isPDFFunction;
  45041. var PDFFunction = coreFunction.PDFFunction;
  45042. var Pattern = corePattern.Pattern;
  45043. var getTilingPatternIR = corePattern.getTilingPatternIR;
  45044. var CMapFactory = coreCMap.CMapFactory;
  45045. var IdentityCMap = coreCMap.IdentityCMap;
  45046. var getMetrics = coreMetrics.getMetrics;
  45047. var bidi = coreBidi.bidi;
  45048. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  45049. var StandardEncoding = coreEncodings.StandardEncoding;
  45050. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  45051. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  45052. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  45053. var getEncoding = coreEncodings.getEncoding;
  45054. var getStdFontMap = coreStandardFonts.getStdFontMap;
  45055. var getSerifFonts = coreStandardFonts.getSerifFonts;
  45056. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  45057. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  45058. var reverseIfRtl = coreUnicode.reverseIfRtl;
  45059. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  45060. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  45061. var PartialEvaluator = function PartialEvaluatorClosure() {
  45062. var DefaultPartialEvaluatorOptions = {
  45063. forceDataSchema: false,
  45064. maxImageSize: -1,
  45065. disableFontFace: false,
  45066. cMapOptions: {
  45067. url: null,
  45068. packed: false
  45069. }
  45070. };
  45071. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  45072. this.xref = xref;
  45073. this.resources = resources;
  45074. this.handler = handler;
  45075. this.forceDataSchema = forceDataSchema;
  45076. }
  45077. NativeImageDecoder.prototype = {
  45078. canDecode: function (image) {
  45079. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  45080. },
  45081. decode: function (image) {
  45082. var dict = image.dict;
  45083. var colorSpace = dict.get('ColorSpace', 'CS');
  45084. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  45085. var numComps = colorSpace.numComps;
  45086. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  45087. image.getIR(this.forceDataSchema),
  45088. numComps
  45089. ]);
  45090. return decodePromise.then(function (message) {
  45091. var data = message.data;
  45092. return new Stream(data, 0, data.length, image.dict);
  45093. });
  45094. }
  45095. };
  45096. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  45097. var dict = image.dict;
  45098. if (dict.has('DecodeParms') || dict.has('DP')) {
  45099. return false;
  45100. }
  45101. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  45102. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  45103. };
  45104. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  45105. var dict = image.dict;
  45106. if (dict.has('DecodeParms') || dict.has('DP')) {
  45107. return false;
  45108. }
  45109. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  45110. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  45111. };
  45112. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  45113. this.pdfManager = pdfManager;
  45114. this.xref = xref;
  45115. this.handler = handler;
  45116. this.pageIndex = pageIndex;
  45117. this.uniquePrefix = uniquePrefix;
  45118. this.idCounters = idCounters;
  45119. this.fontCache = fontCache;
  45120. this.options = options || DefaultPartialEvaluatorOptions;
  45121. }
  45122. var TIME_SLOT_DURATION_MS = 20;
  45123. var CHECK_TIME_EVERY = 100;
  45124. function TimeSlotManager() {
  45125. this.reset();
  45126. }
  45127. TimeSlotManager.prototype = {
  45128. check: function TimeSlotManager_check() {
  45129. if (++this.checked < CHECK_TIME_EVERY) {
  45130. return false;
  45131. }
  45132. this.checked = 0;
  45133. return this.endTime <= Date.now();
  45134. },
  45135. reset: function TimeSlotManager_reset() {
  45136. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  45137. this.checked = 0;
  45138. }
  45139. };
  45140. var deferred = Promise.resolve();
  45141. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  45142. PartialEvaluator.prototype = {
  45143. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  45144. if (!isDict(resources)) {
  45145. return false;
  45146. }
  45147. var processed = Object.create(null);
  45148. if (resources.objId) {
  45149. processed[resources.objId] = true;
  45150. }
  45151. var nodes = [resources], xref = this.xref;
  45152. while (nodes.length) {
  45153. var key, i, ii;
  45154. var node = nodes.shift();
  45155. var graphicStates = node.get('ExtGState');
  45156. if (isDict(graphicStates)) {
  45157. var graphicStatesKeys = graphicStates.getKeys();
  45158. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  45159. key = graphicStatesKeys[i];
  45160. var graphicState = graphicStates.get(key);
  45161. var bm = graphicState.get('BM');
  45162. if (isName(bm) && bm.name !== 'Normal') {
  45163. return true;
  45164. }
  45165. }
  45166. }
  45167. var xObjects = node.get('XObject');
  45168. if (!isDict(xObjects)) {
  45169. continue;
  45170. }
  45171. var xObjectsKeys = xObjects.getKeys();
  45172. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  45173. key = xObjectsKeys[i];
  45174. var xObject = xObjects.getRaw(key);
  45175. if (isRef(xObject)) {
  45176. if (processed[xObject.toString()]) {
  45177. continue;
  45178. }
  45179. xObject = xref.fetch(xObject);
  45180. }
  45181. if (!isStream(xObject)) {
  45182. continue;
  45183. }
  45184. if (xObject.dict.objId) {
  45185. if (processed[xObject.dict.objId]) {
  45186. continue;
  45187. }
  45188. processed[xObject.dict.objId] = true;
  45189. }
  45190. var xResources = xObject.dict.get('Resources');
  45191. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  45192. nodes.push(xResources);
  45193. if (xResources.objId) {
  45194. processed[xResources.objId] = true;
  45195. }
  45196. }
  45197. }
  45198. }
  45199. return false;
  45200. },
  45201. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  45202. var matrix = xobj.dict.getArray('Matrix');
  45203. var bbox = xobj.dict.getArray('BBox');
  45204. var group = xobj.dict.get('Group');
  45205. if (group) {
  45206. var groupOptions = {
  45207. matrix: matrix,
  45208. bbox: bbox,
  45209. smask: smask,
  45210. isolated: false,
  45211. knockout: false
  45212. };
  45213. var groupSubtype = group.get('S');
  45214. var colorSpace;
  45215. if (isName(groupSubtype, 'Transparency')) {
  45216. groupOptions.isolated = group.get('I') || false;
  45217. groupOptions.knockout = group.get('K') || false;
  45218. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  45219. }
  45220. if (smask && smask.backdrop) {
  45221. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  45222. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  45223. }
  45224. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  45225. }
  45226. operatorList.addOp(OPS.paintFormXObjectBegin, [
  45227. matrix,
  45228. bbox
  45229. ]);
  45230. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  45231. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  45232. if (group) {
  45233. operatorList.addOp(OPS.endGroup, [groupOptions]);
  45234. }
  45235. });
  45236. },
  45237. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  45238. var self = this;
  45239. var dict = image.dict;
  45240. var w = dict.get('Width', 'W');
  45241. var h = dict.get('Height', 'H');
  45242. if (!(w && isNum(w)) || !(h && isNum(h))) {
  45243. warn('Image dimensions are missing, or not numbers.');
  45244. return;
  45245. }
  45246. var maxImageSize = this.options.maxImageSize;
  45247. if (maxImageSize !== -1 && w * h > maxImageSize) {
  45248. warn('Image exceeded maximum allowed size and was removed.');
  45249. return;
  45250. }
  45251. var imageMask = dict.get('ImageMask', 'IM') || false;
  45252. var imgData, args;
  45253. if (imageMask) {
  45254. var width = dict.get('Width', 'W');
  45255. var height = dict.get('Height', 'H');
  45256. var bitStrideLength = width + 7 >> 3;
  45257. var imgArray = image.getBytes(bitStrideLength * height);
  45258. var decode = dict.getArray('Decode', 'D');
  45259. var inverseDecode = !!decode && decode[0] > 0;
  45260. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  45261. imgData.cached = true;
  45262. args = [imgData];
  45263. operatorList.addOp(OPS.paintImageMaskXObject, args);
  45264. if (cacheKey) {
  45265. imageCache[cacheKey] = {
  45266. fn: OPS.paintImageMaskXObject,
  45267. args: args
  45268. };
  45269. }
  45270. return;
  45271. }
  45272. var softMask = dict.get('SMask', 'SM') || false;
  45273. var mask = dict.get('Mask') || false;
  45274. var SMALL_IMAGE_DIMENSIONS = 200;
  45275. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  45276. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  45277. imgData = imageObj.createImageData(true);
  45278. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  45279. return;
  45280. }
  45281. var uniquePrefix = this.uniquePrefix || '';
  45282. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  45283. operatorList.addDependency(objId);
  45284. args = [
  45285. objId,
  45286. w,
  45287. h
  45288. ];
  45289. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  45290. operatorList.addOp(OPS.paintJpegXObject, args);
  45291. this.handler.send('obj', [
  45292. objId,
  45293. this.pageIndex,
  45294. 'JpegStream',
  45295. image.getIR(this.options.forceDataSchema)
  45296. ]);
  45297. return;
  45298. }
  45299. var nativeImageDecoder = null;
  45300. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  45301. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  45302. }
  45303. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  45304. var imgData = imageObj.createImageData(false);
  45305. self.handler.send('obj', [
  45306. objId,
  45307. self.pageIndex,
  45308. 'Image',
  45309. imgData
  45310. ], [imgData.data.buffer]);
  45311. }).then(undefined, function (reason) {
  45312. warn('Unable to decode image: ' + reason);
  45313. self.handler.send('obj', [
  45314. objId,
  45315. self.pageIndex,
  45316. 'Image',
  45317. null
  45318. ]);
  45319. });
  45320. operatorList.addOp(OPS.paintImageXObject, args);
  45321. if (cacheKey) {
  45322. imageCache[cacheKey] = {
  45323. fn: OPS.paintImageXObject,
  45324. args: args
  45325. };
  45326. }
  45327. },
  45328. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  45329. var smaskContent = smask.get('G');
  45330. var smaskOptions = {
  45331. subtype: smask.get('S').name,
  45332. backdrop: smask.get('BC')
  45333. };
  45334. var transferObj = smask.get('TR');
  45335. if (isPDFFunction(transferObj)) {
  45336. var transferFn = PDFFunction.parse(this.xref, transferObj);
  45337. var transferMap = new Uint8Array(256);
  45338. var tmp = new Float32Array(1);
  45339. for (var i = 0; i < 256; i++) {
  45340. tmp[0] = i / 255;
  45341. transferFn(tmp, 0, tmp, 0);
  45342. transferMap[i] = tmp[0] * 255 | 0;
  45343. }
  45344. smaskOptions.transferMap = transferMap;
  45345. }
  45346. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  45347. },
  45348. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  45349. var tilingOpList = new OperatorList();
  45350. var resourcesArray = [
  45351. patternDict.get('Resources'),
  45352. resources
  45353. ];
  45354. var patternResources = Dict.merge(this.xref, resourcesArray);
  45355. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  45356. operatorList.addDependencies(tilingOpList.dependencies);
  45357. operatorList.addOp(fn, getTilingPatternIR({
  45358. fnArray: tilingOpList.fnArray,
  45359. argsArray: tilingOpList.argsArray
  45360. }, patternDict, args));
  45361. });
  45362. },
  45363. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  45364. var fontName;
  45365. if (fontArgs) {
  45366. fontArgs = fontArgs.slice();
  45367. fontName = fontArgs[0].name;
  45368. }
  45369. var self = this;
  45370. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  45371. if (!translated.font.isType3Font) {
  45372. return translated;
  45373. }
  45374. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  45375. return translated;
  45376. }, function (reason) {
  45377. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45378. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  45379. });
  45380. }).then(function (translated) {
  45381. state.font = translated.font;
  45382. translated.send(self.handler);
  45383. return translated.loadedName;
  45384. });
  45385. },
  45386. handleText: function PartialEvaluator_handleText(chars, state) {
  45387. var font = state.font;
  45388. var glyphs = font.charsToGlyphs(chars);
  45389. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  45390. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  45391. var buildPath = function (fontChar) {
  45392. if (!font.renderer.hasBuiltPath(fontChar)) {
  45393. var path = font.renderer.getPathJs(fontChar);
  45394. this.handler.send('commonobj', [
  45395. font.loadedName + '_path_' + fontChar,
  45396. 'FontPath',
  45397. path
  45398. ]);
  45399. }
  45400. }.bind(this);
  45401. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  45402. var glyph = glyphs[i];
  45403. buildPath(glyph.fontChar);
  45404. var accent = glyph.accent;
  45405. if (accent && accent.fontChar) {
  45406. buildPath(accent.fontChar);
  45407. }
  45408. }
  45409. }
  45410. return glyphs;
  45411. },
  45412. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  45413. var gStateObj = [];
  45414. var gStateKeys = gState.getKeys();
  45415. var self = this;
  45416. var promise = Promise.resolve();
  45417. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  45418. var key = gStateKeys[i];
  45419. var value = gState.get(key);
  45420. switch (key) {
  45421. case 'Type':
  45422. break;
  45423. case 'LW':
  45424. case 'LC':
  45425. case 'LJ':
  45426. case 'ML':
  45427. case 'D':
  45428. case 'RI':
  45429. case 'FL':
  45430. case 'CA':
  45431. case 'ca':
  45432. gStateObj.push([
  45433. key,
  45434. value
  45435. ]);
  45436. break;
  45437. case 'Font':
  45438. promise = promise.then(function () {
  45439. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  45440. operatorList.addDependency(loadedName);
  45441. gStateObj.push([
  45442. key,
  45443. [
  45444. loadedName,
  45445. value[1]
  45446. ]
  45447. ]);
  45448. });
  45449. });
  45450. break;
  45451. case 'BM':
  45452. gStateObj.push([
  45453. key,
  45454. value
  45455. ]);
  45456. break;
  45457. case 'SMask':
  45458. if (isName(value, 'None')) {
  45459. gStateObj.push([
  45460. key,
  45461. false
  45462. ]);
  45463. break;
  45464. }
  45465. if (isDict(value)) {
  45466. promise = promise.then(function (dict) {
  45467. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  45468. }.bind(this, value));
  45469. gStateObj.push([
  45470. key,
  45471. true
  45472. ]);
  45473. } else {
  45474. warn('Unsupported SMask type');
  45475. }
  45476. break;
  45477. case 'OP':
  45478. case 'op':
  45479. case 'OPM':
  45480. case 'BG':
  45481. case 'BG2':
  45482. case 'UCR':
  45483. case 'UCR2':
  45484. case 'TR':
  45485. case 'TR2':
  45486. case 'HT':
  45487. case 'SM':
  45488. case 'SA':
  45489. case 'AIS':
  45490. case 'TK':
  45491. info('graphic state operator ' + key);
  45492. break;
  45493. default:
  45494. info('Unknown graphic state operator ' + key);
  45495. break;
  45496. }
  45497. }
  45498. return promise.then(function () {
  45499. if (gStateObj.length > 0) {
  45500. operatorList.addOp(OPS.setGState, [gStateObj]);
  45501. }
  45502. });
  45503. },
  45504. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  45505. function errorFont() {
  45506. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  45507. }
  45508. var fontRef;
  45509. if (font) {
  45510. assert(isRef(font));
  45511. fontRef = font;
  45512. } else {
  45513. var fontRes = resources.get('Font');
  45514. if (fontRes) {
  45515. fontRef = fontRes.getRaw(fontName);
  45516. } else {
  45517. warn('fontRes not available');
  45518. return errorFont();
  45519. }
  45520. }
  45521. if (!fontRef) {
  45522. warn('fontRef not available');
  45523. return errorFont();
  45524. }
  45525. if (this.fontCache.has(fontRef)) {
  45526. return this.fontCache.get(fontRef);
  45527. }
  45528. font = xref.fetchIfRef(fontRef);
  45529. if (!isDict(font)) {
  45530. return errorFont();
  45531. }
  45532. if (font.translated) {
  45533. return font.translated;
  45534. }
  45535. var fontCapability = createPromiseCapability();
  45536. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  45537. var descriptor = preEvaluatedFont.descriptor;
  45538. var fontRefIsRef = isRef(fontRef), fontID;
  45539. if (fontRefIsRef) {
  45540. fontID = fontRef.toString();
  45541. }
  45542. if (isDict(descriptor)) {
  45543. if (!descriptor.fontAliases) {
  45544. descriptor.fontAliases = Object.create(null);
  45545. }
  45546. var fontAliases = descriptor.fontAliases;
  45547. var hash = preEvaluatedFont.hash;
  45548. if (fontAliases[hash]) {
  45549. var aliasFontRef = fontAliases[hash].aliasRef;
  45550. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  45551. this.fontCache.putAlias(fontRef, aliasFontRef);
  45552. return this.fontCache.get(fontRef);
  45553. }
  45554. } else {
  45555. fontAliases[hash] = { fontID: Font.getFontID() };
  45556. }
  45557. if (fontRefIsRef) {
  45558. fontAliases[hash].aliasRef = fontRef;
  45559. }
  45560. fontID = fontAliases[hash].fontID;
  45561. }
  45562. if (fontRefIsRef) {
  45563. this.fontCache.put(fontRef, fontCapability.promise);
  45564. } else {
  45565. if (!fontID) {
  45566. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  45567. }
  45568. this.fontCache.put('id_' + fontID, fontCapability.promise);
  45569. }
  45570. assert(fontID, 'The "fontID" must be defined.');
  45571. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  45572. font.translated = fontCapability.promise;
  45573. var translatedPromise;
  45574. try {
  45575. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  45576. } catch (e) {
  45577. translatedPromise = Promise.reject(e);
  45578. }
  45579. var self = this;
  45580. translatedPromise.then(function (translatedFont) {
  45581. if (translatedFont.fontType !== undefined) {
  45582. var xrefFontStats = xref.stats.fontTypes;
  45583. xrefFontStats[translatedFont.fontType] = true;
  45584. }
  45585. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  45586. }, function (reason) {
  45587. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45588. try {
  45589. var descriptor = preEvaluatedFont.descriptor;
  45590. var fontFile3 = descriptor && descriptor.get('FontFile3');
  45591. var subtype = fontFile3 && fontFile3.get('Subtype');
  45592. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  45593. var xrefFontStats = xref.stats.fontTypes;
  45594. xrefFontStats[fontType] = true;
  45595. } catch (ex) {
  45596. }
  45597. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  45598. });
  45599. return fontCapability.promise;
  45600. },
  45601. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  45602. var lastIndex = operatorList.length - 1;
  45603. if (!args) {
  45604. args = [];
  45605. }
  45606. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  45607. operatorList.addOp(OPS.constructPath, [
  45608. [fn],
  45609. args
  45610. ]);
  45611. } else {
  45612. var opArgs = operatorList.argsArray[lastIndex];
  45613. opArgs[0].push(fn);
  45614. Array.prototype.push.apply(opArgs[1], args);
  45615. }
  45616. },
  45617. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  45618. var patternName = args[args.length - 1];
  45619. var pattern;
  45620. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  45621. var dict = isStream(pattern) ? pattern.dict : pattern;
  45622. var typeNum = dict.get('PatternType');
  45623. if (typeNum === TILING_PATTERN) {
  45624. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  45625. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  45626. } else if (typeNum === SHADING_PATTERN) {
  45627. var shading = dict.get('Shading');
  45628. var matrix = dict.getArray('Matrix');
  45629. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  45630. operatorList.addOp(fn, pattern.getIR());
  45631. return Promise.resolve();
  45632. } else {
  45633. return Promise.reject('Unknown PatternType: ' + typeNum);
  45634. }
  45635. }
  45636. operatorList.addOp(fn, args);
  45637. return Promise.resolve();
  45638. },
  45639. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  45640. var self = this;
  45641. var xref = this.xref;
  45642. var imageCache = Object.create(null);
  45643. assert(operatorList);
  45644. resources = resources || Dict.empty;
  45645. var xobjs = resources.get('XObject') || Dict.empty;
  45646. var patterns = resources.get('Pattern') || Dict.empty;
  45647. var stateManager = new StateManager(initialState || new EvalState());
  45648. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45649. var timeSlotManager = new TimeSlotManager();
  45650. return new Promise(function promiseBody(resolve, reject) {
  45651. var next = function (promise) {
  45652. promise.then(function () {
  45653. try {
  45654. promiseBody(resolve, reject);
  45655. } catch (ex) {
  45656. reject(ex);
  45657. }
  45658. }, reject);
  45659. };
  45660. task.ensureNotTerminated();
  45661. timeSlotManager.reset();
  45662. var stop, operation = {}, i, ii, cs;
  45663. while (!(stop = timeSlotManager.check())) {
  45664. operation.args = null;
  45665. if (!preprocessor.read(operation)) {
  45666. break;
  45667. }
  45668. var args = operation.args;
  45669. var fn = operation.fn;
  45670. switch (fn | 0) {
  45671. case OPS.paintXObject:
  45672. if (args[0].code) {
  45673. break;
  45674. }
  45675. var name = args[0].name;
  45676. if (!name) {
  45677. warn('XObject must be referred to by name.');
  45678. continue;
  45679. }
  45680. if (imageCache[name] !== undefined) {
  45681. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  45682. args = null;
  45683. continue;
  45684. }
  45685. var xobj = xobjs.get(name);
  45686. if (xobj) {
  45687. assert(isStream(xobj), 'XObject should be a stream');
  45688. var type = xobj.dict.get('Subtype');
  45689. assert(isName(type), 'XObject should have a Name subtype');
  45690. if (type.name === 'Form') {
  45691. stateManager.save();
  45692. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  45693. stateManager.restore();
  45694. }));
  45695. return;
  45696. } else if (type.name === 'Image') {
  45697. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  45698. args = null;
  45699. continue;
  45700. } else if (type.name === 'PS') {
  45701. info('Ignored XObject subtype PS');
  45702. continue;
  45703. } else {
  45704. error('Unhandled XObject subtype ' + type.name);
  45705. }
  45706. }
  45707. break;
  45708. case OPS.setFont:
  45709. var fontSize = args[1];
  45710. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  45711. operatorList.addDependency(loadedName);
  45712. operatorList.addOp(OPS.setFont, [
  45713. loadedName,
  45714. fontSize
  45715. ]);
  45716. }));
  45717. return;
  45718. case OPS.endInlineImage:
  45719. var cacheKey = args[0].cacheKey;
  45720. if (cacheKey) {
  45721. var cacheEntry = imageCache[cacheKey];
  45722. if (cacheEntry !== undefined) {
  45723. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  45724. args = null;
  45725. continue;
  45726. }
  45727. }
  45728. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  45729. args = null;
  45730. continue;
  45731. case OPS.showText:
  45732. args[0] = self.handleText(args[0], stateManager.state);
  45733. break;
  45734. case OPS.showSpacedText:
  45735. var arr = args[0];
  45736. var combinedGlyphs = [];
  45737. var arrLength = arr.length;
  45738. var state = stateManager.state;
  45739. for (i = 0; i < arrLength; ++i) {
  45740. var arrItem = arr[i];
  45741. if (isString(arrItem)) {
  45742. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  45743. } else if (isNum(arrItem)) {
  45744. combinedGlyphs.push(arrItem);
  45745. }
  45746. }
  45747. args[0] = combinedGlyphs;
  45748. fn = OPS.showText;
  45749. break;
  45750. case OPS.nextLineShowText:
  45751. operatorList.addOp(OPS.nextLine);
  45752. args[0] = self.handleText(args[0], stateManager.state);
  45753. fn = OPS.showText;
  45754. break;
  45755. case OPS.nextLineSetSpacingShowText:
  45756. operatorList.addOp(OPS.nextLine);
  45757. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  45758. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  45759. args[0] = self.handleText(args[0], stateManager.state);
  45760. fn = OPS.showText;
  45761. break;
  45762. case OPS.setTextRenderingMode:
  45763. stateManager.state.textRenderingMode = args[0];
  45764. break;
  45765. case OPS.setFillColorSpace:
  45766. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  45767. continue;
  45768. case OPS.setStrokeColorSpace:
  45769. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  45770. continue;
  45771. case OPS.setFillColor:
  45772. cs = stateManager.state.fillColorSpace;
  45773. args = cs.getRgb(args, 0);
  45774. fn = OPS.setFillRGBColor;
  45775. break;
  45776. case OPS.setStrokeColor:
  45777. cs = stateManager.state.strokeColorSpace;
  45778. args = cs.getRgb(args, 0);
  45779. fn = OPS.setStrokeRGBColor;
  45780. break;
  45781. case OPS.setFillGray:
  45782. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  45783. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45784. fn = OPS.setFillRGBColor;
  45785. break;
  45786. case OPS.setStrokeGray:
  45787. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  45788. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45789. fn = OPS.setStrokeRGBColor;
  45790. break;
  45791. case OPS.setFillCMYKColor:
  45792. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  45793. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45794. fn = OPS.setFillRGBColor;
  45795. break;
  45796. case OPS.setStrokeCMYKColor:
  45797. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  45798. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45799. fn = OPS.setStrokeRGBColor;
  45800. break;
  45801. case OPS.setFillRGBColor:
  45802. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  45803. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45804. break;
  45805. case OPS.setStrokeRGBColor:
  45806. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  45807. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45808. break;
  45809. case OPS.setFillColorN:
  45810. cs = stateManager.state.fillColorSpace;
  45811. if (cs.name === 'Pattern') {
  45812. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  45813. return;
  45814. }
  45815. args = cs.getRgb(args, 0);
  45816. fn = OPS.setFillRGBColor;
  45817. break;
  45818. case OPS.setStrokeColorN:
  45819. cs = stateManager.state.strokeColorSpace;
  45820. if (cs.name === 'Pattern') {
  45821. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  45822. return;
  45823. }
  45824. args = cs.getRgb(args, 0);
  45825. fn = OPS.setStrokeRGBColor;
  45826. break;
  45827. case OPS.shadingFill:
  45828. var shadingRes = resources.get('Shading');
  45829. if (!shadingRes) {
  45830. error('No shading resource found');
  45831. }
  45832. var shading = shadingRes.get(args[0].name);
  45833. if (!shading) {
  45834. error('No shading object found');
  45835. }
  45836. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  45837. var patternIR = shadingFill.getIR();
  45838. args = [patternIR];
  45839. fn = OPS.shadingFill;
  45840. break;
  45841. case OPS.setGState:
  45842. var dictName = args[0];
  45843. var extGState = resources.get('ExtGState');
  45844. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  45845. break;
  45846. }
  45847. var gState = extGState.get(dictName.name);
  45848. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  45849. return;
  45850. case OPS.moveTo:
  45851. case OPS.lineTo:
  45852. case OPS.curveTo:
  45853. case OPS.curveTo2:
  45854. case OPS.curveTo3:
  45855. case OPS.closePath:
  45856. self.buildPath(operatorList, fn, args);
  45857. continue;
  45858. case OPS.rectangle:
  45859. self.buildPath(operatorList, fn, args);
  45860. continue;
  45861. case OPS.markPoint:
  45862. case OPS.markPointProps:
  45863. case OPS.beginMarkedContent:
  45864. case OPS.beginMarkedContentProps:
  45865. case OPS.endMarkedContent:
  45866. case OPS.beginCompat:
  45867. case OPS.endCompat:
  45868. continue;
  45869. default:
  45870. if (args !== null) {
  45871. for (i = 0, ii = args.length; i < ii; i++) {
  45872. if (args[i] instanceof Dict) {
  45873. break;
  45874. }
  45875. }
  45876. if (i < ii) {
  45877. warn('getOperatorList - ignoring operator: ' + fn);
  45878. continue;
  45879. }
  45880. }
  45881. }
  45882. operatorList.addOp(fn, args);
  45883. }
  45884. if (stop) {
  45885. next(deferred);
  45886. return;
  45887. }
  45888. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  45889. operatorList.addOp(OPS.restore, []);
  45890. }
  45891. resolve();
  45892. });
  45893. },
  45894. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  45895. stateManager = stateManager || new StateManager(new TextState());
  45896. var WhitespaceRegexp = /\s/g;
  45897. var textContent = {
  45898. items: [],
  45899. styles: Object.create(null)
  45900. };
  45901. var textContentItem = {
  45902. initialized: false,
  45903. str: [],
  45904. width: 0,
  45905. height: 0,
  45906. vertical: false,
  45907. lastAdvanceWidth: 0,
  45908. lastAdvanceHeight: 0,
  45909. textAdvanceScale: 0,
  45910. spaceWidth: 0,
  45911. fakeSpaceMin: Infinity,
  45912. fakeMultiSpaceMin: Infinity,
  45913. fakeMultiSpaceMax: -0,
  45914. textRunBreakAllowed: false,
  45915. transform: null,
  45916. fontName: null
  45917. };
  45918. var SPACE_FACTOR = 0.3;
  45919. var MULTI_SPACE_FACTOR = 1.5;
  45920. var MULTI_SPACE_FACTOR_MAX = 4;
  45921. var self = this;
  45922. var xref = this.xref;
  45923. resources = xref.fetchIfRef(resources) || Dict.empty;
  45924. var xobjs = null;
  45925. var xobjsCache = Object.create(null);
  45926. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45927. var textState;
  45928. function ensureTextContentItem() {
  45929. if (textContentItem.initialized) {
  45930. return textContentItem;
  45931. }
  45932. var font = textState.font;
  45933. if (!(font.loadedName in textContent.styles)) {
  45934. textContent.styles[font.loadedName] = {
  45935. fontFamily: font.fallbackName,
  45936. ascent: font.ascent,
  45937. descent: font.descent,
  45938. vertical: font.vertical
  45939. };
  45940. }
  45941. textContentItem.fontName = font.loadedName;
  45942. var tsm = [
  45943. textState.fontSize * textState.textHScale,
  45944. 0,
  45945. 0,
  45946. textState.fontSize,
  45947. 0,
  45948. textState.textRise
  45949. ];
  45950. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  45951. var glyphHeight = font.bbox[3] - font.bbox[1];
  45952. if (glyphHeight > 0) {
  45953. glyphHeight = glyphHeight * textState.fontMatrix[3];
  45954. tsm[3] *= glyphHeight;
  45955. }
  45956. }
  45957. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  45958. textContentItem.transform = trm;
  45959. if (!font.vertical) {
  45960. textContentItem.width = 0;
  45961. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  45962. textContentItem.vertical = false;
  45963. } else {
  45964. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  45965. textContentItem.height = 0;
  45966. textContentItem.vertical = true;
  45967. }
  45968. var a = textState.textLineMatrix[0];
  45969. var b = textState.textLineMatrix[1];
  45970. var scaleLineX = Math.sqrt(a * a + b * b);
  45971. a = textState.ctm[0];
  45972. b = textState.ctm[1];
  45973. var scaleCtmX = Math.sqrt(a * a + b * b);
  45974. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  45975. textContentItem.lastAdvanceWidth = 0;
  45976. textContentItem.lastAdvanceHeight = 0;
  45977. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  45978. if (spaceWidth) {
  45979. textContentItem.spaceWidth = spaceWidth;
  45980. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  45981. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  45982. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  45983. textContentItem.textRunBreakAllowed = !font.isMonospace;
  45984. } else {
  45985. textContentItem.spaceWidth = 0;
  45986. textContentItem.fakeSpaceMin = Infinity;
  45987. textContentItem.fakeMultiSpaceMin = Infinity;
  45988. textContentItem.fakeMultiSpaceMax = 0;
  45989. textContentItem.textRunBreakAllowed = false;
  45990. }
  45991. textContentItem.initialized = true;
  45992. return textContentItem;
  45993. }
  45994. function replaceWhitespace(str) {
  45995. var i = 0, ii = str.length, code;
  45996. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  45997. i++;
  45998. }
  45999. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  46000. }
  46001. function runBidiTransform(textChunk) {
  46002. var str = textChunk.str.join('');
  46003. var bidiResult = bidi(str, -1, textChunk.vertical);
  46004. return {
  46005. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  46006. dir: bidiResult.dir,
  46007. width: textChunk.width,
  46008. height: textChunk.height,
  46009. transform: textChunk.transform,
  46010. fontName: textChunk.fontName
  46011. };
  46012. }
  46013. function handleSetFont(fontName, fontRef) {
  46014. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  46015. textState.font = translated.font;
  46016. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  46017. });
  46018. }
  46019. function buildTextContentItem(chars) {
  46020. var font = textState.font;
  46021. var textChunk = ensureTextContentItem();
  46022. var width = 0;
  46023. var height = 0;
  46024. var glyphs = font.charsToGlyphs(chars);
  46025. var defaultVMetrics = font.defaultVMetrics;
  46026. for (var i = 0; i < glyphs.length; i++) {
  46027. var glyph = glyphs[i];
  46028. var vMetricX = null;
  46029. var vMetricY = null;
  46030. var glyphWidth = null;
  46031. if (font.vertical) {
  46032. if (glyph.vmetric) {
  46033. glyphWidth = glyph.vmetric[0];
  46034. vMetricX = glyph.vmetric[1];
  46035. vMetricY = glyph.vmetric[2];
  46036. } else {
  46037. glyphWidth = glyph.width;
  46038. vMetricX = glyph.width * 0.5;
  46039. vMetricY = defaultVMetrics[2];
  46040. }
  46041. } else {
  46042. glyphWidth = glyph.width;
  46043. }
  46044. var glyphUnicode = glyph.unicode;
  46045. var NormalizedUnicodes = getNormalizedUnicodes();
  46046. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  46047. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  46048. }
  46049. glyphUnicode = reverseIfRtl(glyphUnicode);
  46050. var charSpacing = textState.charSpacing;
  46051. if (glyph.isSpace) {
  46052. var wordSpacing = textState.wordSpacing;
  46053. charSpacing += wordSpacing;
  46054. if (wordSpacing > 0) {
  46055. addFakeSpaces(wordSpacing, textChunk.str);
  46056. }
  46057. }
  46058. var tx = 0;
  46059. var ty = 0;
  46060. if (!font.vertical) {
  46061. var w0 = glyphWidth * textState.fontMatrix[0];
  46062. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  46063. width += tx;
  46064. } else {
  46065. var w1 = glyphWidth * textState.fontMatrix[0];
  46066. ty = w1 * textState.fontSize + charSpacing;
  46067. height += ty;
  46068. }
  46069. textState.translateTextMatrix(tx, ty);
  46070. textChunk.str.push(glyphUnicode);
  46071. }
  46072. if (!font.vertical) {
  46073. textChunk.lastAdvanceWidth = width;
  46074. textChunk.width += width * textChunk.textAdvanceScale;
  46075. } else {
  46076. textChunk.lastAdvanceHeight = height;
  46077. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  46078. }
  46079. return textChunk;
  46080. }
  46081. function addFakeSpaces(width, strBuf) {
  46082. if (width < textContentItem.fakeSpaceMin) {
  46083. return;
  46084. }
  46085. if (width < textContentItem.fakeMultiSpaceMin) {
  46086. strBuf.push(' ');
  46087. return;
  46088. }
  46089. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  46090. while (fakeSpaces-- > 0) {
  46091. strBuf.push(' ');
  46092. }
  46093. }
  46094. function flushTextContentItem() {
  46095. if (!textContentItem.initialized) {
  46096. return;
  46097. }
  46098. textContent.items.push(runBidiTransform(textContentItem));
  46099. textContentItem.initialized = false;
  46100. textContentItem.str.length = 0;
  46101. }
  46102. var timeSlotManager = new TimeSlotManager();
  46103. return new Promise(function promiseBody(resolve, reject) {
  46104. var next = function (promise) {
  46105. promise.then(function () {
  46106. try {
  46107. promiseBody(resolve, reject);
  46108. } catch (ex) {
  46109. reject(ex);
  46110. }
  46111. }, reject);
  46112. };
  46113. task.ensureNotTerminated();
  46114. timeSlotManager.reset();
  46115. var stop, operation = {}, args = [];
  46116. while (!(stop = timeSlotManager.check())) {
  46117. args.length = 0;
  46118. operation.args = args;
  46119. if (!preprocessor.read(operation)) {
  46120. break;
  46121. }
  46122. textState = stateManager.state;
  46123. var fn = operation.fn;
  46124. args = operation.args;
  46125. var advance, diff;
  46126. switch (fn | 0) {
  46127. case OPS.setFont:
  46128. var fontNameArg = args[0].name, fontSizeArg = args[1];
  46129. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  46130. break;
  46131. }
  46132. flushTextContentItem();
  46133. textState.fontName = fontNameArg;
  46134. textState.fontSize = fontSizeArg;
  46135. next(handleSetFont(fontNameArg, null));
  46136. return;
  46137. case OPS.setTextRise:
  46138. flushTextContentItem();
  46139. textState.textRise = args[0];
  46140. break;
  46141. case OPS.setHScale:
  46142. flushTextContentItem();
  46143. textState.textHScale = args[0] / 100;
  46144. break;
  46145. case OPS.setLeading:
  46146. flushTextContentItem();
  46147. textState.leading = args[0];
  46148. break;
  46149. case OPS.moveText:
  46150. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  46151. advance = args[0] - args[1];
  46152. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  46153. textState.translateTextLineMatrix(args[0], args[1]);
  46154. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  46155. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  46156. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  46157. addFakeSpaces(diff, textContentItem.str);
  46158. break;
  46159. }
  46160. flushTextContentItem();
  46161. textState.translateTextLineMatrix(args[0], args[1]);
  46162. textState.textMatrix = textState.textLineMatrix.slice();
  46163. break;
  46164. case OPS.setLeadingMoveText:
  46165. flushTextContentItem();
  46166. textState.leading = -args[1];
  46167. textState.translateTextLineMatrix(args[0], args[1]);
  46168. textState.textMatrix = textState.textLineMatrix.slice();
  46169. break;
  46170. case OPS.nextLine:
  46171. flushTextContentItem();
  46172. textState.carriageReturn();
  46173. break;
  46174. case OPS.setTextMatrix:
  46175. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  46176. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  46177. textState.translateTextLineMatrix(advance.width, advance.height);
  46178. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  46179. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  46180. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  46181. addFakeSpaces(diff, textContentItem.str);
  46182. break;
  46183. }
  46184. flushTextContentItem();
  46185. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46186. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46187. break;
  46188. case OPS.setCharSpacing:
  46189. textState.charSpacing = args[0];
  46190. break;
  46191. case OPS.setWordSpacing:
  46192. textState.wordSpacing = args[0];
  46193. break;
  46194. case OPS.beginText:
  46195. flushTextContentItem();
  46196. textState.textMatrix = IDENTITY_MATRIX.slice();
  46197. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  46198. break;
  46199. case OPS.showSpacedText:
  46200. var items = args[0];
  46201. var offset;
  46202. for (var j = 0, jj = items.length; j < jj; j++) {
  46203. if (typeof items[j] === 'string') {
  46204. buildTextContentItem(items[j]);
  46205. } else if (isNum(items[j])) {
  46206. ensureTextContentItem();
  46207. advance = items[j] * textState.fontSize / 1000;
  46208. var breakTextRun = false;
  46209. if (textState.font.vertical) {
  46210. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  46211. textState.translateTextMatrix(0, advance);
  46212. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46213. if (!breakTextRun) {
  46214. textContentItem.height += offset;
  46215. }
  46216. } else {
  46217. advance = -advance;
  46218. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  46219. textState.translateTextMatrix(advance, 0);
  46220. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46221. if (!breakTextRun) {
  46222. textContentItem.width += offset;
  46223. }
  46224. }
  46225. if (breakTextRun) {
  46226. flushTextContentItem();
  46227. } else if (advance > 0) {
  46228. addFakeSpaces(advance, textContentItem.str);
  46229. }
  46230. }
  46231. }
  46232. break;
  46233. case OPS.showText:
  46234. buildTextContentItem(args[0]);
  46235. break;
  46236. case OPS.nextLineShowText:
  46237. flushTextContentItem();
  46238. textState.carriageReturn();
  46239. buildTextContentItem(args[0]);
  46240. break;
  46241. case OPS.nextLineSetSpacingShowText:
  46242. flushTextContentItem();
  46243. textState.wordSpacing = args[0];
  46244. textState.charSpacing = args[1];
  46245. textState.carriageReturn();
  46246. buildTextContentItem(args[2]);
  46247. break;
  46248. case OPS.paintXObject:
  46249. flushTextContentItem();
  46250. if (args[0].code) {
  46251. break;
  46252. }
  46253. if (!xobjs) {
  46254. xobjs = resources.get('XObject') || Dict.empty;
  46255. }
  46256. var name = args[0].name;
  46257. if (xobjsCache.key === name) {
  46258. if (xobjsCache.texts) {
  46259. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  46260. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  46261. }
  46262. break;
  46263. }
  46264. var xobj = xobjs.get(name);
  46265. if (!xobj) {
  46266. break;
  46267. }
  46268. assert(isStream(xobj), 'XObject should be a stream');
  46269. var type = xobj.dict.get('Subtype');
  46270. assert(isName(type), 'XObject should have a Name subtype');
  46271. if ('Form' !== type.name) {
  46272. xobjsCache.key = name;
  46273. xobjsCache.texts = null;
  46274. break;
  46275. }
  46276. stateManager.save();
  46277. var matrix = xobj.dict.getArray('Matrix');
  46278. if (isArray(matrix) && matrix.length === 6) {
  46279. stateManager.transform(matrix);
  46280. }
  46281. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  46282. Util.appendToArray(textContent.items, formTextContent.items);
  46283. Util.extendObj(textContent.styles, formTextContent.styles);
  46284. stateManager.restore();
  46285. xobjsCache.key = name;
  46286. xobjsCache.texts = formTextContent;
  46287. }));
  46288. return;
  46289. case OPS.setGState:
  46290. flushTextContentItem();
  46291. var dictName = args[0];
  46292. var extGState = resources.get('ExtGState');
  46293. if (!isDict(extGState) || !isName(dictName)) {
  46294. break;
  46295. }
  46296. var gState = extGState.get(dictName.name);
  46297. if (!isDict(gState)) {
  46298. break;
  46299. }
  46300. var gStateFont = gState.get('Font');
  46301. if (gStateFont) {
  46302. textState.fontName = null;
  46303. textState.fontSize = gStateFont[1];
  46304. next(handleSetFont(null, gStateFont[0]));
  46305. return;
  46306. }
  46307. break;
  46308. }
  46309. }
  46310. if (stop) {
  46311. next(deferred);
  46312. return;
  46313. }
  46314. flushTextContentItem();
  46315. resolve(textContent);
  46316. });
  46317. },
  46318. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  46319. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46320. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  46321. if (properties.composite) {
  46322. var cidSystemInfo = dict.get('CIDSystemInfo');
  46323. if (isDict(cidSystemInfo)) {
  46324. properties.cidSystemInfo = {
  46325. registry: cidSystemInfo.get('Registry'),
  46326. ordering: cidSystemInfo.get('Ordering'),
  46327. supplement: cidSystemInfo.get('Supplement')
  46328. };
  46329. }
  46330. var cidToGidMap = dict.get('CIDToGIDMap');
  46331. if (isStream(cidToGidMap)) {
  46332. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  46333. }
  46334. }
  46335. var differences = [];
  46336. var baseEncodingName = null;
  46337. var encoding;
  46338. if (dict.has('Encoding')) {
  46339. encoding = dict.get('Encoding');
  46340. if (isDict(encoding)) {
  46341. baseEncodingName = encoding.get('BaseEncoding');
  46342. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  46343. if (encoding.has('Differences')) {
  46344. var diffEncoding = encoding.get('Differences');
  46345. var index = 0;
  46346. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  46347. var data = xref.fetchIfRef(diffEncoding[j]);
  46348. if (isNum(data)) {
  46349. index = data;
  46350. } else if (isName(data)) {
  46351. differences[index++] = data.name;
  46352. } else {
  46353. error('Invalid entry in \'Differences\' array: ' + data);
  46354. }
  46355. }
  46356. }
  46357. } else if (isName(encoding)) {
  46358. baseEncodingName = encoding.name;
  46359. } else {
  46360. error('Encoding is not a Name nor a Dict');
  46361. }
  46362. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  46363. baseEncodingName = null;
  46364. }
  46365. }
  46366. if (baseEncodingName) {
  46367. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  46368. } else {
  46369. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46370. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  46371. encoding = StandardEncoding;
  46372. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  46373. encoding = WinAnsiEncoding;
  46374. }
  46375. if (isSymbolicFont) {
  46376. encoding = MacRomanEncoding;
  46377. if (!properties.file) {
  46378. if (/Symbol/i.test(properties.name)) {
  46379. encoding = SymbolSetEncoding;
  46380. } else if (/Dingbats/i.test(properties.name)) {
  46381. encoding = ZapfDingbatsEncoding;
  46382. }
  46383. }
  46384. }
  46385. properties.defaultEncoding = encoding;
  46386. }
  46387. properties.differences = differences;
  46388. properties.baseEncodingName = baseEncodingName;
  46389. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  46390. properties.dict = dict;
  46391. return toUnicodePromise.then(function (toUnicode) {
  46392. properties.toUnicode = toUnicode;
  46393. return this.buildToUnicode(properties);
  46394. }.bind(this)).then(function (toUnicode) {
  46395. properties.toUnicode = toUnicode;
  46396. return properties;
  46397. });
  46398. },
  46399. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  46400. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  46401. if (properties.hasIncludedToUnicodeMap) {
  46402. return Promise.resolve(properties.toUnicode);
  46403. }
  46404. var toUnicode, charcode, glyphName;
  46405. if (!properties.composite)
  46406. {
  46407. toUnicode = [];
  46408. var encoding = properties.defaultEncoding.slice();
  46409. var baseEncodingName = properties.baseEncodingName;
  46410. var differences = properties.differences;
  46411. for (charcode in differences) {
  46412. glyphName = differences[charcode];
  46413. if (glyphName === '.notdef') {
  46414. continue;
  46415. }
  46416. encoding[charcode] = glyphName;
  46417. }
  46418. var glyphsUnicodeMap = getGlyphsUnicode();
  46419. for (charcode in encoding) {
  46420. glyphName = encoding[charcode];
  46421. if (glyphName === '') {
  46422. continue;
  46423. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  46424. var code = 0;
  46425. switch (glyphName[0]) {
  46426. case 'G':
  46427. if (glyphName.length === 3) {
  46428. code = parseInt(glyphName.substr(1), 16);
  46429. }
  46430. break;
  46431. case 'g':
  46432. if (glyphName.length === 5) {
  46433. code = parseInt(glyphName.substr(1), 16);
  46434. }
  46435. break;
  46436. case 'C':
  46437. case 'c':
  46438. if (glyphName.length >= 3) {
  46439. code = +glyphName.substr(1);
  46440. }
  46441. break;
  46442. default:
  46443. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  46444. if (unicode !== -1) {
  46445. code = unicode;
  46446. }
  46447. }
  46448. if (code) {
  46449. if (baseEncodingName && code === +charcode) {
  46450. var baseEncoding = getEncoding(baseEncodingName);
  46451. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  46452. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46453. continue;
  46454. }
  46455. }
  46456. toUnicode[charcode] = String.fromCharCode(code);
  46457. }
  46458. continue;
  46459. }
  46460. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46461. }
  46462. return Promise.resolve(new ToUnicodeMap(toUnicode));
  46463. }
  46464. 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'))) {
  46465. var registry = properties.cidSystemInfo.registry;
  46466. var ordering = properties.cidSystemInfo.ordering;
  46467. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  46468. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  46469. var cMap = properties.cMap;
  46470. toUnicode = [];
  46471. cMap.forEach(function (charcode, cid) {
  46472. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  46473. var ucs2 = ucs2CMap.lookup(cid);
  46474. if (ucs2) {
  46475. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  46476. }
  46477. });
  46478. return new ToUnicodeMap(toUnicode);
  46479. });
  46480. }
  46481. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  46482. },
  46483. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  46484. var cmapObj = toUnicode;
  46485. if (isName(cmapObj)) {
  46486. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46487. if (cmap instanceof IdentityCMap) {
  46488. return new IdentityToUnicodeMap(0, 0xFFFF);
  46489. }
  46490. return new ToUnicodeMap(cmap.getMap());
  46491. });
  46492. } else if (isStream(cmapObj)) {
  46493. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46494. if (cmap instanceof IdentityCMap) {
  46495. return new IdentityToUnicodeMap(0, 0xFFFF);
  46496. }
  46497. var map = new Array(cmap.length);
  46498. cmap.forEach(function (charCode, token) {
  46499. var str = [];
  46500. for (var k = 0; k < token.length; k += 2) {
  46501. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46502. if ((w1 & 0xF800) !== 0xD800) {
  46503. str.push(w1);
  46504. continue;
  46505. }
  46506. k += 2;
  46507. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46508. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  46509. }
  46510. map[charCode] = String.fromCharCode.apply(String, str);
  46511. });
  46512. return new ToUnicodeMap(map);
  46513. });
  46514. }
  46515. return Promise.resolve(null);
  46516. },
  46517. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  46518. var glyphsData = cidToGidStream.getBytes();
  46519. var result = [];
  46520. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  46521. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  46522. if (glyphID === 0) {
  46523. continue;
  46524. }
  46525. var code = j >> 1;
  46526. result[code] = glyphID;
  46527. }
  46528. return result;
  46529. },
  46530. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  46531. var glyphsWidths = [];
  46532. var defaultWidth = 0;
  46533. var glyphsVMetrics = [];
  46534. var defaultVMetrics;
  46535. var i, ii, j, jj, start, code, widths;
  46536. if (properties.composite) {
  46537. defaultWidth = dict.get('DW') || 1000;
  46538. widths = dict.get('W');
  46539. if (widths) {
  46540. for (i = 0, ii = widths.length; i < ii; i++) {
  46541. start = xref.fetchIfRef(widths[i++]);
  46542. code = xref.fetchIfRef(widths[i]);
  46543. if (isArray(code)) {
  46544. for (j = 0, jj = code.length; j < jj; j++) {
  46545. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  46546. }
  46547. } else {
  46548. var width = xref.fetchIfRef(widths[++i]);
  46549. for (j = start; j <= code; j++) {
  46550. glyphsWidths[j] = width;
  46551. }
  46552. }
  46553. }
  46554. }
  46555. if (properties.vertical) {
  46556. var vmetrics = dict.getArray('DW2') || [
  46557. 880,
  46558. -1000
  46559. ];
  46560. defaultVMetrics = [
  46561. vmetrics[1],
  46562. defaultWidth * 0.5,
  46563. vmetrics[0]
  46564. ];
  46565. vmetrics = dict.get('W2');
  46566. if (vmetrics) {
  46567. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  46568. start = xref.fetchIfRef(vmetrics[i++]);
  46569. code = xref.fetchIfRef(vmetrics[i]);
  46570. if (isArray(code)) {
  46571. for (j = 0, jj = code.length; j < jj; j++) {
  46572. glyphsVMetrics[start++] = [
  46573. xref.fetchIfRef(code[j++]),
  46574. xref.fetchIfRef(code[j++]),
  46575. xref.fetchIfRef(code[j])
  46576. ];
  46577. }
  46578. } else {
  46579. var vmetric = [
  46580. xref.fetchIfRef(vmetrics[++i]),
  46581. xref.fetchIfRef(vmetrics[++i]),
  46582. xref.fetchIfRef(vmetrics[++i])
  46583. ];
  46584. for (j = start; j <= code; j++) {
  46585. glyphsVMetrics[j] = vmetric;
  46586. }
  46587. }
  46588. }
  46589. }
  46590. }
  46591. } else {
  46592. var firstChar = properties.firstChar;
  46593. widths = dict.get('Widths');
  46594. if (widths) {
  46595. j = firstChar;
  46596. for (i = 0, ii = widths.length; i < ii; i++) {
  46597. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  46598. }
  46599. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  46600. } else {
  46601. var baseFontName = dict.get('BaseFont');
  46602. if (isName(baseFontName)) {
  46603. var metrics = this.getBaseFontMetrics(baseFontName.name);
  46604. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  46605. defaultWidth = metrics.defaultWidth;
  46606. }
  46607. }
  46608. }
  46609. var isMonospace = true;
  46610. var firstWidth = defaultWidth;
  46611. for (var glyph in glyphsWidths) {
  46612. var glyphWidth = glyphsWidths[glyph];
  46613. if (!glyphWidth) {
  46614. continue;
  46615. }
  46616. if (!firstWidth) {
  46617. firstWidth = glyphWidth;
  46618. continue;
  46619. }
  46620. if (firstWidth !== glyphWidth) {
  46621. isMonospace = false;
  46622. break;
  46623. }
  46624. }
  46625. if (isMonospace) {
  46626. properties.flags |= FontFlags.FixedPitch;
  46627. }
  46628. properties.defaultWidth = defaultWidth;
  46629. properties.widths = glyphsWidths;
  46630. properties.defaultVMetrics = defaultVMetrics;
  46631. properties.vmetrics = glyphsVMetrics;
  46632. },
  46633. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  46634. var fontNameWoStyle = baseFontName.split('-')[0];
  46635. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  46636. },
  46637. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  46638. var defaultWidth = 0;
  46639. var widths = [];
  46640. var monospace = false;
  46641. var stdFontMap = getStdFontMap();
  46642. var lookupName = stdFontMap[name] || name;
  46643. var Metrics = getMetrics();
  46644. if (!(lookupName in Metrics)) {
  46645. if (this.isSerifFont(name)) {
  46646. lookupName = 'Times-Roman';
  46647. } else {
  46648. lookupName = 'Helvetica';
  46649. }
  46650. }
  46651. var glyphWidths = Metrics[lookupName];
  46652. if (isNum(glyphWidths)) {
  46653. defaultWidth = glyphWidths;
  46654. monospace = true;
  46655. } else {
  46656. widths = glyphWidths();
  46657. }
  46658. return {
  46659. defaultWidth: defaultWidth,
  46660. monospace: monospace,
  46661. widths: widths
  46662. };
  46663. },
  46664. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  46665. var widths = Object.create(null);
  46666. var differences = properties.differences;
  46667. var encoding = properties.defaultEncoding;
  46668. for (var charCode = 0; charCode < 256; charCode++) {
  46669. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  46670. widths[charCode] = widthsByGlyphName[differences[charCode]];
  46671. continue;
  46672. }
  46673. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  46674. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  46675. continue;
  46676. }
  46677. }
  46678. return widths;
  46679. },
  46680. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  46681. var baseDict = dict;
  46682. var type = dict.get('Subtype');
  46683. assert(isName(type), 'invalid font Subtype');
  46684. var composite = false;
  46685. var uint8array;
  46686. if (type.name === 'Type0') {
  46687. var df = dict.get('DescendantFonts');
  46688. if (!df) {
  46689. error('Descendant fonts are not specified');
  46690. }
  46691. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  46692. type = dict.get('Subtype');
  46693. assert(isName(type), 'invalid font Subtype');
  46694. composite = true;
  46695. }
  46696. var descriptor = dict.get('FontDescriptor');
  46697. if (descriptor) {
  46698. var hash = new MurmurHash3_64();
  46699. var encoding = baseDict.getRaw('Encoding');
  46700. if (isName(encoding)) {
  46701. hash.update(encoding.name);
  46702. } else if (isRef(encoding)) {
  46703. hash.update(encoding.toString());
  46704. } else if (isDict(encoding)) {
  46705. var keys = encoding.getKeys();
  46706. for (var i = 0, ii = keys.length; i < ii; i++) {
  46707. var entry = encoding.getRaw(keys[i]);
  46708. if (isName(entry)) {
  46709. hash.update(entry.name);
  46710. } else if (isRef(entry)) {
  46711. hash.update(entry.toString());
  46712. } else if (isArray(entry)) {
  46713. hash.update(entry.length.toString());
  46714. }
  46715. }
  46716. }
  46717. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46718. if (isStream(toUnicode)) {
  46719. var stream = toUnicode.str || toUnicode;
  46720. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  46721. hash.update(uint8array);
  46722. } else if (isName(toUnicode)) {
  46723. hash.update(toUnicode.name);
  46724. }
  46725. var widths = dict.get('Widths') || baseDict.get('Widths');
  46726. if (widths) {
  46727. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  46728. hash.update(uint8array);
  46729. }
  46730. }
  46731. return {
  46732. descriptor: descriptor,
  46733. dict: dict,
  46734. baseDict: baseDict,
  46735. composite: composite,
  46736. type: type.name,
  46737. hash: hash ? hash.hexdigest() : ''
  46738. };
  46739. },
  46740. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  46741. var baseDict = preEvaluatedFont.baseDict;
  46742. var dict = preEvaluatedFont.dict;
  46743. var composite = preEvaluatedFont.composite;
  46744. var descriptor = preEvaluatedFont.descriptor;
  46745. var type = preEvaluatedFont.type;
  46746. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  46747. var cMapOptions = this.options.cMapOptions;
  46748. var properties;
  46749. if (!descriptor) {
  46750. if (type === 'Type3') {
  46751. descriptor = new Dict(null);
  46752. descriptor.set('FontName', Name.get(type));
  46753. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  46754. } else {
  46755. var baseFontName = dict.get('BaseFont');
  46756. if (!isName(baseFontName)) {
  46757. error('Base font is not specified');
  46758. }
  46759. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  46760. var metrics = this.getBaseFontMetrics(baseFontName);
  46761. var fontNameWoStyle = baseFontName.split('-')[0];
  46762. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  46763. properties = {
  46764. type: type,
  46765. name: baseFontName,
  46766. widths: metrics.widths,
  46767. defaultWidth: metrics.defaultWidth,
  46768. flags: flags,
  46769. firstChar: 0,
  46770. lastChar: maxCharIndex
  46771. };
  46772. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  46773. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  46774. return new Font(baseFontName, null, properties);
  46775. }.bind(this));
  46776. }
  46777. }
  46778. var firstChar = dict.get('FirstChar') || 0;
  46779. var lastChar = dict.get('LastChar') || maxCharIndex;
  46780. var fontName = descriptor.get('FontName');
  46781. var baseFont = dict.get('BaseFont');
  46782. if (isString(fontName)) {
  46783. fontName = Name.get(fontName);
  46784. }
  46785. if (isString(baseFont)) {
  46786. baseFont = Name.get(baseFont);
  46787. }
  46788. if (type !== 'Type3') {
  46789. var fontNameStr = fontName && fontName.name;
  46790. var baseFontStr = baseFont && baseFont.name;
  46791. if (fontNameStr !== baseFontStr) {
  46792. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  46793. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  46794. fontName = baseFont;
  46795. }
  46796. }
  46797. }
  46798. fontName = fontName || baseFont;
  46799. assert(isName(fontName), 'invalid font name');
  46800. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  46801. if (fontFile) {
  46802. if (fontFile.dict) {
  46803. var subtype = fontFile.dict.get('Subtype');
  46804. if (subtype) {
  46805. subtype = subtype.name;
  46806. }
  46807. var length1 = fontFile.dict.get('Length1');
  46808. var length2 = fontFile.dict.get('Length2');
  46809. var length3 = fontFile.dict.get('Length3');
  46810. }
  46811. }
  46812. properties = {
  46813. type: type,
  46814. name: fontName.name,
  46815. subtype: subtype,
  46816. file: fontFile,
  46817. length1: length1,
  46818. length2: length2,
  46819. length3: length3,
  46820. loadedName: baseDict.loadedName,
  46821. composite: composite,
  46822. wideChars: composite,
  46823. fixedPitch: false,
  46824. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  46825. firstChar: firstChar || 0,
  46826. lastChar: lastChar || maxCharIndex,
  46827. bbox: descriptor.getArray('FontBBox'),
  46828. ascent: descriptor.get('Ascent'),
  46829. descent: descriptor.get('Descent'),
  46830. xHeight: descriptor.get('XHeight'),
  46831. capHeight: descriptor.get('CapHeight'),
  46832. flags: descriptor.get('Flags'),
  46833. italicAngle: descriptor.get('ItalicAngle'),
  46834. coded: false
  46835. };
  46836. var cMapPromise;
  46837. if (composite) {
  46838. var cidEncoding = baseDict.get('Encoding');
  46839. if (isName(cidEncoding)) {
  46840. properties.cidEncoding = cidEncoding.name;
  46841. }
  46842. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  46843. properties.cMap = cMap;
  46844. properties.vertical = properties.cMap.vertical;
  46845. });
  46846. } else {
  46847. cMapPromise = Promise.resolve(undefined);
  46848. }
  46849. return cMapPromise.then(function () {
  46850. return this.extractDataStructures(dict, baseDict, xref, properties);
  46851. }.bind(this)).then(function (properties) {
  46852. this.extractWidths(dict, xref, descriptor, properties);
  46853. if (type === 'Type3') {
  46854. properties.isType3Font = true;
  46855. }
  46856. return new Font(fontName.name, fontFile, properties);
  46857. }.bind(this));
  46858. }
  46859. };
  46860. return PartialEvaluator;
  46861. }();
  46862. var TranslatedFont = function TranslatedFontClosure() {
  46863. function TranslatedFont(loadedName, font, dict) {
  46864. this.loadedName = loadedName;
  46865. this.font = font;
  46866. this.dict = dict;
  46867. this.type3Loaded = null;
  46868. this.sent = false;
  46869. }
  46870. TranslatedFont.prototype = {
  46871. send: function (handler) {
  46872. if (this.sent) {
  46873. return;
  46874. }
  46875. var fontData = this.font.exportData();
  46876. handler.send('commonobj', [
  46877. this.loadedName,
  46878. 'Font',
  46879. fontData
  46880. ]);
  46881. this.sent = true;
  46882. },
  46883. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  46884. assert(this.font.isType3Font);
  46885. if (this.type3Loaded) {
  46886. return this.type3Loaded;
  46887. }
  46888. var translatedFont = this.font;
  46889. var loadCharProcsPromise = Promise.resolve();
  46890. var charProcs = this.dict.get('CharProcs');
  46891. var fontResources = this.dict.get('Resources') || resources;
  46892. var charProcKeys = charProcs.getKeys();
  46893. var charProcOperatorList = Object.create(null);
  46894. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  46895. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  46896. var glyphStream = charProcs.get(key);
  46897. var operatorList = new OperatorList();
  46898. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  46899. charProcOperatorList[key] = operatorList.getIR();
  46900. parentOperatorList.addDependencies(operatorList.dependencies);
  46901. }, function (reason) {
  46902. warn('Type3 font resource \"' + key + '\" is not available');
  46903. var operatorList = new OperatorList();
  46904. charProcOperatorList[key] = operatorList.getIR();
  46905. });
  46906. }.bind(this, charProcKeys[i]));
  46907. }
  46908. this.type3Loaded = loadCharProcsPromise.then(function () {
  46909. translatedFont.charProcOperatorList = charProcOperatorList;
  46910. });
  46911. return this.type3Loaded;
  46912. }
  46913. };
  46914. return TranslatedFont;
  46915. }();
  46916. var OperatorList = function OperatorListClosure() {
  46917. var CHUNK_SIZE = 1000;
  46918. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  46919. function getTransfers(queue) {
  46920. var transfers = [];
  46921. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  46922. for (var i = 0, ii = queue.length; i < ii; i++) {
  46923. switch (fnArray[i]) {
  46924. case OPS.paintInlineImageXObject:
  46925. case OPS.paintInlineImageXObjectGroup:
  46926. case OPS.paintImageMaskXObject:
  46927. var arg = argsArray[i][0];
  46928. if (!arg.cached) {
  46929. transfers.push(arg.data.buffer);
  46930. }
  46931. break;
  46932. }
  46933. }
  46934. return transfers;
  46935. }
  46936. function OperatorList(intent, messageHandler, pageIndex) {
  46937. this.messageHandler = messageHandler;
  46938. this.fnArray = [];
  46939. this.argsArray = [];
  46940. this.dependencies = Object.create(null);
  46941. this._totalLength = 0;
  46942. this.pageIndex = pageIndex;
  46943. this.intent = intent;
  46944. }
  46945. OperatorList.prototype = {
  46946. get length() {
  46947. return this.argsArray.length;
  46948. },
  46949. get totalLength() {
  46950. return this._totalLength + this.length;
  46951. },
  46952. addOp: function (fn, args) {
  46953. this.fnArray.push(fn);
  46954. this.argsArray.push(args);
  46955. if (this.messageHandler) {
  46956. if (this.fnArray.length >= CHUNK_SIZE) {
  46957. this.flush();
  46958. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  46959. this.flush();
  46960. }
  46961. }
  46962. },
  46963. addDependency: function (dependency) {
  46964. if (dependency in this.dependencies) {
  46965. return;
  46966. }
  46967. this.dependencies[dependency] = true;
  46968. this.addOp(OPS.dependency, [dependency]);
  46969. },
  46970. addDependencies: function (dependencies) {
  46971. for (var key in dependencies) {
  46972. this.addDependency(key);
  46973. }
  46974. },
  46975. addOpList: function (opList) {
  46976. Util.extendObj(this.dependencies, opList.dependencies);
  46977. for (var i = 0, ii = opList.length; i < ii; i++) {
  46978. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  46979. }
  46980. },
  46981. getIR: function () {
  46982. return {
  46983. fnArray: this.fnArray,
  46984. argsArray: this.argsArray,
  46985. length: this.length
  46986. };
  46987. },
  46988. flush: function (lastChunk) {
  46989. if (this.intent !== 'oplist') {
  46990. new QueueOptimizer().optimize(this);
  46991. }
  46992. var transfers = getTransfers(this);
  46993. var length = this.length;
  46994. this._totalLength += length;
  46995. this.messageHandler.send('RenderPageChunk', {
  46996. operatorList: {
  46997. fnArray: this.fnArray,
  46998. argsArray: this.argsArray,
  46999. lastChunk: lastChunk,
  47000. length: length
  47001. },
  47002. pageIndex: this.pageIndex,
  47003. intent: this.intent
  47004. }, transfers);
  47005. this.dependencies = Object.create(null);
  47006. this.fnArray.length = 0;
  47007. this.argsArray.length = 0;
  47008. }
  47009. };
  47010. return OperatorList;
  47011. }();
  47012. var StateManager = function StateManagerClosure() {
  47013. function StateManager(initialState) {
  47014. this.state = initialState;
  47015. this.stateStack = [];
  47016. }
  47017. StateManager.prototype = {
  47018. save: function () {
  47019. var old = this.state;
  47020. this.stateStack.push(this.state);
  47021. this.state = old.clone();
  47022. },
  47023. restore: function () {
  47024. var prev = this.stateStack.pop();
  47025. if (prev) {
  47026. this.state = prev;
  47027. }
  47028. },
  47029. transform: function (args) {
  47030. this.state.ctm = Util.transform(this.state.ctm, args);
  47031. }
  47032. };
  47033. return StateManager;
  47034. }();
  47035. var TextState = function TextStateClosure() {
  47036. function TextState() {
  47037. this.ctm = new Float32Array(IDENTITY_MATRIX);
  47038. this.fontName = null;
  47039. this.fontSize = 0;
  47040. this.font = null;
  47041. this.fontMatrix = FONT_IDENTITY_MATRIX;
  47042. this.textMatrix = IDENTITY_MATRIX.slice();
  47043. this.textLineMatrix = IDENTITY_MATRIX.slice();
  47044. this.charSpacing = 0;
  47045. this.wordSpacing = 0;
  47046. this.leading = 0;
  47047. this.textHScale = 1;
  47048. this.textRise = 0;
  47049. }
  47050. TextState.prototype = {
  47051. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  47052. var m = this.textMatrix;
  47053. m[0] = a;
  47054. m[1] = b;
  47055. m[2] = c;
  47056. m[3] = d;
  47057. m[4] = e;
  47058. m[5] = f;
  47059. },
  47060. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  47061. var m = this.textLineMatrix;
  47062. m[0] = a;
  47063. m[1] = b;
  47064. m[2] = c;
  47065. m[3] = d;
  47066. m[4] = e;
  47067. m[5] = f;
  47068. },
  47069. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  47070. var m = this.textMatrix;
  47071. m[4] = m[0] * x + m[2] * y + m[4];
  47072. m[5] = m[1] * x + m[3] * y + m[5];
  47073. },
  47074. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  47075. var m = this.textLineMatrix;
  47076. m[4] = m[0] * x + m[2] * y + m[4];
  47077. m[5] = m[1] * x + m[3] * y + m[5];
  47078. },
  47079. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  47080. var font = this.font;
  47081. if (!font) {
  47082. return null;
  47083. }
  47084. var m = this.textLineMatrix;
  47085. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  47086. return null;
  47087. }
  47088. var txDiff = e - m[4], tyDiff = f - m[5];
  47089. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  47090. return null;
  47091. }
  47092. var tx, ty, denominator = a * d - b * c;
  47093. if (font.vertical) {
  47094. tx = -tyDiff * c / denominator;
  47095. ty = tyDiff * a / denominator;
  47096. } else {
  47097. tx = txDiff * d / denominator;
  47098. ty = -txDiff * b / denominator;
  47099. }
  47100. return {
  47101. width: tx,
  47102. height: ty,
  47103. value: font.vertical ? ty : tx
  47104. };
  47105. },
  47106. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  47107. var tsm = [
  47108. this.fontSize * this.textHScale,
  47109. 0,
  47110. 0,
  47111. this.fontSize,
  47112. 0,
  47113. this.textRise
  47114. ];
  47115. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  47116. },
  47117. carriageReturn: function TextState_carriageReturn() {
  47118. this.translateTextLineMatrix(0, -this.leading);
  47119. this.textMatrix = this.textLineMatrix.slice();
  47120. },
  47121. clone: function TextState_clone() {
  47122. var clone = Object.create(this);
  47123. clone.textMatrix = this.textMatrix.slice();
  47124. clone.textLineMatrix = this.textLineMatrix.slice();
  47125. clone.fontMatrix = this.fontMatrix.slice();
  47126. return clone;
  47127. }
  47128. };
  47129. return TextState;
  47130. }();
  47131. var EvalState = function EvalStateClosure() {
  47132. function EvalState() {
  47133. this.ctm = new Float32Array(IDENTITY_MATRIX);
  47134. this.font = null;
  47135. this.textRenderingMode = TextRenderingMode.FILL;
  47136. this.fillColorSpace = ColorSpace.singletons.gray;
  47137. this.strokeColorSpace = ColorSpace.singletons.gray;
  47138. }
  47139. EvalState.prototype = {
  47140. clone: function CanvasExtraState_clone() {
  47141. return Object.create(this);
  47142. }
  47143. };
  47144. return EvalState;
  47145. }();
  47146. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  47147. var getOPMap = getLookupTableFactory(function (t) {
  47148. t['w'] = {
  47149. id: OPS.setLineWidth,
  47150. numArgs: 1,
  47151. variableArgs: false
  47152. };
  47153. t['J'] = {
  47154. id: OPS.setLineCap,
  47155. numArgs: 1,
  47156. variableArgs: false
  47157. };
  47158. t['j'] = {
  47159. id: OPS.setLineJoin,
  47160. numArgs: 1,
  47161. variableArgs: false
  47162. };
  47163. t['M'] = {
  47164. id: OPS.setMiterLimit,
  47165. numArgs: 1,
  47166. variableArgs: false
  47167. };
  47168. t['d'] = {
  47169. id: OPS.setDash,
  47170. numArgs: 2,
  47171. variableArgs: false
  47172. };
  47173. t['ri'] = {
  47174. id: OPS.setRenderingIntent,
  47175. numArgs: 1,
  47176. variableArgs: false
  47177. };
  47178. t['i'] = {
  47179. id: OPS.setFlatness,
  47180. numArgs: 1,
  47181. variableArgs: false
  47182. };
  47183. t['gs'] = {
  47184. id: OPS.setGState,
  47185. numArgs: 1,
  47186. variableArgs: false
  47187. };
  47188. t['q'] = {
  47189. id: OPS.save,
  47190. numArgs: 0,
  47191. variableArgs: false
  47192. };
  47193. t['Q'] = {
  47194. id: OPS.restore,
  47195. numArgs: 0,
  47196. variableArgs: false
  47197. };
  47198. t['cm'] = {
  47199. id: OPS.transform,
  47200. numArgs: 6,
  47201. variableArgs: false
  47202. };
  47203. t['m'] = {
  47204. id: OPS.moveTo,
  47205. numArgs: 2,
  47206. variableArgs: false
  47207. };
  47208. t['l'] = {
  47209. id: OPS.lineTo,
  47210. numArgs: 2,
  47211. variableArgs: false
  47212. };
  47213. t['c'] = {
  47214. id: OPS.curveTo,
  47215. numArgs: 6,
  47216. variableArgs: false
  47217. };
  47218. t['v'] = {
  47219. id: OPS.curveTo2,
  47220. numArgs: 4,
  47221. variableArgs: false
  47222. };
  47223. t['y'] = {
  47224. id: OPS.curveTo3,
  47225. numArgs: 4,
  47226. variableArgs: false
  47227. };
  47228. t['h'] = {
  47229. id: OPS.closePath,
  47230. numArgs: 0,
  47231. variableArgs: false
  47232. };
  47233. t['re'] = {
  47234. id: OPS.rectangle,
  47235. numArgs: 4,
  47236. variableArgs: false
  47237. };
  47238. t['S'] = {
  47239. id: OPS.stroke,
  47240. numArgs: 0,
  47241. variableArgs: false
  47242. };
  47243. t['s'] = {
  47244. id: OPS.closeStroke,
  47245. numArgs: 0,
  47246. variableArgs: false
  47247. };
  47248. t['f'] = {
  47249. id: OPS.fill,
  47250. numArgs: 0,
  47251. variableArgs: false
  47252. };
  47253. t['F'] = {
  47254. id: OPS.fill,
  47255. numArgs: 0,
  47256. variableArgs: false
  47257. };
  47258. t['f*'] = {
  47259. id: OPS.eoFill,
  47260. numArgs: 0,
  47261. variableArgs: false
  47262. };
  47263. t['B'] = {
  47264. id: OPS.fillStroke,
  47265. numArgs: 0,
  47266. variableArgs: false
  47267. };
  47268. t['B*'] = {
  47269. id: OPS.eoFillStroke,
  47270. numArgs: 0,
  47271. variableArgs: false
  47272. };
  47273. t['b'] = {
  47274. id: OPS.closeFillStroke,
  47275. numArgs: 0,
  47276. variableArgs: false
  47277. };
  47278. t['b*'] = {
  47279. id: OPS.closeEOFillStroke,
  47280. numArgs: 0,
  47281. variableArgs: false
  47282. };
  47283. t['n'] = {
  47284. id: OPS.endPath,
  47285. numArgs: 0,
  47286. variableArgs: false
  47287. };
  47288. t['W'] = {
  47289. id: OPS.clip,
  47290. numArgs: 0,
  47291. variableArgs: false
  47292. };
  47293. t['W*'] = {
  47294. id: OPS.eoClip,
  47295. numArgs: 0,
  47296. variableArgs: false
  47297. };
  47298. t['BT'] = {
  47299. id: OPS.beginText,
  47300. numArgs: 0,
  47301. variableArgs: false
  47302. };
  47303. t['ET'] = {
  47304. id: OPS.endText,
  47305. numArgs: 0,
  47306. variableArgs: false
  47307. };
  47308. t['Tc'] = {
  47309. id: OPS.setCharSpacing,
  47310. numArgs: 1,
  47311. variableArgs: false
  47312. };
  47313. t['Tw'] = {
  47314. id: OPS.setWordSpacing,
  47315. numArgs: 1,
  47316. variableArgs: false
  47317. };
  47318. t['Tz'] = {
  47319. id: OPS.setHScale,
  47320. numArgs: 1,
  47321. variableArgs: false
  47322. };
  47323. t['TL'] = {
  47324. id: OPS.setLeading,
  47325. numArgs: 1,
  47326. variableArgs: false
  47327. };
  47328. t['Tf'] = {
  47329. id: OPS.setFont,
  47330. numArgs: 2,
  47331. variableArgs: false
  47332. };
  47333. t['Tr'] = {
  47334. id: OPS.setTextRenderingMode,
  47335. numArgs: 1,
  47336. variableArgs: false
  47337. };
  47338. t['Ts'] = {
  47339. id: OPS.setTextRise,
  47340. numArgs: 1,
  47341. variableArgs: false
  47342. };
  47343. t['Td'] = {
  47344. id: OPS.moveText,
  47345. numArgs: 2,
  47346. variableArgs: false
  47347. };
  47348. t['TD'] = {
  47349. id: OPS.setLeadingMoveText,
  47350. numArgs: 2,
  47351. variableArgs: false
  47352. };
  47353. t['Tm'] = {
  47354. id: OPS.setTextMatrix,
  47355. numArgs: 6,
  47356. variableArgs: false
  47357. };
  47358. t['T*'] = {
  47359. id: OPS.nextLine,
  47360. numArgs: 0,
  47361. variableArgs: false
  47362. };
  47363. t['Tj'] = {
  47364. id: OPS.showText,
  47365. numArgs: 1,
  47366. variableArgs: false
  47367. };
  47368. t['TJ'] = {
  47369. id: OPS.showSpacedText,
  47370. numArgs: 1,
  47371. variableArgs: false
  47372. };
  47373. t['\''] = {
  47374. id: OPS.nextLineShowText,
  47375. numArgs: 1,
  47376. variableArgs: false
  47377. };
  47378. t['"'] = {
  47379. id: OPS.nextLineSetSpacingShowText,
  47380. numArgs: 3,
  47381. variableArgs: false
  47382. };
  47383. t['d0'] = {
  47384. id: OPS.setCharWidth,
  47385. numArgs: 2,
  47386. variableArgs: false
  47387. };
  47388. t['d1'] = {
  47389. id: OPS.setCharWidthAndBounds,
  47390. numArgs: 6,
  47391. variableArgs: false
  47392. };
  47393. t['CS'] = {
  47394. id: OPS.setStrokeColorSpace,
  47395. numArgs: 1,
  47396. variableArgs: false
  47397. };
  47398. t['cs'] = {
  47399. id: OPS.setFillColorSpace,
  47400. numArgs: 1,
  47401. variableArgs: false
  47402. };
  47403. t['SC'] = {
  47404. id: OPS.setStrokeColor,
  47405. numArgs: 4,
  47406. variableArgs: true
  47407. };
  47408. t['SCN'] = {
  47409. id: OPS.setStrokeColorN,
  47410. numArgs: 33,
  47411. variableArgs: true
  47412. };
  47413. t['sc'] = {
  47414. id: OPS.setFillColor,
  47415. numArgs: 4,
  47416. variableArgs: true
  47417. };
  47418. t['scn'] = {
  47419. id: OPS.setFillColorN,
  47420. numArgs: 33,
  47421. variableArgs: true
  47422. };
  47423. t['G'] = {
  47424. id: OPS.setStrokeGray,
  47425. numArgs: 1,
  47426. variableArgs: false
  47427. };
  47428. t['g'] = {
  47429. id: OPS.setFillGray,
  47430. numArgs: 1,
  47431. variableArgs: false
  47432. };
  47433. t['RG'] = {
  47434. id: OPS.setStrokeRGBColor,
  47435. numArgs: 3,
  47436. variableArgs: false
  47437. };
  47438. t['rg'] = {
  47439. id: OPS.setFillRGBColor,
  47440. numArgs: 3,
  47441. variableArgs: false
  47442. };
  47443. t['K'] = {
  47444. id: OPS.setStrokeCMYKColor,
  47445. numArgs: 4,
  47446. variableArgs: false
  47447. };
  47448. t['k'] = {
  47449. id: OPS.setFillCMYKColor,
  47450. numArgs: 4,
  47451. variableArgs: false
  47452. };
  47453. t['sh'] = {
  47454. id: OPS.shadingFill,
  47455. numArgs: 1,
  47456. variableArgs: false
  47457. };
  47458. t['BI'] = {
  47459. id: OPS.beginInlineImage,
  47460. numArgs: 0,
  47461. variableArgs: false
  47462. };
  47463. t['ID'] = {
  47464. id: OPS.beginImageData,
  47465. numArgs: 0,
  47466. variableArgs: false
  47467. };
  47468. t['EI'] = {
  47469. id: OPS.endInlineImage,
  47470. numArgs: 1,
  47471. variableArgs: false
  47472. };
  47473. t['Do'] = {
  47474. id: OPS.paintXObject,
  47475. numArgs: 1,
  47476. variableArgs: false
  47477. };
  47478. t['MP'] = {
  47479. id: OPS.markPoint,
  47480. numArgs: 1,
  47481. variableArgs: false
  47482. };
  47483. t['DP'] = {
  47484. id: OPS.markPointProps,
  47485. numArgs: 2,
  47486. variableArgs: false
  47487. };
  47488. t['BMC'] = {
  47489. id: OPS.beginMarkedContent,
  47490. numArgs: 1,
  47491. variableArgs: false
  47492. };
  47493. t['BDC'] = {
  47494. id: OPS.beginMarkedContentProps,
  47495. numArgs: 2,
  47496. variableArgs: false
  47497. };
  47498. t['EMC'] = {
  47499. id: OPS.endMarkedContent,
  47500. numArgs: 0,
  47501. variableArgs: false
  47502. };
  47503. t['BX'] = {
  47504. id: OPS.beginCompat,
  47505. numArgs: 0,
  47506. variableArgs: false
  47507. };
  47508. t['EX'] = {
  47509. id: OPS.endCompat,
  47510. numArgs: 0,
  47511. variableArgs: false
  47512. };
  47513. t['BM'] = null;
  47514. t['BD'] = null;
  47515. t['true'] = null;
  47516. t['fa'] = null;
  47517. t['fal'] = null;
  47518. t['fals'] = null;
  47519. t['false'] = null;
  47520. t['nu'] = null;
  47521. t['nul'] = null;
  47522. t['null'] = null;
  47523. });
  47524. function EvaluatorPreprocessor(stream, xref, stateManager) {
  47525. this.opMap = getOPMap();
  47526. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  47527. this.stateManager = stateManager;
  47528. this.nonProcessedArgs = [];
  47529. }
  47530. EvaluatorPreprocessor.prototype = {
  47531. get savedStatesDepth() {
  47532. return this.stateManager.stateStack.length;
  47533. },
  47534. read: function EvaluatorPreprocessor_read(operation) {
  47535. var args = operation.args;
  47536. while (true) {
  47537. var obj = this.parser.getObj();
  47538. if (isCmd(obj)) {
  47539. var cmd = obj.cmd;
  47540. var opSpec = this.opMap[cmd];
  47541. if (!opSpec) {
  47542. warn('Unknown command "' + cmd + '"');
  47543. continue;
  47544. }
  47545. var fn = opSpec.id;
  47546. var numArgs = opSpec.numArgs;
  47547. var argsLength = args !== null ? args.length : 0;
  47548. if (!opSpec.variableArgs) {
  47549. if (argsLength !== numArgs) {
  47550. var nonProcessedArgs = this.nonProcessedArgs;
  47551. while (argsLength > numArgs) {
  47552. nonProcessedArgs.push(args.shift());
  47553. argsLength--;
  47554. }
  47555. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  47556. if (args === null) {
  47557. args = [];
  47558. }
  47559. args.unshift(nonProcessedArgs.pop());
  47560. argsLength++;
  47561. }
  47562. }
  47563. if (argsLength < numArgs) {
  47564. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  47565. if (args !== null) {
  47566. args.length = 0;
  47567. }
  47568. continue;
  47569. }
  47570. } else if (argsLength > numArgs) {
  47571. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  47572. }
  47573. this.preprocessCommand(fn, args);
  47574. operation.fn = fn;
  47575. operation.args = args;
  47576. return true;
  47577. } else {
  47578. if (isEOF(obj)) {
  47579. return false;
  47580. }
  47581. if (obj !== null) {
  47582. if (args === null) {
  47583. args = [];
  47584. }
  47585. args.push(obj);
  47586. assert(args.length <= 33, 'Too many arguments');
  47587. }
  47588. }
  47589. }
  47590. },
  47591. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  47592. switch (fn | 0) {
  47593. case OPS.save:
  47594. this.stateManager.save();
  47595. break;
  47596. case OPS.restore:
  47597. this.stateManager.restore();
  47598. break;
  47599. case OPS.transform:
  47600. this.stateManager.transform(args);
  47601. break;
  47602. }
  47603. }
  47604. };
  47605. return EvaluatorPreprocessor;
  47606. }();
  47607. var QueueOptimizer = function QueueOptimizerClosure() {
  47608. function addState(parentState, pattern, fn) {
  47609. var state = parentState;
  47610. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  47611. var item = pattern[i];
  47612. state = state[item] || (state[item] = []);
  47613. }
  47614. state[pattern[pattern.length - 1]] = fn;
  47615. }
  47616. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  47617. var iFirstPIMXO = iFirstSave + 2;
  47618. for (var i = 0; i < count; i++) {
  47619. var arg = argsArray[iFirstPIMXO + 4 * i];
  47620. var imageMask = arg.length === 1 && arg[0];
  47621. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  47622. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  47623. continue;
  47624. }
  47625. break;
  47626. }
  47627. return count - i;
  47628. }
  47629. var InitialState = [];
  47630. addState(InitialState, [
  47631. OPS.save,
  47632. OPS.transform,
  47633. OPS.paintInlineImageXObject,
  47634. OPS.restore
  47635. ], function foundInlineImageGroup(context) {
  47636. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  47637. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  47638. var MAX_WIDTH = 1000;
  47639. var IMAGE_PADDING = 1;
  47640. var fnArray = context.fnArray, argsArray = context.argsArray;
  47641. var curr = context.iCurr;
  47642. var iFirstSave = curr - 3;
  47643. var iFirstTransform = curr - 2;
  47644. var iFirstPIIXO = curr - 1;
  47645. var i = iFirstSave + 4;
  47646. var ii = fnArray.length;
  47647. while (i + 3 < ii) {
  47648. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  47649. break;
  47650. }
  47651. i += 4;
  47652. }
  47653. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  47654. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  47655. return i;
  47656. }
  47657. var maxX = 0;
  47658. var map = [], maxLineHeight = 0;
  47659. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  47660. var q;
  47661. for (q = 0; q < count; q++) {
  47662. var transform = argsArray[iFirstTransform + (q << 2)];
  47663. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  47664. if (currentX + img.width > MAX_WIDTH) {
  47665. maxX = Math.max(maxX, currentX);
  47666. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  47667. currentX = 0;
  47668. maxLineHeight = 0;
  47669. }
  47670. map.push({
  47671. transform: transform,
  47672. x: currentX,
  47673. y: currentY,
  47674. w: img.width,
  47675. h: img.height
  47676. });
  47677. currentX += img.width + 2 * IMAGE_PADDING;
  47678. maxLineHeight = Math.max(maxLineHeight, img.height);
  47679. }
  47680. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  47681. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  47682. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  47683. var imgRowSize = imgWidth << 2;
  47684. for (q = 0; q < count; q++) {
  47685. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  47686. var rowSize = map[q].w << 2;
  47687. var dataOffset = 0;
  47688. var offset = map[q].x + map[q].y * imgWidth << 2;
  47689. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  47690. for (var k = 0, kk = map[q].h; k < kk; k++) {
  47691. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  47692. dataOffset += rowSize;
  47693. offset += imgRowSize;
  47694. }
  47695. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  47696. while (offset >= 0) {
  47697. data[offset - 4] = data[offset];
  47698. data[offset - 3] = data[offset + 1];
  47699. data[offset - 2] = data[offset + 2];
  47700. data[offset - 1] = data[offset + 3];
  47701. data[offset + rowSize] = data[offset + rowSize - 4];
  47702. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  47703. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  47704. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  47705. offset -= imgRowSize;
  47706. }
  47707. }
  47708. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  47709. argsArray.splice(iFirstSave, count * 4, [
  47710. {
  47711. width: imgWidth,
  47712. height: imgHeight,
  47713. kind: ImageKind.RGBA_32BPP,
  47714. data: imgData
  47715. },
  47716. map
  47717. ]);
  47718. return iFirstSave + 1;
  47719. });
  47720. addState(InitialState, [
  47721. OPS.save,
  47722. OPS.transform,
  47723. OPS.paintImageMaskXObject,
  47724. OPS.restore
  47725. ], function foundImageMaskGroup(context) {
  47726. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  47727. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  47728. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  47729. var fnArray = context.fnArray, argsArray = context.argsArray;
  47730. var curr = context.iCurr;
  47731. var iFirstSave = curr - 3;
  47732. var iFirstTransform = curr - 2;
  47733. var iFirstPIMXO = curr - 1;
  47734. var i = iFirstSave + 4;
  47735. var ii = fnArray.length;
  47736. while (i + 3 < ii) {
  47737. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  47738. break;
  47739. }
  47740. i += 4;
  47741. }
  47742. var count = (i - iFirstSave) / 4;
  47743. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  47744. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  47745. return i;
  47746. }
  47747. var q;
  47748. var isSameImage = false;
  47749. var iTransform, transformArgs;
  47750. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  47751. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  47752. isSameImage = true;
  47753. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47754. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47755. iTransform = iFirstTransform + 4;
  47756. var iPIMXO = iFirstPIMXO + 4;
  47757. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  47758. transformArgs = argsArray[iTransform];
  47759. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  47760. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  47761. isSameImage = false;
  47762. } else {
  47763. count = q;
  47764. }
  47765. break;
  47766. }
  47767. }
  47768. }
  47769. if (isSameImage) {
  47770. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  47771. var positions = new Float32Array(count * 2);
  47772. iTransform = iFirstTransform;
  47773. for (q = 0; q < count; q++, iTransform += 4) {
  47774. transformArgs = argsArray[iTransform];
  47775. positions[q << 1] = transformArgs[4];
  47776. positions[(q << 1) + 1] = transformArgs[5];
  47777. }
  47778. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  47779. argsArray.splice(iFirstSave, count * 4, [
  47780. firstPIMXOArg0,
  47781. firstTransformArg0,
  47782. firstTransformArg3,
  47783. positions
  47784. ]);
  47785. } else {
  47786. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  47787. var images = [];
  47788. for (q = 0; q < count; q++) {
  47789. transformArgs = argsArray[iFirstTransform + (q << 2)];
  47790. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  47791. images.push({
  47792. data: maskParams.data,
  47793. width: maskParams.width,
  47794. height: maskParams.height,
  47795. transform: transformArgs
  47796. });
  47797. }
  47798. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  47799. argsArray.splice(iFirstSave, count * 4, [images]);
  47800. }
  47801. return iFirstSave + 1;
  47802. });
  47803. addState(InitialState, [
  47804. OPS.save,
  47805. OPS.transform,
  47806. OPS.paintImageXObject,
  47807. OPS.restore
  47808. ], function (context) {
  47809. var MIN_IMAGES_IN_BLOCK = 3;
  47810. var MAX_IMAGES_IN_BLOCK = 1000;
  47811. var fnArray = context.fnArray, argsArray = context.argsArray;
  47812. var curr = context.iCurr;
  47813. var iFirstSave = curr - 3;
  47814. var iFirstTransform = curr - 2;
  47815. var iFirstPIXO = curr - 1;
  47816. var iFirstRestore = curr;
  47817. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  47818. return iFirstRestore + 1;
  47819. }
  47820. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  47821. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47822. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47823. var i = iFirstSave + 4;
  47824. var ii = fnArray.length;
  47825. while (i + 3 < ii) {
  47826. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  47827. break;
  47828. }
  47829. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  47830. break;
  47831. }
  47832. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  47833. break;
  47834. }
  47835. i += 4;
  47836. }
  47837. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  47838. if (count < MIN_IMAGES_IN_BLOCK) {
  47839. return i;
  47840. }
  47841. var positions = new Float32Array(count * 2);
  47842. var iTransform = iFirstTransform;
  47843. for (var q = 0; q < count; q++, iTransform += 4) {
  47844. var transformArgs = argsArray[iTransform];
  47845. positions[q << 1] = transformArgs[4];
  47846. positions[(q << 1) + 1] = transformArgs[5];
  47847. }
  47848. var args = [
  47849. firstPIXOArg0,
  47850. firstTransformArg0,
  47851. firstTransformArg3,
  47852. positions
  47853. ];
  47854. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  47855. argsArray.splice(iFirstSave, count * 4, args);
  47856. return iFirstSave + 1;
  47857. });
  47858. addState(InitialState, [
  47859. OPS.beginText,
  47860. OPS.setFont,
  47861. OPS.setTextMatrix,
  47862. OPS.showText,
  47863. OPS.endText
  47864. ], function (context) {
  47865. var MIN_CHARS_IN_BLOCK = 3;
  47866. var MAX_CHARS_IN_BLOCK = 1000;
  47867. var fnArray = context.fnArray, argsArray = context.argsArray;
  47868. var curr = context.iCurr;
  47869. var iFirstBeginText = curr - 4;
  47870. var iFirstSetFont = curr - 3;
  47871. var iFirstSetTextMatrix = curr - 2;
  47872. var iFirstShowText = curr - 1;
  47873. var iFirstEndText = curr;
  47874. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  47875. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  47876. var i = iFirstBeginText + 5;
  47877. var ii = fnArray.length;
  47878. while (i + 4 < ii) {
  47879. 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) {
  47880. break;
  47881. }
  47882. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  47883. break;
  47884. }
  47885. i += 5;
  47886. }
  47887. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  47888. if (count < MIN_CHARS_IN_BLOCK) {
  47889. return i;
  47890. }
  47891. var iFirst = iFirstBeginText;
  47892. 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) {
  47893. count++;
  47894. iFirst -= 5;
  47895. }
  47896. var iEndText = iFirst + 4;
  47897. for (var q = 1; q < count; q++) {
  47898. fnArray.splice(iEndText, 3);
  47899. argsArray.splice(iEndText, 3);
  47900. iEndText += 2;
  47901. }
  47902. return iEndText + 1;
  47903. });
  47904. function QueueOptimizer() {
  47905. }
  47906. QueueOptimizer.prototype = {
  47907. optimize: function QueueOptimizer_optimize(queue) {
  47908. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  47909. var context = {
  47910. iCurr: 0,
  47911. fnArray: fnArray,
  47912. argsArray: argsArray
  47913. };
  47914. var state;
  47915. var i = 0, ii = fnArray.length;
  47916. while (i < ii) {
  47917. state = (state || InitialState)[fnArray[i]];
  47918. if (typeof state === 'function') {
  47919. context.iCurr = i;
  47920. i = state(context);
  47921. state = undefined;
  47922. ii = context.fnArray.length;
  47923. } else {
  47924. i++;
  47925. }
  47926. }
  47927. }
  47928. };
  47929. return QueueOptimizer;
  47930. }();
  47931. exports.OperatorList = OperatorList;
  47932. exports.PartialEvaluator = PartialEvaluator;
  47933. }));
  47934. (function (root, factory) {
  47935. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  47936. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  47937. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  47938. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  47939. var AnnotationFlag = sharedUtil.AnnotationFlag;
  47940. var AnnotationType = sharedUtil.AnnotationType;
  47941. var OPS = sharedUtil.OPS;
  47942. var Util = sharedUtil.Util;
  47943. var isString = sharedUtil.isString;
  47944. var isArray = sharedUtil.isArray;
  47945. var isInt = sharedUtil.isInt;
  47946. var stringToBytes = sharedUtil.stringToBytes;
  47947. var stringToPDFString = sharedUtil.stringToPDFString;
  47948. var warn = sharedUtil.warn;
  47949. var Dict = corePrimitives.Dict;
  47950. var isDict = corePrimitives.isDict;
  47951. var isName = corePrimitives.isName;
  47952. var isRef = corePrimitives.isRef;
  47953. var Stream = coreStream.Stream;
  47954. var ColorSpace = coreColorSpace.ColorSpace;
  47955. var Catalog = coreObj.Catalog;
  47956. var ObjectLoader = coreObj.ObjectLoader;
  47957. var FileSpec = coreObj.FileSpec;
  47958. var OperatorList = coreEvaluator.OperatorList;
  47959. function AnnotationFactory() {
  47960. }
  47961. AnnotationFactory.prototype = {
  47962. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  47963. var dict = xref.fetchIfRef(ref);
  47964. if (!isDict(dict)) {
  47965. return;
  47966. }
  47967. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  47968. var subtype = dict.get('Subtype');
  47969. subtype = isName(subtype) ? subtype.name : null;
  47970. var parameters = {
  47971. xref: xref,
  47972. dict: dict,
  47973. ref: isRef(ref) ? ref : null,
  47974. subtype: subtype,
  47975. id: id,
  47976. pdfManager: pdfManager
  47977. };
  47978. switch (subtype) {
  47979. case 'Link':
  47980. return new LinkAnnotation(parameters);
  47981. case 'Text':
  47982. return new TextAnnotation(parameters);
  47983. case 'Widget':
  47984. var fieldType = Util.getInheritableProperty(dict, 'FT');
  47985. fieldType = isName(fieldType) ? fieldType.name : null;
  47986. switch (fieldType) {
  47987. case 'Tx':
  47988. return new TextWidgetAnnotation(parameters);
  47989. case 'Btn':
  47990. return new ButtonWidgetAnnotation(parameters);
  47991. case 'Ch':
  47992. return new ChoiceWidgetAnnotation(parameters);
  47993. }
  47994. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  47995. return new WidgetAnnotation(parameters);
  47996. case 'Popup':
  47997. return new PopupAnnotation(parameters);
  47998. case 'Highlight':
  47999. return new HighlightAnnotation(parameters);
  48000. case 'Underline':
  48001. return new UnderlineAnnotation(parameters);
  48002. case 'Squiggly':
  48003. return new SquigglyAnnotation(parameters);
  48004. case 'StrikeOut':
  48005. return new StrikeOutAnnotation(parameters);
  48006. case 'FileAttachment':
  48007. return new FileAttachmentAnnotation(parameters);
  48008. default:
  48009. if (!subtype) {
  48010. warn('Annotation is missing the required /Subtype.');
  48011. } else {
  48012. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  48013. }
  48014. return new Annotation(parameters);
  48015. }
  48016. }
  48017. };
  48018. var Annotation = function AnnotationClosure() {
  48019. function getTransformMatrix(rect, bbox, matrix) {
  48020. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  48021. var minX = bounds[0];
  48022. var minY = bounds[1];
  48023. var maxX = bounds[2];
  48024. var maxY = bounds[3];
  48025. if (minX === maxX || minY === maxY) {
  48026. return [
  48027. 1,
  48028. 0,
  48029. 0,
  48030. 1,
  48031. rect[0],
  48032. rect[1]
  48033. ];
  48034. }
  48035. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  48036. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  48037. return [
  48038. xRatio,
  48039. 0,
  48040. 0,
  48041. yRatio,
  48042. rect[0] - minX * xRatio,
  48043. rect[1] - minY * yRatio
  48044. ];
  48045. }
  48046. function getDefaultAppearance(dict) {
  48047. var appearanceState = dict.get('AP');
  48048. if (!isDict(appearanceState)) {
  48049. return;
  48050. }
  48051. var appearance;
  48052. var appearances = appearanceState.get('N');
  48053. if (isDict(appearances)) {
  48054. var as = dict.get('AS');
  48055. if (as && appearances.has(as.name)) {
  48056. appearance = appearances.get(as.name);
  48057. }
  48058. } else {
  48059. appearance = appearances;
  48060. }
  48061. return appearance;
  48062. }
  48063. function Annotation(params) {
  48064. var dict = params.dict;
  48065. this.setFlags(dict.get('F'));
  48066. this.setRectangle(dict.getArray('Rect'));
  48067. this.setColor(dict.getArray('C'));
  48068. this.setBorderStyle(dict);
  48069. this.appearance = getDefaultAppearance(dict);
  48070. this.data = {};
  48071. this.data.id = params.id;
  48072. this.data.subtype = params.subtype;
  48073. this.data.annotationFlags = this.flags;
  48074. this.data.rect = this.rectangle;
  48075. this.data.color = this.color;
  48076. this.data.borderStyle = this.borderStyle;
  48077. this.data.hasAppearance = !!this.appearance;
  48078. }
  48079. Annotation.prototype = {
  48080. _hasFlag: function Annotation_hasFlag(flags, flag) {
  48081. return !!(flags & flag);
  48082. },
  48083. _isViewable: function Annotation_isViewable(flags) {
  48084. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  48085. },
  48086. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  48087. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  48088. },
  48089. get viewable() {
  48090. if (this.flags === 0) {
  48091. return true;
  48092. }
  48093. return this._isViewable(this.flags);
  48094. },
  48095. get printable() {
  48096. if (this.flags === 0) {
  48097. return false;
  48098. }
  48099. return this._isPrintable(this.flags);
  48100. },
  48101. setFlags: function Annotation_setFlags(flags) {
  48102. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  48103. },
  48104. hasFlag: function Annotation_hasFlag(flag) {
  48105. return this._hasFlag(this.flags, flag);
  48106. },
  48107. setRectangle: function Annotation_setRectangle(rectangle) {
  48108. if (isArray(rectangle) && rectangle.length === 4) {
  48109. this.rectangle = Util.normalizeRect(rectangle);
  48110. } else {
  48111. this.rectangle = [
  48112. 0,
  48113. 0,
  48114. 0,
  48115. 0
  48116. ];
  48117. }
  48118. },
  48119. setColor: function Annotation_setColor(color) {
  48120. var rgbColor = new Uint8Array(3);
  48121. if (!isArray(color)) {
  48122. this.color = rgbColor;
  48123. return;
  48124. }
  48125. switch (color.length) {
  48126. case 0:
  48127. this.color = null;
  48128. break;
  48129. case 1:
  48130. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  48131. this.color = rgbColor;
  48132. break;
  48133. case 3:
  48134. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  48135. this.color = rgbColor;
  48136. break;
  48137. case 4:
  48138. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  48139. this.color = rgbColor;
  48140. break;
  48141. default:
  48142. this.color = rgbColor;
  48143. break;
  48144. }
  48145. },
  48146. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  48147. this.borderStyle = new AnnotationBorderStyle();
  48148. if (!isDict(borderStyle)) {
  48149. return;
  48150. }
  48151. if (borderStyle.has('BS')) {
  48152. var dict = borderStyle.get('BS');
  48153. var dictType = dict.get('Type');
  48154. if (!dictType || isName(dictType, 'Border')) {
  48155. this.borderStyle.setWidth(dict.get('W'));
  48156. this.borderStyle.setStyle(dict.get('S'));
  48157. this.borderStyle.setDashArray(dict.getArray('D'));
  48158. }
  48159. } else if (borderStyle.has('Border')) {
  48160. var array = borderStyle.getArray('Border');
  48161. if (isArray(array) && array.length >= 3) {
  48162. this.borderStyle.setHorizontalCornerRadius(array[0]);
  48163. this.borderStyle.setVerticalCornerRadius(array[1]);
  48164. this.borderStyle.setWidth(array[2]);
  48165. if (array.length === 4) {
  48166. this.borderStyle.setDashArray(array[3]);
  48167. }
  48168. }
  48169. } else {
  48170. this.borderStyle.setWidth(0);
  48171. }
  48172. },
  48173. _preparePopup: function Annotation_preparePopup(dict) {
  48174. if (!dict.has('C')) {
  48175. this.data.color = null;
  48176. }
  48177. this.data.hasPopup = dict.has('Popup');
  48178. this.data.title = stringToPDFString(dict.get('T') || '');
  48179. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  48180. },
  48181. loadResources: function Annotation_loadResources(keys) {
  48182. return new Promise(function (resolve, reject) {
  48183. this.appearance.dict.getAsync('Resources').then(function (resources) {
  48184. if (!resources) {
  48185. resolve();
  48186. return;
  48187. }
  48188. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  48189. objectLoader.load().then(function () {
  48190. resolve(resources);
  48191. }, reject);
  48192. }, reject);
  48193. }.bind(this));
  48194. },
  48195. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  48196. if (!this.appearance) {
  48197. return Promise.resolve(new OperatorList());
  48198. }
  48199. var data = this.data;
  48200. var appearanceDict = this.appearance.dict;
  48201. var resourcesPromise = this.loadResources([
  48202. 'ExtGState',
  48203. 'ColorSpace',
  48204. 'Pattern',
  48205. 'Shading',
  48206. 'XObject',
  48207. 'Font'
  48208. ]);
  48209. var bbox = appearanceDict.getArray('BBox') || [
  48210. 0,
  48211. 0,
  48212. 1,
  48213. 1
  48214. ];
  48215. var matrix = appearanceDict.getArray('Matrix') || [
  48216. 1,
  48217. 0,
  48218. 0,
  48219. 1,
  48220. 0,
  48221. 0
  48222. ];
  48223. var transform = getTransformMatrix(data.rect, bbox, matrix);
  48224. var self = this;
  48225. return resourcesPromise.then(function (resources) {
  48226. var opList = new OperatorList();
  48227. opList.addOp(OPS.beginAnnotation, [
  48228. data.rect,
  48229. transform,
  48230. matrix
  48231. ]);
  48232. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  48233. opList.addOp(OPS.endAnnotation, []);
  48234. self.appearance.reset();
  48235. return opList;
  48236. });
  48237. });
  48238. }
  48239. };
  48240. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  48241. var annotationPromises = [];
  48242. for (var i = 0, n = annotations.length; i < n; ++i) {
  48243. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  48244. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  48245. }
  48246. }
  48247. return Promise.all(annotationPromises).then(function (operatorLists) {
  48248. opList.addOp(OPS.beginAnnotations, []);
  48249. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  48250. opList.addOpList(operatorLists[i]);
  48251. }
  48252. opList.addOp(OPS.endAnnotations, []);
  48253. });
  48254. };
  48255. return Annotation;
  48256. }();
  48257. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  48258. function AnnotationBorderStyle() {
  48259. this.width = 1;
  48260. this.style = AnnotationBorderStyleType.SOLID;
  48261. this.dashArray = [3];
  48262. this.horizontalCornerRadius = 0;
  48263. this.verticalCornerRadius = 0;
  48264. }
  48265. AnnotationBorderStyle.prototype = {
  48266. setWidth: function AnnotationBorderStyle_setWidth(width) {
  48267. if (width === (width | 0)) {
  48268. this.width = width;
  48269. }
  48270. },
  48271. setStyle: function AnnotationBorderStyle_setStyle(style) {
  48272. if (!style) {
  48273. return;
  48274. }
  48275. switch (style.name) {
  48276. case 'S':
  48277. this.style = AnnotationBorderStyleType.SOLID;
  48278. break;
  48279. case 'D':
  48280. this.style = AnnotationBorderStyleType.DASHED;
  48281. break;
  48282. case 'B':
  48283. this.style = AnnotationBorderStyleType.BEVELED;
  48284. break;
  48285. case 'I':
  48286. this.style = AnnotationBorderStyleType.INSET;
  48287. break;
  48288. case 'U':
  48289. this.style = AnnotationBorderStyleType.UNDERLINE;
  48290. break;
  48291. default:
  48292. break;
  48293. }
  48294. },
  48295. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  48296. if (isArray(dashArray) && dashArray.length > 0) {
  48297. var isValid = true;
  48298. var allZeros = true;
  48299. for (var i = 0, len = dashArray.length; i < len; i++) {
  48300. var element = dashArray[i];
  48301. var validNumber = +element >= 0;
  48302. if (!validNumber) {
  48303. isValid = false;
  48304. break;
  48305. } else if (element > 0) {
  48306. allZeros = false;
  48307. }
  48308. }
  48309. if (isValid && !allZeros) {
  48310. this.dashArray = dashArray;
  48311. } else {
  48312. this.width = 0;
  48313. }
  48314. } else if (dashArray) {
  48315. this.width = 0;
  48316. }
  48317. },
  48318. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  48319. if (radius === (radius | 0)) {
  48320. this.horizontalCornerRadius = radius;
  48321. }
  48322. },
  48323. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  48324. if (radius === (radius | 0)) {
  48325. this.verticalCornerRadius = radius;
  48326. }
  48327. }
  48328. };
  48329. return AnnotationBorderStyle;
  48330. }();
  48331. var WidgetAnnotation = function WidgetAnnotationClosure() {
  48332. function WidgetAnnotation(params) {
  48333. Annotation.call(this, params);
  48334. var dict = params.dict;
  48335. var data = this.data;
  48336. data.annotationType = AnnotationType.WIDGET;
  48337. data.fieldName = this._constructFieldName(dict);
  48338. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  48339. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  48340. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  48341. var fieldType = Util.getInheritableProperty(dict, 'FT');
  48342. data.fieldType = isName(fieldType) ? fieldType.name : null;
  48343. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  48344. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  48345. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  48346. data.fieldFlags = 0;
  48347. }
  48348. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  48349. if (data.fieldType === 'Sig') {
  48350. this.setFlags(AnnotationFlag.HIDDEN);
  48351. }
  48352. }
  48353. Util.inherit(WidgetAnnotation, Annotation, {
  48354. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  48355. if (!dict.has('T') && !dict.has('Parent')) {
  48356. warn('Unknown field name, falling back to empty field name.');
  48357. return '';
  48358. }
  48359. if (!dict.has('Parent')) {
  48360. return stringToPDFString(dict.get('T'));
  48361. }
  48362. var fieldName = [];
  48363. if (dict.has('T')) {
  48364. fieldName.unshift(stringToPDFString(dict.get('T')));
  48365. }
  48366. var loopDict = dict;
  48367. while (loopDict.has('Parent')) {
  48368. loopDict = loopDict.get('Parent');
  48369. if (loopDict.has('T')) {
  48370. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  48371. }
  48372. }
  48373. return fieldName.join('.');
  48374. },
  48375. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  48376. return !!(this.data.fieldFlags & flag);
  48377. }
  48378. });
  48379. return WidgetAnnotation;
  48380. }();
  48381. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  48382. function TextWidgetAnnotation(params) {
  48383. WidgetAnnotation.call(this, params);
  48384. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  48385. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  48386. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  48387. alignment = null;
  48388. }
  48389. this.data.textAlignment = alignment;
  48390. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  48391. if (!isInt(maximumLength) || maximumLength < 0) {
  48392. maximumLength = null;
  48393. }
  48394. this.data.maxLen = maximumLength;
  48395. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  48396. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  48397. }
  48398. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  48399. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48400. var operatorList = new OperatorList();
  48401. if (renderForms) {
  48402. return Promise.resolve(operatorList);
  48403. }
  48404. if (this.appearance) {
  48405. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48406. }
  48407. if (!this.data.defaultAppearance) {
  48408. return Promise.resolve(operatorList);
  48409. }
  48410. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  48411. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  48412. return operatorList;
  48413. });
  48414. }
  48415. });
  48416. return TextWidgetAnnotation;
  48417. }();
  48418. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  48419. function ButtonWidgetAnnotation(params) {
  48420. WidgetAnnotation.call(this, params);
  48421. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  48422. if (this.data.checkBox) {
  48423. if (!isName(this.data.fieldValue)) {
  48424. return;
  48425. }
  48426. this.data.fieldValue = this.data.fieldValue.name;
  48427. }
  48428. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  48429. if (this.data.radioButton) {
  48430. this.data.fieldValue = this.data.buttonValue = null;
  48431. var fieldParent = params.dict.get('Parent');
  48432. if (!isDict(fieldParent) || !fieldParent.has('V')) {
  48433. return;
  48434. }
  48435. var fieldParentValue = fieldParent.get('V');
  48436. if (!isName(fieldParentValue)) {
  48437. return;
  48438. }
  48439. this.data.fieldValue = fieldParentValue.name;
  48440. var appearanceStates = params.dict.get('AP');
  48441. if (!isDict(appearanceStates)) {
  48442. return;
  48443. }
  48444. var normalAppearanceState = appearanceStates.get('N');
  48445. if (!isDict(normalAppearanceState)) {
  48446. return;
  48447. }
  48448. var keys = normalAppearanceState.getKeys();
  48449. for (var i = 0, ii = keys.length; i < ii; i++) {
  48450. if (keys[i] !== 'Off') {
  48451. this.data.buttonValue = keys[i];
  48452. break;
  48453. }
  48454. }
  48455. }
  48456. }
  48457. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  48458. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48459. var operatorList = new OperatorList();
  48460. if (renderForms) {
  48461. return Promise.resolve(operatorList);
  48462. }
  48463. if (this.appearance) {
  48464. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48465. }
  48466. return Promise.resolve(operatorList);
  48467. }
  48468. });
  48469. return ButtonWidgetAnnotation;
  48470. }();
  48471. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  48472. function ChoiceWidgetAnnotation(params) {
  48473. WidgetAnnotation.call(this, params);
  48474. this.data.options = [];
  48475. var options = params.dict.get('Opt');
  48476. if (isArray(options)) {
  48477. var xref = params.xref;
  48478. for (var i = 0, ii = options.length; i < ii; i++) {
  48479. var option = xref.fetchIfRef(options[i]);
  48480. var isOptionArray = isArray(option);
  48481. this.data.options[i] = {
  48482. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  48483. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  48484. };
  48485. }
  48486. }
  48487. if (!isArray(this.data.fieldValue)) {
  48488. this.data.fieldValue = [this.data.fieldValue];
  48489. }
  48490. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  48491. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  48492. }
  48493. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  48494. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48495. var operatorList = new OperatorList();
  48496. if (renderForms) {
  48497. return Promise.resolve(operatorList);
  48498. }
  48499. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48500. }
  48501. });
  48502. return ChoiceWidgetAnnotation;
  48503. }();
  48504. var TextAnnotation = function TextAnnotationClosure() {
  48505. var DEFAULT_ICON_SIZE = 22;
  48506. function TextAnnotation(parameters) {
  48507. Annotation.call(this, parameters);
  48508. this.data.annotationType = AnnotationType.TEXT;
  48509. if (this.data.hasAppearance) {
  48510. this.data.name = 'NoIcon';
  48511. } else {
  48512. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  48513. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  48514. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  48515. }
  48516. this._preparePopup(parameters.dict);
  48517. }
  48518. Util.inherit(TextAnnotation, Annotation, {});
  48519. return TextAnnotation;
  48520. }();
  48521. var LinkAnnotation = function LinkAnnotationClosure() {
  48522. function LinkAnnotation(params) {
  48523. Annotation.call(this, params);
  48524. var data = this.data;
  48525. data.annotationType = AnnotationType.LINK;
  48526. Catalog.parseDestDictionary({
  48527. destDict: params.dict,
  48528. resultObj: data,
  48529. docBaseUrl: params.pdfManager.docBaseUrl
  48530. });
  48531. }
  48532. Util.inherit(LinkAnnotation, Annotation, {});
  48533. return LinkAnnotation;
  48534. }();
  48535. var PopupAnnotation = function PopupAnnotationClosure() {
  48536. function PopupAnnotation(parameters) {
  48537. Annotation.call(this, parameters);
  48538. this.data.annotationType = AnnotationType.POPUP;
  48539. var dict = parameters.dict;
  48540. var parentItem = dict.get('Parent');
  48541. if (!parentItem) {
  48542. warn('Popup annotation has a missing or invalid parent annotation.');
  48543. return;
  48544. }
  48545. this.data.parentId = dict.getRaw('Parent').toString();
  48546. this.data.title = stringToPDFString(parentItem.get('T') || '');
  48547. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  48548. if (!parentItem.has('C')) {
  48549. this.data.color = null;
  48550. } else {
  48551. this.setColor(parentItem.getArray('C'));
  48552. this.data.color = this.color;
  48553. }
  48554. if (!this.viewable) {
  48555. var parentFlags = parentItem.get('F');
  48556. if (this._isViewable(parentFlags)) {
  48557. this.setFlags(parentFlags);
  48558. }
  48559. }
  48560. }
  48561. Util.inherit(PopupAnnotation, Annotation, {});
  48562. return PopupAnnotation;
  48563. }();
  48564. var HighlightAnnotation = function HighlightAnnotationClosure() {
  48565. function HighlightAnnotation(parameters) {
  48566. Annotation.call(this, parameters);
  48567. this.data.annotationType = AnnotationType.HIGHLIGHT;
  48568. this._preparePopup(parameters.dict);
  48569. this.data.borderStyle.setWidth(0);
  48570. }
  48571. Util.inherit(HighlightAnnotation, Annotation, {});
  48572. return HighlightAnnotation;
  48573. }();
  48574. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  48575. function UnderlineAnnotation(parameters) {
  48576. Annotation.call(this, parameters);
  48577. this.data.annotationType = AnnotationType.UNDERLINE;
  48578. this._preparePopup(parameters.dict);
  48579. this.data.borderStyle.setWidth(0);
  48580. }
  48581. Util.inherit(UnderlineAnnotation, Annotation, {});
  48582. return UnderlineAnnotation;
  48583. }();
  48584. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  48585. function SquigglyAnnotation(parameters) {
  48586. Annotation.call(this, parameters);
  48587. this.data.annotationType = AnnotationType.SQUIGGLY;
  48588. this._preparePopup(parameters.dict);
  48589. this.data.borderStyle.setWidth(0);
  48590. }
  48591. Util.inherit(SquigglyAnnotation, Annotation, {});
  48592. return SquigglyAnnotation;
  48593. }();
  48594. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  48595. function StrikeOutAnnotation(parameters) {
  48596. Annotation.call(this, parameters);
  48597. this.data.annotationType = AnnotationType.STRIKEOUT;
  48598. this._preparePopup(parameters.dict);
  48599. this.data.borderStyle.setWidth(0);
  48600. }
  48601. Util.inherit(StrikeOutAnnotation, Annotation, {});
  48602. return StrikeOutAnnotation;
  48603. }();
  48604. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  48605. function FileAttachmentAnnotation(parameters) {
  48606. Annotation.call(this, parameters);
  48607. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  48608. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  48609. this.data.file = file.serializable;
  48610. this._preparePopup(parameters.dict);
  48611. }
  48612. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  48613. return FileAttachmentAnnotation;
  48614. }();
  48615. exports.Annotation = Annotation;
  48616. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  48617. exports.AnnotationFactory = AnnotationFactory;
  48618. }));
  48619. (function (root, factory) {
  48620. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  48621. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  48622. var MissingDataException = sharedUtil.MissingDataException;
  48623. var Util = sharedUtil.Util;
  48624. var assert = sharedUtil.assert;
  48625. var error = sharedUtil.error;
  48626. var info = sharedUtil.info;
  48627. var isArray = sharedUtil.isArray;
  48628. var isArrayBuffer = sharedUtil.isArrayBuffer;
  48629. var isNum = sharedUtil.isNum;
  48630. var isString = sharedUtil.isString;
  48631. var shadow = sharedUtil.shadow;
  48632. var stringToBytes = sharedUtil.stringToBytes;
  48633. var stringToPDFString = sharedUtil.stringToPDFString;
  48634. var warn = sharedUtil.warn;
  48635. var isSpace = sharedUtil.isSpace;
  48636. var Dict = corePrimitives.Dict;
  48637. var isDict = corePrimitives.isDict;
  48638. var isName = corePrimitives.isName;
  48639. var isStream = corePrimitives.isStream;
  48640. var NullStream = coreStream.NullStream;
  48641. var Stream = coreStream.Stream;
  48642. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  48643. var Catalog = coreObj.Catalog;
  48644. var ObjectLoader = coreObj.ObjectLoader;
  48645. var XRef = coreObj.XRef;
  48646. var Linearization = coreParser.Linearization;
  48647. var calculateMD5 = coreCrypto.calculateMD5;
  48648. var OperatorList = coreEvaluator.OperatorList;
  48649. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  48650. var Annotation = coreAnnotation.Annotation;
  48651. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  48652. var Page = function PageClosure() {
  48653. var DEFAULT_USER_UNIT = 1.0;
  48654. var LETTER_SIZE_MEDIABOX = [
  48655. 0,
  48656. 0,
  48657. 612,
  48658. 792
  48659. ];
  48660. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  48661. this.pdfManager = pdfManager;
  48662. this.pageIndex = pageIndex;
  48663. this.pageDict = pageDict;
  48664. this.xref = xref;
  48665. this.ref = ref;
  48666. this.fontCache = fontCache;
  48667. this.uniquePrefix = 'p' + this.pageIndex + '_';
  48668. this.idCounters = { obj: 0 };
  48669. this.evaluatorOptions = pdfManager.evaluatorOptions;
  48670. this.resourcesPromise = null;
  48671. }
  48672. Page.prototype = {
  48673. getPageProp: function Page_getPageProp(key) {
  48674. return this.pageDict.get(key);
  48675. },
  48676. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  48677. var dict = this.pageDict, valueArray = null, loopCount = 0;
  48678. var MAX_LOOP_COUNT = 100;
  48679. getArray = getArray || false;
  48680. while (dict) {
  48681. var value = getArray ? dict.getArray(key) : dict.get(key);
  48682. if (value) {
  48683. if (!valueArray) {
  48684. valueArray = [];
  48685. }
  48686. valueArray.push(value);
  48687. }
  48688. if (++loopCount > MAX_LOOP_COUNT) {
  48689. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  48690. break;
  48691. }
  48692. dict = dict.get('Parent');
  48693. }
  48694. if (!valueArray) {
  48695. return Dict.empty;
  48696. }
  48697. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  48698. return valueArray[0];
  48699. }
  48700. return Dict.merge(this.xref, valueArray);
  48701. },
  48702. get content() {
  48703. return this.getPageProp('Contents');
  48704. },
  48705. get resources() {
  48706. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  48707. },
  48708. get mediaBox() {
  48709. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  48710. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  48711. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  48712. }
  48713. return shadow(this, 'mediaBox', mediaBox);
  48714. },
  48715. get cropBox() {
  48716. var cropBox = this.getInheritedPageProp('CropBox', true);
  48717. if (!isArray(cropBox) || cropBox.length !== 4) {
  48718. return shadow(this, 'cropBox', this.mediaBox);
  48719. }
  48720. return shadow(this, 'cropBox', cropBox);
  48721. },
  48722. get userUnit() {
  48723. var obj = this.getPageProp('UserUnit');
  48724. if (!isNum(obj) || obj <= 0) {
  48725. obj = DEFAULT_USER_UNIT;
  48726. }
  48727. return shadow(this, 'userUnit', obj);
  48728. },
  48729. get view() {
  48730. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  48731. if (mediaBox === cropBox) {
  48732. return shadow(this, 'view', mediaBox);
  48733. }
  48734. var intersection = Util.intersect(cropBox, mediaBox);
  48735. return shadow(this, 'view', intersection || mediaBox);
  48736. },
  48737. get rotate() {
  48738. var rotate = this.getInheritedPageProp('Rotate') || 0;
  48739. if (rotate % 90 !== 0) {
  48740. rotate = 0;
  48741. } else if (rotate >= 360) {
  48742. rotate = rotate % 360;
  48743. } else if (rotate < 0) {
  48744. rotate = (rotate % 360 + 360) % 360;
  48745. }
  48746. return shadow(this, 'rotate', rotate);
  48747. },
  48748. getContentStream: function Page_getContentStream() {
  48749. var content = this.content;
  48750. var stream;
  48751. if (isArray(content)) {
  48752. var xref = this.xref;
  48753. var i, n = content.length;
  48754. var streams = [];
  48755. for (i = 0; i < n; ++i) {
  48756. streams.push(xref.fetchIfRef(content[i]));
  48757. }
  48758. stream = new StreamsSequenceStream(streams);
  48759. } else if (isStream(content)) {
  48760. stream = content;
  48761. } else {
  48762. stream = new NullStream();
  48763. }
  48764. return stream;
  48765. },
  48766. loadResources: function Page_loadResources(keys) {
  48767. if (!this.resourcesPromise) {
  48768. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  48769. }
  48770. return this.resourcesPromise.then(function resourceSuccess() {
  48771. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  48772. return objectLoader.load();
  48773. }.bind(this));
  48774. },
  48775. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  48776. var self = this;
  48777. var pdfManager = this.pdfManager;
  48778. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48779. var resourcesPromise = this.loadResources([
  48780. 'ExtGState',
  48781. 'ColorSpace',
  48782. 'Pattern',
  48783. 'Shading',
  48784. 'XObject',
  48785. 'Font'
  48786. ]);
  48787. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  48788. var dataPromises = Promise.all([
  48789. contentStreamPromise,
  48790. resourcesPromise
  48791. ]);
  48792. var pageListPromise = dataPromises.then(function (data) {
  48793. var contentStream = data[0];
  48794. var opList = new OperatorList(intent, handler, self.pageIndex);
  48795. handler.send('StartRenderPage', {
  48796. transparency: partialEvaluator.hasBlendModes(self.resources),
  48797. pageIndex: self.pageIndex,
  48798. intent: intent
  48799. });
  48800. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  48801. return opList;
  48802. });
  48803. });
  48804. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  48805. return Promise.all([
  48806. pageListPromise,
  48807. annotationsPromise
  48808. ]).then(function (datas) {
  48809. var pageOpList = datas[0];
  48810. var annotations = datas[1];
  48811. if (annotations.length === 0) {
  48812. pageOpList.flush(true);
  48813. return pageOpList;
  48814. }
  48815. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  48816. return annotationsReadyPromise.then(function () {
  48817. pageOpList.flush(true);
  48818. return pageOpList;
  48819. });
  48820. });
  48821. },
  48822. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  48823. var handler = {
  48824. on: function nullHandlerOn() {
  48825. },
  48826. send: function nullHandlerSend() {
  48827. }
  48828. };
  48829. var self = this;
  48830. var pdfManager = this.pdfManager;
  48831. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48832. var resourcesPromise = this.loadResources([
  48833. 'ExtGState',
  48834. 'XObject',
  48835. 'Font'
  48836. ]);
  48837. var dataPromises = Promise.all([
  48838. contentStreamPromise,
  48839. resourcesPromise
  48840. ]);
  48841. return dataPromises.then(function (data) {
  48842. var contentStream = data[0];
  48843. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  48844. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  48845. });
  48846. },
  48847. getAnnotationsData: function Page_getAnnotationsData(intent) {
  48848. var annotations = this.annotations;
  48849. var annotationsData = [];
  48850. for (var i = 0, n = annotations.length; i < n; ++i) {
  48851. if (intent) {
  48852. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  48853. continue;
  48854. }
  48855. }
  48856. annotationsData.push(annotations[i].data);
  48857. }
  48858. return annotationsData;
  48859. },
  48860. get annotations() {
  48861. var annotations = [];
  48862. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  48863. var annotationFactory = new AnnotationFactory();
  48864. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  48865. var annotationRef = annotationRefs[i];
  48866. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  48867. if (annotation) {
  48868. annotations.push(annotation);
  48869. }
  48870. }
  48871. return shadow(this, 'annotations', annotations);
  48872. }
  48873. };
  48874. return Page;
  48875. }();
  48876. var PDFDocument = function PDFDocumentClosure() {
  48877. var FINGERPRINT_FIRST_BYTES = 1024;
  48878. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  48879. function PDFDocument(pdfManager, arg, password) {
  48880. if (isStream(arg)) {
  48881. init.call(this, pdfManager, arg, password);
  48882. } else if (isArrayBuffer(arg)) {
  48883. init.call(this, pdfManager, new Stream(arg), password);
  48884. } else {
  48885. error('PDFDocument: Unknown argument type');
  48886. }
  48887. }
  48888. function init(pdfManager, stream, password) {
  48889. assert(stream.length > 0, 'stream must have data');
  48890. this.pdfManager = pdfManager;
  48891. this.stream = stream;
  48892. var xref = new XRef(this.stream, password, pdfManager);
  48893. this.xref = xref;
  48894. }
  48895. function find(stream, needle, limit, backwards) {
  48896. var pos = stream.pos;
  48897. var end = stream.end;
  48898. var strBuf = [];
  48899. if (pos + limit > end) {
  48900. limit = end - pos;
  48901. }
  48902. for (var n = 0; n < limit; ++n) {
  48903. strBuf.push(String.fromCharCode(stream.getByte()));
  48904. }
  48905. var str = strBuf.join('');
  48906. stream.pos = pos;
  48907. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  48908. if (index === -1) {
  48909. return false;
  48910. }
  48911. stream.pos += index;
  48912. return true;
  48913. }
  48914. var DocumentInfoValidators = {
  48915. get entries() {
  48916. return shadow(this, 'entries', {
  48917. Title: isString,
  48918. Author: isString,
  48919. Subject: isString,
  48920. Keywords: isString,
  48921. Creator: isString,
  48922. Producer: isString,
  48923. CreationDate: isString,
  48924. ModDate: isString,
  48925. Trapped: isName
  48926. });
  48927. }
  48928. };
  48929. PDFDocument.prototype = {
  48930. parse: function PDFDocument_parse(recoveryMode) {
  48931. this.setup(recoveryMode);
  48932. var version = this.catalog.catDict.get('Version');
  48933. if (isName(version)) {
  48934. this.pdfFormatVersion = version.name;
  48935. }
  48936. try {
  48937. this.acroForm = this.catalog.catDict.get('AcroForm');
  48938. if (this.acroForm) {
  48939. this.xfa = this.acroForm.get('XFA');
  48940. var fields = this.acroForm.get('Fields');
  48941. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  48942. this.acroForm = null;
  48943. }
  48944. }
  48945. } catch (ex) {
  48946. info('Something wrong with AcroForm entry');
  48947. this.acroForm = null;
  48948. }
  48949. },
  48950. get linearization() {
  48951. var linearization = null;
  48952. if (this.stream.length) {
  48953. try {
  48954. linearization = Linearization.create(this.stream);
  48955. } catch (err) {
  48956. if (err instanceof MissingDataException) {
  48957. throw err;
  48958. }
  48959. info(err);
  48960. }
  48961. }
  48962. return shadow(this, 'linearization', linearization);
  48963. },
  48964. get startXRef() {
  48965. var stream = this.stream;
  48966. var startXRef = 0;
  48967. var linearization = this.linearization;
  48968. if (linearization) {
  48969. stream.reset();
  48970. if (find(stream, 'endobj', 1024)) {
  48971. startXRef = stream.pos + 6;
  48972. }
  48973. } else {
  48974. var step = 1024;
  48975. var found = false, pos = stream.end;
  48976. while (!found && pos > 0) {
  48977. pos -= step - 'startxref'.length;
  48978. if (pos < 0) {
  48979. pos = 0;
  48980. }
  48981. stream.pos = pos;
  48982. found = find(stream, 'startxref', step, true);
  48983. }
  48984. if (found) {
  48985. stream.skip(9);
  48986. var ch;
  48987. do {
  48988. ch = stream.getByte();
  48989. } while (isSpace(ch));
  48990. var str = '';
  48991. while (ch >= 0x20 && ch <= 0x39) {
  48992. str += String.fromCharCode(ch);
  48993. ch = stream.getByte();
  48994. }
  48995. startXRef = parseInt(str, 10);
  48996. if (isNaN(startXRef)) {
  48997. startXRef = 0;
  48998. }
  48999. }
  49000. }
  49001. return shadow(this, 'startXRef', startXRef);
  49002. },
  49003. get mainXRefEntriesOffset() {
  49004. var mainXRefEntriesOffset = 0;
  49005. var linearization = this.linearization;
  49006. if (linearization) {
  49007. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  49008. }
  49009. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  49010. },
  49011. checkHeader: function PDFDocument_checkHeader() {
  49012. var stream = this.stream;
  49013. stream.reset();
  49014. if (find(stream, '%PDF-', 1024)) {
  49015. stream.moveStart();
  49016. var MAX_VERSION_LENGTH = 12;
  49017. var version = '', ch;
  49018. while ((ch = stream.getByte()) > 0x20) {
  49019. if (version.length >= MAX_VERSION_LENGTH) {
  49020. break;
  49021. }
  49022. version += String.fromCharCode(ch);
  49023. }
  49024. if (!this.pdfFormatVersion) {
  49025. this.pdfFormatVersion = version.substring(5);
  49026. }
  49027. return;
  49028. }
  49029. },
  49030. parseStartXRef: function PDFDocument_parseStartXRef() {
  49031. var startXRef = this.startXRef;
  49032. this.xref.setStartXRef(startXRef);
  49033. },
  49034. setup: function PDFDocument_setup(recoveryMode) {
  49035. this.xref.parse(recoveryMode);
  49036. var self = this;
  49037. var pageFactory = {
  49038. createPage: function (pageIndex, dict, ref, fontCache) {
  49039. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  49040. }
  49041. };
  49042. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  49043. },
  49044. get numPages() {
  49045. var linearization = this.linearization;
  49046. var num = linearization ? linearization.numPages : this.catalog.numPages;
  49047. return shadow(this, 'numPages', num);
  49048. },
  49049. get documentInfo() {
  49050. var docInfo = {
  49051. PDFFormatVersion: this.pdfFormatVersion,
  49052. IsAcroFormPresent: !!this.acroForm,
  49053. IsXFAPresent: !!this.xfa
  49054. };
  49055. var infoDict;
  49056. try {
  49057. infoDict = this.xref.trailer.get('Info');
  49058. } catch (err) {
  49059. info('The document information dictionary is invalid.');
  49060. }
  49061. if (infoDict) {
  49062. var validEntries = DocumentInfoValidators.entries;
  49063. for (var key in validEntries) {
  49064. if (infoDict.has(key)) {
  49065. var value = infoDict.get(key);
  49066. if (validEntries[key](value)) {
  49067. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  49068. } else {
  49069. info('Bad value in document info for "' + key + '"');
  49070. }
  49071. }
  49072. }
  49073. }
  49074. return shadow(this, 'documentInfo', docInfo);
  49075. },
  49076. get fingerprint() {
  49077. var xref = this.xref, hash, fileID = '';
  49078. var idArray = xref.trailer.get('ID');
  49079. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  49080. hash = stringToBytes(idArray[0]);
  49081. } else {
  49082. if (this.stream.ensureRange) {
  49083. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  49084. }
  49085. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  49086. }
  49087. for (var i = 0, n = hash.length; i < n; i++) {
  49088. var hex = hash[i].toString(16);
  49089. fileID += hex.length === 1 ? '0' + hex : hex;
  49090. }
  49091. return shadow(this, 'fingerprint', fileID);
  49092. },
  49093. getPage: function PDFDocument_getPage(pageIndex) {
  49094. return this.catalog.getPage(pageIndex);
  49095. },
  49096. cleanup: function PDFDocument_cleanup() {
  49097. return this.catalog.cleanup();
  49098. }
  49099. };
  49100. return PDFDocument;
  49101. }();
  49102. exports.Page = Page;
  49103. exports.PDFDocument = PDFDocument;
  49104. }));
  49105. (function (root, factory) {
  49106. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  49107. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  49108. var warn = sharedUtil.warn;
  49109. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49110. var shadow = sharedUtil.shadow;
  49111. var NotImplementedException = sharedUtil.NotImplementedException;
  49112. var MissingDataException = sharedUtil.MissingDataException;
  49113. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49114. var Util = sharedUtil.Util;
  49115. var Stream = coreStream.Stream;
  49116. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  49117. var PDFDocument = coreDocument.PDFDocument;
  49118. var BasePdfManager = function BasePdfManagerClosure() {
  49119. function BasePdfManager() {
  49120. throw new Error('Cannot initialize BaseManagerManager');
  49121. }
  49122. BasePdfManager.prototype = {
  49123. get docId() {
  49124. return this._docId;
  49125. },
  49126. get docBaseUrl() {
  49127. var docBaseUrl = null;
  49128. if (this._docBaseUrl) {
  49129. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  49130. if (absoluteUrl) {
  49131. docBaseUrl = absoluteUrl.href;
  49132. } else {
  49133. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  49134. }
  49135. }
  49136. return shadow(this, 'docBaseUrl', docBaseUrl);
  49137. },
  49138. onLoadedStream: function BasePdfManager_onLoadedStream() {
  49139. throw new NotImplementedException();
  49140. },
  49141. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  49142. return this.ensure(this.pdfDocument, prop, args);
  49143. },
  49144. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  49145. return this.ensure(this.pdfDocument.xref, prop, args);
  49146. },
  49147. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  49148. return this.ensure(this.pdfDocument.catalog, prop, args);
  49149. },
  49150. getPage: function BasePdfManager_getPage(pageIndex) {
  49151. return this.pdfDocument.getPage(pageIndex);
  49152. },
  49153. cleanup: function BasePdfManager_cleanup() {
  49154. return this.pdfDocument.cleanup();
  49155. },
  49156. ensure: function BasePdfManager_ensure(obj, prop, args) {
  49157. return new NotImplementedException();
  49158. },
  49159. requestRange: function BasePdfManager_requestRange(begin, end) {
  49160. return new NotImplementedException();
  49161. },
  49162. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  49163. return new NotImplementedException();
  49164. },
  49165. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  49166. return new NotImplementedException();
  49167. },
  49168. updatePassword: function BasePdfManager_updatePassword(password) {
  49169. this.pdfDocument.xref.password = this.password = password;
  49170. if (this._passwordChangedCapability) {
  49171. this._passwordChangedCapability.resolve();
  49172. }
  49173. },
  49174. passwordChanged: function BasePdfManager_passwordChanged() {
  49175. this._passwordChangedCapability = createPromiseCapability();
  49176. return this._passwordChangedCapability.promise;
  49177. },
  49178. terminate: function BasePdfManager_terminate() {
  49179. return new NotImplementedException();
  49180. }
  49181. };
  49182. return BasePdfManager;
  49183. }();
  49184. var LocalPdfManager = function LocalPdfManagerClosure() {
  49185. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  49186. this._docId = docId;
  49187. this._docBaseUrl = docBaseUrl;
  49188. this.evaluatorOptions = evaluatorOptions;
  49189. var stream = new Stream(data);
  49190. this.pdfDocument = new PDFDocument(this, stream, password);
  49191. this._loadedStreamCapability = createPromiseCapability();
  49192. this._loadedStreamCapability.resolve(stream);
  49193. }
  49194. Util.inherit(LocalPdfManager, BasePdfManager, {
  49195. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  49196. return new Promise(function (resolve, reject) {
  49197. try {
  49198. var value = obj[prop];
  49199. var result;
  49200. if (typeof value === 'function') {
  49201. result = value.apply(obj, args);
  49202. } else {
  49203. result = value;
  49204. }
  49205. resolve(result);
  49206. } catch (e) {
  49207. reject(e);
  49208. }
  49209. });
  49210. },
  49211. requestRange: function LocalPdfManager_requestRange(begin, end) {
  49212. return Promise.resolve();
  49213. },
  49214. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  49215. return;
  49216. },
  49217. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  49218. return this._loadedStreamCapability.promise;
  49219. },
  49220. terminate: function LocalPdfManager_terminate() {
  49221. return;
  49222. }
  49223. });
  49224. return LocalPdfManager;
  49225. }();
  49226. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  49227. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  49228. this._docId = docId;
  49229. this._docBaseUrl = docBaseUrl;
  49230. this.msgHandler = args.msgHandler;
  49231. this.evaluatorOptions = evaluatorOptions;
  49232. var params = {
  49233. msgHandler: args.msgHandler,
  49234. url: args.url,
  49235. length: args.length,
  49236. disableAutoFetch: args.disableAutoFetch,
  49237. rangeChunkSize: args.rangeChunkSize
  49238. };
  49239. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  49240. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  49241. }
  49242. Util.inherit(NetworkPdfManager, BasePdfManager, {
  49243. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  49244. var pdfManager = this;
  49245. return new Promise(function (resolve, reject) {
  49246. function ensureHelper() {
  49247. try {
  49248. var result;
  49249. var value = obj[prop];
  49250. if (typeof value === 'function') {
  49251. result = value.apply(obj, args);
  49252. } else {
  49253. result = value;
  49254. }
  49255. resolve(result);
  49256. } catch (e) {
  49257. if (!(e instanceof MissingDataException)) {
  49258. reject(e);
  49259. return;
  49260. }
  49261. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  49262. }
  49263. }
  49264. ensureHelper();
  49265. });
  49266. },
  49267. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  49268. return this.streamManager.requestRange(begin, end);
  49269. },
  49270. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  49271. this.streamManager.requestAllChunks();
  49272. },
  49273. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  49274. this.streamManager.onReceiveData({ chunk: chunk });
  49275. },
  49276. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  49277. return this.streamManager.onLoadedStream();
  49278. },
  49279. terminate: function NetworkPdfManager_terminate() {
  49280. this.streamManager.abort();
  49281. }
  49282. });
  49283. return NetworkPdfManager;
  49284. }();
  49285. exports.LocalPdfManager = LocalPdfManager;
  49286. exports.NetworkPdfManager = NetworkPdfManager;
  49287. }));
  49288. (function (root, factory) {
  49289. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  49290. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  49291. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  49292. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49293. var MessageHandler = sharedUtil.MessageHandler;
  49294. var MissingPDFException = sharedUtil.MissingPDFException;
  49295. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  49296. var PasswordException = sharedUtil.PasswordException;
  49297. var PasswordResponses = sharedUtil.PasswordResponses;
  49298. var UnknownErrorException = sharedUtil.UnknownErrorException;
  49299. var XRefParseException = sharedUtil.XRefParseException;
  49300. var arrayByteLength = sharedUtil.arrayByteLength;
  49301. var arraysToBytes = sharedUtil.arraysToBytes;
  49302. var assert = sharedUtil.assert;
  49303. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49304. var error = sharedUtil.error;
  49305. var info = sharedUtil.info;
  49306. var warn = sharedUtil.warn;
  49307. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  49308. var Ref = corePrimitives.Ref;
  49309. var LocalPdfManager = corePdfManager.LocalPdfManager;
  49310. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  49311. var globalScope = sharedUtil.globalScope;
  49312. var WorkerTask = function WorkerTaskClosure() {
  49313. function WorkerTask(name) {
  49314. this.name = name;
  49315. this.terminated = false;
  49316. this._capability = createPromiseCapability();
  49317. }
  49318. WorkerTask.prototype = {
  49319. get finished() {
  49320. return this._capability.promise;
  49321. },
  49322. finish: function () {
  49323. this._capability.resolve();
  49324. },
  49325. terminate: function () {
  49326. this.terminated = true;
  49327. },
  49328. ensureNotTerminated: function () {
  49329. if (this.terminated) {
  49330. throw new Error('Worker task was terminated');
  49331. }
  49332. }
  49333. };
  49334. return WorkerTask;
  49335. }();
  49336. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  49337. function PDFWorkerStream(params, msgHandler) {
  49338. this._queuedChunks = [];
  49339. var initialData = params.initialData;
  49340. if (initialData && initialData.length > 0) {
  49341. this._queuedChunks.push(initialData);
  49342. }
  49343. this._msgHandler = msgHandler;
  49344. this._isRangeSupported = !params.disableRange;
  49345. this._isStreamingSupported = !params.disableStream;
  49346. this._contentLength = params.length;
  49347. this._fullRequestReader = null;
  49348. this._rangeReaders = [];
  49349. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  49350. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  49351. }
  49352. PDFWorkerStream.prototype = {
  49353. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  49354. if (args.begin === undefined) {
  49355. if (this._fullRequestReader) {
  49356. this._fullRequestReader._enqueue(args.chunk);
  49357. } else {
  49358. this._queuedChunks.push(args.chunk);
  49359. }
  49360. } else {
  49361. var found = this._rangeReaders.some(function (rangeReader) {
  49362. if (rangeReader._begin !== args.begin) {
  49363. return false;
  49364. }
  49365. rangeReader._enqueue(args.chunk);
  49366. return true;
  49367. });
  49368. assert(found);
  49369. }
  49370. },
  49371. _onProgress: function PDFWorkerStream_onProgress(evt) {
  49372. if (this._rangeReaders.length > 0) {
  49373. var firstReader = this._rangeReaders[0];
  49374. if (firstReader.onProgress) {
  49375. firstReader.onProgress({ loaded: evt.loaded });
  49376. }
  49377. }
  49378. },
  49379. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  49380. var i = this._rangeReaders.indexOf(reader);
  49381. if (i >= 0) {
  49382. this._rangeReaders.splice(i, 1);
  49383. }
  49384. },
  49385. getFullReader: function PDFWorkerStream_getFullReader() {
  49386. assert(!this._fullRequestReader);
  49387. var queuedChunks = this._queuedChunks;
  49388. this._queuedChunks = null;
  49389. return new PDFWorkerStreamReader(this, queuedChunks);
  49390. },
  49391. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  49392. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  49393. this._msgHandler.send('RequestDataRange', {
  49394. begin: begin,
  49395. end: end
  49396. });
  49397. this._rangeReaders.push(reader);
  49398. return reader;
  49399. },
  49400. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  49401. if (this._fullRequestReader) {
  49402. this._fullRequestReader.cancel(reason);
  49403. }
  49404. var readers = this._rangeReaders.slice(0);
  49405. readers.forEach(function (rangeReader) {
  49406. rangeReader.cancel(reason);
  49407. });
  49408. }
  49409. };
  49410. function PDFWorkerStreamReader(stream, queuedChunks) {
  49411. this._stream = stream;
  49412. this._done = false;
  49413. this._queuedChunks = queuedChunks || [];
  49414. this._requests = [];
  49415. this._headersReady = Promise.resolve();
  49416. stream._fullRequestReader = this;
  49417. this.onProgress = null;
  49418. }
  49419. PDFWorkerStreamReader.prototype = {
  49420. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  49421. if (this._done) {
  49422. return;
  49423. }
  49424. if (this._requests.length > 0) {
  49425. var requestCapability = this._requests.shift();
  49426. requestCapability.resolve({
  49427. value: chunk,
  49428. done: false
  49429. });
  49430. return;
  49431. }
  49432. this._queuedChunks.push(chunk);
  49433. },
  49434. get headersReady() {
  49435. return this._headersReady;
  49436. },
  49437. get isRangeSupported() {
  49438. return this._stream._isRangeSupported;
  49439. },
  49440. get isStreamingSupported() {
  49441. return this._stream._isStreamingSupported;
  49442. },
  49443. get contentLength() {
  49444. return this._stream._contentLength;
  49445. },
  49446. read: function PDFWorkerStreamReader_read() {
  49447. if (this._queuedChunks.length > 0) {
  49448. var chunk = this._queuedChunks.shift();
  49449. return Promise.resolve({
  49450. value: chunk,
  49451. done: false
  49452. });
  49453. }
  49454. if (this._done) {
  49455. return Promise.resolve({
  49456. value: undefined,
  49457. done: true
  49458. });
  49459. }
  49460. var requestCapability = createPromiseCapability();
  49461. this._requests.push(requestCapability);
  49462. return requestCapability.promise;
  49463. },
  49464. cancel: function PDFWorkerStreamReader_cancel(reason) {
  49465. this._done = true;
  49466. this._requests.forEach(function (requestCapability) {
  49467. requestCapability.resolve({
  49468. value: undefined,
  49469. done: true
  49470. });
  49471. });
  49472. this._requests = [];
  49473. }
  49474. };
  49475. function PDFWorkerStreamRangeReader(stream, begin, end) {
  49476. this._stream = stream;
  49477. this._begin = begin;
  49478. this._end = end;
  49479. this._queuedChunk = null;
  49480. this._requests = [];
  49481. this._done = false;
  49482. this.onProgress = null;
  49483. }
  49484. PDFWorkerStreamRangeReader.prototype = {
  49485. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  49486. if (this._done) {
  49487. return;
  49488. }
  49489. if (this._requests.length === 0) {
  49490. this._queuedChunk = chunk;
  49491. } else {
  49492. var requestsCapability = this._requests.shift();
  49493. requestsCapability.resolve({
  49494. value: chunk,
  49495. done: false
  49496. });
  49497. this._requests.forEach(function (requestCapability) {
  49498. requestCapability.resolve({
  49499. value: undefined,
  49500. done: true
  49501. });
  49502. });
  49503. this._requests = [];
  49504. }
  49505. this._done = true;
  49506. this._stream._removeRangeReader(this);
  49507. },
  49508. get isStreamingSupported() {
  49509. return false;
  49510. },
  49511. read: function PDFWorkerStreamRangeReader_read() {
  49512. if (this._queuedChunk) {
  49513. return Promise.resolve({
  49514. value: this._queuedChunk,
  49515. done: false
  49516. });
  49517. }
  49518. if (this._done) {
  49519. return Promise.resolve({
  49520. value: undefined,
  49521. done: true
  49522. });
  49523. }
  49524. var requestCapability = createPromiseCapability();
  49525. this._requests.push(requestCapability);
  49526. return requestCapability.promise;
  49527. },
  49528. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  49529. this._done = true;
  49530. this._requests.forEach(function (requestCapability) {
  49531. requestCapability.resolve({
  49532. value: undefined,
  49533. done: true
  49534. });
  49535. });
  49536. this._requests = [];
  49537. this._stream._removeRangeReader(this);
  49538. }
  49539. };
  49540. return PDFWorkerStream;
  49541. }();
  49542. var PDFNetworkStream;
  49543. function setPDFNetworkStreamClass(cls) {
  49544. PDFNetworkStream = cls;
  49545. }
  49546. var WorkerMessageHandler = {
  49547. setup: function wphSetup(handler, port) {
  49548. var testMessageProcessed = false;
  49549. handler.on('test', function wphSetupTest(data) {
  49550. if (testMessageProcessed) {
  49551. return;
  49552. }
  49553. testMessageProcessed = true;
  49554. if (!(data instanceof Uint8Array)) {
  49555. handler.send('test', 'main', false);
  49556. return;
  49557. }
  49558. var supportTransfers = data[0] === 255;
  49559. handler.postMessageTransfers = supportTransfers;
  49560. var xhr = new XMLHttpRequest();
  49561. var responseExists = 'response' in xhr;
  49562. try {
  49563. var dummy = xhr.responseType;
  49564. } catch (e) {
  49565. responseExists = false;
  49566. }
  49567. if (!responseExists) {
  49568. handler.send('test', false);
  49569. return;
  49570. }
  49571. handler.send('test', {
  49572. supportTypedArray: true,
  49573. supportTransfers: supportTransfers
  49574. });
  49575. });
  49576. handler.on('configure', function wphConfigure(data) {
  49577. setVerbosityLevel(data.verbosity);
  49578. });
  49579. handler.on('GetDocRequest', function wphSetupDoc(data) {
  49580. return WorkerMessageHandler.createDocumentHandler(data, port);
  49581. });
  49582. },
  49583. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  49584. var pdfManager;
  49585. var terminated = false;
  49586. var cancelXHRs = null;
  49587. var WorkerTasks = [];
  49588. var docId = docParams.docId;
  49589. var docBaseUrl = docParams.docBaseUrl;
  49590. var workerHandlerName = docParams.docId + '_worker';
  49591. var handler = new MessageHandler(workerHandlerName, docId, port);
  49592. handler.postMessageTransfers = docParams.postMessageTransfers;
  49593. function ensureNotTerminated() {
  49594. if (terminated) {
  49595. throw new Error('Worker was terminated');
  49596. }
  49597. }
  49598. function startWorkerTask(task) {
  49599. WorkerTasks.push(task);
  49600. }
  49601. function finishWorkerTask(task) {
  49602. task.finish();
  49603. var i = WorkerTasks.indexOf(task);
  49604. WorkerTasks.splice(i, 1);
  49605. }
  49606. function loadDocument(recoveryMode) {
  49607. var loadDocumentCapability = createPromiseCapability();
  49608. var parseSuccess = function parseSuccess() {
  49609. var numPagesPromise = pdfManager.ensureDoc('numPages');
  49610. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  49611. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  49612. Promise.all([
  49613. numPagesPromise,
  49614. fingerprintPromise,
  49615. encryptedPromise
  49616. ]).then(function onDocReady(results) {
  49617. var doc = {
  49618. numPages: results[0],
  49619. fingerprint: results[1],
  49620. encrypted: !!results[2]
  49621. };
  49622. loadDocumentCapability.resolve(doc);
  49623. }, parseFailure);
  49624. };
  49625. var parseFailure = function parseFailure(e) {
  49626. loadDocumentCapability.reject(e);
  49627. };
  49628. pdfManager.ensureDoc('checkHeader', []).then(function () {
  49629. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  49630. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  49631. }, parseFailure);
  49632. }, parseFailure);
  49633. return loadDocumentCapability.promise;
  49634. }
  49635. function getPdfManager(data, evaluatorOptions) {
  49636. var pdfManagerCapability = createPromiseCapability();
  49637. var pdfManager;
  49638. var source = data.source;
  49639. if (source.data) {
  49640. try {
  49641. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  49642. pdfManagerCapability.resolve(pdfManager);
  49643. } catch (ex) {
  49644. pdfManagerCapability.reject(ex);
  49645. }
  49646. return pdfManagerCapability.promise;
  49647. }
  49648. var pdfStream;
  49649. try {
  49650. if (source.chunkedViewerLoading) {
  49651. pdfStream = new PDFWorkerStream(source, handler);
  49652. } else {
  49653. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  49654. pdfStream = new PDFNetworkStream(data);
  49655. }
  49656. } catch (ex) {
  49657. pdfManagerCapability.reject(ex);
  49658. return pdfManagerCapability.promise;
  49659. }
  49660. var fullRequest = pdfStream.getFullReader();
  49661. fullRequest.headersReady.then(function () {
  49662. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  49663. fullRequest.onProgress = function (evt) {
  49664. handler.send('DocProgress', {
  49665. loaded: evt.loaded,
  49666. total: evt.total
  49667. });
  49668. };
  49669. }
  49670. if (!fullRequest.isRangeSupported) {
  49671. return;
  49672. }
  49673. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  49674. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  49675. msgHandler: handler,
  49676. url: source.url,
  49677. password: source.password,
  49678. length: fullRequest.contentLength,
  49679. disableAutoFetch: disableAutoFetch,
  49680. rangeChunkSize: source.rangeChunkSize
  49681. }, evaluatorOptions, docBaseUrl);
  49682. pdfManagerCapability.resolve(pdfManager);
  49683. cancelXHRs = null;
  49684. }).catch(function (reason) {
  49685. pdfManagerCapability.reject(reason);
  49686. cancelXHRs = null;
  49687. });
  49688. var cachedChunks = [], loaded = 0;
  49689. var flushChunks = function () {
  49690. var pdfFile = arraysToBytes(cachedChunks);
  49691. if (source.length && pdfFile.length !== source.length) {
  49692. warn('reported HTTP length is different from actual');
  49693. }
  49694. try {
  49695. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  49696. pdfManagerCapability.resolve(pdfManager);
  49697. } catch (ex) {
  49698. pdfManagerCapability.reject(ex);
  49699. }
  49700. cachedChunks = [];
  49701. };
  49702. var readPromise = new Promise(function (resolve, reject) {
  49703. var readChunk = function (chunk) {
  49704. try {
  49705. ensureNotTerminated();
  49706. if (chunk.done) {
  49707. if (!pdfManager) {
  49708. flushChunks();
  49709. }
  49710. cancelXHRs = null;
  49711. return;
  49712. }
  49713. var data = chunk.value;
  49714. loaded += arrayByteLength(data);
  49715. if (!fullRequest.isStreamingSupported) {
  49716. handler.send('DocProgress', {
  49717. loaded: loaded,
  49718. total: Math.max(loaded, fullRequest.contentLength || 0)
  49719. });
  49720. }
  49721. if (pdfManager) {
  49722. pdfManager.sendProgressiveData(data);
  49723. } else {
  49724. cachedChunks.push(data);
  49725. }
  49726. fullRequest.read().then(readChunk, reject);
  49727. } catch (e) {
  49728. reject(e);
  49729. }
  49730. };
  49731. fullRequest.read().then(readChunk, reject);
  49732. });
  49733. readPromise.catch(function (e) {
  49734. pdfManagerCapability.reject(e);
  49735. cancelXHRs = null;
  49736. });
  49737. cancelXHRs = function () {
  49738. pdfStream.cancelAllRequests('abort');
  49739. };
  49740. return pdfManagerCapability.promise;
  49741. }
  49742. var setupDoc = function (data) {
  49743. var onSuccess = function (doc) {
  49744. ensureNotTerminated();
  49745. handler.send('GetDoc', { pdfInfo: doc });
  49746. };
  49747. var onFailure = function (e) {
  49748. if (e instanceof PasswordException) {
  49749. if (e.code === PasswordResponses.NEED_PASSWORD) {
  49750. handler.send('NeedPassword', e);
  49751. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  49752. handler.send('IncorrectPassword', e);
  49753. }
  49754. } else if (e instanceof InvalidPDFException) {
  49755. handler.send('InvalidPDF', e);
  49756. } else if (e instanceof MissingPDFException) {
  49757. handler.send('MissingPDF', e);
  49758. } else if (e instanceof UnexpectedResponseException) {
  49759. handler.send('UnexpectedResponse', e);
  49760. } else {
  49761. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  49762. }
  49763. };
  49764. ensureNotTerminated();
  49765. var cMapOptions = {
  49766. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  49767. packed: data.cMapPacked === true
  49768. };
  49769. var evaluatorOptions = {
  49770. forceDataSchema: data.disableCreateObjectURL,
  49771. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  49772. disableFontFace: data.disableFontFace,
  49773. cMapOptions: cMapOptions
  49774. };
  49775. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  49776. if (terminated) {
  49777. newPdfManager.terminate();
  49778. throw new Error('Worker was terminated');
  49779. }
  49780. pdfManager = newPdfManager;
  49781. handler.send('PDFManagerReady', null);
  49782. pdfManager.onLoadedStream().then(function (stream) {
  49783. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  49784. });
  49785. }).then(function pdfManagerReady() {
  49786. ensureNotTerminated();
  49787. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  49788. ensureNotTerminated();
  49789. if (!(ex instanceof XRefParseException)) {
  49790. if (ex instanceof PasswordException) {
  49791. pdfManager.passwordChanged().then(pdfManagerReady);
  49792. }
  49793. onFailure(ex);
  49794. return;
  49795. }
  49796. pdfManager.requestLoadedStream();
  49797. pdfManager.onLoadedStream().then(function () {
  49798. ensureNotTerminated();
  49799. loadDocument(true).then(onSuccess, onFailure);
  49800. });
  49801. }, onFailure);
  49802. }, onFailure);
  49803. };
  49804. handler.on('GetPage', function wphSetupGetPage(data) {
  49805. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49806. var rotatePromise = pdfManager.ensure(page, 'rotate');
  49807. var refPromise = pdfManager.ensure(page, 'ref');
  49808. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  49809. var viewPromise = pdfManager.ensure(page, 'view');
  49810. return Promise.all([
  49811. rotatePromise,
  49812. refPromise,
  49813. userUnitPromise,
  49814. viewPromise
  49815. ]).then(function (results) {
  49816. return {
  49817. rotate: results[0],
  49818. ref: results[1],
  49819. userUnit: results[2],
  49820. view: results[3]
  49821. };
  49822. });
  49823. });
  49824. });
  49825. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  49826. var ref = new Ref(data.ref.num, data.ref.gen);
  49827. var catalog = pdfManager.pdfDocument.catalog;
  49828. return catalog.getPageIndex(ref);
  49829. });
  49830. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  49831. return pdfManager.ensureCatalog('destinations');
  49832. });
  49833. handler.on('GetDestination', function wphSetupGetDestination(data) {
  49834. return pdfManager.ensureCatalog('getDestination', [data.id]);
  49835. });
  49836. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  49837. return pdfManager.ensureCatalog('pageLabels');
  49838. });
  49839. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  49840. return pdfManager.ensureCatalog('attachments');
  49841. });
  49842. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  49843. return pdfManager.ensureCatalog('javaScript');
  49844. });
  49845. handler.on('GetOutline', function wphSetupGetOutline(data) {
  49846. return pdfManager.ensureCatalog('documentOutline');
  49847. });
  49848. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  49849. return Promise.all([
  49850. pdfManager.ensureDoc('documentInfo'),
  49851. pdfManager.ensureCatalog('metadata')
  49852. ]);
  49853. });
  49854. handler.on('GetData', function wphSetupGetData(data) {
  49855. pdfManager.requestLoadedStream();
  49856. return pdfManager.onLoadedStream().then(function (stream) {
  49857. return stream.bytes;
  49858. });
  49859. });
  49860. handler.on('GetStats', function wphSetupGetStats(data) {
  49861. return pdfManager.pdfDocument.xref.stats;
  49862. });
  49863. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  49864. pdfManager.updatePassword(data);
  49865. });
  49866. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  49867. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49868. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  49869. });
  49870. });
  49871. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  49872. var pageIndex = data.pageIndex;
  49873. pdfManager.getPage(pageIndex).then(function (page) {
  49874. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  49875. startWorkerTask(task);
  49876. var pageNum = pageIndex + 1;
  49877. var start = Date.now();
  49878. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  49879. finishWorkerTask(task);
  49880. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  49881. }, function (e) {
  49882. finishWorkerTask(task);
  49883. if (task.terminated) {
  49884. return;
  49885. }
  49886. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  49887. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  49888. var wrappedException;
  49889. if (typeof e === 'string') {
  49890. wrappedException = {
  49891. message: e,
  49892. stack: minimumStackMessage
  49893. };
  49894. } else if (typeof e === 'object') {
  49895. wrappedException = {
  49896. message: e.message || e.toString(),
  49897. stack: e.stack || minimumStackMessage
  49898. };
  49899. } else {
  49900. wrappedException = {
  49901. message: 'Unknown exception type: ' + typeof e,
  49902. stack: minimumStackMessage
  49903. };
  49904. }
  49905. handler.send('PageError', {
  49906. pageNum: pageNum,
  49907. error: wrappedException,
  49908. intent: data.intent
  49909. });
  49910. });
  49911. });
  49912. }, this);
  49913. handler.on('GetTextContent', function wphExtractText(data) {
  49914. var pageIndex = data.pageIndex;
  49915. var normalizeWhitespace = data.normalizeWhitespace;
  49916. var combineTextItems = data.combineTextItems;
  49917. return pdfManager.getPage(pageIndex).then(function (page) {
  49918. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  49919. startWorkerTask(task);
  49920. var pageNum = pageIndex + 1;
  49921. var start = Date.now();
  49922. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  49923. finishWorkerTask(task);
  49924. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  49925. return textContent;
  49926. }, function (reason) {
  49927. finishWorkerTask(task);
  49928. if (task.terminated) {
  49929. return;
  49930. }
  49931. throw reason;
  49932. });
  49933. });
  49934. });
  49935. handler.on('Cleanup', function wphCleanup(data) {
  49936. return pdfManager.cleanup();
  49937. });
  49938. handler.on('Terminate', function wphTerminate(data) {
  49939. terminated = true;
  49940. if (pdfManager) {
  49941. pdfManager.terminate();
  49942. pdfManager = null;
  49943. }
  49944. if (cancelXHRs) {
  49945. cancelXHRs();
  49946. }
  49947. var waitOn = [];
  49948. WorkerTasks.forEach(function (task) {
  49949. waitOn.push(task.finished);
  49950. task.terminate();
  49951. });
  49952. return Promise.all(waitOn).then(function () {
  49953. handler.destroy();
  49954. handler = null;
  49955. });
  49956. });
  49957. handler.on('Ready', function wphReady(data) {
  49958. setupDoc(docParams);
  49959. docParams = null;
  49960. });
  49961. return workerHandlerName;
  49962. }
  49963. };
  49964. function initializeWorker() {
  49965. if (!('console' in globalScope)) {
  49966. var consoleTimer = {};
  49967. var workerConsole = {
  49968. log: function log() {
  49969. var args = Array.prototype.slice.call(arguments);
  49970. globalScope.postMessage({
  49971. targetName: 'main',
  49972. action: 'console_log',
  49973. data: args
  49974. });
  49975. },
  49976. error: function error() {
  49977. var args = Array.prototype.slice.call(arguments);
  49978. globalScope.postMessage({
  49979. targetName: 'main',
  49980. action: 'console_error',
  49981. data: args
  49982. });
  49983. throw 'pdf.js execution error';
  49984. },
  49985. time: function time(name) {
  49986. consoleTimer[name] = Date.now();
  49987. },
  49988. timeEnd: function timeEnd(name) {
  49989. var time = consoleTimer[name];
  49990. if (!time) {
  49991. error('Unknown timer name ' + name);
  49992. }
  49993. this.log('Timer:', name, Date.now() - time);
  49994. }
  49995. };
  49996. globalScope.console = workerConsole;
  49997. }
  49998. var handler = new MessageHandler('worker', 'main', self);
  49999. WorkerMessageHandler.setup(handler, self);
  50000. handler.send('ready', null);
  50001. }
  50002. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  50003. initializeWorker();
  50004. }
  50005. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  50006. exports.WorkerTask = WorkerTask;
  50007. exports.WorkerMessageHandler = WorkerMessageHandler;
  50008. }));
  50009. (function (root, factory) {
  50010. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  50011. }(this, function (exports, sharedUtil, coreWorker) {
  50012. var OK_RESPONSE = 200;
  50013. var PARTIAL_CONTENT_RESPONSE = 206;
  50014. function NetworkManager(url, args) {
  50015. this.url = url;
  50016. args = args || {};
  50017. this.isHttp = /^https?:/i.test(url);
  50018. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  50019. this.withCredentials = args.withCredentials || false;
  50020. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  50021. return new XMLHttpRequest();
  50022. };
  50023. this.currXhrId = 0;
  50024. this.pendingRequests = Object.create(null);
  50025. this.loadedRequests = Object.create(null);
  50026. }
  50027. function getArrayBuffer(xhr) {
  50028. var data = xhr.response;
  50029. if (typeof data !== 'string') {
  50030. return data;
  50031. }
  50032. var length = data.length;
  50033. var array = new Uint8Array(length);
  50034. for (var i = 0; i < length; i++) {
  50035. array[i] = data.charCodeAt(i) & 0xFF;
  50036. }
  50037. return array.buffer;
  50038. }
  50039. var supportsMozChunked = function supportsMozChunkedClosure() {
  50040. try {
  50041. var x = new XMLHttpRequest();
  50042. x.open('GET', 'https://example.com');
  50043. x.responseType = 'moz-chunked-arraybuffer';
  50044. return x.responseType === 'moz-chunked-arraybuffer';
  50045. } catch (e) {
  50046. return false;
  50047. }
  50048. }();
  50049. NetworkManager.prototype = {
  50050. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  50051. var args = {
  50052. begin: begin,
  50053. end: end
  50054. };
  50055. for (var prop in listeners) {
  50056. args[prop] = listeners[prop];
  50057. }
  50058. return this.request(args);
  50059. },
  50060. requestFull: function NetworkManager_requestFull(listeners) {
  50061. return this.request(listeners);
  50062. },
  50063. request: function NetworkManager_request(args) {
  50064. var xhr = this.getXhr();
  50065. var xhrId = this.currXhrId++;
  50066. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  50067. xhr.open('GET', this.url);
  50068. xhr.withCredentials = this.withCredentials;
  50069. for (var property in this.httpHeaders) {
  50070. var value = this.httpHeaders[property];
  50071. if (typeof value === 'undefined') {
  50072. continue;
  50073. }
  50074. xhr.setRequestHeader(property, value);
  50075. }
  50076. if (this.isHttp && 'begin' in args && 'end' in args) {
  50077. var rangeStr = args.begin + '-' + (args.end - 1);
  50078. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  50079. pendingRequest.expectedStatus = 206;
  50080. } else {
  50081. pendingRequest.expectedStatus = 200;
  50082. }
  50083. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  50084. if (useMozChunkedLoading) {
  50085. xhr.responseType = 'moz-chunked-arraybuffer';
  50086. pendingRequest.onProgressiveData = args.onProgressiveData;
  50087. pendingRequest.mozChunked = true;
  50088. } else {
  50089. xhr.responseType = 'arraybuffer';
  50090. }
  50091. if (args.onError) {
  50092. xhr.onerror = function (evt) {
  50093. args.onError(xhr.status);
  50094. };
  50095. }
  50096. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  50097. xhr.onprogress = this.onProgress.bind(this, xhrId);
  50098. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  50099. pendingRequest.onDone = args.onDone;
  50100. pendingRequest.onError = args.onError;
  50101. pendingRequest.onProgress = args.onProgress;
  50102. xhr.send(null);
  50103. return xhrId;
  50104. },
  50105. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  50106. var pendingRequest = this.pendingRequests[xhrId];
  50107. if (!pendingRequest) {
  50108. return;
  50109. }
  50110. if (pendingRequest.mozChunked) {
  50111. var chunk = getArrayBuffer(pendingRequest.xhr);
  50112. pendingRequest.onProgressiveData(chunk);
  50113. }
  50114. var onProgress = pendingRequest.onProgress;
  50115. if (onProgress) {
  50116. onProgress(evt);
  50117. }
  50118. },
  50119. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  50120. var pendingRequest = this.pendingRequests[xhrId];
  50121. if (!pendingRequest) {
  50122. return;
  50123. }
  50124. var xhr = pendingRequest.xhr;
  50125. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  50126. pendingRequest.onHeadersReceived();
  50127. delete pendingRequest.onHeadersReceived;
  50128. }
  50129. if (xhr.readyState !== 4) {
  50130. return;
  50131. }
  50132. if (!(xhrId in this.pendingRequests)) {
  50133. return;
  50134. }
  50135. delete this.pendingRequests[xhrId];
  50136. if (xhr.status === 0 && this.isHttp) {
  50137. if (pendingRequest.onError) {
  50138. pendingRequest.onError(xhr.status);
  50139. }
  50140. return;
  50141. }
  50142. var xhrStatus = xhr.status || OK_RESPONSE;
  50143. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  50144. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  50145. if (pendingRequest.onError) {
  50146. pendingRequest.onError(xhr.status);
  50147. }
  50148. return;
  50149. }
  50150. this.loadedRequests[xhrId] = true;
  50151. var chunk = getArrayBuffer(xhr);
  50152. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  50153. var rangeHeader = xhr.getResponseHeader('Content-Range');
  50154. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  50155. var begin = parseInt(matches[1], 10);
  50156. pendingRequest.onDone({
  50157. begin: begin,
  50158. chunk: chunk
  50159. });
  50160. } else if (pendingRequest.onProgressiveData) {
  50161. pendingRequest.onDone(null);
  50162. } else if (chunk) {
  50163. pendingRequest.onDone({
  50164. begin: 0,
  50165. chunk: chunk
  50166. });
  50167. } else if (pendingRequest.onError) {
  50168. pendingRequest.onError(xhr.status);
  50169. }
  50170. },
  50171. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  50172. for (var xhrId in this.pendingRequests) {
  50173. return true;
  50174. }
  50175. return false;
  50176. },
  50177. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  50178. return this.pendingRequests[xhrId].xhr;
  50179. },
  50180. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  50181. return !!this.pendingRequests[xhrId].onProgressiveData;
  50182. },
  50183. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  50184. return xhrId in this.pendingRequests;
  50185. },
  50186. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  50187. return xhrId in this.loadedRequests;
  50188. },
  50189. abortAllRequests: function NetworkManager_abortAllRequests() {
  50190. for (var xhrId in this.pendingRequests) {
  50191. this.abortRequest(xhrId | 0);
  50192. }
  50193. },
  50194. abortRequest: function NetworkManager_abortRequest(xhrId) {
  50195. var xhr = this.pendingRequests[xhrId].xhr;
  50196. delete this.pendingRequests[xhrId];
  50197. xhr.abort();
  50198. }
  50199. };
  50200. var assert = sharedUtil.assert;
  50201. var createPromiseCapability = sharedUtil.createPromiseCapability;
  50202. var isInt = sharedUtil.isInt;
  50203. var MissingPDFException = sharedUtil.MissingPDFException;
  50204. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  50205. function PDFNetworkStream(options) {
  50206. this._options = options;
  50207. var source = options.source;
  50208. this._manager = new NetworkManager(source.url, {
  50209. httpHeaders: source.httpHeaders,
  50210. withCredentials: source.withCredentials
  50211. });
  50212. this._rangeChunkSize = source.rangeChunkSize;
  50213. this._fullRequestReader = null;
  50214. this._rangeRequestReaders = [];
  50215. }
  50216. PDFNetworkStream.prototype = {
  50217. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  50218. var i = this._rangeRequestReaders.indexOf(reader);
  50219. if (i >= 0) {
  50220. this._rangeRequestReaders.splice(i, 1);
  50221. }
  50222. },
  50223. getFullReader: function PDFNetworkStream_getFullReader() {
  50224. assert(!this._fullRequestReader);
  50225. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  50226. return this._fullRequestReader;
  50227. },
  50228. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  50229. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  50230. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  50231. this._rangeRequestReaders.push(reader);
  50232. return reader;
  50233. },
  50234. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  50235. if (this._fullRequestReader) {
  50236. this._fullRequestReader.cancel(reason);
  50237. }
  50238. var readers = this._rangeRequestReaders.slice(0);
  50239. readers.forEach(function (reader) {
  50240. reader.cancel(reason);
  50241. });
  50242. }
  50243. };
  50244. function PDFNetworkStreamFullRequestReader(manager, options) {
  50245. this._manager = manager;
  50246. var source = options.source;
  50247. var args = {
  50248. onHeadersReceived: this._onHeadersReceived.bind(this),
  50249. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  50250. onDone: this._onDone.bind(this),
  50251. onError: this._onError.bind(this),
  50252. onProgress: this._onProgress.bind(this)
  50253. };
  50254. this._url = source.url;
  50255. this._fullRequestId = manager.requestFull(args);
  50256. this._headersReceivedCapability = createPromiseCapability();
  50257. this._disableRange = options.disableRange || false;
  50258. this._contentLength = source.length;
  50259. this._rangeChunkSize = source.rangeChunkSize;
  50260. if (!this._rangeChunkSize && !this._disableRange) {
  50261. this._disableRange = true;
  50262. }
  50263. this._isStreamingSupported = false;
  50264. this._isRangeSupported = false;
  50265. this._cachedChunks = [];
  50266. this._requests = [];
  50267. this._done = false;
  50268. this._storedError = undefined;
  50269. this.onProgress = null;
  50270. }
  50271. PDFNetworkStreamFullRequestReader.prototype = {
  50272. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  50273. if (this._disableRange) {
  50274. return false;
  50275. }
  50276. var networkManager = this._manager;
  50277. if (!networkManager.isHttp) {
  50278. return false;
  50279. }
  50280. var fullRequestXhrId = this._fullRequestId;
  50281. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  50282. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  50283. return false;
  50284. }
  50285. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  50286. if (contentEncoding !== 'identity') {
  50287. return false;
  50288. }
  50289. var length = fullRequestXhr.getResponseHeader('Content-Length');
  50290. length = parseInt(length, 10);
  50291. if (!isInt(length)) {
  50292. return false;
  50293. }
  50294. this._contentLength = length;
  50295. if (length <= 2 * this._rangeChunkSize) {
  50296. return false;
  50297. }
  50298. return true;
  50299. },
  50300. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  50301. if (this._validateRangeRequestCapabilities()) {
  50302. this._isRangeSupported = true;
  50303. }
  50304. var networkManager = this._manager;
  50305. var fullRequestXhrId = this._fullRequestId;
  50306. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  50307. this._isStreamingSupported = true;
  50308. } else if (this._isRangeSupported) {
  50309. networkManager.abortRequest(fullRequestXhrId);
  50310. }
  50311. this._headersReceivedCapability.resolve();
  50312. },
  50313. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  50314. if (this._requests.length > 0) {
  50315. var requestCapability = this._requests.shift();
  50316. requestCapability.resolve({
  50317. value: chunk,
  50318. done: false
  50319. });
  50320. } else {
  50321. this._cachedChunks.push(chunk);
  50322. }
  50323. },
  50324. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  50325. if (args) {
  50326. this._onProgressiveData(args.chunk);
  50327. }
  50328. this._done = true;
  50329. if (this._cachedChunks.length > 0) {
  50330. return;
  50331. }
  50332. this._requests.forEach(function (requestCapability) {
  50333. requestCapability.resolve({
  50334. value: undefined,
  50335. done: true
  50336. });
  50337. });
  50338. this._requests = [];
  50339. },
  50340. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  50341. var url = this._url;
  50342. var exception;
  50343. if (status === 404 || status === 0 && /^file:/.test(url)) {
  50344. exception = new MissingPDFException('Missing PDF "' + url + '".');
  50345. } else {
  50346. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  50347. }
  50348. this._storedError = exception;
  50349. this._headersReceivedCapability.reject(exception);
  50350. this._requests.forEach(function (requestCapability) {
  50351. requestCapability.reject(exception);
  50352. });
  50353. this._requests = [];
  50354. this._cachedChunks = [];
  50355. },
  50356. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  50357. if (this.onProgress) {
  50358. this.onProgress({
  50359. loaded: data.loaded,
  50360. total: data.lengthComputable ? data.total : this._contentLength
  50361. });
  50362. }
  50363. },
  50364. get isRangeSupported() {
  50365. return this._isRangeSupported;
  50366. },
  50367. get isStreamingSupported() {
  50368. return this._isStreamingSupported;
  50369. },
  50370. get contentLength() {
  50371. return this._contentLength;
  50372. },
  50373. get headersReady() {
  50374. return this._headersReceivedCapability.promise;
  50375. },
  50376. read: function PDFNetworkStreamFullRequestReader_read() {
  50377. if (this._storedError) {
  50378. return Promise.reject(this._storedError);
  50379. }
  50380. if (this._cachedChunks.length > 0) {
  50381. var chunk = this._cachedChunks.shift();
  50382. return Promise.resolve(chunk);
  50383. }
  50384. if (this._done) {
  50385. return Promise.resolve({
  50386. value: undefined,
  50387. done: true
  50388. });
  50389. }
  50390. var requestCapability = createPromiseCapability();
  50391. this._requests.push(requestCapability);
  50392. return requestCapability.promise;
  50393. },
  50394. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  50395. this._done = true;
  50396. this._headersReceivedCapability.reject(reason);
  50397. this._requests.forEach(function (requestCapability) {
  50398. requestCapability.resolve({
  50399. value: undefined,
  50400. done: true
  50401. });
  50402. });
  50403. this._requests = [];
  50404. if (this._manager.isPendingRequest(this._fullRequestId)) {
  50405. this._manager.abortRequest(this._fullRequestId);
  50406. }
  50407. this._fullRequestReader = null;
  50408. }
  50409. };
  50410. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  50411. this._manager = manager;
  50412. var args = {
  50413. onDone: this._onDone.bind(this),
  50414. onProgress: this._onProgress.bind(this)
  50415. };
  50416. this._requestId = manager.requestRange(begin, end, args);
  50417. this._requests = [];
  50418. this._queuedChunk = null;
  50419. this._done = false;
  50420. this.onProgress = null;
  50421. this.onClosed = null;
  50422. }
  50423. PDFNetworkStreamRangeRequestReader.prototype = {
  50424. _close: function PDFNetworkStreamRangeRequestReader_close() {
  50425. if (this.onClosed) {
  50426. this.onClosed(this);
  50427. }
  50428. },
  50429. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  50430. var chunk = data.chunk;
  50431. if (this._requests.length > 0) {
  50432. var requestCapability = this._requests.shift();
  50433. requestCapability.resolve({
  50434. value: chunk,
  50435. done: false
  50436. });
  50437. } else {
  50438. this._queuedChunk = chunk;
  50439. }
  50440. this._done = true;
  50441. this._requests.forEach(function (requestCapability) {
  50442. requestCapability.resolve({
  50443. value: undefined,
  50444. done: true
  50445. });
  50446. });
  50447. this._requests = [];
  50448. this._close();
  50449. },
  50450. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  50451. if (!this.isStreamingSupported && this.onProgress) {
  50452. this.onProgress({ loaded: evt.loaded });
  50453. }
  50454. },
  50455. get isStreamingSupported() {
  50456. return false;
  50457. },
  50458. read: function PDFNetworkStreamRangeRequestReader_read() {
  50459. if (this._queuedChunk !== null) {
  50460. var chunk = this._queuedChunk;
  50461. this._queuedChunk = null;
  50462. return Promise.resolve({
  50463. value: chunk,
  50464. done: false
  50465. });
  50466. }
  50467. if (this._done) {
  50468. return Promise.resolve({
  50469. value: undefined,
  50470. done: true
  50471. });
  50472. }
  50473. var requestCapability = createPromiseCapability();
  50474. this._requests.push(requestCapability);
  50475. return requestCapability.promise;
  50476. },
  50477. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  50478. this._done = true;
  50479. this._requests.forEach(function (requestCapability) {
  50480. requestCapability.resolve({
  50481. value: undefined,
  50482. done: true
  50483. });
  50484. });
  50485. this._requests = [];
  50486. if (this._manager.isPendingRequest(this._requestId)) {
  50487. this._manager.abortRequest(this._requestId);
  50488. }
  50489. this._close();
  50490. }
  50491. };
  50492. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  50493. exports.PDFNetworkStream = PDFNetworkStream;
  50494. exports.NetworkManager = NetworkManager;
  50495. }));
  50496. }.call(pdfjsLibs));
  50497. exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  50498. }));